Ticket #6979: swfupload.2.diff
File swfupload.2.diff, 4.0 KB (added by , 16 years ago) |
---|
-
wp-includes/js/swfupload/plugins/swfupload.queue.js
2 2 Queue Plug-in 3 3 4 4 Features: 5 cancelQueue method for cancelling the entire queue. 6 All queued files are uploaded when startUpload() is called. 7 If false is returned from uploadComplete then the queue upload is stopped. If false is not returned (strict comparison) then the queue upload is continued. 5 *Adds a cancelQueue() method for cancelling the entire queue. 6 *All queued files are uploaded when startUpload() is called. 7 *If false is returned from uploadComplete then the queue upload is stopped. 8 If false is not returned (strict comparison) then the queue upload is continued. 9 *Adds a QueueComplete event that is fired when all the queued files have finished uploading. 10 Set the event handler with the queue_complete_handler setting. 8 11 9 12 */ 10 13 … … 12 15 if (typeof(SWFUpload) === "function") { 13 16 SWFUpload.queue = {}; 14 17 15 SWFUpload.prototype.initSettings = function (old_initSettings) {16 return function ( init_settings) {17 if (typeof(old _initSettings) === "function") {18 old _initSettings.call(this, init_settings);18 SWFUpload.prototype.initSettings = (function (oldInitSettings) { 19 return function () { 20 if (typeof(oldInitSettings) === "function") { 21 oldInitSettings.call(this); 19 22 } 20 23 21 24 this.customSettings.queue_cancelled_flag = false; 25 this.customSettings.queue_upload_count = 0; 22 26 23 this.addSetting("user_upload_complete_handler", init_settings.upload_complete_handler, SWFUpload.uploadComplete); 24 this.uploadComplete_handler = SWFUpload.queue.uploadComplete; 27 this.settings.user_upload_complete_handler = this.settings.upload_complete_handler; 28 this.settings.upload_complete_handler = SWFUpload.queue.uploadCompleteHandler; 29 30 this.settings.queue_complete_handler = this.settings.queue_complete_handler || null; 25 31 }; 26 } (SWFUpload.prototype.initSettings);32 })(SWFUpload.prototype.initSettings); 27 33 28 SWFUpload.prototype.cancelQueue = function () { 29 var stats = this.getStats(); 34 SWFUpload.prototype.startUpload = function (fileID) { 30 35 this.customSettings.queue_cancelled_flag = false; 36 this.callFlash("StartUpload", false, [fileID]); 37 }; 31 38 32 if (stats.in_progress > 0) {33 34 }39 SWFUpload.prototype.cancelQueue = function () { 40 this.customSettings.queue_cancelled_flag = true; 41 this.stopUpload(); 35 42 36 while(stats.files_queued > 0) { 43 var stats = this.getStats(); 44 while (stats.files_queued > 0) { 37 45 this.cancelUpload(); 38 46 stats = this.getStats(); 39 47 } 40 48 }; 41 49 42 SWFUpload.queue.uploadComplete = function (file) { 43 var user_upload_complete_handler = this.getSetting("user_upload_complete_handler"); 44 var continue_upload = true; 50 SWFUpload.queue.uploadCompleteHandler = function (file) { 51 var user_upload_complete_handler = this.settings.user_upload_complete_handler; 52 var continueUpload; 53 54 if (file.filestatus === SWFUpload.FILE_STATUS.COMPLETE) { 55 this.customSettings.queue_upload_count++; 56 } 57 45 58 if (typeof(user_upload_complete_handler) === "function") { 46 continue_upload = (user_upload_complete_handler.call(this, file) === false) ? false : true; 59 continueUpload = (user_upload_complete_handler.call(this, file) === false) ? false : true; 60 } else { 61 continueUpload = true; 47 62 } 48 63 49 if (continue _upload) {64 if (continueUpload) { 50 65 var stats = this.getStats(); 51 66 if (stats.files_queued > 0 && this.customSettings.queue_cancelled_flag === false) { 52 67 this.startUpload(); 68 } else if (this.customSettings.queue_cancelled_flag === false) { 69 this.queueEvent("queue_complete_handler", [this.customSettings.queue_upload_count]); 70 this.customSettings.queue_upload_count = 0; 53 71 } else { 54 72 this.customSettings.queue_cancelled_flag = false; 73 this.customSettings.queue_upload_count = 0; 55 74 } 56 75 } 57 76 };