From 9b78091d6f96a4d4e7bb6f3afcbc045b38a3b3d5 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Wed, 24 Feb 2016 12:18:01 -0500 Subject: [PATCH] Bug 15910 - Move header search keep text JavaScript into staff-global.js Content-Type: text/plain; charset="utf-8" Bug 14189 added some global JavaScript to a new include file which is included in doc-head-close.inc. Since it's included globally, there is no reason not to move it to staff-global.js. This patch does so. To test, apply the patch and clear your browser cache if necessary. - Navigate to any page in the staff client which has multiple header search tabs. - Type something in one of the tabs. - Switch tabs. Verify that your text was copied to the newly-displayed form field. --- .../prog/en/includes/doc-head-close.inc | 3 --- .../prog/en/includes/searchbox-keep-text.inc | 30 ---------------------- koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js | 28 ++++++++++++++++++++ 3 files changed, 28 insertions(+), 33 deletions(-) delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/searchbox-keep-text.inc diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc index c31932a..b47e9dd 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc @@ -85,6 +85,3 @@ }); [% END %] - - -[% INCLUDE 'searchbox-keep-text.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/searchbox-keep-text.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/searchbox-keep-text.inc deleted file mode 100644 index 3d7dbc2..0000000 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/searchbox-keep-text.inc +++ /dev/null @@ -1,30 +0,0 @@ - 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 d915136..6049fbc 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/staff-global.js @@ -129,3 +129,31 @@ function playSound( sound ) { } document.getElementById("audio-alert").innerHTML = ''; } + +// For keeping the text when navigating the search tabs +function keep_text(clicked_index) { + var searchboxes = document.getElementsByClassName("head-searchbox"); + var persist = searchboxes[0].value; + + for (i = 0; i < searchboxes.length - 1; i++) { + if (searchboxes[i].value != searchboxes[i+1].value) { + if (i === searchboxes.length-2) { + if (searchboxes[i].value != searchboxes[0].value) { + persist = searchboxes[i].value; + } else if (searchboxes.length === 2) { + if (clicked_index === 0) { + persist = searchboxes[1].value; + } + } else { + persist = searchboxes[i+1].value; + } + } else if (searchboxes[i+1].value != searchboxes[i+2].value) { + persist = searchboxes[i+1].value; + } + } + } + + for (i = 0; i < searchboxes.length; i++) { + searchboxes[i].value = persist; + } +} \ No newline at end of file -- 2.1.4