Koha/koha-tmpl/intranet-tmpl/prog/js/file-upload.js
Owen Leonard 5e1bcc4aa7 Bug 16242 - Move staff client JavaScript out of language directory
This patch moves the JavaScript files in prog/en/js to prog/js.
JavaScript files do not need to be in the directory which is processed
by the translator.

To test, apply the patch and visit various pages in the staff client to
confirm that JavaScript files are still loading correctly.

Revised: I intended for this to be built on top of Bug 15883 as well as
Bug 16242. Now it is.

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
On top of 15883 and 16241
All seems to work, js files pulled from new dir.
No errors

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
2016-04-29 14:32:42 +00:00

32 lines
1.2 KiB
JavaScript

function AjaxUpload ( input, progressbar, xtra, callback ) {
// input and progressbar are jQuery objects
// callback is the callback function for completion
var formData= new FormData();
$.each( input.prop('files'), function( dx, file ) {
formData.append( "uploadfile", file );
});
var xhr= new XMLHttpRequest();
var url= '/cgi-bin/koha/tools/upload-file.pl?' + xtra;
progressbar.val( 0 );
progressbar.next('.fileuploadpercent').text( '0' );
xhr.open('POST', url, true);
xhr.upload.onprogress = function (e) {
var p = Math.round( (e.loaded/e.total) * 100 );
progressbar.val( p );
progressbar.next('.fileuploadpercent').text( p );
}
xhr.onload = function (e) {
var data = JSON.parse( xhr.responseText );
if( data.status == 'done' ) {
progressbar.val( 100 );
progressbar.next('.fileuploadpercent').text( '100' );
}
callback( data.status, data.fileid, data.errors );
}
xhr.onerror = function (e) {
// Probably only fires for network failure
alert('An error occurred while uploading.');
}
xhr.send( formData );
return xhr;
}