Bugzilla – Attachment 69068 Details for
Bug 19600
Move admin templates JavaScript to the footer: Other catalog pages
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19600: Move admin templates JavaScript to the footer: Other catalog pages
Bug-19600-Move-admin-templates-JavaScript-to-the-f.patch (text/plain), 20.55 KB, created by
Simon Pouchol
on 2017-11-09 16:12:13 UTC
(
hide
)
Description:
Bug 19600: Move admin templates JavaScript to the footer: Other catalog pages
Filename:
MIME Type:
Creator:
Simon Pouchol
Created:
2017-11-09 16:12:13 UTC
Size:
20.55 KB
patch
obsolete
>From d73bd2e4d5489ff670cbb185871321b8d287039a Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Thu, 9 Nov 2017 13:24:04 +0000 >Subject: [PATCH] Bug 19600: Move admin templates JavaScript to the footer: > Other catalog pages > >This patch modifies the staff client catalog-related administration >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: All button controls, DataTables functionality, >tabs, etc. > >Signed-off-by: Simon Pouchol <simon.pouchol@biblibre.com> >--- > .../prog/en/modules/admin/classsources.tt | 5 + > .../prog/en/modules/admin/items_search_field.tt | 7 +- > .../prog/en/modules/admin/items_search_fields.tt | 16 +- > .../prog/en/modules/admin/matching-rules.tt | 295 +++++++++++---------- > .../prog/en/modules/admin/oai_set_mappings.tt | 75 +++--- > .../prog/en/modules/admin/oai_sets.tt | 79 +++--- > 6 files changed, 250 insertions(+), 227 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/classsources.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/classsources.tt >index 314b51e..45afd53 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/classsources.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/classsources.tt >@@ -1,3 +1,4 @@ >+[% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Administration › Classification sources > [% IF ( class_source_form ) %] >@@ -265,4 +266,8 @@ > [% INCLUDE 'admin-menu.inc' %] > </div> > </div> >+ >+[% MACRO jsinclude BLOCK %] >+ <script type="text/javascript" src="[% interface %]/[% theme %]/js/admin-menu.js"></script> >+[% END %] > [% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/items_search_field.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/items_search_field.tt >index 06fcd06..aea8b46 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/items_search_field.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/items_search_field.tt >@@ -1,3 +1,4 @@ >+[% SET footerjs = 1 %] > [% USE AuthorisedValues %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Administration › Item search fields</title> >@@ -39,4 +40,8 @@ > </div> > </div> > >- [% INCLUDE 'intranet-bottom.inc' %] >+[% MACRO jsinclude BLOCK %] >+ <script type="text/javascript" src="[% interface %]/[% theme %]/js/admin-menu.js"></script> >+[% END %] >+ >+[% INCLUDE 'intranet-bottom.inc' %] >\ No newline at end of file >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/items_search_fields.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/items_search_fields.tt >index 6e12b1b..ea419ca 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/items_search_fields.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/items_search_fields.tt >@@ -1,12 +1,10 @@ >+[% SET footerjs = 1 %] > [% USE AuthorisedValues %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Administration › Item search fields</title> > [% INCLUDE 'doc-head-close.inc' %] >- <script type="text/javascript"> >- var MSG_ITEM_SEARCH_DELETE_CONFIRM = _("Are you sure you want to delete this field?"); >- </script> >- <script type="text/javascript" src="[% interface %]/[% theme %]/js/item_search_fields.js"></script> > </head> >+ > <body id="admin_itemssearchfields" class="admin"> > [% INCLUDE 'header.inc' %] > [% INCLUDE 'prefs-admin-search.inc' %] >@@ -110,4 +108,12 @@ > </div> > </div> > >- [% INCLUDE 'intranet-bottom.inc' %] >+[% MACRO jsinclude BLOCK %] >+ <script type="text/javascript" src="[% interface %]/[% theme %]/js/admin-menu.js"></script> >+ <script type="text/javascript"> >+ var MSG_ITEM_SEARCH_DELETE_CONFIRM = _("Are you sure you want to delete this field?"); >+ </script> >+ <script type="text/javascript" src="[% interface %]/[% theme %]/js/item_search_fields.js"></script> >+[% END %] >+ >+[% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/matching-rules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/matching-rules.tt >index 6c15b2b..b49f7ed 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/matching-rules.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/matching-rules.tt >@@ -1,3 +1,4 @@ >+[% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Administration › Record matching rules > [% IF ( matching_rule_form ) %] >@@ -46,153 +47,6 @@ > </select> > [% END %] > >-<script type="text/javascript"> >-//<![CDATA[ >- >-var maxMatchPoint = [% max_matchpoint %]; >-var maxMatchCheck = [% max_matchcheck %]; >- >-function InsertMatchpoint(loc, index) { >- var original= $("#"+index); >- var clone = original.clone(); >- clone.show(); >- >- // update IDs and form names >- maxMatchPoint++; >- clone.attr('id', 'mp_' + maxMatchPoint); >- $("span.counter",clone).html(maxMatchPoint); >- $("label",clone).each(function(){ >- var s = $(this).attr("for"); >- if (s.match(/mp_num/)) { >- $(this).attr("for",s.replace(/mp_num/, 'mp_' + maxMatchPoint)); >- } >- }); >- >- $("div",clone).each(function(){ >- var s = $(this).attr("id"); >- if (s.match(/mp_num/)) { >- $(this).attr("id",s.replace(/mp_num/, 'mp_' + maxMatchPoint)); >- } >- }); >- $("input",clone).each(function(){ >- var s = $(this).attr("id"); >- if(s.match(/mp_num/)){ >- $(this).attr("id",s.replace(/mp_num/, 'mp_' + maxMatchPoint)); >- } >- >- var s = $(this).attr("name"); >- if(s.match(/mp_num/)){ >- $(this).attr("name",s.replace(/mp_num/, 'mp_' + maxMatchPoint)); >- } >- }); >- $("#match_points").append(clone); >-} >- >-function InsertMatchcheck(loc, index) { >- var original= $("#"+index); >- var clone = original.clone(); >- clone.show(); >- >- // update IDs and form names >- maxMatchCheck++; >- clone.attr('id', 'mc_' + maxMatchCheck); >- $("span.counter",clone).html(maxMatchCheck); >- $("label",clone).each(function(){ >- var s = $(this).attr("for"); >- if (s.match(/mc_num/)) { >- $(this).attr("for",s.replace(/mc_num/, 'mc_' + maxMatchCheck)); >- } >- }); >- >- $("div",clone).each(function(){ >- var s = $(this).attr("id"); >- if (s.match(/mc_num/)) { >- $(this).attr("id",s.replace(/mc_num/, 'mc_' + maxMatchCheck)); >- } >- }); >- $("input",clone).each(function(){ >- var s = $(this).attr("id"); >- if(s.match(/mc_num/)){ >- $(this).attr("id",s.replace(/mc_num/, 'mc_' + maxMatchCheck)); >- } >- >- var s = $(this).attr("name"); >- if(s.match(/mc_num/)){ >- $(this).attr("name",s.replace(/mc_num/, 'mc_' + maxMatchCheck)); >- } >- }); >- $("#match_checks").append(clone); >-} >- >-function DeleteMatchpoint(loc) { >- $(loc).parent().parent().parent().remove(); >- if($(".matchgroup",$("#match_points")).length == 0){ >- maxMatchPoint = 0; >- $("#addMatchPoint").show(); >- } >-} >- >-function DeleteMatchcheck(loc) { >- $(loc).parent().parent().parent().remove(); >- if($(".matchgroup",$("#match_checks")).length == 0){ >- maxMatchCheck = 0; >- $("#addMatchCheck").show(); >- } >-} >- >-function DoCancel(f) { >- f.op.value=''; >- document.Aform.submit(); >-} >- >-function CheckMatchingRuleForm(f) { >- var ok=1; >- var _alertString=""; >- var alertString2; >- if (f.code.value.length==0) { >- _alertString += "\n- " + _("Matching rule code missing"); >- } >- if (f.description.value.length==0) { >- _alertString += "\n- " + _("Description missing"); >- } >- if (f.threshold.value.length==0) { >- _alertString += "\n- " + _("Threshold missing"); >- } >- if (_alertString.length==0) { >- document.Aform.submit(); >- } else { >- alertString2 = _("Form not submitted because of the following problem(s)"); >- alertString2 += "\n------------------------------------------------------------------------------------\n"; >- alertString2 += _alertString; >- alert(alertString2); >- } >-} >- >-function CheckRuleForm(f) { >- var ok=1; >- var _alertString=""; >- var alertString2; >- if (f.sort_rule.value.length==0) { >- _alertString += "\n- " + _("Filing rule code missing"); >- } >- if (f.description.value.length==0) { >- _alertString += "\n- " + _("Description missing"); >- } >- if (f.sort_routine.value.length==0) { >- _alertString += "\n- " + _("Sort routine missing"); >- } >- if (_alertString.length==0) { >- document.Aform.submit(); >- } else { >- alertString2 = _("Form not submitted because of the following problem(s)"); >- alertString2 += "\n------------------------------------------------------------------------------------\n"; >- alertString2 += _alertString; >- alert(alertString2); >- } >-} >- >-//]]> >-</script> > <style type="text/css"> > fieldset.rows fieldset.rows { border-width : 0; } > fieldset.rows fieldset.rows fieldset.rows { border-width : 1px; } >@@ -723,4 +577,151 @@ function CheckRuleForm(f) { > [% INCLUDE 'admin-menu.inc' %] > </div> > </div> >+ >+[% MACRO jsinclude BLOCK %] >+ <script type="text/javascript" src="[% interface %]/[% theme %]/js/admin-menu.js"></script> >+ <script type="text/javascript"> >+ var maxMatchPoint = [% max_matchpoint %]; >+ var maxMatchCheck = [% max_matchcheck %]; >+ >+ function InsertMatchpoint(loc, index) { >+ var original= $("#"+index); >+ var clone = original.clone(); >+ clone.show(); >+ >+ // update IDs and form names >+ maxMatchPoint++; >+ clone.attr('id', 'mp_' + maxMatchPoint); >+ $("span.counter",clone).html(maxMatchPoint); >+ $("label",clone).each(function(){ >+ var s = $(this).attr("for"); >+ if (s.match(/mp_num/)) { >+ $(this).attr("for",s.replace(/mp_num/, 'mp_' + maxMatchPoint)); >+ } >+ }); >+ >+ $("div",clone).each(function(){ >+ var s = $(this).attr("id"); >+ if (s.match(/mp_num/)) { >+ $(this).attr("id",s.replace(/mp_num/, 'mp_' + maxMatchPoint)); >+ } >+ }); >+ $("input",clone).each(function(){ >+ var s = $(this).attr("id"); >+ if(s.match(/mp_num/)){ >+ $(this).attr("id",s.replace(/mp_num/, 'mp_' + maxMatchPoint)); >+ } >+ >+ var s = $(this).attr("name"); >+ if(s.match(/mp_num/)){ >+ $(this).attr("name",s.replace(/mp_num/, 'mp_' + maxMatchPoint)); >+ } >+ }); >+ $("#match_points").append(clone); >+ } >+ >+ function InsertMatchcheck(loc, index) { >+ var original= $("#"+index); >+ var clone = original.clone(); >+ clone.show(); >+ >+ // update IDs and form names >+ maxMatchCheck++; >+ clone.attr('id', 'mc_' + maxMatchCheck); >+ $("span.counter",clone).html(maxMatchCheck); >+ $("label",clone).each(function(){ >+ var s = $(this).attr("for"); >+ if (s.match(/mc_num/)) { >+ $(this).attr("for",s.replace(/mc_num/, 'mc_' + maxMatchCheck)); >+ } >+ }); >+ >+ $("div",clone).each(function(){ >+ var s = $(this).attr("id"); >+ if (s.match(/mc_num/)) { >+ $(this).attr("id",s.replace(/mc_num/, 'mc_' + maxMatchCheck)); >+ } >+ }); >+ $("input",clone).each(function(){ >+ var s = $(this).attr("id"); >+ if(s.match(/mc_num/)){ >+ $(this).attr("id",s.replace(/mc_num/, 'mc_' + maxMatchCheck)); >+ } >+ >+ var s = $(this).attr("name"); >+ if(s.match(/mc_num/)){ >+ $(this).attr("name",s.replace(/mc_num/, 'mc_' + maxMatchCheck)); >+ } >+ }); >+ $("#match_checks").append(clone); >+ } >+ >+ function DeleteMatchpoint(loc) { >+ $(loc).parent().parent().parent().remove(); >+ if($(".matchgroup",$("#match_points")).length == 0){ >+ maxMatchPoint = 0; >+ $("#addMatchPoint").show(); >+ } >+ } >+ >+ function DeleteMatchcheck(loc) { >+ $(loc).parent().parent().parent().remove(); >+ if($(".matchgroup",$("#match_checks")).length == 0){ >+ maxMatchCheck = 0; >+ $("#addMatchCheck").show(); >+ } >+ } >+ >+ function DoCancel(f) { >+ f.op.value=''; >+ document.Aform.submit(); >+ } >+ >+ function CheckMatchingRuleForm(f) { >+ var ok=1; >+ var _alertString=""; >+ var alertString2; >+ if (f.code.value.length==0) { >+ _alertString += "\n- " + _("Matching rule code missing"); >+ } >+ if (f.description.value.length==0) { >+ _alertString += "\n- " + _("Description missing"); >+ } >+ if (f.threshold.value.length==0) { >+ _alertString += "\n- " + _("Threshold missing"); >+ } >+ if (_alertString.length==0) { >+ document.Aform.submit(); >+ } else { >+ alertString2 = _("Form not submitted because of the following problem(s)"); >+ alertString2 += "\n------------------------------------------------------------------------------------\n"; >+ alertString2 += _alertString; >+ alert(alertString2); >+ } >+ } >+ >+ function CheckRuleForm(f) { >+ var ok=1; >+ var _alertString=""; >+ var alertString2; >+ if (f.sort_rule.value.length==0) { >+ _alertString += "\n- " + _("Filing rule code missing"); >+ } >+ if (f.description.value.length==0) { >+ _alertString += "\n- " + _("Description missing"); >+ } >+ if (f.sort_routine.value.length==0) { >+ _alertString += "\n- " + _("Sort routine missing"); >+ } >+ if (_alertString.length==0) { >+ document.Aform.submit(); >+ } else { >+ alertString2 = _("Form not submitted because of the following problem(s)"); >+ alertString2 += "\n------------------------------------------------------------------------------------\n"; >+ alertString2 += _alertString; >+ alert(alertString2); >+ } >+ } >+ </script> >+[% END %] > [% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/oai_set_mappings.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/oai_set_mappings.tt >index 338a53f..2c1a267 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/oai_set_mappings.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/oai_set_mappings.tt >@@ -1,42 +1,7 @@ >+[% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Administration › OAI sets › OAI set mappings</title> > [% INCLUDE 'doc-head-close.inc' %] >-<script type="text/javascript"> >-//<![CDATA[ >-$(document).ready(function() { >- $("#mappingform").submit(function(){ >- hideDialogBox(); >- }); >- $("body").on("click","#ORbutton", function(e){ >- e.preventDefault(); >- newCondition(); >- }); >- $("body").on("click",".clear-field",function(e){ >- e.preventDefault(); >- clearRow(e.target); >- }); >-}); >- >-function newCondition() { >- var tr = $('#ORbutton').parents('tr'); >- var clone = $(tr).clone(); >- $("#ORbutton").parent('td').replaceWith('<td style="text-align:center">OR</td>'); >- $(tr).parent('tbody').append(clone); >-} >-function clearRow(link){ >- var tr = $(link).parent().parent(); >- var found = tr.find('#ORbutton'); >- if( found.length ){ >- tr.find('input[type="text"]').attr("value",""); >- } else { >- tr.find('input[type="text"]').attr("value","").end().hide(); >- } >-} >-function hideDialogBox() { >- $('div.dialog').remove(); >-} >-//]]> >-</script> > </head> > > <body id="admin_oai_set_mappings" class="admin"> >@@ -126,4 +91,42 @@ function hideDialogBox() { > [% INCLUDE 'admin-menu.inc' %] > </div> > </div> >+ >+[% MACRO jsinclude BLOCK %] >+ <script type="text/javascript" src="[% interface %]/[% theme %]/js/admin-menu.js"></script> >+ <script type="text/javascript"> >+ $(document).ready(function() { >+ $("#mappingform").submit(function(){ >+ hideDialogBox(); >+ }); >+ $("body").on("click","#ORbutton", function(e){ >+ e.preventDefault(); >+ newCondition(); >+ }); >+ $("body").on("click",".clear-field",function(e){ >+ e.preventDefault(); >+ clearRow(e.target); >+ }); >+ }); >+ >+ function newCondition() { >+ var tr = $('#ORbutton').parents('tr'); >+ var clone = $(tr).clone(); >+ $("#ORbutton").parent('td').replaceWith('<td style="text-align:center">OR</td>'); >+ $(tr).parent('tbody').append(clone); >+ } >+ function clearRow(link){ >+ var tr = $(link).parent().parent(); >+ var found = tr.find('#ORbutton'); >+ if( found.length ){ >+ tr.find('input[type="text"]').attr("value",""); >+ } else { >+ tr.find('input[type="text"]').attr("value","").end().hide(); >+ } >+ } >+ function hideDialogBox() { >+ $('div.dialog').remove(); >+ } >+ </script> >+[% END %] > [% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/oai_sets.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/oai_sets.tt >index 3475442..b715911 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/oai_sets.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/oai_sets.tt >@@ -1,44 +1,7 @@ >+[% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Administration › [% IF ( op_new ) %]OAI sets configuration › Add a new OAI set[% ELSE %]OAI sets configuration[% END %]</title> > [% INCLUDE 'doc-head-close.inc' %] >-<script type="text/javascript"> >-//<![CDATA[ >-function newDescField() { >- $("#adddescription").before( >- '<li><label>setDescription: </label>' + >- '<textarea style="vertical-align:middle" rows="2" cols="30" name="description"></textarea>' + >- '<a class="remove_description" href="#"><i class="fa fa-fw fa-trash"></i> Remove</a>' + >- '</li>' >- ); >-} >- >-function delDescField(minusButton) { >- var li = minusButton.parent('li'); >- $(li).remove(); >-} >- >-function confirmDelete() { >- return confirm(_("Are you sure you want to delete this OAI set?")); >-} >- >-$(document).ready(function() { >- $(".delete_oai_set").on("click",function(){ >- return confirmDelete(); >- }); >- >- $("body").on("click", ".remove_description", function(e){ >- e.preventDefault(); >- delDescField($(this)); >- }); >- >- $(".add_description").on("click", function(e){ >- e.preventDefault(); >- newDescField(); >- }); >- >-}); >-//]]> >-</script> > </head> > > <body id="admin_oai_sets" class="admin"> >@@ -148,4 +111,44 @@ $(document).ready(function() { > [% INCLUDE 'admin-menu.inc' %] > </div> > </div> >+ >+[% MACRO jsinclude BLOCK %] >+ <script type="text/javascript" src="[% interface %]/[% theme %]/js/admin-menu.js"></script> >+ <script type="text/javascript"> >+ function newDescField() { >+ $("#adddescription").before( >+ '<li><label>setDescription: </label>' + >+ '<textarea style="vertical-align:middle" rows="2" cols="30" name="description"></textarea>' + >+ '<a class="remove_description" href="#"><i class="fa fa-fw fa-trash"></i> Remove</a>' + >+ '</li>' >+ ); >+ } >+ >+ function delDescField(minusButton) { >+ var li = minusButton.parent('li'); >+ $(li).remove(); >+ } >+ >+ function confirmDelete() { >+ return confirm(_("Are you sure you want to delete this OAI set?")); >+ } >+ >+ $(document).ready(function() { >+ $(".delete_oai_set").on("click",function(){ >+ return confirmDelete(); >+ }); >+ >+ $("body").on("click", ".remove_description", function(e){ >+ e.preventDefault(); >+ delDescField($(this)); >+ }); >+ >+ $(".add_description").on("click", function(e){ >+ e.preventDefault(); >+ newDescField(); >+ }); >+ >+ }); >+ </script> >+[% END %] > [% INCLUDE 'intranet-bottom.inc' %] >-- >2.7.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 19600
:
69051
|
69053
|
69068
|
69497
|
69498