diff options
author | Devaev Maxim <[email protected]> | 2018-07-28 17:03:34 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2018-07-28 17:03:34 +0300 |
commit | d8b1dfe5404a33f2dfab92dda7a0ef62d58672b9 (patch) | |
tree | c88e6b8993144349f8e80021aa73949e92c96100 /kvmd | |
parent | 5a9b86457c7329eac8db0fa73c129ef0d0b7fd5d (diff) |
esc menu fix
Diffstat (limited to 'kvmd')
-rw-r--r-- | kvmd/web/js/ui.js | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/kvmd/web/js/ui.js b/kvmd/web/js/ui.js index 95b61a8d..e4d3228f 100644 --- a/kvmd/web/js/ui.js +++ b/kvmd/web/js/ui.js @@ -6,11 +6,6 @@ var ui = new function() { this.init = function() { Array.prototype.forEach.call(document.getElementsByClassName("ctl-item"), function(el_item) { el_item.onclick = () => __toggleMenu(el_item); - el_item.onkeyup = function(event) { - if (event.code == "Escape") { - __toggleMenu(el_item); - } - }; __ctl_items.push(el_item); }); @@ -89,6 +84,7 @@ var ui = new function() { var __toggleMenu = function(el_a) { var all_hidden = true; + __ctl_items.forEach(function(el_item) { var el_menu = el_item.parentElement.querySelector(".ctl-dropdown-content"); if (el_item === el_a && el_menu.style.display === "none") { @@ -100,8 +96,17 @@ var ui = new function() { el_menu.style.display = "none"; } }); + if (all_hidden) { __raiseLastWindow(); + document.onkeyup = null; + } else { + document.onkeyup = function(event) { + if (event.code == "Escape") { + event.preventDefault(); + __toggleMenu(null); + } + } } }; @@ -151,7 +156,7 @@ var ui = new function() { } el_grab.onmousedown = startMoving; - el_window.onclick = function() { __raiseWindow(el_window) }; + el_window.onclick = () => __raiseWindow(el_window); }; var __raiseLastWindow = function() { |