From 00cfd934c1095bfb2f5cee6296955d3a4de4950b Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Fri, 10 Nov 2017 13:23:43 +0000 Subject: [PATCH] Bug 19607: Move admin templates JavaScript to the footer: Basic parameters 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 Edit: Rebased on Bug 19560 Signed-off-by: Josef Moravec Signed-off-by: Jonathan Druart --- .../en/modules/admin/authorised_values.tt | 70 ++++++++------- .../prog/en/modules/admin/branches.tt | 87 ++++++++++--------- .../prog/en/modules/admin/itemtypes.tt | 58 +++++++------ 3 files changed, 111 insertions(+), 104 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt index 8dd1d7bbfa..fc6c559d7c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt @@ -1,3 +1,4 @@ +[% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] Koha › Administration › Authorized values [% IF op == 'add_form' %] @@ -9,42 +10,6 @@ [% INCLUDE 'doc-head-close.inc' %] <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" /> -[% INCLUDE 'datatables.inc' %] -<script type="text/javascript"> -//<![CDATA[ - $(document).ready(function() { - $("#table_authorized_values").dataTable($.extend(true, {}, dataTablesDefaults, { - "aoColumnDefs": [ - { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false }, - ], - "aaSorting": [[ 1, "asc" ]], - "sPaginationType": "four_button" - })); - - if ( $("#branches option:selected").length < 1 ) { - $("#branches option:first").attr("selected", "selected"); - } - $('#icons').tabs(); - - $("a.delete").click(function(){ - return confirm(_("Are you sure you want to delete this authorized value?")); - }); -}); -//]]> -</script> - -[% IF op == 'list' %] -<script type="text/javascript"> -//<![CDATA[ -$(document).ready(function() { - $('#category').find("input:submit").hide(); - $('#searchfield').change(function() { - $('#category').submit(); - }); -}); -//]]> -</script> -[% END %] <style type="text/css"> fieldset.rows div.toptabs li { clear:none;margin-right:.5em;padding-bottom:0;width:auto; } @@ -53,6 +18,7 @@ $(document).ready(function() { fieldset.rows .ui-tabs-nav { margin-left : 10px; } </style> </head> + <body id="admin_authorised_values" class="admin"> [% INCLUDE 'header.inc' %] [% INCLUDE 'prefs-admin-search.inc' %] @@ -313,4 +279,36 @@ $(document).ready(function() { [% INCLUDE 'admin-menu.inc' %] </div> </div> + +[% MACRO jsinclude BLOCK %] + <script type="text/javascript" src="[% interface %]/[% theme %]/js/admin-menu.js"></script> + [% INCLUDE 'datatables.inc' %] + <script type="text/javascript"> + $(document).ready(function() { + $("#table_authorized_values").dataTable($.extend(true, {}, dataTablesDefaults, { + "aoColumnDefs": [ + { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false }, + ], + "aaSorting": [[ 1, "asc" ]], + "sPaginationType": "four_button" + })); + + if ( $("#branches option:selected").length < 1 ) { + $("#branches option:first").attr("selected", "selected"); + } + $('#icons').tabs(); + + $("a.delete").click(function(){ + return confirm(_("Are you sure you want to delete this authorized value?")); + }); + [% IF op == 'list' %] + $('#category').find("input:submit").hide(); + $('#searchfield').change(function() { + $('#category').submit(); + }); + [% END %] + }); + </script> + +[% END %] [% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt index 7964e69c56..d8c5b5c96e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt @@ -1,3 +1,4 @@ +[% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] <title>Koha › Administration › Libraries and groups [% IF op == 'editcategory' %] @@ -12,48 +13,8 @@ [% INCLUDE 'doc-head-close.inc' %] -[% INCLUDE 'datatables.inc' %] - - + [% INCLUDE 'header.inc' %] [% INCLUDE 'prefs-admin-search.inc' %] @@ -407,4 +368,48 @@ tinyMCE.init({ [% INCLUDE 'admin-menu.inc' %] + +[% MACRO jsinclude BLOCK %] + + [% INCLUDE 'datatables.inc' %] + + +[% END %] + [% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt index 3729d656f1..4062312ecd 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt @@ -1,6 +1,7 @@ [% USE Koha %] [% USE AuthorisedValues %] [% USE Price %] +[% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] Koha › Administration › Item types [% IF op == 'add_form' %]› [% IF ( itemtype ) %] @@ -22,33 +23,6 @@ Data deleted [% INCLUDE 'doc-head-close.inc' %] -[% INCLUDE 'greybox.inc' %] -[% INCLUDE 'datatables.inc' %] - + [% INCLUDE 'header.inc' %] [% INCLUDE 'prefs-admin-search.inc' %] @@ -418,4 +393,33 @@ Item types administration [% INCLUDE 'admin-menu.inc' %] + +[% MACRO jsinclude BLOCK %] + + [% INCLUDE 'greybox.inc' %] + [% INCLUDE 'datatables.inc' %] + +[% END %] [% INCLUDE 'intranet-bottom.inc' %] -- 2.39.5