Bug 32030: Improve I18N
[koha.git] / koha-tmpl / intranet-tmpl / prog / js / pages / circulation.js
1 $(document).ready(function() {
2     $("#CheckAllExports").on("click",function(){
3         $(".export:visible").prop("checked", true);
4         return false;
5     });
6     $("#UncheckAllExports").on("click",function(){
7         $(".export:visible").prop("checked", false);
8         return false;
9     });
10
11     $("#patronlists a[data-toggle='tab']").on("shown.bs.tab", function(e){
12         $(this).click();
13     });
14
15     $("#borrower_messages .cancel").on("click",function(){
16         $("#add_message_form").hide();
17         $("#addmessage").show();
18     });
19
20     $("#addmessage").on("click",function(){
21         $(this).hide();
22         $("#add_message_form").show();
23      });
24
25     $("input.radio").on("click",function(){
26         radioCheckBox($(this));
27     });
28
29     $(".clear_date").on("click", function(){
30         $("#stickyduedate").prop( "checked", false );
31     });
32
33     $("#export_submit").on("click",function(){
34         export_checkouts($("#issues-table-output-format").val());
35         return false;
36     });
37
38     var circ_settings = $(".circ-settings");
39     var circ_settings_icon = $(".circ-settings-icon");
40
41     // If any checkboxes in the circ settings are selected, show the settings by default
42     if ( $(".circ-settings input:checked,#duedatespec[value!='']").length ) {
43         circ_settings.show();
44         circ_settings_icon.removeClass("fa-caret-right").addClass("fa-caret-down");
45     } else {
46         circ_settings.hide();
47         circ_settings_icon.removeClass("fa-caret-down").addClass("fa-caret-right");
48     }
49
50     $("#show-circ-settings a").on("click",function(){
51         if( circ_settings.is(":hidden")){
52             circ_settings.show();
53             circ_settings_icon.removeClass("fa-caret-right").addClass("fa-caret-down");
54         } else {
55             $("#barcode").focus();
56             circ_settings.hide();
57             circ_settings_icon.removeClass("fa-caret-down").addClass("fa-caret-right");
58         }
59     });
60
61     $(".circ_setting").on("click",function(){
62         $("#barcode").focus();
63     });
64
65     $("#itemSearchFallback").ready(function(){
66         $("#itemSearchFallback").modal("show");
67     });
68
69     // Debarments
70     $("div#reldebarments .remove_restriction").on("click",function(){
71         return confirm( __("Remove restriction?") );
72     });
73     var mrform = $("#manual_restriction_form");
74     var mrlink = $("#add_manual_restriction");
75     mrform.hide();
76     mrlink.on("click",function(e){
77         $(this).hide();
78         mrform.show();
79         e.preventDefault();
80     });
81     $("#cancel_manual_restriction").on("click",function(e){
82         mrlink.show();
83         mrform.hide();
84         e.preventDefault();
85     });
86     $(".clear-date").on("click",function(e){
87         e.preventDefault();
88         var fieldID = this.id.replace("clear-date-","");
89         $("#" + fieldID).val("");
90     });
91
92     /* Preselect Bootstrap tab based on location hash */
93     var hash = window.location.hash.substring(1);
94     if( hash ){
95         var activeTab = $('a[href="#' + hash + '"]');
96         activeTab && activeTab.tab('show');
97     }
98
99 });
100
101 function export_checkouts(format) {
102     if ($("input:checkbox[name='biblionumbers']:checked").length < 1){
103         alert( __("You must select checkout(s) to export") );
104         return;
105     }
106
107     $("input:checkbox[name='biblionumbers']").each( function(){
108         var input_item = $(this).siblings("input:checkbox");
109         if ( $(this).is(":checked") ) {
110             $(input_item).prop("checked", true);
111         } else {
112             $(input_item).prop("checked", false);
113         }
114     } );
115
116     if (format == 'iso2709_995') {
117         format = 'iso2709';
118         $("#dont_export_item").val(0);
119     } else if (format == 'iso2709') {
120         $("#dont_export_item").val(1);
121     }
122
123     document.getElementById("output_format").value = format;
124     document.issues.submit();
125 }