NIFI-346:

- Fixing issue when attempting to close dialogs via Esc keystroke. Was exiting method early with dialogs open to prevent other shortcuts.
This commit is contained in:
Matt Gilman 2015-02-12 10:19:56 -05:00
parent 05c01952ad
commit a416dfdb0f
1 changed files with 13 additions and 6 deletions

View File

@ -510,12 +510,24 @@ nf.Canvas = (function () {
$(window).on('resize', function () { $(window).on('resize', function () {
updateGraphSize(); updateGraphSize();
}).on('keydown', function (evt) { }).on('keydown', function (evt) {
var isCtrl = evt.ctrlKey || evt.metaKey;
// consider escape, before checking dialogs
if (!isCtrl && evt.keyCode === 27) {
// esc
nf.Actions.hideDialogs();
evt.preventDefault();
return;
}
// if a dialog is open, disable canvas shortcuts // if a dialog is open, disable canvas shortcuts
if ($('.dialog').is(':visible')) { if ($('.dialog').is(':visible')) {
return; return;
} }
if (evt.ctrlKey || evt.metaKey) { // handle shortcuts
if (isCtrl) {
if (evt.keyCode === 82) { if (evt.keyCode === 82) {
// ctrl-r // ctrl-r
nf.Actions.reloadStatus(); nf.Actions.reloadStatus();
@ -543,11 +555,6 @@ nf.Canvas = (function () {
// delete // delete
nf.Actions['delete'](nf.CanvasUtils.getSelection()); nf.Actions['delete'](nf.CanvasUtils.getSelection());
evt.preventDefault();
} else if (evt.keyCode === 27) {
// esc
nf.Actions.hideDialogs();
evt.preventDefault(); evt.preventDefault();
} }
} }