Bug 17011 - Remove "onblur" event attribute from some templates
[koha.git] / koha-tmpl / intranet-tmpl / prog / js / biblio_framework.js
1 /* Import/Export from/to spreadsheet */
2
3     var importing = false;
4
5     $(document).ready(function() {
6         $("#table_biblio_frameworks").dataTable($.extend(true, {}, dataTablesDefaults, {
7             "aoColumnDefs": [
8                 { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
9                 { "aTargets": [ 0, 1 ], "sType": "natural" },
10             ],
11             "bSort": true,
12             "sPaginationType": "four_button"
13         }));
14
15         $("body").css("cursor", "auto");
16         $('.import_export_options').hide();
17         $('a.import_export_fw').click(function() {
18             if (!importing) {
19                 $('.import_export_options').hide();
20                 $(this).next().show('slide');
21             }
22             return false;
23         });
24         $('.import_export_close').click(function() {
25             if (!importing) {
26                 $('.import_export_options').fadeOut('fast');
27                 $("body").css("cursor", "auto");
28                 return false;
29             }
30         });
31         $('.input_import').val("");
32
33         var matches = new RegExp("\\?error_import_export=(.+)$").exec(window.location.search);
34         if (matches && matches.length > 1) {
35             alert( MSG_IMPORT_ERROR + " %s".format(decodeURIComponent(matches[1])));
36         }
37
38         $('input.input_import').change( function() {
39             var filename = $(this).val();
40             if ( ! /(?:\.csv|\.ods|\.xml)$/.test(filename)) {
41                 $(this).css("background-color","yellow");
42                 alert( MSG_SELECT_FILE_FORMAT );
43                 $(this).val("");
44                 $(this).css("background-color","white");
45             }
46         });
47         $('form.form_export').submit(function() {
48             $('.modal').modal("hide");
49             return true;
50         });
51         $('form.form_import').submit(function() {
52             var id = $(this).attr('id');
53             var obj = $('#' + id + ' input:file');
54             if (/(?:\.csv|\.ods|\.xml)$/.test(obj.val())) {
55                 if (confirm( MSG_OVERWRITE_WARNING )) {
56                     var frameworkcode = $('#' + id + ' input:hidden[name=frameworkcode]').val();
57                     $('#importing_' + frameworkcode).find("span").html(MSG_IMPORTING_TO_FRAMEWORK.format("<strong>" + frameworkcode + "</strong>", "<i>" + obj.val().replace(new RegExp("^.+[/\\\\]"),"") + "</i>"));
58                     if (navigator.userAgent.toLowerCase().indexOf('msie') != -1) {
59                         var timestamp = new Date().getTime();
60                         $('#importing_' + frameworkcode).find("img").attr('src', template_path + '/img/loading-small.gif' + '?' +timestamp);
61                     }
62                     $('#importing_' + frameworkcode).css('display', 'block');
63                     if (navigator.userAgent.toLowerCase().indexOf('firefox') == -1) $("body").css("cursor", "progress");
64                     importing = true;
65                     $(".modal-footer,.closebtn").hide();
66                     return true;
67                 } else
68                     return false;
69             }
70             obj.css("background-color","yellow");
71             alert( MSG_SELECT_FILE_FORMAT );
72             obj.val("");
73             obj.css("background-color","white");
74             return false;
75         });
76         $("#frameworkcode").on("blur",function(){
77             toUC(this);
78         });
79     });