From 3d2646938c8592ec37069817f06747e89d3c3ec3 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 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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. Followed test plan, works as expected. Signed-off-by: Marc Véron Signed-off-by: Jonathan Druart Signed-off-by: Brendan Gallagher brendan@bywatersolutions.com --- .../prog/en/includes/doc-head-close.inc | 3 -- .../prog/en/includes/searchbox-keep-text.inc | 30 ------------------- .../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 c31932a724..b47e9dd64c 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 3d7dbc2e28..0000000000 --- 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 d915136f09..6049fbc031 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.39.5