From e037f0dcd1b6cfa7cd8b268244c86f77c8a1afc3 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Mon, 6 Jan 2020 16:26:33 +0000 Subject: [PATCH] Bug 15850: Correct eslint errors in cataloging.js This patch makes corrections to cataloging.js so that there are no issues flagged by eslint. The fewer eslint warnings we have to see makes it more likely that real problems will be noticed. Some functions were unused have been removed. To test, apply the patch and clear your browser cache if necessary. - Open a MARC record for editing in the basic cataloging editor. - Test the JavaScript-driven functionality affected by the changed file: - Open the authority browser from a field (e.g. 100a) which is linked to an authority type. - Clone a repeatable tag. - Clone a repeatable subfield - "Unclone" a tag or subfield: This should remove the tag or subfield (if possible) or clear the contents of the tag or subfield if not. - Clone a subfield on the item edit page (In my MARC21 installation I had to modify the default framework in order to have a repeatable item subfield to test with). Signed-off-by: David Nind --- koha-tmpl/intranet-tmpl/prog/js/cataloging.js | 100 ++++++++------------------ 1 file changed, 28 insertions(+), 72 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js index 1bce295f0f..a172f5f1c0 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js +++ b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js @@ -1,3 +1,5 @@ +/* exported openAuth ExpandField CloneField CloneSubfield UnCloneField CloneItemSubfield CheckMandatorySubfields */ + /* * Unified file for catalogue edition */ @@ -52,7 +54,7 @@ function openAuth(tagsubfieldid,authtype,source) { } } mainstring = mainstring.join(' '); - newin=window.open("../authorities/auth_finder.pl?source="+source+"&authtypecode="+authtype+"&index="+tagsubfieldid+"&value_mainstr="+encodeURI(mainmainstring)+"&value_main="+encodeURI(mainstring), "_blank",'width=700,height=550,toolbar=false,scrollbars=yes'); + window.open("../authorities/auth_finder.pl?source="+source+"&authtypecode="+authtype+"&index="+tagsubfieldid+"&value_mainstr="+encodeURI(mainmainstring)+"&value_main="+encodeURI(mainstring), "_blank",'width=700,height=550,toolbar=false,scrollbars=yes'); } function ExpandField(index) { @@ -120,7 +122,8 @@ function CloneField(index, hideMarc, advancedMARCEditor) { } // settings all subfields - for(var i=0,divslen = divs.length ; i") - - // getting all visible subfields for this tag - var subfields = tag.querySelectorAll("div.subfield_line:not( [style*='display:none;'] )"); - var subfieldsLength = subfields.length; - - if(subfieldsLength<=1) return; // nothing to do if there is just one subfield. - - // among all subfields - for(var i=0;i