summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-10-21 13:16:19 +0200
committerTor Andersson <tor@ccxvii.net>2023-10-21 19:41:47 +0200
commit7d2ca3c07f347a819cd7e56134c9201aac9ff238 (patch)
tree5c0b9e0d9570b5ad535a9d994fc719ecfa445e27 /public
parent25747f3abd3ce953039757e0178b132580418afb (diff)
downloadserver-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.js21
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")