From c15b176efd072e3feb0fac436c8b1a4953d325cf Mon Sep 17 00:00:00 2001 From: Jacek Ablewicz Date: Fri, 5 Dec 2014 11:36:49 +0100 Subject: [PATCH] Bug 13391 - MARC 008 builder plugin not compatible with browser autocompletion In the koha-tmpl/intranet-tmpl/prog/en/js/xmlControlfield.js (currently used by 006 and 008 MARC21 plugins), in line 317 there are two JS events (onkeyup and onfocus) associated with fields. But there is a slight problem with onkeyup event handler, apparently this event does not fire when: - user starts to enter some characters using the keyboard, - and then chooses something from the autocompletion list offered by browser. In such circumstances only the first character[s] entered in the given field are saved in 006 and/or 008 (only the part that was typed on the keyboard), and the remaining characters are effectively being ignored. This patch adds two additional event handlers to the fields generated by the renderPositions() function in xmlControlfield.js: oninput (that should completely solve the problem for recent, HTML5-compliant browsers) and onblur (that, while not being quite satisfactory solution, should at least somehow improve things for old/lagacy WWW browsers as well). To test: - reproduce the aforementioned issue (try to enter some data into e.g. "country code" / 15-17 positions in the 008 MARC21 plugin: first using only the keyboard, and then by the means of the browser autocomplete) - observe that when the value is choosen from the autocompletion list, only the 1st part of it is being stored in the respective 008 field positions on the top - apply patch - clear browser cache - retest (preferably using some modern WWW browser first, and then something much older and inherently broken like IE7 or IE8 etc.) - make sure there are no aparent regresions of any kinds regarding 006 and 008 MARC21 plugins behaviour. --- koha-tmpl/intranet-tmpl/prog/en/js/xmlControlfield.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/xmlControlfield.js b/koha-tmpl/intranet-tmpl/prog/en/js/xmlControlfield.js index d995bda..14c1bb7 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/xmlControlfield.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/xmlControlfield.js @@ -314,7 +314,8 @@ function changeH4Result(form, h4_result, tr_result, pos, value) var ini = parseInt(pos.substring(0, index) ,10); var end = parseInt(pos.substr(index + 1) ,10); value = value.replace(/ /g, "#"); - strInnerHTML = ""; + var event_str = "'this.value = this.value.replace(/ /g, \"#\"); changeH4Result(document.getElementById(\"" + this.form_id + "\"), document.getElementById(\"" + this.h4_result + "\"), document.getElementById(\"" + this.tr_result + "\"), \"" + pos + "\", this.value)'"; + strInnerHTML = ""; } else { strInnerHTML = "