Owen Leonard
127b931681
This patch moves the ajaxfileupload jQuery plugin to intranet-tmpl/prog/lib/jquery/plugins so that it will not be duplicated for each set of translated templates. To test, apply the patch and test a page which requires the file upload plugin. For instance: Tools -> Upload local cover image. The upload process should finish correctly. Tested with patron and local cover images. Works as expected. Signed-off-by: Marc Veron <veron@veron.ch> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
70 lines
2.9 KiB
HTML
70 lines
2.9 KiB
HTML
<!-- AJAX file upload stuff -->
|
|
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/ajaxfileupload.js"></script>
|
|
<script type="text/javascript">
|
|
//<![CDATA[
|
|
var fileUploadProgressTimer = 0;
|
|
var inFileUploadProgressTimer = false;
|
|
var fileUploadProgressTimerCanceled = false;
|
|
function updateProgress() {
|
|
if (inFileUploadProgressTimer) {
|
|
// since $.getJSON is asynchronous, wait
|
|
// until the last one is finished
|
|
return;
|
|
}
|
|
inFileUploadProgressTimer = true;
|
|
$.getJSON("/cgi-bin/koha/tools/upload-file-progress.pl", function(json) {
|
|
if (!fileUploadProgressTimerCanceled) {
|
|
var bgproperty = (parseInt(json.progress)*2-300)+"px 0px";
|
|
$("#fileuploadprogress").css("background-position",bgproperty);
|
|
$("#fileuploadpercent").text(json.progress);
|
|
}
|
|
inFileUploadProgressTimer = false;
|
|
});
|
|
}
|
|
function ajaxFileUpload()
|
|
{
|
|
fileUploadProgressTimerCanceled = false;
|
|
$("#uploadpanel").show();
|
|
$("#fileuploadstatus").show();
|
|
fileUploadProgressTimer = setInterval("updateProgress()",500);
|
|
$.ajaxFileUpload (
|
|
{
|
|
url:'/cgi-bin/koha/tools/upload-file.pl',
|
|
secureuri:false,
|
|
global:false,
|
|
fileElementId:'fileToUpload',
|
|
dataType: 'json',
|
|
success: function (data, status) {
|
|
if (data.status == 'denied') {
|
|
$("#fileuploadstatus").hide();
|
|
$("#fileuploadfailed").show();
|
|
$("#fileuploadfailed").text("Upload failed -- no permission to upload files");
|
|
} else if (data.status == 'failed') {
|
|
$("#fileuploadstatus").hide();
|
|
$("#fileuploadfailed").show();
|
|
$("#fileuploadfailed").text("Upload failed -- unable to store file on server");
|
|
} else if (data.status == 'maintenance') {
|
|
$("#fileuploadstatus").hide();
|
|
$("#fileuploadfailed").show();
|
|
$("#fileuploadfailed").text("Upload failed -- database in maintenance state");
|
|
} else {
|
|
$("#uploadedfileid").val(data.fileid);
|
|
$("#fileuploadprogress").css("background-position","0px 0px");
|
|
$("#processfile").show();
|
|
$("#fileuploadpercent").text("100");
|
|
}
|
|
fileUploadProgressTimerCanceled = true;
|
|
clearInterval(fileUploadProgressTimer);
|
|
},
|
|
error: function (data, status, e) {
|
|
fileUploadProgressTimerCanceled = true;
|
|
alert(e);
|
|
clearInterval(fileUploadProgressTimer);
|
|
}
|
|
}
|
|
)
|
|
return false;
|
|
|
|
}
|
|
//]]>
|
|
</script>
|