diff options
author | Frederic Guillot <fred@kanboard.net> | 2017-01-11 22:07:19 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2017-01-11 22:07:19 -0500 |
commit | d0dad82a278af213f56a279804d9f40348921b5e (patch) | |
tree | cca894c104831c27c2b43ff759e1917d05abc555 /assets/js/components/keyboard-shortcuts.js | |
parent | d459bec035acaa8a03de6de1b33cb1048361d8d0 (diff) |
Improve keyboard shortcuts handling
Diffstat (limited to 'assets/js/components/keyboard-shortcuts.js')
-rw-r--r-- | assets/js/components/keyboard-shortcuts.js | 62 |
1 files changed, 43 insertions, 19 deletions
diff --git a/assets/js/components/keyboard-shortcuts.js b/assets/js/components/keyboard-shortcuts.js index 046e027c..037d5c5f 100644 --- a/assets/js/components/keyboard-shortcuts.js +++ b/assets/js/components/keyboard-shortcuts.js @@ -1,9 +1,11 @@ KB.keyboardShortcuts = function () { function goToLink (selector) { - var element = KB.find(selector); + if (! KB.modal.isOpen()) { + var element = KB.find(selector); - if (element !== null) { - window.location = element.attr('href'); + if (element !== null) { + window.location = element.attr('href'); + } } } @@ -22,7 +24,9 @@ KB.keyboardShortcuts = function () { } KB.onKey('?', function () { - KB.modal.open(KB.find('body').data('keyboardShortcutUrl')); + if (! KB.modal.isOpen()) { + KB.modal.open(KB.find('body').data('keyboardShortcutUrl')); + } }); KB.onKey('Escape', function () { @@ -32,55 +36,75 @@ KB.keyboardShortcuts = function () { } }); - KB.onKey('Meta+Enter', submitForm, true); - KB.onKey('Control+Enter', submitForm, true); + KB.onKey('Enter', submitForm, true, true); + KB.onKey('Enter', submitForm, true, false, true); KB.onKey('b', function () { - KB.trigger('board.selector.open'); + if (! KB.modal.isOpen()) { + KB.trigger('board.selector.open'); + } }); if (KB.exists('#board')) { KB.onKey('c', function () { - _KB.get('BoardHorizontalScrolling').toggle(); + if (! KB.modal.isOpen()) { + _KB.get('BoardHorizontalScrolling').toggle(); + } }); KB.onKey('s', function () { - _KB.get('BoardCollapsedMode').toggle(); + if (! KB.modal.isOpen()) { + _KB.get('BoardCollapsedMode').toggle(); + } }); KB.onKey('n', function () { - KB.modal.open(KB.find('#board').data('taskCreationUrl'), 'large', false); + if (! KB.modal.isOpen()) { + KB.modal.open(KB.find('#board').data('taskCreationUrl'), 'large', false); + } }); } if (KB.exists('#task-view')) { KB.onKey('e', function () { - KB.modal.open(KB.find('#task-view').data('editUrl'), 'large'); + if (! KB.modal.isOpen()) { + KB.modal.open(KB.find('#task-view').data('editUrl'), 'large', false); + } }); KB.onKey('c', function () { - KB.modal.open(KB.find('#task-view').data('commentUrl')); + if (! KB.modal.isOpen()) { + KB.modal.open(KB.find('#task-view').data('commentUrl'), 'medium', false); + } }); KB.onKey('s', function () { - KB.modal.open(KB.find('#task-view').data('subtaskUrl')); + if (! KB.modal.isOpen()) { + KB.modal.open(KB.find('#task-view').data('subtaskUrl'), 'medium', false); + } }); KB.onKey('l', function () { - KB.modal.open(KB.find('#task-view').data('internalLinkUrl')); + if (! KB.modal.isOpen()) { + KB.modal.open(KB.find('#task-view').data('internalLinkUrl'), 'medium', false); + } }); } KB.onKey('f', function () { - KB.focus('#form-search'); + if (! KB.modal.isOpen()) { + KB.focus('#form-search'); + } }); KB.onKey('r', function () { - var reset = $(".filter-reset").data("filter"); - var input = $("#form-search"); + if (! KB.modal.isOpen()) { + var reset = $(".filter-reset").data("filter"); + var input = $("#form-search"); - input.val(reset); - $("form.search").submit(); + input.val(reset); + $("form.search").submit(); + } }); KB.onKey('v+o', function () { |