From 2e9dde6d085d68b1601c31f9938c2530ff55d77a Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Thu, 28 Jul 2022 10:43:06 +1000 Subject: simplify close listeners in contact finder --- content/contactFinder.js | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'content/contactFinder.js') diff --git a/content/contactFinder.js b/content/contactFinder.js index 6868b47..c55d46a 100644 --- a/content/contactFinder.js +++ b/content/contactFinder.js @@ -186,20 +186,8 @@ function main() { overlay.remove(); }; - const closeListener = e => { - const t = e.currentTarget; - if (t.href && t.href !== document.URL) { // link navigation - if (t.href.includes("#")) { - window.addEventListener("hashchange", close); - } - return; - } - close(); - }; - const makeCloser = clickable => clickable.addEventListener("click", closeListener); - // Clicking the "outer area" closes the dialog. - makeCloser(overlay); + overlay.addEventListener("click", close); const initFrame = prefs => { debug("initFrame"); @@ -217,6 +205,7 @@ function main() { const closeButton = body.appendChild(contentDoc.createElement('button')); closeButton.classList.toggle('close', true); closeButton.textContent = 'x'; + closeButton.addEventListener("click", close); const content = body.appendChild(contentDoc.createElement("div")); content.id = "content"; @@ -253,7 +242,7 @@ function main() { } } - contentDoc.querySelectorAll(".close, a").forEach(makeCloser); + // contentDoc.querySelectorAll(".close, a").forEach(makeCloser); debug("frame initialized"); } -- cgit v1.2.3