Skip to content

Commit

Permalink
Don't trigger the search function when modifiers are pressed.
Browse files Browse the repository at this point in the history
  • Loading branch information
dwt committed Jul 10, 2018
1 parent ccb1a33 commit 381c76a
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/OFS/zpt/main.zpt
Expand Up @@ -202,20 +202,37 @@
// +++++++++++++++++++++++++++
// Tablefilter/Search Element
// +++++++++++++++++++++++++++
$(document).keypress( function(e) {

function isModifierKeyPressed(event) {
return event.altKey
|| event.ctrlKey
|| event.metaKey;
}

$(document).keypress( function(event) {

if (isModifierKeyPressed(event)) {
return; // ignore
}

// Set Focus to Tablefilter only when Modal Dialog is not Shown
if ( !$('#zmi-modal').hasClass('show') ) {
$('#tablefilter').focus();
// Prevent Submitting a form by hitting Enter
// https://stackoverflow.com/questions/895171/prevent-users-from-submitting-a-form-by-hitting-enter
if ( e.which == 13 ) {
if ( event.which == 13 ) {
event.preventDefault();
return false;
};
};
})

$('#tablefilter').keyup( function (e) {

if (isModifierKeyPressed(event)) {
return; // ignore
}

var tablefilter = $(this).val();
if( e.which==13 ) {
window.location.href = 'manage_findForm?btn_submit=Find&search_sub:int=1&obj_ids%3Atokens=' + tablefilter;
Expand Down

0 comments on commit 381c76a

Please sign in to comment.