From eaa3287705d607bb9b8e22d3903f5f3a457098e2 Mon Sep 17 00:00:00 2001 From: Owen Leonard 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 Signed-off-by: Josef Moravec Signed-off-by: Jonathan Druart --- .../prog/en/modules/admin/classsources.tt | 5 + .../en/modules/admin/items_search_field.tt | 7 +- .../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 314b51e841..45afd53768 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' %] 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 06fcd06ca5..aea8b46227 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 @@ -39,4 +40,8 @@ - [% INCLUDE 'intranet-bottom.inc' %] +[% MACRO jsinclude BLOCK %] + +[% 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 6e12b1b1bd..ea419ca939 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' %] Koha › Administration › Item search fields [% INCLUDE 'doc-head-close.inc' %] - - + [% INCLUDE 'header.inc' %] [% INCLUDE 'prefs-admin-search.inc' %] @@ -110,4 +108,12 @@ - [% INCLUDE 'intranet-bottom.inc' %] +[% MACRO jsinclude BLOCK %] + + + +[% 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 6c15b2b328..b49f7ed68f 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' %] 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 338a53f74f..2c1a2675f5 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 [% INCLUDE 'doc-head-close.inc' %] - @@ -126,4 +91,42 @@ function hideDialogBox() { [% INCLUDE 'admin-menu.inc' %] + +[% MACRO jsinclude BLOCK %] + + +[% 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 3475442070..b715911ae6 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' %] Koha › Administration › [% IF ( op_new ) %]OAI sets configuration › Add a new OAI set[% ELSE %]OAI sets configuration[% END %] [% INCLUDE 'doc-head-close.inc' %] - @@ -148,4 +111,44 @@ $(document).ready(function() { [% INCLUDE 'admin-menu.inc' %] + +[% MACRO jsinclude BLOCK %] + + +[% END %] [% INCLUDE 'intranet-bottom.inc' %] -- 2.39.5