Bug 19682: Move JS to the footer: Two patron-related tools
authorOwen Leonard <oleonard@myacpl.org>
Wed, 22 Nov 2017 19:33:48 +0000 (19:33 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 15 Feb 2018 16:30:23 +0000 (13:30 -0300)
This patch modifies two patron-related tools templates in the staff
client 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,
form validation, etc.

  - Import patrons
  - Upload patron images

Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>
Edit for QA: Fixed datepickers on import patron form

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/modules/tools/import_borrowers.tt
koha-tmpl/intranet-tmpl/prog/en/modules/tools/picture-upload.tt

index 7e8245d..ae5765a 100644 (file)
@@ -1,5 +1,6 @@
 [% USE Koha %]
 [% USE Branches %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Tools &rsaquo; Import patrons [% IF ( uploadborrowers ) %]&rsaquo; Results[% END %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
     .line_error { width: 100%; }
     code { background-color: yellow; }
 </style>
-<script type="text/javascript">
-//<![CDATA[
-    $(document).ready(function() {
-        [%# Make date fields have the datepicker %]
-        $("#dateenrolled").addClass('datepicker');
-        $("#dateexpiry").addClass('datepicker');
-        $("#dateofbirth").addClass('datepicker');
-    });
-</script>
 </head>
+
 <body id="tools_import_borrowers" class="tools">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'patron-search.inc' %]
-[% INCLUDE 'calendar.inc' %]
 
 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; <a href="/cgi-bin/koha/tools/import_borrowers.pl">Import patrons</a>[% IF ( uploadborrowers ) %] &rsaquo; Results[% END %]</div>
 
@@ -245,4 +237,17 @@ Alternatively, you can supply dates in ISO format.
 [% INCLUDE 'tools-menu.inc' %]
   </div>
  </div>
+
+[% MACRO jsinclude BLOCK %]
+    [% INCLUDE 'calendar.inc' %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/tools-menu.js"></script>
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/members-menu.js"></script>
+    <script type="text/javascript">
+        $(document).ready(function() {
+            [%# Make date fields have the datepicker %]
+            $("#dateenrolled, #dateexpiry, #dateofbirth").datepicker();
+        });
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index 958f810..fa0db25 100644 (file)
@@ -1,28 +1,9 @@
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Tools &rsaquo; Upload patron images</title>
 [% INCLUDE 'doc-head-close.inc' %]
-<script type="text/javascript">
- $(document).ready(function() {
-       $("#zipfile").click(function(){
-               $("#cardnum").hide();
-       });
-       $("#image").click(function(){
-               $("#cardnum").show();
-       });
-    $( "#upload_form" ).validate({
-        rules: {
-            cardnumber: {
-                required: {
-                    depends: function(element) {
-                        return $("#image").is(":checked");
-                    }
-                }
-            }
-        }
-    });
-});
-</script>
 </head>
+
 <body id="tools_picture-upload" class="tools">
 
 [% INCLUDE 'header.inc' %]
     [% INCLUDE 'tools-menu.inc' %]
 </div>
 </div>
+
+[% MACRO jsinclude BLOCK %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/tools-menu.js"></script>
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/members-menu.js"></script>
+    <script type="text/javascript">
+        $(document).ready(function() {
+            $("#zipfile").click(function(){
+                $("#cardnum").hide();
+            });
+            $("#image").click(function(){
+                $("#cardnum").show();
+            });
+            $( "#upload_form" ).validate({
+                rules: {
+                    cardnumber: {
+                        required: {
+                            depends: function(element) {
+                                return $("#image").is(":checked");
+                            }
+                        }
+                    }
+                }
+            });
+        });
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]