From 1e5e4505654ea7bc4b4a793d647da9b59c3e38f3 Mon Sep 17 00:00:00 2001 From: MatMoul Date: Sat, 21 Oct 2017 17:10:51 +0200 Subject: [PATCH] Improvement: Add escape support on popup --- src/js/dial.js | 2 ++ src/js/properties.js | 7 +++++++ src/js/settings.js | 7 +++++++ 3 files changed, 16 insertions(+) diff --git a/src/js/dial.js b/src/js/dial.js index 3530758..cfd241d 100644 --- a/src/js/dial.js +++ b/src/js/dial.js @@ -495,6 +495,7 @@ dial.editSettings = function(){ iframe.src = '/html/settings.html'; iframe.popup = popup; popup.popup(); + iframe.focus(); } dial.editProperties = function(selectedItem){ @@ -510,4 +511,5 @@ dial.editProperties = function(selectedItem){ iframe.src = '/html/properties.html?id=' + selectedItem.Node.id; iframe.popup = popup; popup.popup(); + iframe.focus(); } diff --git a/src/js/properties.js b/src/js/properties.js index c17d946..b37e711 100644 --- a/src/js/properties.js +++ b/src/js/properties.js @@ -7,6 +7,13 @@ document.addEventListener("DOMContentLoaded", function(event) { }); app.init = function(){ + document.addEventListener('keyup', function(e){ + switch(e.key){ + case 'Escape': + window.frameElement.popup.close(); + break; + } + }); app.Messages.getSettings(function(settings){ app.settings = settings; app.Messages.getNodeByID(new URL(window.location).searchParams.get('id'), function(node){ diff --git a/src/js/settings.js b/src/js/settings.js index c921771..6d46cb0 100644 --- a/src/js/settings.js +++ b/src/js/settings.js @@ -10,6 +10,13 @@ document.addEventListener("DOMContentLoaded", function(event) { app.init = function(){ + document.addEventListener('keyup', function(e){ + switch(e.key){ + case 'Escape': + window.frameElement.popup.close(); + break; + } + }); app.Messages.getSettings(function(settings){ app.settings = settings; BackgroundColor.value = app.settings.backgroundColor;