From d7eea46ade06ab22634526ec0909f7f3c036b9f7 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 15 Aug 2013 16:14:50 -0400 Subject: [PATCH] Bug 9294 - Move JavaScript out of circulation template This patch creates a new js file, js/pages/circulation.js, and begins the process of moving JavaScript into it from circulation.tt. I have started the process by focusing on sections which are least dependent on template variables. To test, load a patron for checkout who has something checked out. There should be no JavaScript errors: - Tabs should work. - Showing and hiding the "Add message" form should work. - The "specify due date" datepicker should work. - Controls for selecting checkboxes in the checkouts table should work Signed-off-by: Campbell Reid-Tait Signed-off-by: Jonathan Druart Just found a weird behavior with checkboxes in the checkouts table, but still exists on master. Signed-off-by: Galen Charlton (cherry picked from commit 249b37ef488d90d8cd9104c4d3d806f7a30590d8) Signed-off-by: Tomas Cohen Arazi --- .../prog/en/js/pages/circulation.js | 139 ++++++++++++++++ .../prog/en/modules/circ/circulation.tt | 153 +----------------- 2 files changed, 146 insertions(+), 146 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/js/pages/circulation.js diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/pages/circulation.js b/koha-tmpl/intranet-tmpl/prog/en/js/pages/circulation.js new file mode 100644 index 0000000000..80e61ca9d1 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/js/pages/circulation.js @@ -0,0 +1,139 @@ +$(document).ready(function() { + $('#patronlists').tabs(); + var allcheckboxes = $(".checkboxed"); + $("#renew_all").on("click",function(){ + allcheckboxes.checkCheckboxes(":input[name*=items]"); + allcheckboxes.unCheckCheckboxes(":input[name*=barcodes]"); + }); + $("#CheckAllitems").on("click",function(){ + allcheckboxes.checkCheckboxes(":input[name*=items]"); + allcheckboxes.unCheckCheckboxes(":input[name*=barcodes]"); return false; + }); + $("#CheckNoitems").on("click",function(){ + allcheckboxes.unCheckCheckboxes(":input[name*=items]"); return false; + }); + $("#CheckAllreturns").on("click",function(){ + allcheckboxes.checkCheckboxes(":input[name*=barcodes]"); + allcheckboxes.unCheckCheckboxes(":input[name*=items]"); return false; + }); + $("#CheckNoreturns" ).on("click",function(){ + allcheckboxes.unCheckCheckboxes(":input[name*=barcodes]"); return false; + }); + + $("#CheckAllexports").on("click",function(){ + allcheckboxes.checkCheckboxes(":input[name*=biblionumbers]"); + allcheckboxes.unCheckCheckboxes(":input[name*=items]"); + return false; + }); + $("#CheckNoexports").on("click",function(){ + allcheckboxes.unCheckCheckboxes(":input[name*=biblionumbers]"); + return false; + }); + + $("#relrenew_all").on("click",function(){ + allcheckboxes.checkCheckboxes(":input[name*=items]"); + allcheckboxes.unCheckCheckboxes(":input[name*=barcodes]"); + }); + $("#relCheckAllitems").on("click",function(){ + allcheckboxes.checkCheckboxes(":input[name*=items]"); + allcheckboxes.unCheckCheckboxes(":input[name*=barcodes]"); return false; + }); + $("#relCheckNoitems").on("click",function(){ + allcheckboxes.unCheckCheckboxes(":input[name*=items]"); return false; + }); + $("#relCheckAllreturns").on("click",function(){ + allcheckboxes.checkCheckboxes(":input[name*=barcodes]"); + allcheckboxes.unCheckCheckboxes(":input[name*=items]"); return false; + }); + $("#relCheckNoreturns").on("click",function(){ + allcheckboxes.unCheckCheckboxes(":input[name*=barcodes]"); return false; + }); + $("#messages ul").after(""+MSG_ADD_MESSAGE+""); + $("#borrower_messages .cancel").on("click",function(){ + $("#add_message_form").hide(); + $("#addmessage").show(); + }); + $("#addmessage").on("click",function(){ + $(this).hide(); + $("#add_message_form").show(); + }); + + $("input.radio").on("click",function(){ + radioCheckBox($(this)); + }); + + $("#newduedate").datetimepicker({ + minDate: 1, // require that renewal date is after today + hour: 23, + minute: 59 + }); + $("#duedatespec").datetimepicker({ + onClose: function(dateText, inst) { $("#barcode").focus(); }, + hour: 23, + minute: 59 + }); + $("#export_submit").on("click",function(){ + var export_format = $("#export_formats").val(); + export_checkouts(export_format); + return false; + }); + // Clicking the table cell checks the checkbox inside it + $("td").on("click",function(e){ + if(e.target.tagName.toLowerCase() == 'td'){ + $(this).find("input:checkbox:visible").each( function() { + if($(this).attr("checked")){ + $(this).removeAttr("checked"); + } else { + $(this).attr("checked","checked"); + radioCheckBox($(this)); + } + }); + } + }); +}); + +function export_checkouts(format) { + if ($("input:checkbox[name='biblionumbers'][checked]").length < 1){ + alert(MSG_EXPORT_SELECT_CHECKOUTS); + return; + } + + $("input:checkbox[name='biblionumbers']").each( function(){ + var input_item = $(this).siblings("input:checkbox"); + if ( $(this).is(":checked") ) { + $(input_item).attr("checked", "checked"); + } else { + $(input_item).attr("checked", ""); + } + } ); + + if (format == 'iso2709_995') { + format = 'iso2709'; + $("#dont_export_item").val(0); + } else if (format == 'iso2709') { + $("#dont_export_item").val(1); + } + document.issues.action="/cgi-bin/koha/tools/export.pl"; + document.getElementById("export_format").value = format; + document.issues.submit(); + + /* Reset form action to its initial value */ + document.issues.action="/cgi-bin/koha/reserve/renewscript.pl"; + +} + +function validate1(date) { + var today = new Date(); + if ( date < today ) { + return true; + } else { + return false; + } +} + +// prevent adjacent checkboxes from being checked simultaneously +function radioCheckBox(box){ + if($(this).attr("checked")){ + $(this).removeAttr("checked"); + } + } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt index 9144d27745..8efce0ad07 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -19,8 +19,11 @@ [% END %] + @@ -1000,7 +858,10 @@ No patron matched [% message %] -- 2.39.5