Bugzilla – Attachment 72287 Details for
Bug 19786
Move template JavaScript to the footer: Authorities, part 2
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19786: Move template JavaScript to the footer: Authorities, part 2
Bug-19786-Move-template-JavaScript-to-the-footer-A.patch (text/plain), 22.81 KB, created by
Katrin Fischer
on 2018-02-28 07:12:58 UTC
(
hide
)
Description:
Bug 19786: Move template JavaScript to the footer: Authorities, part 2
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2018-02-28 07:12:58 UTC
Size:
22.81 KB
patch
obsolete
>From 69d901e6d78c87569f6e5e650776f176306ba5bb Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Fri, 8 Dec 2017 19:57:28 +0000 >Subject: [PATCH] Bug 19786: Move template JavaScript to the footer: > Authorities, part 2 > >This patch modifies the staff client patron lists templates so that >JavaScript is included in the footer instead of the header. > >To test, apply the patch and test the JavaScript-driven features of >each modified template. > >I've made one change to the JavaScript in addition to moving it: I've >made it so that the blank window which pops up briefly in this process >is 100px x 100px instead of full screen. > >- Cataloging -> Add or edit bibliographic record in a framework which > has authorities linked to a tag > -> Click authorities plugin link > -> Create new authority button > -> Autocomplete on text inputs (except "Search all headings") > -> Search > -> Select authority record ("choose") > -> Click authorities plugin link again > -> Clear field > >Signed-off-by: Claire Gravely <claire_gravely@hotmail.com> > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > .../prog/en/includes/auth-finder-search.inc | 105 ---------- > .../prog/en/modules/authorities/auth_finder.tt | 12 +- > .../authorities/blinddetail-biblio-search.tt | 230 +++++++++++---------- > .../modules/authorities/searchresultlist-auth.tt | 49 +++-- > .../intranet-tmpl/prog/js/auth-finder-search.js | 100 +++++++++ > 5 files changed, 256 insertions(+), 240 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/js/auth-finder-search.js > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/auth-finder-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/auth-finder-search.inc >index 16a666e..22f9a75 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/auth-finder-search.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/auth-finder-search.inc >@@ -1,109 +1,4 @@ > [% PROCESS 'form-blocks.inc' %] >-<script type="text/javascript"> >-//<![CDATA[ >- >-$(document).ready(function(){ >- $("#clear").on("click",function(e){ >- e.preventDefault(); >- finderjumpfull('blinddetail-biblio-search.pl?authid=0&index=[% index %]'); >- }); >- $("#createnew").on("click",function(e){ >- e.preventDefault(); >- finderjumpfull('authorities.pl?index=[% index %]&authtypecode=[% authtypecode %]'); >- }); >- // marclist >- $( "#value_any" ).autocomplete({ >- source: function(request, response) { >- $.ajax({ >- url: "/cgi-bin/koha/authorities/ysearch.pl", >- dataType: "json", >- data: { >- authtypecode : "[% authtypecode %]", >- term: request.term, >- op: "do_search", >- type: "intranet", >- and_or: "and", >- operator: "contains", >- orderby: "HeadingAsc", >- querytype: "marclist" >- }, >- success: function(data) { >- response( $.map( data, function( item ) { >- return { >- label: item.summary, >- value: item.summary >- } >- })); >- } >- }); >- }, >- minLength: 3, >- }); >- // mainentry >- $( "#value_main" ).autocomplete({ >- source: function(request, response) { >- $.ajax({ >- url: "/cgi-bin/koha/authorities/ysearch.pl", >- dataType: "json", >- data: { >- authtypecode : "[% authtypecode %]", >- term: request.term, >- op: "do_search", >- type: "intranet", >- and_or: "and", >- operator: "contains", >- orderby: "HeadingAsc", >- querytype: "mainentry" >- }, >- success: function(data) { >- response( $.map( data, function( item ) { >- return { >- label: item.summary, >- value: item.summary >- } >- })); >- } >- }); >- }, >- minLength: 3, >- }); >- // mainmainentry >- $( "#value_mainstr" ).autocomplete({ >- source: function(request, response) { >- $.ajax({ >- url: "/cgi-bin/koha/authorities/ysearch.pl", >- dataType: "json", >- data: { >- authtypecode : "[% authtypecode %]", >- term: request.term, >- op: "do_search", >- type: "intranet", >- and_or: "and", >- operator: "contains", >- orderby: "HeadingAsc", >- querytype: "mainmainentry" >- }, >- success: function(data) { >- response( $.map( data, function( item ) { >- return { >- label: item.summary, >- value: item.summary >- } >- })); >- } >- }); >- }, >- minLength: 3, >- }); >-}); >- >-function finderjumpfull(page) >-{ >- window.open(page,'','fullscreen,scrollbars'); >-} >- >-//]]> >-</script> > > <div id="toolbar" class="btn-toolbar"> > <div class="btn-group"><a href="#" id="clear" class="btn btn-default btn-sm"><i class="fa fa-trash"></i> Clear field</a></div> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/auth_finder.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/auth_finder.tt >index b1d9971..7460ecc 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/auth_finder.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/auth_finder.tt >@@ -1,3 +1,4 @@ >+[% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Cataloging authority plugin</title> > [% INCLUDE 'doc-head-close.inc' %] >@@ -21,4 +22,13 @@ > </div> > </div> > </div> >-[% INCLUDE 'popup-bottom.inc' %] >+ >+[% MACRO jsinclude BLOCK %] >+ <script type="text/javascript"> >+ var index = "[% index %]"; >+ var authtypecode = "[% authtypecode %]"; >+ </script> >+ <script type="text/javascript" src="[% interface %]/[% theme %]/js/auth-finder-search.js"></script> >+[% END %] >+ >+[% INCLUDE 'intranet-bottom.inc' popup_window = 1 %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/blinddetail-biblio-search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/blinddetail-biblio-search.tt >index f6ab158..8bd3bcd 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/blinddetail-biblio-search.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/blinddetail-biblio-search.tt >@@ -1,129 +1,131 @@ >+[% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Authority details</title> > [% INCLUDE 'doc-head-close.inc' %] >-<script type="text/javascript"> >-//<![CDATA[ >- $(document).ready(function(){ >- var index_start = "[% index %]"; >- var whichfield; >- try { >- whichfield = opener.opener.document.getElementById(index_start); >- } catch(e) { >- return; >- } >- >- var field_start = whichfield.parentNode.parentNode; >- >- // Sets the good number of form fields for the specified subfield >- // Returns false if the cloning failed >- function SetSubfieldNumber(subfield_name, nb) { >- // Nothing to do if we only have one value >- if(nb <= 1) { >- return true; >- } >- >- // Find the subfield we want to clone >- var re = new RegExp('^subfield' + subfield_name,'g'); >- var subfields = $(field_start).children('div').filter( function() { >- return this.id.match(re); >- }); >- >- // Try to add as many clones as needed >- try { >- for(var i=0; i<nb-subfields.length; i++) { >- window.opener.opener.CloneSubfield(subfields[0].getAttribute('id'),'[% advancedMARCEditor %]'); >- } >- } >- catch(err) { >- return false; >- } >- return true; >- } >- >- // Fills the subfield with the values entered in argument >- function SetSubfieldValues() { >- // Get the arguments >- var subfield_name = arguments[0]; >- var values = new Array(); >- for(var i=1; i<arguments.length; i++) { >- values.push(arguments[i]); >- } >- >- // Create the correct number of form fields for all values >- // If the field cloning failed, only the first value will be added to the form. >- SetSubfieldNumber(subfield_name, values.length); >- >- // Find the subfields where we will add the new values >- var re = new RegExp('^subfield' + subfield_name,'g'); >- var subfields = $(field_start).children('div').filter( function() { >- return this.id.match(re); >- }); >- >- // Add the new values to those subfields, empty the additional fields >- var i=0; >- subfields.each(function() { >- if(i in values) { >- this.getElementsByTagName('input')[1].value = values[i]; >- } >- else { >- this.getElementsByTagName('input')[1].value = ""; >- } >- i++; >- }); >- } >- >- [% UNLESS ( clear ) %] >- [% FOREACH SUBFIELD_LOO IN SUBFIELD_LOOP %] >- SetSubfieldValues( >- "[% tag_number |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %][% SUBFIELD_LOO.marc_subfield |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]" >- [% FOREACH marc_value IN SUBFIELD_LOO.marc_values %] >- ,"[% marc_value |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]" >- [% END %] >- ); >- [% END %] >- var indicators = field_start.getElementsByClassName('indicator flat'); >- indicators[0].value="[% indicator1 %]"; >- indicators[1].value="[% indicator2 %]"; >- [% END %] >- >- // browse all its subfields (clear and $9) >- var subfields = field_start.getElementsByTagName('input'); >- var re = /^tag_\d*_code_/; >- for(var i=0, len = subfields.length ; i< len ; i++) { // browse all subfields >- if(subfields[i].hasAttribute('name') == 0 ) {continue; } // div elements specific to Select2 >- if(subfields[i].getAttribute('name').match(re)){ // it s a subfield >- var code = subfields[i]; // code is the first input >- var subfield = subfields[i+1]; // subfield the second >- >- [% IF ( clear ) %] >- if (subfield){subfield.value="" ;} >- [% ELSE %] >- if(code.value=='9'){ >- subfield.value = "[% authid |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]"; >- break; >- } >- [% END %] >- } >- } >- >- opener.close(); >- window.close(); >- >- return false; >- }); >-//]]> >-</script> > </head> >+ > <body id="auth_blinddetail-biblio-search" class="auth"> > > <div id="doc" class="yui-t7"> > <div id="bd"> > <div class="yui-g"> > >- >+ <div id="loading"> <img src="[% interface %]/[% theme %]/img/spinner-small.gif" alt="" /> Loading </div> > > </div> > </div> > </div> > >-[% INCLUDE 'popup-bottom.inc' %] >+[% MACRO jsinclude BLOCK %] >+ <script type="text/javascript"> >+ $(document).ready(function(){ >+ var index_start = "[% index %]"; >+ var whichfield; >+ try { >+ whichfield = opener.opener.document.getElementById(index_start); >+ } catch(e) { >+ return; >+ } >+ >+ var field_start = whichfield.parentNode.parentNode; >+ >+ // Sets the good number of form fields for the specified subfield >+ // Returns false if the cloning failed >+ function SetSubfieldNumber(subfield_name, nb) { >+ // Nothing to do if we only have one value >+ if(nb <= 1) { >+ return true; >+ } >+ >+ // Find the subfield we want to clone >+ var re = new RegExp('^subfield' + subfield_name,'g'); >+ var subfields = $(field_start).children('div').filter( function() { >+ return this.id.match(re); >+ }); >+ >+ // Try to add as many clones as needed >+ try { >+ for(var i=0; i<nb-subfields.length; i++) { >+ window.opener.opener.CloneSubfield(subfields[0].getAttribute('id'),'[% advancedMARCEditor %]'); >+ } >+ } >+ catch(err) { >+ return false; >+ } >+ return true; >+ } >+ >+ // Fills the subfield with the values entered in argument >+ function SetSubfieldValues() { >+ // Get the arguments >+ var subfield_name = arguments[0]; >+ var values = new Array(); >+ for(var i=1; i<arguments.length; i++) { >+ values.push(arguments[i]); >+ } >+ >+ // Create the correct number of form fields for all values >+ // If the field cloning failed, only the first value will be added to the form. >+ SetSubfieldNumber(subfield_name, values.length); >+ >+ // Find the subfields where we will add the new values >+ var re = new RegExp('^subfield' + subfield_name,'g'); >+ var subfields = $(field_start).children('div').filter( function() { >+ return this.id.match(re); >+ }); >+ >+ // Add the new values to those subfields, empty the additional fields >+ var i=0; >+ subfields.each(function() { >+ if(i in values) { >+ this.getElementsByTagName('input')[1].value = values[i]; >+ } >+ else { >+ this.getElementsByTagName('input')[1].value = ""; >+ } >+ i++; >+ }); >+ } >+ >+ [% UNLESS ( clear ) %] >+ [% FOREACH SUBFIELD_LOO IN SUBFIELD_LOOP %] >+ SetSubfieldValues( >+ "[% tag_number |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %][% SUBFIELD_LOO.marc_subfield |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]" >+ [% FOREACH marc_value IN SUBFIELD_LOO.marc_values %] >+ ,"[% marc_value |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]" >+ [% END %] >+ ); >+ [% END %] >+ var indicators = field_start.getElementsByClassName('indicator flat'); >+ indicators[0].value="[% indicator1 %]"; >+ indicators[1].value="[% indicator2 %]"; >+ [% END %] >+ >+ // browse all its subfields (clear and $9) >+ var subfields = field_start.getElementsByTagName('input'); >+ var re = /^tag_\d*_code_/; >+ for(var i=0, len = subfields.length ; i< len ; i++) { // browse all subfields >+ if(subfields[i].hasAttribute('name') == 0 ) {continue; } // div elements specific to Select2 >+ if(subfields[i].getAttribute('name').match(re)){ // it s a subfield >+ var code = subfields[i]; // code is the first input >+ var subfield = subfields[i+1]; // subfield the second >+ >+ [% IF ( clear ) %] >+ if (subfield){subfield.value="" ;} >+ [% ELSE %] >+ if(code.value=='9'){ >+ subfield.value = "[% authid |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]"; >+ break; >+ } >+ [% END %] >+ } >+ } >+ >+ opener.close(); >+ window.close(); >+ return false; >+ }); >+ </script> >+[% END %] >+ >+[% INCLUDE 'intranet-bottom.inc' popup_window = 1 %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tt >index a73759f..7ba7b1b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tt >@@ -1,3 +1,4 @@ >+[% SET footerjs = 1 %] > [% PROCESS 'authorities-search-results.inc' %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Cataloging authority plugin</title> >@@ -5,26 +6,8 @@ > <style type="text/css"> > #custom-doc { width:51.46em;*width:50.17em;min-width:675px; margin:auto; text-align:left; } > </style> >-<script type="text/javascript"> >- >-function jumpfull(page) >-{ >- window.open(page,'','fullscreen,scrollbars'); >-} >- >-function doauth(authid, index, repet) >-{ >-[% IF source == 'auth' %] >- var e = document.getElementById("relationship"); >- var relationship = e.options[e.selectedIndex].value; >- >- jumpfull('blinddetail-biblio-search.pl?authid=' + authid + '&index=' + index + '&repet=' + repet + '&relationship=' + relationship); >-[% ELSE %] >- jumpfull('blinddetail-biblio-search.pl?authid=' + authid + '&index=' + index + '&repet=' + repet); >-[% END %] >-} >-</script> > </head> >+ > <body id="auth_searchresultlist_auth" class="auth"> > <div id="custom-doc" class="yui-t7"> > >@@ -111,4 +94,30 @@ function doauth(authid, index, repet) > </div> > </div> > </div> >-[% INCLUDE 'popup-bottom.inc' %] >+ >+[% MACRO jsinclude BLOCK %] >+ <script type="text/javascript"> >+ var index = "[% index %]"; >+ var authtypecode = "[% authtypecode %]"; >+ </script> >+ <script type="text/javascript" src="[% interface %]/[% theme %]/js/auth-finder-search.js"></script> >+ <script type="text/javascript"> >+ >+ function jumpfull(page){ >+ window.open(page,'','width=100,height=100,resizable=yes,toolbar=false,scrollbars=yes,top'); >+ } >+ >+ function doauth(authid, index, repet){ >+ [% IF source == 'auth' %] >+ var e = document.getElementById("relationship"); >+ var relationship = e.options[e.selectedIndex].value; >+ >+ jumpfull('blinddetail-biblio-search.pl?authid=' + authid + '&index=' + index + '&repet=' + repet + '&relationship=' + relationship); >+ [% ELSE %] >+ jumpfull('blinddetail-biblio-search.pl?authid=' + authid + '&index=' + index + '&repet=' + repet); >+ [% END %] >+ } >+ </script> >+[% END %] >+ >+[% INCLUDE 'intranet-bottom.inc' popup_window = 1 %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/auth-finder-search.js b/koha-tmpl/intranet-tmpl/prog/js/auth-finder-search.js >new file mode 100644 >index 0000000..ab1d394 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/js/auth-finder-search.js >@@ -0,0 +1,100 @@ >+/* global index authtypecode */ >+ >+$(document).ready(function(){ >+ $("#clear").on("click",function(e){ >+ e.preventDefault(); >+ finderjumpfull('blinddetail-biblio-search.pl?authid=0&index=' + index ); >+ }); >+ $("#createnew").on("click",function(e){ >+ e.preventDefault(); >+ finderjumpfull('authorities.pl?index=' + index + '&authtypecode=' + authtypecode ); >+ }); >+ // marclist >+ $( "#value_any" ).autocomplete({ >+ source: function(request, response) { >+ $.ajax({ >+ url: "/cgi-bin/koha/authorities/ysearch.pl", >+ dataType: "json", >+ data: { >+ authtypecode : authtypecode, >+ term: request.term, >+ op: "do_search", >+ type: "intranet", >+ and_or: "and", >+ operator: "contains", >+ orderby: "HeadingAsc", >+ querytype: "marclist" >+ }, >+ success: function(data) { >+ response( $.map( data, function( item ) { >+ return { >+ label: item.summary, >+ value: item.summary >+ }; >+ })); >+ } >+ }); >+ }, >+ minLength: 3, >+ }); >+ // mainentry >+ $( "#value_main" ).autocomplete({ >+ source: function(request, response) { >+ $.ajax({ >+ url: "/cgi-bin/koha/authorities/ysearch.pl", >+ dataType: "json", >+ data: { >+ authtypecode : authtypecode, >+ term: request.term, >+ op: "do_search", >+ type: "intranet", >+ and_or: "and", >+ operator: "contains", >+ orderby: "HeadingAsc", >+ querytype: "mainentry" >+ }, >+ success: function(data) { >+ response( $.map( data, function( item ) { >+ return { >+ label: item.summary, >+ value: item.summary >+ }; >+ })); >+ } >+ }); >+ }, >+ minLength: 3, >+ }); >+ // mainmainentry >+ $( "#value_mainstr" ).autocomplete({ >+ source: function(request, response) { >+ $.ajax({ >+ url: "/cgi-bin/koha/authorities/ysearch.pl", >+ dataType: "json", >+ data: { >+ authtypecode : authtypecode, >+ term: request.term, >+ op: "do_search", >+ type: "intranet", >+ and_or: "and", >+ operator: "contains", >+ orderby: "HeadingAsc", >+ querytype: "mainmainentry" >+ }, >+ success: function(data) { >+ response( $.map( data, function( item ) { >+ return { >+ label: item.summary, >+ value: item.summary >+ }; >+ })); >+ } >+ }); >+ }, >+ minLength: 3, >+ }); >+}); >+ >+function finderjumpfull(page){ >+ window.open(page,'','width=100,height=100,resizable=yes,toolbar=false,scrollbars=yes,top'); >+} >-- >2.1.4
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 19786
:
69744
|
71820
|
71903
|
72002
|
72212
| 72287 |
72288