summaryrefslogtreecommitdiff
path: root/kvmd
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2018-08-27 20:53:17 +0300
committerDevaev Maxim <[email protected]>2018-08-27 20:53:17 +0300
commit62a90ed92fb97e400b859fc2986fb7b173872664 (patch)
tree6bfef9b01177a836fcabb15322649f3cd300437a /kvmd
parent493b19c8bac14f1b34bd8120a96161e446b35ab6 (diff)
escape/enter events in modal
Diffstat (limited to 'kvmd')
-rw-r--r--kvmd/web/js/ui.js14
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();
+ }
+ };
});
}