@@ -, +, @@ --- koha-tmpl/intranet-tmpl/prog/js/staff-global.js | 30 +++++++++---------------- 1 file changed, 10 insertions(+), 20 deletions(-) --- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js +++ a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js @@ -259,28 +259,18 @@ function playSound( sound ) { // 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; - } + var current_value = searchboxes[clicked_index].value; + var different_value = ""; + for (i = 0; i < searchboxes.length; i++) { + if ( searchboxes[i].value != current_value ){ + different_value = searchboxes[i].value; + break; } } - - for (i = 0; i < searchboxes.length; i++) { - searchboxes[i].value = persist; + if (different_value){ + for (i = 0; i < searchboxes.length; i++) { + searchboxes[i].value = different_value; + } } } --