Bug 19785: Move template JavaScript to the footer: Authorities, part 1
authorOwen Leonard <oleonard@myacpl.org>
Fri, 8 Dec 2017 19:09:05 +0000 (19:09 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Sun, 18 Feb 2018 19:48:44 +0000 (16:48 -0300)
This patch modifies even more staff client authorities 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
modified templates: All button controls, DataTables functionality, tabs,
etc.

 - Authorities
   - New from Z39.50
   -> Search
      -> Results
         - New from Z39.50
         - Deletion confirmation
         - Merge records -> Merge
           - Tabs
           - Tag selection
         -> Authority detail
            - Tabs
            - Deletion confirmation
            - New from Z39.50

Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
koha-tmpl/intranet-tmpl/prog/en/includes/authorities-search.inc
koha-tmpl/intranet-tmpl/prog/en/includes/authorities-toolbar.inc
koha-tmpl/intranet-tmpl/prog/en/includes/authorities_js.inc
koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities-home.tt
koha-tmpl/intranet-tmpl/prog/en/modules/authorities/detail.tt
koha-tmpl/intranet-tmpl/prog/en/modules/authorities/merge.tt
koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist.tt

index 45517c8..1f4bab7 100644 (file)
@@ -1,22 +1,6 @@
 <div class="gradient">
 <h1 id="logo"><a href="/cgi-bin/koha/mainpage.pl">[% LibraryName %]</a></h1>
 <!-- Begin Authorities Resident Search Box -->
-<script type="text/javascript">
-//<![CDATA[
-    $(document).ready(function() {
-        var searchType = '[% marclist %]';
-        if (searchType) {
-            if ('mainentry' == searchType) {
-                $("#header_search").tabs( "option", "selected", 0 );
-            } else if ('match' == searchType) {
-                $("#header_search").tabs( "option", "selected", 1 );
-            } else if ('all' == searchType) {
-                $("#header_search").tabs( "option", "selected", 2 );
-            }
-        }
-    });
-//]]>
-</script>
 <div id="header_search" class="residentsearch">
     <div id="mainmain_heading" class="residentsearch">
     <p class="tip">Enter main heading ($a only):</p>
index 52209e1..b42074a 100644 (file)
@@ -1,28 +1,4 @@
 [% INCLUDE 'blocking_errors.inc' %]
-<script type="text/javascript">
-//<![CDATA[
-    $(document).ready(function() {
-        $("#delAuth").click(function(){
-            confirm_deletion();
-            return false;
-        });
-
-        $("#z3950submit").click(function(){
-            [% IF ( authid ) %]
-                if (confirm(_("Please note that this Z39.50 search could replace the current record."))){
-                    window.open("/cgi-bin/koha/cataloguing/z3950_auth_search.pl?authid=[% authid %]","z3950search",'width=800,height=500,location=yes,toolbar=no,scrollbars=yes,resize=yes');
-                }
-            [% ELSE %]
-                window.open("/cgi-bin/koha/cataloguing/z3950_auth_search.pl","z3950search",'width=800,height=500,location=yes,toolbar=no,scrollbars=yes,resize=yes');
-            [% END %]
-            return false;
-        });
-
-    });
-
-//]]>
-</script>
-
 [% IF ( authid || CAN_user_editauthorities) %]
 
 <div id="toolbar" class="btn-toolbar">
index cf4a072..6e3b176 100644 (file)
@@ -1,5 +1,5 @@
 <script type="text/javascript">
-//<![CDATA[
+
 function mergeAuth(authid, summary) {
     var alreadySelected = $.cookie('auth_to_merge');
     if (alreadySelected !== undefined) {
@@ -31,12 +31,62 @@ function showMergingInProgress() {
     }
 }
 
+function confirm_deletion(id) {
+    var is_confirmed = confirm(_("Are you sure you want to delete this authority?"));
+    if( !id ){
+        id = "[% authid %]";
+    }
+    if (is_confirmed) {
+      window.location="authorities-home.pl?op=delete"
+          + "&authid=" + id
+          + "&type=intranet"
+          + "&authtypecode=[% authtypecode %]"
+          + "&marclist=[% marclist %]"
+          + "&and_or=[% and_or %]"
+          + "&excluding=[% excluding %]"
+          + "&operator=[% operator %]"
+          + "&orderby=[% orderby %]"
+          + "&value=[% value |url %]"
+          + "&startfrom=[% startfrom %]"
+          + "&resultsperpage=[% resultsperpage %]"
+          + "&csrf_token=[% csrf_token %]";
+    }
+}
+
 $(document).ready(function () {
     showMergingInProgress();
     $('.merge_auth').click(function (event) {
         event.preventDefault();
         mergeAuth($(this).parents('tr').attr('data-authid'), $(this).parents('tr').find('div.authorizedheading').text());
     });
+
+    $("#delAuth").click(function(){
+        confirm_deletion();
+        return false;
+    });
+
+    $("#z3950submit").click(function(){
+        [% IF ( authid ) %]
+            if (confirm(_("Please note that this Z39.50 search could replace the current record."))){
+                window.open("/cgi-bin/koha/cataloguing/z3950_auth_search.pl?authid=[% authid %]","z3950search",'width=800,height=500,location=yes,toolbar=no,scrollbars=yes,resize=yes');
+            }
+        [% ELSE %]
+            window.open("/cgi-bin/koha/cataloguing/z3950_auth_search.pl","z3950search",'width=800,height=500,location=yes,toolbar=no,scrollbars=yes,resize=yes');
+        [% END %]
+        return false;
+    });
+
+    var searchType = '[% marclist %]';
+    if (searchType) {
+        if ('mainentry' == searchType) {
+            $("#header_search").tabs( "option", "selected", 0 );
+        } else if ('match' == searchType) {
+            $("#header_search").tabs( "option", "selected", 1 );
+        } else if ('all' == searchType) {
+            $("#header_search").tabs( "option", "selected", 2 );
+        }
+    }
+
 });
-//]]>
+
 </script>
index 7290744..9a71269 100644 (file)
@@ -1,28 +1,9 @@
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Authorities</title>
 [% INCLUDE 'doc-head-close.inc' %]
-<script language="JavaScript" type="text/javascript">
-//<![CDATA[
-function Help() {
-    newin=window.open("/cgi-bin/koha/help.pl","KohaHelp",'width=600,height=600,toolbar=false,scrollbars=yes');
-}
-
-function addauthority() {
-    X = document.forms[0].authtype.value;
-    window.location="/cgi-bin/koha/authorities/authorities.pl?authtypecode="+X;
-}
-function searchauthority() {
-    X = document.forms[0].authtype2.value;
-    Y = document.forms[0].value.value;
-    window.location="/cgi-bin/koha/authorities/authorities-home.pl?op=do_search&type=intranet&authtypecode="+X+"&value="+Y+"&marclist=&and_or=and&excluding=&operator=contains";
-}
-function confirm_deletion() {   // not really implemented, but required by phantom delAuthButton code in authorities-toolbar.inc
-    return true;
-}
-//]]>
-</script>
-[% INCLUDE 'authorities_js.inc' %]
 </head>
+
 <body id="auth_authorities_home" class="auth">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'authorities-search.inc' %]
@@ -41,4 +22,9 @@ function confirm_deletion() {   // not really implemented, but required by phant
     </div>
     </div>
   </div>
+
+[% MACRO jsinclude BLOCK %]
+    [% INCLUDE 'authorities_js.inc' %]
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index 5694a2d..b8d7c37 100644 (file)
@@ -1,3 +1,4 @@
+[% SET footerjs = 1 %]
 [% PROCESS 'authorities.inc' %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Authorities &rsaquo;
@@ -8,56 +9,8 @@
     [% END %]
 </title>
 [% INCLUDE 'doc-head-close.inc' %]
-[% IF ( displayhierarchy ) %]
-<script type="text/javascript" src="/intranet-tmpl/lib/jquery/plugins/jquery.jstree_[% KOHA_VERSION %].js"></script>
-[% END %]
-<script type="text/javascript">
-
-//<![CDATA[
-
-        $(document).ready(function() {
-    $('#authoritiestabs').tabs();
-    [% IF ( displayhierarchy ) %]
-        var current_nodes = [];
-        $('.currentauth').each(function() {
-            current_nodes.push('#' + $(this).parent().parents('li:first').attr('id'));
-            });
-        $('#hierarchies').jstree({
-                "plugins": [ "themes", "html_data"],
-                "themes": { "theme": "classic",
-                            "icons": false },
-                "core": { "initially_open": current_nodes }
-            });
-    [% END %]
-        });
-
-function confirm_deletion() {
-    var is_confirmed = confirm(_("Are you sure you want to delete this authority?"));
-    if (is_confirmed) {
-        window.location="authorities-home.pl?op=delete&authid=[% authid %]&csrf_token=[% csrf_token %]";
-    }
-}
-function Dopop(link) {
-       newin=window.open(link,'width=500,height=400,toolbar=false,scrollbars=yes');
-}
-//]]>
-</script>
-<script type="text/javascript">
-function Help() {
-    newin=window.open("/cgi-bin/koha/help.pl","KohaHelp",'width=600,height=600,toolbar=false,scrollbars=yes');
-}
-
-function addauthority() {
-    X = document.forms[0].authtype.value;
-    window.location="/cgi-bin/koha/authorities/authorities.pl?authtypecode="+X;
-}
-function searchauthority() {
-    X = document.forms[0].authtype2.value;
-    Y = document.forms[0].value.value;
-    window.location="/cgi-bin/koha/authorities/authorities-home.pl?op=do_search&type=intranet&authtypecode="+X+"&value="+Y+"&marclist=&and_or=and&excluding=&operator=contains";
-}
-</script>
 </head>
+
 <body id="auth_detail" class="auth">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'authorities-search.inc' %]
@@ -143,4 +96,28 @@ function searchauthority() {
 [% END %]
 </div>
 
+[% MACRO jsinclude BLOCK %]
+    [% INCLUDE 'authorities_js.inc' %]
+    [% IF ( displayhierarchy ) %]
+        <script type="text/javascript" src="/intranet-tmpl/lib/jquery/plugins/jquery.jstree_[% KOHA_VERSION %].js"></script>
+    [% END %]
+    <script type="text/javascript">
+        $(document).ready(function() {
+            $('#authoritiestabs').tabs();
+            [% IF ( displayhierarchy ) %]
+                var current_nodes = [];
+                $('.currentauth').each(function() {
+                    current_nodes.push('#' + $(this).parent().parents('li:first').attr('id'));
+                    });
+                $('#hierarchies').jstree({
+                        "plugins": [ "themes", "html_data"],
+                        "themes": { "theme": "classic",
+                                    "icons": false },
+                        "core": { "initially_open": current_nodes }
+                    });
+            [% END %]
+         });
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index 0d30a78..4badb7b 100644 (file)
@@ -1,47 +1,15 @@
 [% PROCESS 'merge-record.inc' %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Cataloging &rsaquo; Merging records</title>
 [% INCLUDE 'doc-head-close.inc' %]
-<script type="text/javascript" src="[% interface %]/[% theme %]/js/merge-record_[% KOHA_VERSION %].js"></script>
-[% INCLUDE 'merge-record-strings.inc' %]
 <style type="text/css">
 div.record ul, div.record li { float:none; display:block; }
 div#result { margin-top: 1em; }
 /* We use this style "against" the li ui-tabs-nav style automatically applied */
 </style>
-<script type="text/javascript">
-//<![CDATA[
-
-    // When submiting the form
-    function mergeformsubmit() {
-        $('#tabs').remove();
-    }
-
-$(document).ready(function(){
-    // Getting marc structure via ajax
-    tagslib = [];
-    $.getJSON("/cgi-bin/koha/authorities/merge_ajax.pl", {frameworkcode : "[% framework %]" }, function(json) {
-        tagslib = json;
-        rebuild_target($("#tabs"), $("#resultul"));
-    });
-
-    $('.preview-merge-reference').click(function (ev) {
-        ev.preventDefault();
-        newin=window.open($(this).attr('href'),'merge_reference', 'width=1000,height=600,toolbar=false,scrollbars=yes');
-    });
-
-    // Creating tabs
-    $("#tabs").tabs();
-});
-
-
-function changeFramework(fw) {
-    $("#Frameworks").val(fw);
-}
-
-//]]>
-</script>
 </head>
+
 <body id="auth_merge" class="cat">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'authorities-search.inc' %]
@@ -139,4 +107,43 @@ function changeFramework(fw) {
 </div>
 </div>
 
+[% MACRO jsinclude BLOCK %]
+    [% INCLUDE 'merge-record-strings.inc' %]
+    [% INCLUDE 'authorities_js.inc' %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/merge-record_[% KOHA_VERSION %].js"></script>
+    [% INCLUDE 'merge-record-strings.inc' %]
+    <script type="text/javascript">
+    //<![CDATA[
+
+        // When submiting the form
+        function mergeformsubmit() {
+            $('#tabs').remove();
+        }
+
+    $(document).ready(function(){
+        // Getting marc structure via ajax
+        tagslib = [];
+        $.getJSON("/cgi-bin/koha/authorities/merge_ajax.pl", {frameworkcode : "[% framework %]" }, function(json) {
+            tagslib = json;
+            rebuild_target($("#tabs"), $("#resultul"));
+        });
+
+        $('.preview-merge-reference').click(function (ev) {
+            ev.preventDefault();
+            newin=window.open($(this).attr('href'),'merge_reference', 'width=1000,height=600,toolbar=false,scrollbars=yes');
+        });
+
+        // Creating tabs
+        $("#tabs").tabs();
+    });
+
+
+    function changeFramework(fw) {
+        $("#Frameworks").val(fw);
+    }
+
+    //]]>
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index 76e4589..2c8e8e0 100644 (file)
@@ -1,46 +1,10 @@
+[% SET footerjs = 1 %]
 [% PROCESS 'authorities-search-results.inc' %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Authorities &rsaquo; Authority search results</title>
 [% INCLUDE 'doc-head-close.inc' %]
-<script type="text/javascript">
-//<![CDATA[
-
-function confirm_deletion(id) {
-    var is_confirmed = confirm(_("Are you sure you want to delete this authority?"));
-    if (is_confirmed) {
-      window.location="authorities-home.pl?op=delete"
-          + "&authid=" + id
-          + "&type=intranet"
-          + "&authtypecode=[% authtypecode %]"
-          + "&marclist=[% marclist %]"
-          + "&and_or=[% and_or %]"
-          + "&excluding=[% excluding %]"
-          + "&operator=[% operator %]"
-          + "&orderby=[% orderby %]"
-          + "&value=[% value |url %]"
-          + "&startfrom=[% startfrom %]"
-          + "&resultsperpage=[% resultsperpage %]"
-          + "&csrf_token=[% csrf_token %]";
-    }
-}
-
-function Help() {
-    newin=window.open("/cgi-bin/koha/help.pl","KohaHelp",'width=600,height=600,toolbar=false,scrollbars=yes');
-}
-
-function addauthority() {
-    X = document.forms[0].authtype.value;
-    window.location="/cgi-bin/koha/authorities/authorities.pl?authtypecode="+X;
-}
-function searchauthority() {
-    X = document.forms[0].authtype2.value;
-    Y = document.forms[0].value.value;
-    window.location="/cgi-bin/koha/authorities/authorities-home.pl?op=do_search&type=intranet&authtypecode="+X+"&value="+Y+"&marclist=&and_or=and&excluding=&operator=contains";
-}
-//]]>
-</script>
-[% INCLUDE 'authorities_js.inc' %]
 </head>
+
 <body id="auth_searchresultlist" class="auth">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'authorities-search.inc' %]
@@ -116,4 +80,9 @@ function searchauthority() {
 </div>
 </div>
 </div>
+
+[% MACRO jsinclude BLOCK %]
+    [% INCLUDE 'authorities_js.inc' %]
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]