Skip to content

Commit

Permalink
Disable arrow hotkey navigation in forms
Browse files Browse the repository at this point in the history
  • Loading branch information
cmrd-senya committed Mar 5, 2017
1 parent 4745a1b commit 4248ef5
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions assets/javascripts/hotkeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,13 @@
});
},

bindIssuesTableKeys()
bindIssuesTableKeys : function ()
{
var issues_table = 'table.list.issues';
if ($(issues_table).length) { //issues table exists

$(document).bind('keydown', function (e) {
var focus_selector = issues_table + ' tbody tr';
var focused_selector = focus_selector + '.issue_focus';
var focus_selector = issues_table + ' tbody tr';
var focused_selector = focus_selector + '.issue_focus';
var issues_table_navigation = function (e) {
//move issue selector by "ArrowDown" and "ArrowUp"
if ((e.which == 38 || e.which == 40) && !e.ctrlKey && !e.altKey) {
var to_focus;
Expand All @@ -174,15 +173,26 @@
if (e.shiftKey) {
$(focused_selector).find('td.checkbox input')[0].click();
}
e.preventDefault();
}
e.preventDefault();
}
//perform actions on focused issue
if ($(focused_selector).length) {
if (e.which == 13) { //enter
$(focused_selector + ' td.subject a')[0].click();
e.preventDefault();
}
}
};

$(document).on('keydown', issues_table_navigation);
$(document).on('focus', 'form, .select2', function (e) {
$(document).off('keydown', issues_table_navigation);
$(focused_selector).removeClass('issue_focus');
});

$(document).on('focusout', 'form, .select2', function (e) {
$(document).on('keydown', issues_table_navigation);
});

/*$(issues_table).bind('contextmenu', function(e){
Expand Down

0 comments on commit 4248ef5

Please sign in to comment.