diff options
author | Devaev Maxim <[email protected]> | 2018-08-27 20:53:17 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2018-08-27 20:53:17 +0300 |
commit | 62a90ed92fb97e400b859fc2986fb7b173872664 (patch) | |
tree | 6bfef9b01177a836fcabb15322649f3cd300437a /kvmd | |
parent | 493b19c8bac14f1b34bd8120a96161e446b35ab6 (diff) |
escape/enter events in modal
Diffstat (limited to 'kvmd')
-rw-r--r-- | kvmd/web/js/ui.js | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/kvmd/web/js/ui.js b/kvmd/web/js/ui.js index c0a1bef0..60284d61 100644 --- a/kvmd/web/js/ui.js +++ b/kvmd/web/js/ui.js @@ -71,16 +71,15 @@ function Ui() { el_buttons.className = "modal-buttons"; el_window.appendChild(el_buttons); - var close = function(retval) { + function close (retval) { el_modal.outerHTML = ""; var index = __windows.indexOf(el_modal); if (index !== -1) { __windows.splice(index, 1); } - tools.info(__windows); __raiseLastWindow(); resolve(retval); - }; + } if (cancel) { var el_cancel_button = document.createElement("button"); @@ -98,6 +97,15 @@ function Ui() { el_ok_button.className = "row50"; el_cancel_button.className = "row50"; } + + el_window.onkeyup = function(event) { + event.preventDefault(); + if (ok && event.code === "Enter") { + el_ok_button.click(); + } else if (cancel && event.code === "Escape") { + el_cancel_button.click(); + } + }; }); } |