2008-01-25 14:21:11 -05:00
|
|
|
/*
|
|
|
|
Queue Plug-in
|
|
|
|
|
|
|
|
Features:
|
2008-06-06 03:34:30 -04:00
|
|
|
cancelQueue method for cancelling the entire queue.
|
|
|
|
All queued files are uploaded when startUpload() is called.
|
|
|
|
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.
|
2008-01-25 14:21:11 -05:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
var SWFUpload;
|
|
|
|
if (typeof(SWFUpload) === "function") {
|
|
|
|
SWFUpload.queue = {};
|
|
|
|
|
2008-06-06 03:34:30 -04:00
|
|
|
SWFUpload.prototype.initSettings = function (old_initSettings) {
|
|
|
|
return function (init_settings) {
|
|
|
|
if (typeof(old_initSettings) === "function") {
|
|
|
|
old_initSettings.call(this, init_settings);
|
2008-01-25 14:21:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
this.customSettings.queue_cancelled_flag = false;
|
|
|
|
|
2008-06-06 03:34:30 -04:00
|
|
|
this.addSetting("user_upload_complete_handler", init_settings.upload_complete_handler, SWFUpload.uploadComplete);
|
|
|
|
this.uploadComplete_handler = SWFUpload.queue.uploadComplete;
|
2008-01-25 14:21:11 -05:00
|
|
|
};
|
2008-06-06 03:34:30 -04:00
|
|
|
}(SWFUpload.prototype.initSettings);
|
2008-01-25 14:21:11 -05:00
|
|
|
|
2008-06-06 03:34:30 -04:00
|
|
|
SWFUpload.prototype.cancelQueue = function () {
|
|
|
|
var stats = this.getStats();
|
2008-01-25 14:21:11 -05:00
|
|
|
this.customSettings.queue_cancelled_flag = false;
|
|
|
|
|
2008-06-06 03:34:30 -04:00
|
|
|
if (stats.in_progress > 0) {
|
|
|
|
this.customSettings.queue_cancelled_flag = true;
|
|
|
|
}
|
2008-01-25 14:21:11 -05:00
|
|
|
|
2008-06-06 03:34:30 -04:00
|
|
|
while(stats.files_queued > 0) {
|
2008-01-25 14:21:11 -05:00
|
|
|
this.cancelUpload();
|
|
|
|
stats = this.getStats();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2008-06-06 03:34:30 -04:00
|
|
|
SWFUpload.queue.uploadComplete = function (file) {
|
|
|
|
var user_upload_complete_handler = this.getSetting("user_upload_complete_handler");
|
|
|
|
var continue_upload = true;
|
2008-01-25 14:21:11 -05:00
|
|
|
if (typeof(user_upload_complete_handler) === "function") {
|
2008-06-06 03:34:30 -04:00
|
|
|
continue_upload = (user_upload_complete_handler.call(this, file) === false) ? false : true;
|
2008-01-25 14:21:11 -05:00
|
|
|
}
|
|
|
|
|
2008-06-06 03:34:30 -04:00
|
|
|
if (continue_upload) {
|
2008-01-25 14:21:11 -05:00
|
|
|
var stats = this.getStats();
|
|
|
|
if (stats.files_queued > 0 && this.customSettings.queue_cancelled_flag === false) {
|
|
|
|
this.startUpload();
|
|
|
|
} else {
|
|
|
|
this.customSettings.queue_cancelled_flag = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2008-06-06 03:34:30 -04:00
|
|
|
}
|