From 368ae1de4266fc172ac52a74f6cce8f154442227 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Mon, 7 Jun 2021 12:26:02 +0000 Subject: [PATCH] Bug 28522: Correct eslint errors in staff-global.js This patch makes minor corrections to staff-global.js in order to quiet warnings from ESLint. This includes: - Remove unused variables - Declare undeclared variables - Update list of global and exported variables and functions - Correct whitespace - Remove an unused function (paramOfUrl) To test, apply the patch and clear your browser cache if necessary. - Confirm that the first search header form field has focus when switching bewteen pages. - Confirm that text entered in any search header form field persists when you switch search header form tabs, e.g. a word typed into the "Check out" tab is copied to the "Check in" form when you switch to that tab. - Perform a search from the "Search the catalog" tab in the header. On the search results page and any following detail page your search term should remain in the header search form. - From a bibliographic detail page, confirm that selecting a list from the "Add to list" button menu correctly triggers a popup window. Signed-off-by: David Nind Signed-off-by: Nick Clemens Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall (cherry picked from commit 69108a4605d2dac3e38fb914d5a0f4f55b7463c1) Signed-off-by: Fridolin Somers --- .../intranet-tmpl/prog/js/staff-global.js | 31 ++++++------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js index 5a7f7fff74..c62a037e52 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js +++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js @@ -1,5 +1,5 @@ -/* global shortcut delCookie delBasket Sticky */ -/* exported paramOfUrl addBibToContext delBibToContext */ +/* global shortcut delBasket Sticky AUDIO_ALERT_PATH */ +/* exported addBibToContext delBibToContext escape_str escape_price openWindow _ removeFocus toUC confirmDelete confirmClone playSound */ if ( KOHA === undefined ) var KOHA = {}; function _(s) { return s; } // dummy function for gettext @@ -48,8 +48,8 @@ $.fn.selectTabByID = function (tabID) { $(this).tabs("option", "active", $( tabID ).tabIndex()); }; - $(document).ready(function() { - $('#header_search').tabs().on( "tabsactivate", function(e, ui) { $(this).find("div:visible").find('input').eq(0).focus(); }); +$(document).ready(function() { + $('#header_search').tabs().on( "tabsactivate", function() { $(this).find("div:visible").find('input').eq(0).focus(); }); $(".close").click(function(){ window.close(); }); @@ -213,7 +213,7 @@ function openHelp(){ jQuery.fn.preventDoubleFormSubmit = function() { jQuery(this).submit(function() { - $("body, form input[type='submit'], form button[type='submit'], form a").addClass('waiting'); + $("body, form input[type='submit'], form button[type='submit'], form a").addClass('waiting'); if (this.beenSubmitted) return false; else @@ -225,12 +225,11 @@ function openWindow(link,name,width,height) { name = (typeof name == "undefined")?'popup':name; width = (typeof width == "undefined")?'600':width; height = (typeof height == "undefined")?'400':height; - var newwin; //IE <= 9 can't handle a "name" with whitespace try { - newin=window.open(link,name,'width='+width+',height='+height+',resizable=yes,toolbar=false,scrollbars=yes,top'); + window.open(link,name,'width='+width+',height='+height+',resizable=yes,toolbar=false,scrollbars=yes,top'); } catch(e) { - newin=window.open(link,null,'width='+width+',height='+height+',resizable=yes,toolbar=false,scrollbars=yes,top'); + window.open(link,null,'width='+width+',height='+height+',resizable=yes,toolbar=false,scrollbars=yes,top'); } } @@ -267,7 +266,7 @@ function keep_text(clicked_index) { var searchboxes = document.getElementsByClassName("head-searchbox"); var persist = searchboxes[0].value; - for (i = 0; i < searchboxes.length - 1; i++) { + for (var 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) { @@ -306,18 +305,6 @@ function removeByValue(arr, val) { } } -function paramOfUrl( url, param ) { - param = param.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); - var regexS = "[\\?&]"+param+"=([^&#]*)"; - var regex = new RegExp( regexS ); - var results = regex.exec( url ); - if( results == null ) { - return ""; - } else { - return results[1]; - } -} - function addBibToContext( bibnum ) { bibnum = parseInt(bibnum, 10); var bibnums = getContextBiblioNumbers(); @@ -351,6 +338,8 @@ function resetSearchContext() { function saveOrClearSimpleSearchParams() { // Simple masthead search - pass value for display on details page + var pulldown_selection; + var searchbox_value; if( $("#cat-search-block select.advsearch").length ){ pulldown_selection = $("#cat-search-block select.advsearch").val(); } else { -- 2.39.5