MultipleFileUpload/UI/Uploadify/initJS.latte
<script>
(function($){
var uploadifyId = {$uploadifyId|escapeJS|noescape};
var queue = $('#' + uploadifyId + '-queue');
var clearQueueButton = $('#' + uploadifyId + 'ClearQueue');
var uploadify = $('#' + uploadifyId);
var uploadedCount = 0;
uploadify.uploadify({
auto: false,
buttonImage: {$interface->baseUrl|escapeJS|noescape} + '/imgs/uploadifyButton.png',
fileSizeLimit: {$sizeLimit|escapeJS|noescape},
formData: {
token: {$token|escapeJS|noescape},
sender: 'MFU-Uploadify'
},
height: 22,
method: 'post',
multi: true,
overrideEvents: ['onQueueComplete'],
queueID: uploadifyId + '-queue',
queueSizeLimit: {$maxFiles|escapeJS|noescape},
removeCompleted: true,
swf: {$interface->baseUrl|escapeJS|noescape} + '/swf/uploadify.swf',
uploader: {$backLink|escapeJS|noescape},
width: 70,
/**
* Triggered when all files in the queue have been processed.
onQueueComplete: function(queueData){
if (queueData.uploadsErrored > 0) {
showError('Niekoľko súborov sa nepodarilo nahrať (' + queueData.uploadsErrored + ')');
} else {
showError('Všetky súbory boli úspešne nahrané');
}
queue.fadeOut(500);
clearQueueButton.fadeOut(500);
},
*/
onClearQueue: function(queueItemCount) {
queue.fadeOut(500);
clearQueueButton.fadeOut(500);
},
/**
* Triggered for each file that successfully uploads.
*/
onUploadSuccess: function(fileObj, data, response){
uploadedCount++;
$('#' + uploadifyId + 'Count').text('Počet nahraných súborov:' + uploadedCount);
},
/**
* Triggered for each file that is selected from the browse files dialog and added to the queue.
*/
onSelect: function(fileObj){
if(fileObj.size > uploadify.uploadify('settings' , 'sizeLimit')) {
uploadify.trigger({
type: "sizeLimitExceeded",
fileObj: fileObj,
});
uploadify.uploadify('cancel');
return false;
}
if(fileObj.size == 0) {
uploadify.trigger({
type: "emptyFile",
fileObj: fileObj,
});
uploadify.uploadify('cancel');
return false;
}
queue.fadeIn(500);
clearQueueButton.fadeIn(500);
}
});
uploadify.bind("sizeLimitExceeded",function(event){
showError("File '" + event.fileObj.name + "' is too big. Skipping.");
});
uploadify.bind("emptyFile",function(event){
showError("File '" + event.fileObj.name + "' is empty! Skipping.");
});
/**
* Show info message to user.
* @param string
*/
function showError(msg)
{
alert(msg);
}
return true; // OK
})(jQuery);
</script>