From c9e3c1a55c4d7c056b826e6d3aaf0805ce8556df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Sun, 20 Jul 2014 11:48:51 +0100 Subject: [PATCH] Close modal with escape key --- js/glowingbear.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/js/glowingbear.js b/js/glowingbear.js index 3a15f42..b59d04d 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -1513,6 +1513,16 @@ weechat.directive('inputBar', function() { // Double-tap Escape -> disconnect if (code === 27) { $event.preventDefault(); + + // Check if a modal is visible. If so, close it instead of disconnecting + var modals = document.querySelectorAll('.gb-modal'); + for (var modalId in modals) { + if (modals[modalId].getAttribute('data-state') === 'visible') { + modals[modalId].setAttribute('data-state', 'hidden'); + return true; + } + } + if (typeof $scope.lastEscape !== "undefined" && (Date.now() - $scope.lastEscape) <= 500) { // Double-tap connection.disconnect();