uploadify 插件 cancel

   

cancel: function (fileID, supressEvent) {
var args = arguments;

this.each(function () {
// Create a reference to the jQuery DOM object
var $this = $(this),
swfuploadify = $this.data('uploadify'),
settings = swfuploadify.settings,
delay = -1;

if (args[0]) {
// Clear the queue
if (args[0] == '*') {
var queueItemCount = swfuploadify.queueData.queueLength;
$('#' + settings.queueID).find('.uploadify-queue-item').each(function () {
delay++;
if (args[1] === true) {
swfuploadify.cancelUpload($(this).attr('id'), false);
} else {
swfuploadify.cancelUpload($(this).attr('id'));
}
$(this).find('.data').removeClass('data').html(' - Cancelled');
$(this).find('.uploadify-progress-bar').remove();
$(this).delay(1000 + 100 * delay).fadeOut(500, function () {
$(this).remove();
});
});
swfuploadify.queueData.queueSize = 0;
swfuploadify.queueData.queueLength = 0;
// Trigger the onClearQueue event
if (settings.onClearQueue) settings.onClearQueue.call($this, queueItemCount);
} else {
for (var n = 0; n < args.length; n++) {
swfuploadify.cancelUpload(args[n]);
/* 删除队列 清空隐藏域要保存的信息 */ 
delete swfuploadify.queueData.files[args[n]];
swfuploadify.queueData.queueLength = swfuploadify.queueData.queueLength - 1;
$("#file_upload").uploadify('settings', 'uploadLimit', swfuploadify.settings.uploadLimit + 1);
if (swfuploadify.queueData.queueLength == -1) {
$("#name").val("");
$("#storename").val("");
$("#size").val("");
$("#format").val("");
$("#voidname").html("");
}
/* */
$('#' + args[n]).find('.data').removeClass('data').html(' - Cancelled');
$('#' + args[n]).find('.uploadify-progress-bar').remove();
$('#' + args[n]).delay(1000 + 100 * n).fadeOut(500, function () {
$(this).remove();
});
}
}
} else {
var item = $('#' + settings.queueID).find('.uploadify-queue-item').get(0);
$item = $(item);
swfuploadify.cancelUpload($item.attr('id'));
/* 删除队列 清空隐藏域要保存的信息 */
delete swfuploadify.queueData.files[$item.attr('id')];
$("#file_upload").uploadify('settings', 'uploadLimit', swfuploadify.settings.uploadLimit + 1);
if (swfuploadify.queueData.queueLength == -1) {
$("#name").val("");
$("#storename").val("");
$("#size").val("");
$("#format").val("");
$("#voidname").html("");
}
/*  */
$item.find('.data').removeClass('data').html(' - Cancelled');
$item.find('.uploadify-progress-bar').remove();
$item.delay(1000).fadeOut(500, function () {
$(this).remove();
});
}
});}

posted @ 2017-09-01 14:46  Schauspieler  阅读(209)  评论(0编辑  收藏  举报