From bbe90f900059cac7f470954473a406081c897bc1 Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Tue, 25 Feb 2014 12:13:13 +0100 Subject: [PATCH] Bug 11563: restore preventing the enter key from submitting several forms Several forms that take patron or item barcodes as input stopped preventing the enter key (which is often sent by barcode scanners) from submitting the form. The code binding the CSS class noEnterSubmit to the handler preventing submission when hitting the enter key was no longer triggered. This is because this class is added using JavaScript in $(document).ready() and the keypress event listerning is also set using $(document).ready(). This patch corrects by using JQuery live() with will set event handlers for HTML generated with JavaScript. Also sets noEnterSubmit to use the checkEnter(e) function, as that has broader browser compatibility. Also corrects a small bug, for IE, window.event must be used, not event alone. Test plan : - Flush browser cache (Crtl+F5) to update js files - Go to patron creation : members/memberentrygen.tt - Type a text in all mandatory inputs - Type some caracters in a non mandatory input - Press Enter key => Without patch : the form is submitted => With patch : the form is not submitted - Try to set several lines in a textarea => It works (checks that in this case enter key is allowed) - Test other pages usign noEnterSubmit class : cataloguing/additem.tt course_reserves/course.tt members/mancredit.tt members/maninvoice.tt patron_lists/list.tt Signed-off-by: Kyle M Hall Signed-off-by: Jonathan Druart Signed-off-by: Christopher Brannon Signed-off-by: Katrin Fischer Works as described, tested in Firefox and Chromium. Passes tests and QA script. Signed-off-by: Galen Charlton (cherry picked from commit e5ab2203745d7c70e1c4d2f54cea967710a88b96) Signed-off-by: Fridolin Somers --- koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js index 234a8710f2..de0ec5b96d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js @@ -25,8 +25,8 @@ function _(s) { return s; } // dummy function for gettext return false; }); - $('.noEnterSubmit').keypress(function(e){ - if ( e.which == 13 ) return false; + $('.noEnterSubmit').live("keypress", function(e){ + return checkEnter(e); }); }); @@ -37,7 +37,7 @@ function checkEnter(e){ //e is event object passed from function invocation e = e; characterCode = e.which; //character code is contained in NN4's which property } else { - e = event; + e = window.event; characterCode = e.keyCode; //character code is contained in IE's keyCode property } -- 2.39.5