Bug 19594: Move admin templates JavaScript to the footer: MARC-related
authorOwen Leonard <oleonard@myacpl.org>
Wed, 8 Nov 2017 17:40:55 +0000 (17:40 +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 MARC-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 the
cart: All button controls, DataTables functionality, tabs, etc.

Signed-off-by: Simon Pouchol <simon.pouchol@biblibre.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/admin-menu.inc
koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_subfields_structure.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_tag_structure.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/authtypes.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/biblio_framework.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/checkmarc.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/fieldmapping.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/koha2marclinks.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_subfields_structure.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/marctagstructure.tt
koha-tmpl/intranet-tmpl/prog/js/admin-menu.js [new file with mode: 0644]

index 514e233..5a08564 100644 (file)
@@ -1,19 +1,5 @@
 [% USE Koha %]
-<script type="text/javascript">//<![CDATA[
-    $(document).ready(function() {
-        var path = location.pathname.substring(1);
-        if (path == "cgi-bin/koha/admin/marctagstructure.pl" || path == "cgi-bin/koha/admin/marc_subfields_structure.pl") {
-            $('#navmenulist a[href$="/cgi-bin/koha/admin/biblio_framework.pl"]').css('font-weight','bold');
-        } else if (path == "cgi-bin/koha/admin/auth_tag_structure.pl" || path == "cgi-bin/koha/admin/auth_subfields_structure.pl") {
-            $('#navmenulist a[href$="/cgi-bin/koha/admin/authtypes.pl"]').css('font-weight','bold');
-        } else if (path == "cgi-bin/koha/admin/oai_set_mappings.pl") {
-            $('#navmenulist a[href$="/cgi-bin/koha/admin/oai_sets.pl"]').css('font-weight','bold');
-        } else {
-            $('#navmenulist a[href$="/' + path + '"]').css('font-weight','bold');
-        }
-    });
-//]]>
-</script>
+
 <div id="navmenu">
 <div id="navmenulist">
 <h5>System preferences</h5>
index aa1baa7..abff20e 100644 (file)
@@ -1,14 +1,9 @@
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Administration &rsaquo; Authority MARC subfield structure</title>
 [% INCLUDE 'doc-head-close.inc' %]
-<script type="text/javascript">
-//<![CDATA[
-     $(document).ready(function() {
-        $('#subfieldtabs').tabs();
-     });
-//]]>
-</script>
 </head>
+
 <body id="admin_auth_subfields_structure" class="admin">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'prefs-admin-search.inc' %]
 [% 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">
+     $(document).ready(function() {
+        $('#subfieldtabs').tabs();
+     });
+    </script>
+[% END %]
 [% INCLUDE 'intranet-bottom.inc' %]
index f083e25..a55c605 100644 (file)
@@ -1,4 +1,5 @@
 [% USE AuthorisedValues %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Administration &rsaquo; Authority MARC framework [% IF ( add_form ) %][% IF ( use_heading_flags_p ) %]
     [% IF ( heading_modify_tag_p ) %]&rsaquo; [% IF ( authtypecode ) %][% authtypecode %] Framework[% ELSE %]Default framework[% END %] &rsaquo; Modify tag[% END %]
@@ -7,20 +8,8 @@
 [% 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_authtagstructure").dataTable($.extend(true, {}, dataTablesDefaults, {
-        "aoColumnDefs": [
-            { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
-        ],
-        "sPaginationType": "four_button"
-    }));
- });
-//]]>
-</script>
 </head>
+
 <body id="admin_auth_tag_structure" class="admin">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'prefs-admin-search.inc' %]
 [% INCLUDE 'admin-menu.inc' %]
 </div>
 </div>
+
+[% MACRO jsinclude BLOCK %]
+    [% INCLUDE 'datatables.inc' %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/admin-menu.js"></script>
+    <script type="text/javascript">
+        $(document).ready(function() {
+            $("#table_authtagstructure").dataTable($.extend(true, {}, dataTablesDefaults, {
+                "aoColumnDefs": [
+                    { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
+                ],
+                "sPaginationType": "four_button"
+            }));
+        });
+    </script>
+[% END %]
 [% INCLUDE 'intranet-bottom.inc' %]
index 2f69f53..77cca18 100644 (file)
@@ -1,3 +1,4 @@
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Administration &rsaquo; Authority types
 [% IF op == 'add_form' %]
@@ -8,22 +9,6 @@
 </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">
-//<![CDATA[
-    $(document).ready(function() {
-        $("#authtypes").dataTable($.extend(true, {}, dataTablesDefaults, {
-            "aoColumnDefs": [
-                { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
-            ],
-            "sPaginationType": "four_button"
-        }));
-        $("#authtypecode").on("blur",function(){
-            toUC(this);
-        });
-    });
-//]]>
-</script>
 </head>
 
 <body id="admin_authtypes" class="admin">
 [% INCLUDE 'admin-menu.inc' %]
 </div>
 </div>
+
+[% MACRO jsinclude BLOCK %]
+    [% INCLUDE 'datatables.inc' %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/admin-menu.js"></script>
+    <script type="text/javascript">
+        $(document).ready(function() {
+            $("#authtypes").dataTable($.extend(true, {}, dataTablesDefaults, {
+                "aoColumnDefs": [
+                    { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
+                ],
+                "sPaginationType": "four_button"
+            }));
+            $("#authtypecode").on("blur",function(){
+                toUC(this);
+            });
+        });
+    </script>
+[% END %]
 [% INCLUDE 'intranet-bottom.inc' %]
index 9b81657..8f430cf 100644 (file)
@@ -1,3 +1,4 @@
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Administration &rsaquo; MARC frameworks
 [% IF op == 'add_form' %]
@@ -8,18 +9,8 @@
 </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">
-    /* Set some variable needed in biblio_framework.js */
-    var MSG_IMPORT_ERROR = _("Error importing the framework");
-    var MSG_SELECT_FILE_FORMAT = _("Please select a CSV (.csv), ODS (.ods) or XML (.xml) spreadsheet file.");
-    var MSG_OVERWRITE_WARNING = _("Do you really want to import the framework fields and subfields? This will overwrite the current configuration. For safety reasons please use the export option to make a backup");
-    var MSG_IMPORTING_TO_FRAMEWORK = _("Importing to framework: %s. Importing from file: %s.");
-    var template_path = "[% interface %]/[% theme %]";
-</script>
-<script type="text/javascript" src="[% interface %]/[% theme %]/js/biblio_framework.js"></script>
-
 </head>
+
 <body id="admin_biblio_framework" class="admin">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'prefs-admin-search.inc' %]
 [% INCLUDE 'admin-menu.inc' %]
   </div>
 </div>
+
+[% MACRO jsinclude BLOCK %]
+    [% INCLUDE 'datatables.inc' %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/admin-menu.js"></script>
+    <script type="text/javascript">
+        /* Set some variable needed in biblio_framework.js */
+        var MSG_IMPORT_ERROR = _("Error importing the framework");
+        var MSG_SELECT_FILE_FORMAT = _("Please select a CSV (.csv), ODS (.ods) or XML (.xml) spreadsheet file.");
+        var MSG_OVERWRITE_WARNING = _("Do you really want to import the framework fields and subfields? This will overwrite the current configuration. For safety reasons please use the export option to make a backup");
+        var MSG_IMPORTING_TO_FRAMEWORK = _("Importing to framework: %s. Importing from file: %s.");
+        var template_path = "[% interface %]/[% theme %]";
+    </script>
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/biblio_framework.js"></script>
+[% END %]
 [% INCLUDE 'intranet-bottom.inc' %]
index 7fdf2d0..24ce22e 100644 (file)
@@ -1,3 +1,4 @@
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Administration &rsaquo; MARC check
 [% IF ( total ) %] :[% total %] errors found[% ELSE %] : Configuration OK![% END %]</title>
 [% 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' %]
index 7e2f073..46cd8d5 100644 (file)
@@ -1,19 +1,7 @@
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Administration &rsaquo; Keyword to MARC mapping</title>
 [% INCLUDE 'doc-head-close.inc' %]
-
-<script type="text/javascript">
-//<![CDATA[
-$(document).ready(function() {
-        $('#selectframework').find("input:submit").hide();
-        $('#framework').change(function() {
-                $('#selectframework').submit();
-        });
-});
-//]]>
-</script>
-
-
 </head>
 
 <body id="admin_fieldmapping" class="admin">
@@ -85,4 +73,15 @@ $(document).ready(function() {
                [% INCLUDE 'admin-menu.inc' %]
        </div>
 
+[% MACRO jsinclude BLOCK %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/admin-menu.js"></script>
+    <script type="text/javascript">
+        $(document).ready(function() {
+            $('#selectframework').find("input:submit").hide();
+            $('#framework').change(function() {
+                    $('#selectframework').submit();
+            });
+        });
+    </script>
+[% END %]
 [% INCLUDE 'intranet-bottom.inc' %]
index afddb9b..020519d 100644 (file)
@@ -1,31 +1,7 @@
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Administration &rsaquo; Koha to MARC mapping</title>
-
 [% INCLUDE 'doc-head-close.inc' %]
-<script type="text/javascript">
-//<![CDATA[
-$(document).ready(function() {
-});
-
-function AddFld(kohafield) {
-    var fieldstr = prompt( _("Adding a mapping for: ") + kohafield + ".\n" + _("Please enter field tag and subfield code, separated by a comma. (For control fields: add '@' as subfield code.)\nThe change will be applied immediately.") );
-    var temp = fieldstr.split(',');
-    if( temp.length == 2 ) {
-        $('#add_field').val( kohafield+','+fieldstr );
-        $('#koha2marc').submit();
-    } else {
-        alert( "Invalid input. Enter something like: 245,a" );
-    }
-}
-
-function RemFld(tagfield, subfield ) {
-    if( confirm( _("Mapping will be removed for: ") + tagfield + subfield + ".\n" + _("The change will be applied immediately." ))) {
-        $('#remove_field').val(tagfield+','+subfield);
-        $('#koha2marc').submit();
-    }
-}
-//]]>
-</script>
 </head>
 
 <body id="admin_koha2marclinks" class="admin">
@@ -88,4 +64,27 @@ function RemFld(tagfield, subfield ) {
 </div>
 
 </div>
+
+[% MACRO jsinclude BLOCK %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/admin-menu.js"></script>
+    <script type="text/javascript">
+        function AddFld(kohafield) {
+            var fieldstr = prompt( _("Adding a mapping for: ") + kohafield + ".\n" + _("Please enter field tag and subfield code, separated by a comma. (For control fields: add '@' as subfield code.)\nThe change will be applied immediately.") );
+            var temp = fieldstr.split(',');
+            if( temp.length == 2 ) {
+                $('#add_field').val( kohafield+','+fieldstr );
+                $('#koha2marc').submit();
+            } else {
+                alert( "Invalid input. Enter something like: 245,a" );
+            }
+        }
+
+        function RemFld(tagfield, subfield ) {
+            if( confirm( _("Mapping will be removed for: ") + tagfield + subfield + ".\n" + _("The change will be applied immediately." ))) {
+                $('#remove_field').val(tagfield+','+subfield);
+                $('#koha2marc').submit();
+            }
+        }
+    </script>
+[% END %]
 [% INCLUDE 'intranet-bottom.inc' %]
index 65d8624..fdb9262 100644 (file)
@@ -1,9 +1,10 @@
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Administration &rsaquo;[% IF ( add_form ) %][% IF ( use_heading_flags_p ) %][% IF ( heading_edit_subfields_p ) %] MARC subfield structure &rsaquo; Edit MARC subfields constraints[% END %][% ELSE %] MARC subfield structure &rsaquo; [% action %][% END %][% END %]
 [% IF ( delete_confirm ) %] MARC subfield structure &rsaquo; Confirm deletion of subfield [% tagsubfield %][% END %][% IF ( delete_confirmed ) %] MARC subfield structure &rsaquo; Subfield deleted[% END %][% IF ( else ) %]MARC subfield structure[% END %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
-<script type="text/javascript" src="[% interface %]/[% theme %]/js/marc_subfields_structure.js"></script>
 </head>
+
 <body id="admin_marc_subfields_structure" class="admin">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'prefs-admin-search.inc' %]
     [% 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" src="[% interface %]/[% theme %]/js/marc_subfields_structure.js"></script>
+[% END %]
 [% INCLUDE 'intranet-bottom.inc' %]
index e4033a3..2f4d0fa 100644 (file)
@@ -1,4 +1,5 @@
 [% USE AuthorisedValues %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Administration &rsaquo;
 [% IF ( add_form ) %]MARC frameworks &rsaquo; [% action %] [% searchfield %][% END %]
@@ -7,29 +8,8 @@
 [% IF ( else ) %]MARC frameworks[% END %]</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 %]/lib/jquery/plugins/jquery.cookie.min.js"></script>
-
-<script type="text/javascript">
-//<![CDATA[
-
-$(document).ready(function() {
-    $("#table_marctagstructure").dataTable($.extend(true, {}, dataTablesDefaults, {
-        "aoColumnDefs": [
-            { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
-        ],
-        "sPaginationType": "four_button"
-    }));
-    $("#select_display").on("change",function(){
-        var checked = $(this).prop("checked") ? 1: 0;
-        $.cookie('marctagstructure_selectdisplay', checked);
-        this.form.submit();
-    });
-});
-
-//]]>
-</script>
 </head>
+
 <body id="admin_marctagstructure" class="admin">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'prefs-admin-search.inc' %]
@@ -259,4 +239,25 @@ $(document).ready(function() {
 [% INCLUDE 'admin-menu.inc' %]
 </div>
 </div>
+
+[% MACRO jsinclude BLOCK %]
+    [% INCLUDE 'datatables.inc' %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/admin-menu.js"></script>
+    <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.cookie.min.js"></script>
+    <script type="text/javascript">
+        $(document).ready(function() {
+            $("#table_marctagstructure").dataTable($.extend(true, {}, dataTablesDefaults, {
+                "aoColumnDefs": [
+                    { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
+                ],
+                "sPaginationType": "four_button"
+            }));
+            $("#select_display").on("change",function(){
+                var checked = $(this).prop("checked") ? 1: 0;
+                $.cookie('marctagstructure_selectdisplay', checked);
+                this.form.submit();
+            });
+        });
+    </script>
+[% END %]
 [% INCLUDE 'intranet-bottom.inc' %]
diff --git a/koha-tmpl/intranet-tmpl/prog/js/admin-menu.js b/koha-tmpl/intranet-tmpl/prog/js/admin-menu.js
new file mode 100644 (file)
index 0000000..0d3aab7
--- /dev/null
@@ -0,0 +1,12 @@
+$(document).ready(function() {
+    var path = location.pathname.substring(1);
+    if (path == "cgi-bin/koha/admin/marctagstructure.pl" || path == "cgi-bin/koha/admin/marc_subfields_structure.pl") {
+        $('#navmenulist a[href$="/cgi-bin/koha/admin/biblio_framework.pl"]').css('font-weight','bold');
+    } else if (path == "cgi-bin/koha/admin/auth_tag_structure.pl" || path == "cgi-bin/koha/admin/auth_subfields_structure.pl") {
+        $('#navmenulist a[href$="/cgi-bin/koha/admin/authtypes.pl"]').css('font-weight','bold');
+    } else if (path == "cgi-bin/koha/admin/oai_set_mappings.pl") {
+        $('#navmenulist a[href$="/cgi-bin/koha/admin/oai_sets.pl"]').css('font-weight','bold');
+    } else {
+        $('#navmenulist a[href$="/' + path + '"]').css('font-weight','bold');
+    }
+});