]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-includes/js/swfupload/plugins/swfupload.queue.js
Wordpress 2.5.1
[autoinstalls/wordpress.git] / wp-includes / js / swfupload / plugins / swfupload.queue.js
1 /*
2         Queue Plug-in
3         
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.
8                 
9         */
10
11 var SWFUpload;
12 if (typeof(SWFUpload) === "function") {
13         SWFUpload.queue = {};
14         
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);
19                         }
20                         
21                         this.customSettings.queue_cancelled_flag = false;
22                         
23                         this.addSetting("user_upload_complete_handler", init_settings.upload_complete_handler, SWFUpload.uploadComplete);
24                         this.uploadComplete_handler = SWFUpload.queue.uploadComplete;
25                 };
26         }(SWFUpload.prototype.initSettings);
27
28         SWFUpload.prototype.cancelQueue = function () {
29                 var stats = this.getStats();
30                 this.customSettings.queue_cancelled_flag = false;
31
32                 if (stats.in_progress > 0) {
33                         this.customSettings.queue_cancelled_flag = true;
34                 }
35                 
36                 while(stats.files_queued > 0) {
37                         this.cancelUpload();
38                         stats = this.getStats();
39                 }
40         };
41         
42         SWFUpload.queue.uploadComplete = function (file) {
43                 var user_upload_complete_handler = this.getSetting("user_upload_complete_handler");
44                 var continue_upload = true;
45                 if (typeof(user_upload_complete_handler) === "function") {
46                         continue_upload = (user_upload_complete_handler.call(this, file) === false) ? false : true;
47                 }
48                 
49                 if (continue_upload) {
50                         var stats = this.getStats();
51                         if (stats.files_queued > 0 && this.customSettings.queue_cancelled_flag === false) {
52                                 this.startUpload();
53                         } else {
54                                 this.customSettings.queue_cancelled_flag = false;
55                         }
56                 }
57         };
58 }