|
Lines 10-93
Link Here
|
| 10 |
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" /> |
10 |
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" /> |
| 11 |
[% INCLUDE 'datatables.inc' %] |
11 |
[% INCLUDE 'datatables.inc' %] |
| 12 |
<script type="text/javascript"> |
12 |
<script type="text/javascript"> |
| 13 |
/* Import/Export from/to spreadsheet */ |
13 |
/* Set some variable needed in biblio_framework.js */ |
| 14 |
|
14 |
var MSG_IMPORT_ERROR = _("Error importing the framework"); |
| 15 |
var importing = false; |
15 |
var MSG_SELECT_FILE_FORMAT = _("Please select a CSV (.csv), ODS (.ods) or XML (.xml) spreadsheet file."); |
| 16 |
|
16 |
var MSG_OVERWRITE_WARNING = _("Do you really want to import the framework fields and subfields? This will overwrite the current configuration. For safety reasons please use the export option to make a backup"); |
| 17 |
$(document).ready(function() { |
17 |
var MSG_IMPORTING_TO_FRAMEWORK = _("Importing to framework: %s. Importing from file: %s."); |
| 18 |
$("#table_biblio_frameworks").dataTable($.extend(true, {}, dataTablesDefaults, { |
18 |
var template_path = "[% interface %]/[% theme %]"; |
| 19 |
"aoColumnDefs": [ |
|
|
| 20 |
{ "aTargets": [ -1, -2, -3, -4, -5 ], "bSortable": false, "bSearchable": false }, |
| 21 |
{ "aTargets": [ 0, 1 ], "sType": "natural" }, |
| 22 |
], |
| 23 |
"bSort": true, |
| 24 |
"sPaginationType": "four_button" |
| 25 |
})); |
| 26 |
|
| 27 |
$("body").css("cursor", "auto"); |
| 28 |
$('.import_export_options').hide(); |
| 29 |
$('a.import_export_fw').click(function() { |
| 30 |
if (!importing) { |
| 31 |
$('.import_export_options').hide(); |
| 32 |
$(this).next().show('slide'); |
| 33 |
} |
| 34 |
return false; |
| 35 |
}); |
| 36 |
$('.import_export_close').click(function() { |
| 37 |
if (!importing) { |
| 38 |
$('.import_export_options').fadeOut('fast'); |
| 39 |
$("body").css("cursor", "auto"); |
| 40 |
return false; |
| 41 |
} |
| 42 |
}); |
| 43 |
$('.input_import').val(""); |
| 44 |
|
| 45 |
var matches = new RegExp("\\?error_import_export=(.+)$").exec(window.location.search); |
| 46 |
if (matches && matches.length > 1) { |
| 47 |
alert(_("Error importing the framework %s").format(decodeURIComponent(matches[1]))); |
| 48 |
} |
| 49 |
|
| 50 |
$('input.input_import').change( function() { |
| 51 |
var filename = $(this).val(); |
| 52 |
if ( ! /(?:\.csv|\.ods|\.xml)$/.test(filename)) { |
| 53 |
$(this).css("background-color","yellow"); |
| 54 |
alert(_("Please select a CSV (.csv), ODS (.ods) or XML (.xml) spreadsheet file.")); |
| 55 |
$(this).val(""); |
| 56 |
$(this).css("background-color","white"); |
| 57 |
} |
| 58 |
}); |
| 59 |
$('form.form_export').submit(function() { |
| 60 |
$('.modal').modal("hide"); |
| 61 |
return true; |
| 62 |
}); |
| 63 |
$('form.form_import').submit(function() { |
| 64 |
var id = $(this).attr('id'); |
| 65 |
var obj = $('#' + id + ' input:file'); |
| 66 |
if (/(?:\.csv|\.ods|\.xml)$/.test(obj.val())) { |
| 67 |
if (confirm(_("Do you really want to import the framework fields and subfields? This will overwrite the current configuration. For safety reasons please use the export option to make a backup"))) { |
| 68 |
var frameworkcode = $('#' + id + ' input:hidden[name=frameworkcode]').val(); |
| 69 |
$('#importing_' + frameworkcode).find("span").html(_("Importing to framework: %s. Importing from file: %s").format("<strong>" + frameworkcode + "</strong>", "<i>" + obj.val().replace(new RegExp("^.+[/\\\\]"),"") + "</i>")); |
| 70 |
if (navigator.userAgent.toLowerCase().indexOf('msie') != -1) { |
| 71 |
var timestamp = new Date().getTime(); |
| 72 |
$('#importing_' + frameworkcode).find("img").attr('src', '[% interface %]/[% theme %]/img/loading-small.gif' + '?' +timestamp); |
| 73 |
} |
| 74 |
$('#importing_' + frameworkcode).css('display', 'block'); |
| 75 |
if (navigator.userAgent.toLowerCase().indexOf('firefox') == -1) $("body").css("cursor", "progress"); |
| 76 |
importing = true; |
| 77 |
$(".modal-footer,.closebtn").hide(); |
| 78 |
return true; |
| 79 |
} else |
| 80 |
return false; |
| 81 |
} |
| 82 |
obj.css("background-color","yellow"); |
| 83 |
alert(_("Please select a CSV (.csv), ODS (.ods) or XML (.xml) spreadsheet file.")); |
| 84 |
obj.val(""); |
| 85 |
obj.css("background-color","white"); |
| 86 |
return false; |
| 87 |
}); |
| 88 |
}); |
| 89 |
|
| 90 |
</script> |
19 |
</script> |
|
|
20 |
<script type="text/javascript" src="[% themelang %]/js/biblio_framework.js"></script> |
| 91 |
|
21 |
|
| 92 |
</head> |
22 |
</head> |
| 93 |
<body id="admin_biblio_framework" class="admin"> |
23 |
<body id="admin_biblio_framework" class="admin"> |
| 94 |
- |
|
|