Bug 19679: Move templates JavaScript to the footer: More tools templates
authorOwen Leonard <oleonard@myacpl.org>
Wed, 22 Nov 2017 15:53:42 +0000 (15:53 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 11 Dec 2017 14:34:23 +0000 (11:34 -0300)
This patch modifies more staff client tools 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
each modified template: All button controls, DataTables functionality,
form validation, etc.

  Export data
  Inventory
  Notices & slips
  Upload local cover image

Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>
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/export.tt
koha-tmpl/intranet-tmpl/prog/en/modules/tools/inventory.tt
koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt
koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload-images.tt

index 19224f4..36fe142 100644 (file)
@@ -1,40 +1,15 @@
 [% USE Branches %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Tools &rsaquo; Export data</title>
 [% INCLUDE 'doc-head-close.inc' %]
-[% INCLUDE 'calendar.inc' %]
-<script type="text/javascript">
-//<![CDATA[
-$(document).ready(function() {
-    $('#exporttype').tabs();
-
-    $("li.csv_profiles").hide();
-
-    $("#bibs select[name='output_format']").on('change', function(){
-        var format = $(this).val();
-        if ( format == 'csv' ) {
-            $("#bibs li.csv_profiles").show();
-        } else {
-            $("#bibs li.csv_profiles").hide();
-        }
-    });
-    $("#checkall").on("click",function(e){
-        e.preventDefault();
-        $(".branch_select").prop("checked",1);
-    });
-    $("#checknone").on("click",function(e){
-        e.preventDefault();
-        $(".branch_select").prop("checked",0);
-    });
-});
-//]]>
-</script>
 <style type="text/css">
     fieldset.rows fieldset.rows {
         width: 90%;
     }
 </style>
 </head>
+
 <body id="tools_export" class="tools">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'cat-search.inc' %]
@@ -311,4 +286,34 @@ $(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 'calendar.inc' %]
+    <script type="text/javascript">
+        $(document).ready(function() {
+            $('#exporttype').tabs();
+
+            $("li.csv_profiles").hide();
+
+            $("#bibs select[name='output_format']").on('change', function(){
+                var format = $(this).val();
+                if ( format == 'csv' ) {
+                    $("#bibs li.csv_profiles").show();
+                } else {
+                    $("#bibs li.csv_profiles").hide();
+                }
+            });
+            $("#checkall").on("click",function(e){
+                e.preventDefault();
+                $(".branch_select").prop("checked",1);
+            });
+            $("#checknone").on("click",function(e){
+                e.preventDefault();
+                $(".branch_select").prop("checked",0);
+            });
+        });
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index 00b8183..3cb722a 100644 (file)
 [% USE KohaDates %]
 [% USE Branches %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Tools &rsaquo; Inventory</title>
 [% INCLUDE 'doc-head-close.inc' %]
 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
-[% INCLUDE 'datatables.inc' %]
-[% INCLUDE 'calendar.inc' %]
-<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
-<script type="text/javascript">
-//<![CDATA[
-function checkForm() {
-    if ( $('#uploadbarcodes').val() ) {
-        if ( !(
-            $('#branchloop').val()   ||
-            $('#locationloop').val() ||
-            $('#minlocation').val()  ||
-            $('#maxlocation').val()  ||
-            $('#statuses input:checked').length
-        ) ) {
-            return confirm(
-                _("You have not selected any catalog filters and are about to compare a file of barcodes to your entire catalog.") + "\n\n" +
-                _("For large catalogs this can result in unexpected behavior") + "\n\n" +
-                _("Are you sure you want to do this?")
-            );
-        }
-    }
-
-    return true;
-}
-
-$(document).ready(function(){
-        inventorydt = $('#inventoryt').dataTable($.extend(true, {}, dataTablesDefaults, {
-            'sPaginationType': 'full_numbers',
-            [% IF compareinv2barcd %]
-                // sort on callnumber
-                "aaSorting": [[ 1, "asc" ]],
-            [% ELSE %]
-                // first column contains checkboxes
-                "aoColumnDefs": [
-                    { "bSortable": false, "bSearchable": false, "aTargets": [ 0 ] },
-                ],
-                // 3rd column is callnumber
-                "aaSorting": [[ 2, "asc" ]],
-            [% END %]
-            'fnDrawCallback': function() {
-                //bind the click handler script to the newly created elements held in the table
-                $('.openWin').bind('click',function(e){
-                    e.preventDefault();
-                    openWindow(this.href,'marcview',800,600);
-                });
-            }
-        } ));
-
-
-        $("#continuewithoutmarkingbutton").click(function(){
-            inventorydt.fnPageChange( 'next' );
-            return false;
-        });
-
-        $("#markseenandcontinuebutton").click(function(){
-            var param = '';
-            $("input:checked").each(function() {
-                param += "|" + $(this).attr('name');
-            });
-            $.post('/cgi-bin/koha/tools/ajax-inventory.pl', { seen: param });
-            inventorydt.fnPageChange( 'next' );
-            return false;
-        });
-
-        $("#markseenandquit").click(function(){
-            var param = '';
-            $("input:checked").each(function() {
-                param += "|" + $(this).attr('name');
-            });
-            $.ajax({
-              type: 'POST',
-              url: '/cgi-bin/koha/tools/ajax-inventory.pl',
-              data: { seen: param},
-              async: false
-            });
-            document.location.href = '/cgi-bin/koha/tools/inventory.pl';
-            return false;
-        });
-
-
-    $(".checkall").click(function(){
-            $(".checkboxed").checkCheckboxes();
-            return false;
-        });
-    $(".clearall").click(function(){
-            $(".checkboxed").unCheckCheckboxes();
-            return false;
-        });
-    $("#inventory_form").on("submit",function(){
-        return checkForm();
-    });
-
-    // #uploadbarcodes and #compareinv2barcd determine the behavior of
-    // the controls within the barcode fieldset and the optional filters
-    $("#uploadbarcodes").change(function() {
-        if( $("#uploadbarcodes").val() ) {
-            $("#setdate").prop('disabled',false);
-            $("#compareinv2barcd").prop('disabled',false);
-            $("#dont_checkin").prop('disabled',false);
-            if( $("#compareinv2barcd").attr('checked') ) {
-                $("fieldset#optionalfilters").show();
-            } else {
-                $("fieldset#optionalfilters").hide();
-            }
-        } else {
-            $("#setdate").prop('disabled',true);
-            $("#compareinv2barcd").prop('disabled',true);
-            $("#compareinv2barcd").attr('checked',false);
-            $("#dont_checkin").prop('disabled',true);
-            $("#dont_checkin").attr('checked',false);
-            $("fieldset#optionalfilters").show();
-        }
-    });
-    $("#compareinv2barcd").click(function() {
-        if( $("#compareinv2barcd").attr('checked') ) {
-            $("fieldset#optionalfilters").show();
-        } else {
-            $("fieldset#optionalfilters").hide();
-        }
-    });
-});
-//]]>
-</script>
 </head>
+
 <body id="tools_inventory" class="tools">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'cat-search.inc' %]
@@ -368,4 +247,130 @@ $(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' %]
+    [% INCLUDE 'calendar.inc' %]
+    <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
+    <script type="text/javascript">
+        function checkForm() {
+            if ( $('#uploadbarcodes').val() ) {
+                if ( !(
+                    $('#branchloop').val()   ||
+                    $('#locationloop').val() ||
+                    $('#minlocation').val()  ||
+                    $('#maxlocation').val()  ||
+                    $('#statuses input:checked').length
+                ) ) {
+                    return confirm(
+                        _("You have not selected any catalog filters and are about to compare a file of barcodes to your entire catalog.") + "\n\n" +
+                        _("For large catalogs this can result in unexpected behavior") + "\n\n" +
+                        _("Are you sure you want to do this?")
+                    );
+                }
+            }
+
+            return true;
+        }
+
+        $(document).ready(function(){
+            inventorydt = $('#inventoryt').dataTable($.extend(true, {}, dataTablesDefaults, {
+                'sPaginationType': 'full_numbers',
+                [% IF compareinv2barcd %]
+                    // sort on callnumber
+                    "aaSorting": [[ 1, "asc" ]],
+                [% ELSE %]
+                    // first column contains checkboxes
+                    "aoColumnDefs": [
+                        { "bSortable": false, "bSearchable": false, "aTargets": [ 0 ] },
+                    ],
+                    // 3rd column is callnumber
+                    "aaSorting": [[ 2, "asc" ]],
+                [% END %]
+                'fnDrawCallback': function() {
+                    //bind the click handler script to the newly created elements held in the table
+                    $('.openWin').bind('click',function(e){
+                        e.preventDefault();
+                        openWindow(this.href,'marcview',800,600);
+                    });
+                }
+            } ));
+
+
+            $("#continuewithoutmarkingbutton").click(function(){
+                inventorydt.fnPageChange( 'next' );
+                return false;
+            });
+
+            $("#markseenandcontinuebutton").click(function(){
+                var param = '';
+                $("input:checked").each(function() {
+                    param += "|" + $(this).attr('name');
+                });
+                $.post('/cgi-bin/koha/tools/ajax-inventory.pl', { seen: param });
+                inventorydt.fnPageChange( 'next' );
+                return false;
+            });
+
+            $("#markseenandquit").click(function(){
+                var param = '';
+                $("input:checked").each(function() {
+                    param += "|" + $(this).attr('name');
+                });
+                $.ajax({
+                  type: 'POST',
+                  url: '/cgi-bin/koha/tools/ajax-inventory.pl',
+                  data: { seen: param},
+                  async: false
+                });
+                document.location.href = '/cgi-bin/koha/tools/inventory.pl';
+                return false;
+            });
+
+
+            $(".checkall").click(function(){
+                    $(".checkboxed").checkCheckboxes();
+                    return false;
+                });
+            $(".clearall").click(function(){
+                    $(".checkboxed").unCheckCheckboxes();
+                    return false;
+                });
+            $("#inventory_form").on("submit",function(){
+                return checkForm();
+            });
+
+            // #uploadbarcodes and #compareinv2barcd determine the behavior of
+            // the controls within the barcode fieldset and the optional filters
+            $("#uploadbarcodes").change(function() {
+                if( $("#uploadbarcodes").val() ) {
+                    $("#setdate").prop('disabled',false);
+                    $("#compareinv2barcd").prop('disabled',false);
+                    $("#dont_checkin").prop('disabled',false);
+                    if( $("#compareinv2barcd").attr('checked') ) {
+                        $("fieldset#optionalfilters").show();
+                    } else {
+                        $("fieldset#optionalfilters").hide();
+                    }
+                } else {
+                    $("#setdate").prop('disabled',true);
+                    $("#compareinv2barcd").prop('disabled',true);
+                    $("#compareinv2barcd").attr('checked',false);
+                    $("#dont_checkin").prop('disabled',true);
+                    $("#dont_checkin").attr('checked',false);
+                    $("fieldset#optionalfilters").show();
+                }
+            });
+            $("#compareinv2barcd").click(function() {
+                if( $("#compareinv2barcd").attr('checked') ) {
+                    $("fieldset#optionalfilters").show();
+                } else {
+                    $("fieldset#optionalfilters").hide();
+                }
+            });
+        });
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index 25523ce..cae2112 100644 (file)
 [% USE Koha %]
 [% USE Branches %]
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Tools &rsaquo; Notices[% IF ( add_form or copy_form ) %][% IF ( modify ) %] &rsaquo; Modify notice[% ELSE %] &rsaquo; Add notice[% END %][% END %][% IF ( add_validate or copy_validate) %] &rsaquo; Notice added[% END %][% IF ( delete_confirm ) %] &rsaquo; Confirm deletion[% 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.fixFloat.js"></script>
-<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.insertatcaret.js"></script>
-<script type="text/javascript">
-//<![CDATA[
-$(document).ready(function() {
-    [% IF add_form or copy_form %]
-        $('#toolbar').fixFloat();
-    [% END %]
-    $("#lettert:has(tbody tr)").dataTable($.extend(true, {}, dataTablesDefaults, {
-        "sDom": 't',
-        "aoColumnDefs": [
-            { "bSortable": false, "bSearchable": false, 'aTargets': [ 'nosort' ] }
-        ],
-        "bPaginate": false
-    }));
-    [% IF no_op_set %]
-      $('#branch').change(function() {
-            $('#op').val("");
-            $('#selectlibrary').submit();
-      });
-      $('#newnotice').click(function() {
-            $('#op').val("add_form");
-            return true;
-      });
-    [% END %]
-
-    $("#newmodule").on("change",function(){
-        if( $("#branch").val() == ""){
-            var branchcode = "*";
-        } else {
-            var branchcode = $("#branch").val();
-        }
-        window.location.href = "/cgi-bin/koha/tools/letter.pl?op=add_form&module=" + $(this).val() + "&branchcode=" + branchcode;
-    });
-
-    $("#submit_form").click( function(event) {
-        event.preventDefault();
-        var at_least_one_exists = 0;
-        var are_valid = 1;
-        $("fieldset.mtt").each( function(){
-            var title = $(this).find('input[name="title"]').val();
-            var content = $(this).find('textarea[name="content"]').val();
-            if (
-                    ( title.length == 0 && content.length > 0 )
-                 || ( title.length > 0 && content.length == 0 )
-            ) {
-                var mtt = $(this).find('input[name="message_transport_type"]').val();
-                var msg = _("Please specify title and content for %s");
-                msg = msg.replace( "%s", mtt );
-                at_least_one_exists = 1;
-                alert(msg);
-                return are_valid = false;
-            } else if ( title.length > 0 && content.length > 0 ) {
-                at_least_one_exists = 1;
-            }
-        } );
-        if ( ! at_least_one_exists ) {
-            alert( _("Please fill at least one template.") );
-            return false;
-        }
-        if ( ! are_valid ) {
-            return false;
-        }
-
-        // Test if code already exists in DB
-        var new_lettercode = $("#code").val();
-        var new_branchcode = $("#branch").val();
-        [% IF ( add_form and code ) # IF edit %]
-          if ( new_lettercode != '[% code %]' ) {
-        [% END %]
-          $.ajax({
-            data: { code: new_lettercode, branchcode: new_branchcode },
-            type: 'GET',
-            url: '/cgi-bin/koha/svc/letters/',
-            success: function (data) {
-              if ( data.letters.length > 0 ) {
-                if( new_branchcode == '' ) {
-                    alert( _("A default letter with the code '%s' already exists.").format(new_lettercode) );
-                } else {
-                    alert( _("A letter with the code '%s' already exists for '%s'.").format(new_lettercode, new_branchcode) );
-                }
-                return false;
-              } else {
-                $("#add_notice").submit();
-              }
-            },
-          });
-        [% IF ( add_form and code ) %]
-          } else {
-            $("#add_notice").submit();
-          }
-        [% END %]
-    });
-
-    var sms_limit = 160;
-    $("#content_sms").on("keyup", function(){
-        var length = $(this).val().length;
-        $("#sms_counter").html(length + "/" + sms_limit + _(" characters"));
-        if ( length  > sms_limit ) {
-            $("#sms_counter").css("color", "red");
-        } else {
-            $("#sms_counter").css("color", "black");
-        }
-    });
-    $( ".transport-types" ).accordion({ collapsible: true, active:false, animate: 200 });
-    $(".insert").on("click",function(){
-        var containerid = $(this).data("containerid");
-        insertValueQuery( containerid );
-    })
-
-    $("#tabs").tabs();
-
-    $("#saveandcontinue").on("click",function(e){
-        e.preventDefault();
-        $("#redirect").val("just_save");
-        $("#submit_form").click();
-    });
-
-});
-[% IF add_form or copy_form %]
-       
-    function cancel(f) {
-        $('#op').val("");
-        f.method = "get";
-        f.submit();
-    }
-
-               function isNotNull(f,noalert) {
-                       if (f.value.length ==0) {
-       return false;
-                       }
-                       return true;
-               }
-
-               function isNum(v,maybenull) {
-               var n = new Number(v.value);
-               if (isNaN(n)) {
-                       return false;
-                       }
-               if (maybenull==0 && v.value=='') {
-                       return false;
-               }
-               return true;
-               }
-        function insertValueQuery(containerid) {
-            var fieldset = $("#" + containerid);
-            var myQuery = $(fieldset).find('textarea[name="content"]');
-            var myListBox = $(fieldset).find('select[name="SQLfieldname"]');
-
-            if($(myListBox).find('option').length > 0) {
-                $(myListBox).find('option').each( function (){
-                    if ( $(this).attr('selected') && $(this).val().length > 0 ) {
-                        $(myQuery).insertAtCaret("<<" + $(this).val() + ">>");
-                    }
-                });
-            }
-        }
-       [% END %]
-               //]]>
-               </script>
 </head>
+
 <body id="tools_letter" class="tools">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'letters-search.inc' %]
@@ -555,4 +396,167 @@ $(document).ready(function() {
     </div>
 [% END %]
 </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 %]/lib/jquery/plugins/jquery.fixFloat.js"></script>
+    <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.insertatcaret.js"></script>
+    <script type="text/javascript">
+        $(document).ready(function() {
+            [% IF add_form or copy_form %]
+                $('#toolbar').fixFloat();
+            [% END %]
+            $("#lettert:has(tbody tr)").dataTable($.extend(true, {}, dataTablesDefaults, {
+                "sDom": 't',
+                "aoColumnDefs": [
+                    { "bSortable": false, "bSearchable": false, 'aTargets': [ 'nosort' ] }
+                ],
+                "bPaginate": false
+            }));
+            [% IF no_op_set %]
+                $('#branch').change(function() {
+                    $('#op').val("");
+                    $('#selectlibrary').submit();
+                });
+                $('#newnotice').click(function() {
+                    $('#op').val("add_form");
+                    return true;
+                });
+            [% END %]
+
+            $("#newmodule").on("change",function(){
+                if( $("#branch").val() == ""){
+                    var branchcode = "*";
+                } else {
+                    var branchcode = $("#branch").val();
+                }
+                window.location.href = "/cgi-bin/koha/tools/letter.pl?op=add_form&module=" + $(this).val() + "&branchcode=" + branchcode;
+            });
+
+            $("#submit_form").click( function(event) {
+                event.preventDefault();
+                var at_least_one_exists = 0;
+                var are_valid = 1;
+                $("fieldset.mtt").each( function(){
+                    var title = $(this).find('input[name="title"]').val();
+                    var content = $(this).find('textarea[name="content"]').val();
+                    if (
+                            ( title.length == 0 && content.length > 0 )
+                         || ( title.length > 0 && content.length == 0 )
+                    ) {
+                        var mtt = $(this).find('input[name="message_transport_type"]').val();
+                        var msg = _("Please specify title and content for %s");
+                        msg = msg.replace( "%s", mtt );
+                        at_least_one_exists = 1;
+                        alert(msg);
+                        return are_valid = false;
+                    } else if ( title.length > 0 && content.length > 0 ) {
+                        at_least_one_exists = 1;
+                    }
+                } );
+                if ( ! at_least_one_exists ) {
+                    alert( _("Please fill at least one template.") );
+                    return false;
+                }
+                if ( ! are_valid ) {
+                    return false;
+                }
+
+                // Test if code already exists in DB
+                var new_lettercode = $("#code").val();
+                var new_branchcode = $("#branch").val();
+                [% IF ( add_form and code ) # IF edit %]
+                    if ( new_lettercode != '[% code %]' ) {
+                [% END %]
+                    $.ajax({
+                        data: { code: new_lettercode, branchcode: new_branchcode },
+                        type: 'GET',
+                        url: '/cgi-bin/koha/svc/letters/',
+                        success: function (data) {
+                             if ( data.letters.length > 0 ) {
+                                 if( new_branchcode == '' ) {
+                                     alert( _("A default letter with the code '%s' already exists.").format(new_lettercode) );
+                                 } else {
+                                     alert( _("A letter with the code '%s' already exists for '%s'.").format(new_lettercode, new_branchcode) );
+                                 }
+                                 return false;
+                             } else {
+                                 $("#add_notice").submit();
+                             }
+                        },
+                    });
+                [% IF ( add_form and code ) %]
+                    } else {
+                        $("#add_notice").submit();
+                    }
+                [% END %]
+            });
+
+            var sms_limit = 160;
+            $("#content_sms").on("keyup", function(){
+                var length = $(this).val().length;
+                $("#sms_counter").html(length + "/" + sms_limit + _(" characters"));
+                if ( length  > sms_limit ) {
+                    $("#sms_counter").css("color", "red");
+                } else {
+                    $("#sms_counter").css("color", "black");
+                }
+            });
+            $( ".transport-types" ).accordion({ collapsible: true, active:false, animate: 200 });
+            $(".insert").on("click",function(){
+                var containerid = $(this).data("containerid");
+                insertValueQuery( containerid );
+            })
+
+            $("#tabs").tabs();
+
+            $("#saveandcontinue").on("click",function(e){
+                e.preventDefault();
+                $("#redirect").val("just_save");
+                $("#submit_form").click();
+            });
+
+        });
+        [% IF add_form or copy_form %]
+            function cancel(f) {
+                $('#op').val("");
+                f.method = "get";
+                f.submit();
+            }
+
+            function isNotNull(f,noalert) {
+              if (f.value.length ==0) {
+                  return false;
+              }
+              return true;
+            }
+
+            function isNum(v,maybenull) {
+                var n = new Number(v.value);
+                if (isNaN(n)) {
+                    return false;
+                }
+                if (maybenull==0 && v.value==''){
+                  return false;
+                }
+                return true;
+            }
+            function insertValueQuery(containerid) {
+                var fieldset = $("#" + containerid);
+                var myQuery = $(fieldset).find('textarea[name="content"]');
+                var myListBox = $(fieldset).find('select[name="SQLfieldname"]');
+
+                if($(myListBox).find('option').length > 0) {
+                    $(myListBox).find('option').each( function (){
+                        if ( $(this).attr('selected') && $(this).val().length > 0 ) {
+                            $(myQuery).insertAtCaret("<<" + $(this).val() + ">>");
+                        }
+                    });
+                }
+            }
+        [% END %]
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index 28a35de..b684fb0 100644 (file)
@@ -1,58 +1,12 @@
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Tools &rsaquo; Upload images</title>
 [% INCLUDE 'doc-head-close.inc' %]
-
-<script type="text/javascript" src="[% interface %]/[% theme %]/js/background-job-progressbar.js"></script>
-<script type="text/javascript" src="[% interface %]/[% theme %]/js/file-upload.js"></script>
-
 <style type="text/css">
     #fileuploadstatus,#fileuploadfailed,#jobpanel,#jobstatus,#jobfailed { display : none; }
 </style>
-
-<script type="text/javascript">
-//<![CDATA[
-function StartUpload() {
-    if( $('#fileToUpload').prop('files').length == 0 ) return;
-    $('#uploadform button.submit').prop('disabled',true);
-    $("#fileuploadstatus").show();
-    $("#uploadedfileid").val('');
-    xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), 'temp=1', cbUpload );
-}
-function cbUpload( status, fileid, errors ) {
-    if( status=='done' ) {
-        $("#uploadedfileid").val( fileid );
-        $('#fileToUpload').prop('disabled',true);
-        $("#processfile").show();
-    } else {
-        var errMsgs = [ _("Error code 0 not used"), _("File already exists"), _("Directory is not writeable"), _("Root directory for uploads not defined"), _("Temporary directory for uploads not defined") ];
-        var errCode = errors[$('#fileToUpload').prop('files')[0].name].code;
-        $("#fileuploadstatus").hide();
-        $("#fileuploadfailed").show();
-        $("#fileuploadfailed").text( _("Upload status: ") +
-            ( status=='failed'? _("Failed") + " - (" + errCode + ") " + errMsgs[errCode]:
-            ( status=='denied'? _("Denied"): status ))
-        );
-        $("#processfile").hide();
-    }
-}
-$(document).ready(function(){
-       $("#processfile").hide();
-       $("#zipfile").click(function(){
-               $("#bibnum").hide();
-       });
-       $("#image").click(function(){
-               $("#bibnum").show();
-       });
-    $("#uploadfile").validate({
-        submitHandler: function(form) {
-            StartUpload();
-            return false;
-        }
-    });
-});
-//]]>
-</script>
 </head>
+
 <body id="tools_upload-images" class="tools">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'cat-search.inc' %]
@@ -153,4 +107,52 @@ $(document).ready(function(){
 [% 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/background-job-progressbar.js"></script>
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/file-upload.js"></script>
+    <script type="text/javascript">
+        function StartUpload() {
+            if( $('#fileToUpload').prop('files').length == 0 ) return;
+            $('#uploadform button.submit').prop('disabled',true);
+            $("#fileuploadstatus").show();
+            $("#uploadedfileid").val('');
+            xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), 'temp=1', cbUpload );
+        }
+        function cbUpload( status, fileid, errors ) {
+            if( status=='done' ) {
+                $("#uploadedfileid").val( fileid );
+                $('#fileToUpload').prop('disabled',true);
+                $("#processfile").show();
+            } else {
+                var errMsgs = [ _("Error code 0 not used"), _("File already exists"), _("Directory is not writeable"), _("Root directory for uploads not defined"), _("Temporary directory for uploads not defined") ];
+                var errCode = errors[$('#fileToUpload').prop('files')[0].name].code;
+                $("#fileuploadstatus").hide();
+                $("#fileuploadfailed").show();
+                $("#fileuploadfailed").text( _("Upload status: ") +
+                    ( status=='failed'? _("Failed") + " - (" + errCode + ") " + errMsgs[errCode]:
+                    ( status=='denied'? _("Denied"): status ))
+                );
+                $("#processfile").hide();
+            }
+        }
+        $(document).ready(function(){
+            $("#processfile").hide();
+            $("#zipfile").click(function(){
+                $("#bibnum").hide();
+            });
+            $("#image").click(function(){
+                $("#bibnum").show();
+            });
+            $("#uploadfile").validate({
+                submitHandler: function(form) {
+                    StartUpload();
+                    return false;
+                }
+            });
+        });
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]