Bugzilla – Attachment 154584 Details for
Bug 34571
Remove use of onclick for ExpandField
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34571: Remove use of "onclick" for ExpandField in cataloguing editors
Bug-34571-Remove-use-of-onclick-for-ExpandField-in.patch (text/plain), 8.28 KB, created by
David Cook
on 2023-08-18 04:35:06 UTC
(
hide
)
Description:
Bug 34571: Remove use of "onclick" for ExpandField in cataloguing editors
Filename:
MIME Type:
Creator:
David Cook
Created:
2023-08-18 04:35:06 UTC
Size:
8.28 KB
patch
obsolete
>From 3d7a3e7df1eda341202a07336b2392cc4654436b Mon Sep 17 00:00:00 2001 >From: David Cook <dcook@prosentient.com.au> >Date: Fri, 18 Aug 2023 04:32:31 +0000 >Subject: [PATCH] Bug 34571: Remove use of "onclick" for ExpandField in > cataloguing editors > >This change replaces the onclick HTML attribute with a Javascript binding >to make it more in line with Koha conventions and make it CSP compatible. > >Test plan: >0. Apply patch >1. Go to http://localhost:8081/cgi-bin/koha/cataloguing/addbiblio.pl?frameworkcode=# >2. Try hiding/unhiding fields >3. Try cloning fields and hiding/unhiding those too >4. Note that everything works as expected >5. Do the same thing for authorities by going to >http://localhost:8081/cgi-bin/koha/authorities/authorities.pl?authtypecode=# >--- > .../prog/en/modules/authorities/authorities.tt | 8 ++++++-- > .../prog/en/modules/cataloguing/addbiblio.tt | 9 +++++++-- > koha-tmpl/intranet-tmpl/prog/js/cataloging.js | 6 ++++-- > 3 files changed, 17 insertions(+), 6 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt >index 7e20732846..b71160a6e4 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt >@@ -341,6 +341,10 @@ > function formatFieldName( string ){ > return "<strong><em>" + string + "</em></strong>"; > } >+ >+ $(document).ready(function(){ >+ $('body').on('click','.expandfield',ExpandField); >+ }); > </script> > [% Asset.css("css/addbiblio.css") | $raw %] > >@@ -528,7 +532,7 @@ > <div class="tag_title" id="div_indicator_tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]"> > [% UNLESS hide_marc %] > [% IF advancedMARCEditor %] >- <a href="#" tabindex="1" class="tagnum" title="[% innerloo.tag_lib | html %] - Click to expand this tag" onclick="ExpandField('tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]'); return false;">[% innerloo.tag | html %]</a> >+ <a href="#" tabindex="1" class="tagnum" title="[% innerloo.tag_lib | html %] - Click to expand this tag" data-field_id="tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]'">[% innerloo.tag | html %]</a> > [% ELSE %] > <span class="tagnum" title="[% innerloo.tag_lib | html %]">[% innerloo.tag | html %]</span> > [% END %] >@@ -588,7 +592,7 @@ > [% END # /UNLESS hide_marc %] > > [% UNLESS advancedMARCEditor %] >- <a href="#" tabindex="1" class="expandfield" onclick="ExpandField('tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]'); return false;" title="Click to expand this tag">[% innerloo.tag_lib | html %]</a> >+ <a href="#" tabindex="1" class="expandfield" data-field_id="tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]" title="Click to expand this tag">[% innerloo.tag_lib | html %]</a> > [% END %] > <span class="field_controls"> > [% IF ( innerloo.repeatable ) %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt >index 1c1e7db0a3..cadbf08e72 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt >@@ -780,6 +780,11 @@ function PopupMARCFieldDoc(field) { > function formatFieldName( string ){ > return "<strong><em>" + string + "</em></strong>"; > } >+ >+ $(document).ready(function(){ >+ $('body').on('click','.expandfield',ExpandField); >+ }); >+ > </script> > [% Asset.css("css/addbiblio.css") | $raw %] > </head> >@@ -1037,7 +1042,7 @@ function PopupMARCFieldDoc(field) { > [% END %] > <div class="tag_title" id="div_indicator_tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]"> > [% IF advancedMARCEditor %] >- <a href="#" tabindex="1" class="tagnum" title="[% innerloo.tag_lib | html %] - Click to expand this tag" onclick="ExpandField('tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]'); return false;">[% innerloo.tag | html %]</a> >+ <a href="#" tabindex="1" class="tagnum" title="[% innerloo.tag_lib | html %] - Click to expand this tag" data-field_id="tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]">[% innerloo.tag | html %]</a> > [% ELSE %] > <span class="tagnum" title="[% innerloo.tag_lib | html %]">[% innerloo.tag | html %]</span> > <a href="#" class="marcdocs" onclick="PopupMARCFieldDoc('[% innerloo.tag | html %]'); return false;"> ?</a> >@@ -1078,7 +1083,7 @@ function PopupMARCFieldDoc(field) { > [% END # /IF innerloo.fixedfield %] - > > [% UNLESS advancedMARCEditor %] >- <a href="#" tabindex="1" class="expandfield" onclick="ExpandField('tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]'); return false;" title="Click to expand this tag">[% innerloo.tag_lib | html %]</a> >+ <a href="#" tabindex="1" class="expandfield" data-field_id="tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]" title="Click to expand this tag">[% innerloo.tag_lib | html %]</a> > [% END %] > > <span class="field_controls"> >diff --git a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js >index d6f6715cc3..602ae9ceaf 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js >@@ -59,7 +59,8 @@ function openAuth(tagsubfieldid,authtype,source) { > window.open("../authorities/auth_finder.pl?source="+source+"&authtypecode="+authtype+"&index="+tagsubfieldid+"&value_mainstr="+encodeURIComponent(mainmainstring)+"&value_main="+encodeURIComponent(mainstring), "_blank",'width=700,height=550,toolbar=false,scrollbars=yes'); > } > >-function ExpandField(index) { >+function ExpandField() { >+ let index = this.dataset.field_id; > var original = document.getElementById(index); //original <li> > var lis = original.getElementsByTagName('li'); > for(var i=0,lislen = lis.length ; i<lislen ; i++){ // foreach li >@@ -77,6 +78,7 @@ function ExpandField(index) { > } > } > } >+ return false; > } > > var current_select2; >@@ -307,7 +309,7 @@ function CloneField(index, hideMarc, advancedMARCEditor) { > } else if (anchors[j].getAttribute('class') == 'buttonMinus') { > anchors[j].setAttribute('onclick',"UnCloneField('" + new_id + "'); return false;"); > } else if (anchors[j].getAttribute('class') == 'expandfield') { >- anchors[j].setAttribute('onclick',"ExpandField('" + new_id + "'); return false;"); >+ anchors[j].setAttribute('data-field_id',new_id); > } > } > } >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 34571
:
154584
|
154586
|
154803