Bug 19647: Move patron lists templates JS to the footer
authorOwen Leonard <oleonard@myacpl.org>
Fri, 17 Nov 2017 16:32:56 +0000 (16:32 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 11 Dec 2017 14:34:20 +0000 (11:34 -0300)
This patch modifies the staff client patron lists templates so that
JavaScript is included in the footer instead of the header.

This patch adds a new JS file, tools-menu.js, which will be added to
each template which has the Tools sidebar menu. Highlighting of the
current page in the sidebar menu will be broken for pages which have not
been modified to use this file.

To test, apply the patch and test the JavaScript-driven features of
each modified template: All button controls, DataTables functionality,
form validation, etc.
resolved the issue, sorry about that, everything is working fine!Signed-off-by: Dominic Pichette <dominic@inlibro.com>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc
koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/add-modify.tt
koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/list.tt
koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/lists.tt
koha-tmpl/intranet-tmpl/prog/js/tools-menu.js [new file with mode: 0644]

index d7b40cf..50e52f7 100644 (file)
@@ -1,20 +1,3 @@
-<script type="text/javascript">//<![CDATA[
-    $(document).ready(function() {
-        var path = location.pathname.substring(1);
-        if (path.indexOf("labels") >= 0 && path.indexOf("spine") < 0 ) {
-          $('#navmenulist a[href$="/cgi-bin/koha/labels/label-home.pl"]').css('font-weight','bold');
-        } else if (path.indexOf("patroncards") >= 0 ) {
-          $('#navmenulist a[href$="/cgi-bin/koha/patroncards/home.pl"]').css('font-weight','bold');
-        } else if (path.indexOf("patron_lists") >= 0 ) {
-          $('#navmenulist a[href$="/cgi-bin/koha/patron_lists/lists.pl"]').css('font-weight','bold');
-        } else if ((path+location.search).indexOf("batchMod.pl?del=1") >= 0 ) {
-          $('#navmenulist a[href$="/cgi-bin/koha/tools/batchMod.pl?del=1"]').css('font-weight','bold');
-        } else {
-          $('#navmenulist a[href$="/' + path + '"]').css('font-weight','bold');
-        }
-    });
-//]]>
-</script>
 <div id="navmenu">
 <div id="navmenulist">
 <ul>
index 6f8408d..f094a61 100644 (file)
@@ -1,3 +1,4 @@
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Tools &rsaquo; Patron lists &rsaquo;
     [% IF list.patron_list_id %]
@@ -63,4 +64,8 @@
         </form>
     </div>
 
+[% MACRO jsinclude BLOCK %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/tools-menu.js"></script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index c06997a..e0092fb 100644 (file)
@@ -1,69 +1,10 @@
 [% USE KohaDates %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Tools &rsaquo; Patron lists &rsaquo; [% list.name %] &rsaquo; Add patrons</title>
 [% INCLUDE 'doc-head-close.inc' %]
 
 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
-[% INCLUDE 'datatables.inc' %]
-
-<script type="text/javascript" src="[% interface %]/js/autocomplete/patrons.js"></script>
-<script type="text/javascript">
-//<![CDATA[
-var MSG_REMOVE_PATRON = _("Remove");
-$(document).ready(function() {
-    $('#patrons_to_add_fieldset').hide();
-
-        $('#patron-list-table').dataTable($.extend(true, {}, dataTablesDefaults, {
-            "order": [[ 3, "asc" ]],
-            "aoColumns": [
-                null,null,null,null,null,null,null,{ "sType": "title-string" },null
-            ],
-            "aoColumnDefs": [
-                { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
-            ],
-            "sPaginationType": "four_button"
-        } ));
-
-    patron_autocomplete({
-        patron_container: $("#patrons_to_add"),
-        input_autocomplete: $("#find_patron"),
-        patron_input_name: 'patrons_to_add'
-    });
-
-    var checkBoxes = $("input[type='checkbox']","#patron-list-table");
-
-    $("#CheckAll").click(function(e){
-        e.preventDefault();
-        checkBoxes.each(function(){
-            $(this).prop("checked",1);
-        });
-    });
-    $("#CheckNone").click(function(e){
-        e.preventDefault();
-        checkBoxes.each(function(){
-            $(this).prop("checked",0);
-        });
-    });
-
-    $("#remove_patrons").submit(function(){
-        var checkedItems = $("input:checked");
-        if ($(checkedItems).size() == 0) {
-            alert(_("You must select one or more patrons to remove"));
-            return false;
-        }
-        $(checkedItems).parents('tr').addClass("warn");
-        if( confirm(_("Are you sure you want to remove the selected patrons?")) ) {
-            return true;
-        } else {
-            $(checkedItems).parents('tr').removeClass("warn");
-            return false;
-        }
-    });
-});
-
-//]]>
-</script>
-
 </head>
 
 <body id="patlist_list" class="pat patlist">
@@ -161,4 +102,65 @@ $(document).ready(function() {
             [% INCLUDE 'tools-menu.inc' %]
         </div>
     </div>
+
+[% MACRO jsinclude BLOCK %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/tools-menu.js"></script>
+    [% INCLUDE 'datatables.inc' %]
+
+    <script type="text/javascript" src="[% interface %]/js/autocomplete/patrons.js"></script>
+    <script type="text/javascript">
+        var MSG_REMOVE_PATRON = _("Remove");
+        $(document).ready(function() {
+            $('#patrons_to_add_fieldset').hide();
+
+                $('#patron-list-table').dataTable($.extend(true, {}, dataTablesDefaults, {
+                    "order": [[ 3, "asc" ]],
+                    "aoColumns": [
+                        null,null,null,null,null,null,null,{ "sType": "title-string" },null
+                    ],
+                    "aoColumnDefs": [
+                        { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
+                    ],
+                    "sPaginationType": "four_button"
+                } ));
+
+            patron_autocomplete({
+                patron_container: $("#patrons_to_add"),
+                input_autocomplete: $("#find_patron"),
+                patron_input_name: 'patrons_to_add'
+            });
+
+            var checkBoxes = $("input[type='checkbox']","#patron-list-table");
+
+            $("#CheckAll").click(function(e){
+                e.preventDefault();
+                checkBoxes.each(function(){
+                    $(this).prop("checked",1);
+                });
+            });
+            $("#CheckNone").click(function(e){
+                e.preventDefault();
+                checkBoxes.each(function(){
+                    $(this).prop("checked",0);
+                });
+            });
+
+            $("#remove_patrons").submit(function(){
+                var checkedItems = $("input:checked");
+                if ($(checkedItems).size() == 0) {
+                    alert(_("You must select one or more patrons to remove"));
+                    return false;
+                }
+                $(checkedItems).parents('tr').addClass("warn");
+                if( confirm(_("Are you sure you want to remove the selected patrons?")) ) {
+                    return true;
+                } else {
+                    $(checkedItems).parents('tr').removeClass("warn");
+                    return false;
+                }
+            });
+        });
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index 9bdf4ab..e0b13ad 100644 (file)
@@ -1,58 +1,9 @@
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Tools &rsaquo; Patron lists</title>
 [% INCLUDE 'doc-head-close.inc' %]
 [% INCLUDE 'greybox.inc' %]
 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
-[% INCLUDE 'datatables.inc' %]
-
-<script type="text/javascript">
-//<![CDATA[
-    $(document).ready(function() {
-        var patronExportModal = $("#patronExportModal");
-        var patronExportModalBody = $("#patronExportModal .modal-body")
-
-        $('#patron-lists-table').dataTable($.extend(true, {}, dataTablesDefaults, {
-            "autoWidth": false,
-            "aoColumnDefs": [
-                { "bSortable": false, "bSearchable": false, 'aTargets': [ 'NoSort' ] }
-            ],
-            "sPaginationType": "four_button"
-        } ));
-        $(".delete_patron").on("click", function(){
-            $(".dropdown").removeClass("open");
-            var list = $(this).data("list-name");
-            return confirmDelete( _("Are you sure you want to delete the list %s?").format(list) );
-        });
-
-        $(".print_cards").on("click", function(e){
-            e.preventDefault();
-            var page = $(this).attr("href");
-            patronExportModalBody.load(page + " #exportingf");
-            patronExportModal.modal("show");
-        });
-
-        patronExportModal.on("hidden", function(){
-            patronExportModalBody.html("<div id=\"loading\"><img src=\"[% interface %]/[% theme %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
-        });
-
-        patronExportModal.on("submit", "#exportingf", function(e){
-            e.preventDefault();
-            modal_body = patronExportModalBody;
-            modal_body.html("<div id=\"loading\"><img src=\"[% interface %]/[% theme %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
-            target_url = $(this).attr("action");
-            params =  $( this ).serialize();
-            modal_body.load( target_url + "?" + params + " #custom-doc");
-        });
-
-        patronExportModal.on("click",".closebtn,.gb-close",function(e){
-            e.preventDefault();
-            patronExportModal.modal("hide");
-        });
-
-    });
-//]]>
-</script>
-
 </head>
 
 <body id="patlist_lists" class="pat patlist">
             [% INCLUDE 'tools-menu.inc' %]
         </div>
     </div>
+
+[% MACRO jsinclude BLOCK %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/tools-menu.js"></script>
+    [% INCLUDE 'datatables.inc' %]
+
+    <script type="text/javascript">
+        $(document).ready(function() {
+            var patronExportModal = $("#patronExportModal");
+            var patronExportModalBody = $("#patronExportModal .modal-body")
+
+            $('#patron-lists-table').dataTable($.extend(true, {}, dataTablesDefaults, {
+                "autoWidth": false,
+                "aoColumnDefs": [
+                    { "bSortable": false, "bSearchable": false, 'aTargets': [ 'NoSort' ] }
+                ],
+                "sPaginationType": "four_button"
+            } ));
+            $(".delete_patron").on("click", function(){
+                $(".dropdown").removeClass("open");
+                var list = $(this).data("list-name");
+                return confirmDelete( _("Are you sure you want to delete the list %s?").format(list) );
+            });
+
+            $(".print_cards").on("click", function(e){
+                e.preventDefault();
+                var page = $(this).attr("href");
+                patronExportModalBody.load(page + " #exportingf");
+                patronExportModal.modal("show");
+            });
+
+            patronExportModal.on("hidden", function(){
+                patronExportModalBody.html("<div id=\"loading\"><img src=\"[% interface %]/[% theme %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
+            });
+
+            patronExportModal.on("submit", "#exportingf", function(e){
+                e.preventDefault();
+                modal_body = patronExportModalBody;
+                modal_body.html("<div id=\"loading\"><img src=\"[% interface %]/[% theme %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
+                target_url = $(this).attr("action");
+                params =  $( this ).serialize();
+                modal_body.load( target_url + "?" + params + " #custom-doc");
+            });
+
+            patronExportModal.on("click",".closebtn,.gb-close",function(e){
+                e.preventDefault();
+                patronExportModal.modal("hide");
+            });
+
+        });
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
diff --git a/koha-tmpl/intranet-tmpl/prog/js/tools-menu.js b/koha-tmpl/intranet-tmpl/prog/js/tools-menu.js
new file mode 100644 (file)
index 0000000..6a73363
--- /dev/null
@@ -0,0 +1,14 @@
+  $(document).ready(function() {
+      var path = location.pathname.substring(1);
+      if (path.indexOf("labels") >= 0 && path.indexOf("spine") < 0 ) {
+        $('#navmenulist a[href$="/cgi-bin/koha/labels/label-home.pl"]').css('font-weight','bold');
+      } else if (path.indexOf("patroncards") >= 0 ) {
+        $('#navmenulist a[href$="/cgi-bin/koha/patroncards/home.pl"]').css('font-weight','bold');
+      } else if (path.indexOf("patron_lists") >= 0 ) {
+        $('#navmenulist a[href$="/cgi-bin/koha/patron_lists/lists.pl"]').css('font-weight','bold');
+      } else if ((path+location.search).indexOf("batchMod.pl?del=1") >= 0 ) {
+        $('#navmenulist a[href$="/cgi-bin/koha/tools/batchMod.pl?del=1"]').css('font-weight','bold');
+      } else {
+        $('#navmenulist a[href$="/' + path + '"]').css('font-weight','bold');
+      }
+  });