diff options
author | Maxim Devaev <[email protected]> | 2022-05-02 17:19:14 +0300 |
---|---|---|
committer | Maxim Devaev <[email protected]> | 2022-05-02 17:19:14 +0300 |
commit | 53d0855cf84164e05c91b7c53eb7a98852a2b48d (patch) | |
tree | e596131e3e75adb41f3cf9bec0a0560773a00426 /web/share/js/wm.js | |
parent | 6c5ed69c0b07710740d9b81be119801c165e12f7 (diff) |
refactoring
Diffstat (limited to 'web/share/js/wm.js')
-rw-r--r-- | web/share/js/wm.js | 29 |
1 files changed, 9 insertions, 20 deletions
diff --git a/web/share/js/wm.js b/web/share/js/wm.js index 0a7c8d4f..c6c71b9b 100644 --- a/web/share/js/wm.js +++ b/web/share/js/wm.js @@ -125,8 +125,8 @@ function __WindowManager() { window.onmouseup = __globalMouseButtonHandler; window.ontouchend = __globalMouseButtonHandler; - window.addEventListener("focusin", __focusIn); - window.addEventListener("focusout", __focusOut); + window.addEventListener("focusin", (event) => __focusInOut(event, true)); + window.addEventListener("focusout", (event) => __focusInOut(event, false)); window.addEventListener("resize", __organizeWindowsOnBrowserResize); window.addEventListener("orientationchange", __organizeWindowsOnBrowserResize); @@ -314,28 +314,16 @@ function __WindowManager() { } }; - var __focusIn = function(event) { + var __focusInOut = function(event, focus_in) { let el_parent; if ((el_parent = event.target.closest(".modal-window")) !== null) { - el_parent.classList.add("window-active"); + el_parent.classList.toggle("window-active", focus_in); } else if ((el_parent = event.target.closest(".window")) !== null) { - el_parent.classList.add("window-active"); + el_parent.classList.toggle("window-active", focus_in); } else if ((el_parent = event.target.closest(".menu")) !== null) { - el_parent.classList.add("menu-active"); + el_parent.classList.toggle("menu-active", focus_in); } - tools.debug("UI: Focus in:", el_parent); - }; - - var __focusOut = function(event) { - let el_parent; - if ((el_parent = event.target.closest(".modal-window")) !== null) { - el_parent.classList.remove("window-active"); - } else if ((el_parent = event.target.closest(".window")) !== null) { - el_parent.classList.remove("window-active"); - } else if ((el_parent = event.target.closest(".menu")) !== null) { - el_parent.classList.remove("menu-active"); - } - tools.debug("UI: Focus out:", el_parent); + tools.debug(`UI: Focus ${focus_in ? "IN" : "OUT"}:`, el_parent); }; var __globalMouseButtonHandler = function(event) { @@ -569,7 +557,8 @@ function __WindowManager() { }; var __maximizeWindow = function(el_window) { - let vertical_offset = $("navbar").offsetHeight; + let el_navbar = $("navbar"); + let vertical_offset = (el_navbar ? el_navbar.offsetHeight : 0); el_window.style.left = "0px"; el_window.style.top = vertical_offset + "px"; el_window.style.width = window.innerWidth + "px"; |