removeElementOnKey - rewrite on vanilla ks

This commit is contained in:
Azgaar 2021-09-12 01:51:51 +03:00
parent bedbb7cbff
commit bb6941a1f5
2 changed files with 94 additions and 66 deletions

View file

@ -136,10 +136,14 @@ function toggleMode() {
}
}
// trigger trash button click on "Delete" keypress
function removeElementOnKey() {
$(".dialog:visible .fastDelete").click();
$("button:visible:contains('Remove')").click();
const fastDelete = Array.from(document.querySelectorAll("[role='dialog'] .fastDelete")).find(dialog => dialog.style.display !== "none");
if (fastDelete) fastDelete.click();
const visibleDialogs = Array.from(document.querySelectorAll("[role='dialog']")).filter(dialog => dialog.style.display !== "none");
if (!visibleDialogs.length) return;
visibleDialogs.forEach(dialog => dialog.querySelectorAll("button").forEach(button => button.textContent === "Remove" && button.click()));
}
function closeAllDialogs() {