forked from rDrama/rDrama
1
0
Fork 0

make ppl able to select text from popover

master
Aevann 2023-06-24 15:28:42 +03:00
parent 0d033d0435
commit 8cdc4e6ee7
1 changed files with 21 additions and 2 deletions

View File

@ -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]);