From 8cdc4e6ee73ef87d31c8c746c5a7d718db494c4b Mon Sep 17 00:00:00 2001 From: Aevann Date: Sat, 24 Jun 2023 15:28:42 +0300 Subject: [PATCH] make ppl able to select text from popover --- files/assets/js/comments+post_listing.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/files/assets/js/comments+post_listing.js b/files/assets/js/comments+post_listing.js index 8373dc2ae0..5b489809fc 100644 --- a/files/assets/js/comments+post_listing.js +++ b/files/assets/js/comments+post_listing.js @@ -14,8 +14,13 @@ popClickBadgeTemplateDOM.loading = "lazy"; popClickBadgeTemplateDOM.alt = "badge"; document.addEventListener('shown.bs.popover', (e) => { - let popover = document.getElementsByClassName("popover") - popover = popover[popover.length-1] + const popfix = document.getElementById("popover-fix") + if (popfix) document.body.removeChild(popfix); + + const popover_old = document.getElementsByClassName("popover")[0]; + const popover = document.createElement("DIV"); + popover.innerHTML = popover_old.outerHTML; + popover.id = "popover-fix"; const author = JSON.parse(e.target.dataset.popInfo); @@ -52,8 +57,22 @@ document.addEventListener('shown.bs.popover', (e) => { if (author["original_usernames"]) { popover.getElementsByClassName('pop-original-usernames')[0].innerHTML = author["original_usernames"] } + + document.body.appendChild(popover); + document.body.removeChild(popover_old); }) +document.addEventListener("click", function(){ + const cellText = document.getSelection(); + if (cellText.type === 'Range') e.preventDefault(); + + active = document.activeElement.getAttributeNode("class"); + if (!(active && active.nodeValue == "user-name text-decoration-none")){ + const popfix = document.getElementById("popover-fix") + if (popfix) document.body.removeChild(popfix); + } +}); + function post(url) { const xhr = createXhrWithFormKey(url); xhr[0].send(xhr[1]);