From bf624afc9b435042db1dd3f072b01a379feb4d12 Mon Sep 17 00:00:00 2001 From: Timothy Alexis Vass Date: Fri, 5 Jun 2020 13:29:08 +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 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/js/members.js b/koha-tmpl/intranet-tmpl/prog/js/members.js index 1e102f1be7..c0eadb57d3 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/members.js +++ b/koha-tmpl/intranet-tmpl/prog/js/members.js @@ -326,6 +326,15 @@ $(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(); + window.scrollBy(0,$(window).height()/1.618); + } + }, rules: { email: { email: true -- 2.20.1