From 7ff1ca353c821be305711fe1fa76cde6ac77a613 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Tue, 5 May 2020 18:04:11 +0000 Subject: [PATCH] Bug 25349: Add checkEnter function and apply it to SCO page This patch adds the checkEnter function to the OPAC global.js and then applies it to the SCO login page. TO TEST: 1. Go to SCO login and try entering something in the "Login:" input amd "Password:" input. 2. Pressing enter while in either will automatically submit the form. 3. Apply patch. 4. Repeat step 1-2. 5. This time the form should not submit itself when you press Enter. --- .../opac-tmpl/bootstrap/en/modules/sco/sco-main.tt | 6 +++--- koha-tmpl/opac-tmpl/bootstrap/js/global.js | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt index 4b3fe8a652..841aa8658c 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt @@ -372,16 +372,16 @@ [% IF ( Koha.Preference('SelfCheckoutByLogin') ) %] Log in to your account - + - +
[% ELSE %]
- +
[% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/global.js b/koha-tmpl/opac-tmpl/bootstrap/js/global.js index 76ce7b5cb0..4ad2374a5b 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/js/global.js +++ b/koha-tmpl/opac-tmpl/bootstrap/js/global.js @@ -52,6 +52,24 @@ function suffixOf (s, tok) { return s.substring(index + 1); } +// http://jennifermadden.com/javascript/stringEnterKeyDetector.html +function checkEnter(e){ //e is event object passed from function invocation + var characterCode; // literal character code will be stored in this variable + if(e && e.which){ //if which property of event object is supported (NN4) + characterCode = e.which; //character code is contained in NN4's which property + } else { + characterCode = e.keyCode; //character code is contained in IE's keyCode property + } + if( characterCode == 13 //if generated character code is equal to ascii 13 (if enter key) + && e.target.nodeName == "INPUT" + && e.target.type != "submit" // Allow enter to submit using the submit button + ){ + return false; + } else { + return true; + } +} + // Adapted from https://gist.github.com/jnormore/7418776 function confirmModal(message, title, yes_label, no_label, callback) { $("#bootstrap-confirm-box-modal").data('confirm-yes', false); -- 2.11.0