From 8a5d538251449cb8ddfb0b7f513b9ecabafdd7f4 Mon Sep 17 00:00:00 2001 From: Timothy Alexis Vass Date: Mon, 8 Jun 2020 07:20:05 +0200 Subject: [PATCH] Bug 25680 - When adding a new patron and missing to fill a field, on saving, the invalidFocus should show the focused field clearly in view. This patch will center the focused field at the golden section in the window. To test: 1) Begin to add a new patron. 2) Leave a required field empty, which is outside the screen view, and click Save. 3) Notice that the field is at the bottom, behind the language bar if there is one. 4) Apply patch 5) Add a new patron. 6) Leave the required field empty again and Save. 7) Notice that the required field is now clearly shown in view. 8) Sign off. --- koha-tmpl/intranet-tmpl/prog/js/members.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/js/members.js b/koha-tmpl/intranet-tmpl/prog/js/members.js index 1e102f1be7..88af688643 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/members.js +++ b/koha-tmpl/intranet-tmpl/prog/js/members.js @@ -326,6 +326,17 @@ $(document).ready(function(){ jQuery.validator.messages.phone); $("#entryform").validate({ + focusInvalid: false, + invalidHandler: function(form, validator) { + var errors = validator.numberOfInvalids(); + if(errors) { + window.scrollTo(0, 0); + validator.errorList[0].element.focus(); + if($(validator.errorList[0].element).offset().top > $(window).height()) { + window.scrollBy(0,$(window).height()/1.618); + } + } + }, rules: { email: { email: true -- 2.20.1