1 /* Import/Export from/to spreadsheet */
5 $(document).ready(function() {
6 $("#table_biblio_frameworks").dataTable($.extend(true, {}, dataTablesDefaults, {
8 { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
9 { "aTargets": [ 0, 1 ], "sType": "natural" },
12 "sPaginationType": "four_button"
15 $("body").css("cursor", "auto");
16 $('.import_export_options').hide();
17 $('a.import_export_fw').click(function() {
19 $('.import_export_options').hide();
20 $(this).next().show('slide');
24 $('.import_export_close').click(function() {
26 $('.import_export_options').fadeOut('fast');
27 $("body").css("cursor", "auto");
31 $('.input_import').val("");
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])));
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 );
44 $(this).css("background-color","white");
47 $('form.form_export').submit(function() {
48 $('.modal').modal("hide");
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/spinner-small.gif' + '?' +timestamp);
62 $('#importing_' + frameworkcode).css('display', 'block');
63 if (navigator.userAgent.toLowerCase().indexOf('firefox') == -1) $("body").css("cursor", "progress");
65 $(".modal-footer,.closebtn").hide();
70 obj.css("background-color","yellow");
71 alert( MSG_SELECT_FILE_FORMAT );
73 obj.css("background-color","white");
76 $("#frameworkcode").on("blur",function(){