diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-10-21 13:16:19 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-10-21 19:41:47 +0200 |
commit | 7d2ca3c07f347a819cd7e56134c9201aac9ff238 (patch) | |
tree | 5c0b9e0d9570b5ad535a9d994fc719ecfa445e27 /public | |
parent | 25747f3abd3ce953039757e0178b132580418afb (diff) | |
download | server-7d2ca3c07f347a819cd7e56134c9201aac9ff238.tar.gz |
toolbar menus: Click to open, click anywhere or leave window to close.
Diffstat (limited to 'public')
-rw-r--r-- | public/common/client.js | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/public/common/client.js b/public/common/client.js index 2d6e94d..8168250 100644 --- a/public/common/client.js +++ b/public/common/client.js @@ -769,13 +769,30 @@ function close_menus(self) { } for (let node of document.querySelectorAll("#toolbar > details")) { - node.onclick = function () { close_menus(node) } - node.onmouseleave = function () { node.removeAttribute("open") } + //node.onclick = function () { close_menus(node) } + //node.onmouseleave = function () { node.removeAttribute("open") } } + +/* close menu after selecting something */ for (let node of document.querySelectorAll("#toolbar > details > menu")) { node.onclick = function () { close_menus(null) } } +/* click anywhere else than menu to close it */ +window.addEventListener("mousedown", function (evt) { + let e = evt.target + while (e) { + if (e.tagName === "DETAILS") + return + e = e.parentElement + } + close_menus(null) +}) + +window.addEventListener("blur", function (evt) { + close_menus(null) +}) + function toggle_fullscreen() { // Safari on iPhone doesn't support Fullscreen if (typeof document.documentElement.requestFullscreen !== "function") |