Close modal with escape key

This commit is contained in:
Lorenz Hübschle-Schneider 2014-07-20 11:48:51 +01:00
parent bc958a3f7b
commit c9e3c1a55c

View file

@ -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();