From 1e746becc277883281923900891fdb3f5ae755c9 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Mon, 20 Nov 2017 16:41:33 +0000 Subject: [PATCH] Bug 19656: Move rotating collections templates JS to the footer This patch modifies the staff client's rotating collections templates so that JavaScript is included in the footer instead of the header. The patch moves JavaScript from each template and the rotating collections toolbar into a single external JavaScript file. To test, apply the patch and test the JavaScript-driven features of each page: All button controls, DataTables functionality, form validation, etc. Signed-off-by: Claire Gravely Signed-off-by: Josef Moravec Signed-off-by: Jonathan Druart --- .../includes/rotating-collections-toolbar.inc | 46 +++++++------------ .../modules/rotating_collections/addItems.tt | 15 +++--- .../rotating_collections/editCollections.tt | 7 +++ .../rotatingCollections.tt | 30 ++++-------- .../transferCollection.tt | 7 +++ .../prog/js/rotating-collections.js | 27 +++++++++++ 6 files changed, 74 insertions(+), 58 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/js/rotating-collections.js diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/rotating-collections-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/rotating-collections-toolbar.inc index 9dd3e7a45a..f46f9f2378 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/rotating-collections-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/rotating-collections-toolbar.inc @@ -1,31 +1,17 @@ - +
+ -
- - - [% IF ( colId ) %] - -
- Edit -
-
- Delete -
- [% END %] -
+ [% IF ( colId ) %] + +
+ Edit +
+
+ Delete +
+ [% END %] +
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/addItems.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/addItems.tt index 43d4a8b66e..c7bf918e70 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/addItems.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/addItems.tt @@ -1,14 +1,9 @@ +[% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] Koha › Tools › Rotating collections › Collection [% colTitle %] ’ Add or remove items [% INCLUDE 'doc-head-close.inc' %] - + [% INCLUDE 'header.inc' %] [% INCLUDE 'cat-search.inc' %] @@ -124,4 +119,10 @@ [% INCLUDE 'tools-menu.inc' %] + +[% MACRO jsinclude BLOCK %] + + +[% END %] + [% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/editCollections.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/editCollections.tt index 9504b61e5e..cb0e7297b9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/editCollections.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/editCollections.tt @@ -1,3 +1,4 @@ +[% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] Koha › Tools › Rotating collections › [%- IF ( action == "new" ) %] @@ -134,4 +135,10 @@ [% INCLUDE 'tools-menu.inc' %] </div> </div> <!-- /#bd --> + +[% MACRO jsinclude BLOCK %] + <script type="text/javascript" src="[% interface %]/[% theme %]/js/tools-menu.js"></script> + <script type="text/javascript" src="[% interface %]/[% theme %]/js/rotating-collections.js"></script> +[% END %] + [% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/rotatingCollections.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/rotatingCollections.tt index 7cf35f7d14..3564235cc1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/rotatingCollections.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/rotatingCollections.tt @@ -1,30 +1,11 @@ [% USE Branches %] +[% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] <title>Koha › Tools › Rotating collections [% INCLUDE 'doc-head-close.inc' %] -[% INCLUDE 'datatables.inc' %] - + [% INCLUDE 'header.inc' %] [% INCLUDE 'cat-search.inc' %] @@ -83,4 +64,11 @@ [% INCLUDE 'tools-menu.inc' %] + +[% MACRO jsinclude BLOCK %] + [% INCLUDE 'datatables.inc' %] + + +[% END %] + [% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/transferCollection.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/transferCollection.tt index 43f76a4f24..7d457b8972 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/transferCollection.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/rotating_collections/transferCollection.tt @@ -1,4 +1,5 @@ [% USE Branches %] +[% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] Koha › Tools › Rotating collections › Transfer collection [% INCLUDE 'doc-head-close.inc' %] @@ -56,4 +57,10 @@ [% INCLUDE 'tools-menu.inc' %] + +[% MACRO jsinclude BLOCK %] + + +[% END %] + [% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/rotating-collections.js b/koha-tmpl/intranet-tmpl/prog/js/rotating-collections.js new file mode 100644 index 0000000000..bed5e9a093 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/rotating-collections.js @@ -0,0 +1,27 @@ +/* global _ dataTablesDefaults */ + +$(document).ready(function(){ + $("#barcode").focus(); + + $(".confirmdelete").click(function(){ + $(this).parents('tr').addClass("warn"); + if(confirm(_("Are you sure you want to delete this rotating collection?"))){ + return true; + } else { + $(this).parents('tr').removeClass("warn"); + return false; + } + }); + + if( $('#rotating-collections-table').length > 0 ){ + $('#rotating-collections-table').dataTable($.extend(true, {}, dataTablesDefaults, { + "autoWidth": false, + "aoColumnDefs": [ + { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false }, + ], + "sPaginationType": "four_button" + } )); + } + + +}); -- 2.39.5