@@ -12,180 +12,181 @@ The FileProgress class is not part of SWFUpload.
12
12
of the actions SWFUpload makes will show up in my application.
13
13
********************** */
14
14
function preLoad ( ) {
15
- if ( ! this . support . loading ) {
15
+ if ( ! this . support . loading ) {
16
16
$ ( '#swfuploadContent' ) . hide ( ) ;
17
17
$ ( '#jqueryFileUploadContent' ) . show ( ) ;
18
- initJqueryFileupload ( ) ;
19
- return false ;
20
- }
18
+ this . customSettings . pageObj . initJqueryFileupload ( ) ;
19
+ return false ;
20
+ }
21
21
}
22
+
22
23
function loadFailed ( ) {
23
- $ ( '#swfuploadContent' ) . hide ( ) ;
24
+ $ ( '#swfuploadContent' ) . hide ( ) ;
24
25
$ ( '#jqueryFileUploadContent' ) . show ( ) ;
25
- initJqueryFileupload ( ) ;
26
+ this . customSettings . pageObj . initJqueryFileupload ( ) ;
26
27
}
27
28
28
29
function fileQueued ( file ) {
29
- try {
30
- var progress = new FileProgress ( file , this . customSettings . progressTarget ) ;
31
- progress . setStatus ( "Pending..." ) ;
32
- progress . toggleCancel ( true , this ) ;
30
+ try {
31
+ var progress = new FileProgress ( file , this . customSettings . progressTarget ) ;
32
+ progress . setStatus ( "Pending..." ) ;
33
+ progress . toggleCancel ( true , this ) ;
33
34
34
- } catch ( ex ) {
35
- this . debug ( ex ) ;
36
- }
35
+ } catch ( ex ) {
36
+ this . debug ( ex ) ;
37
+ }
37
38
38
39
}
39
40
40
41
function fileQueueError ( file , errorCode , message ) {
41
- try {
42
- if ( errorCode === SWFUpload . QUEUE_ERROR . QUEUE_LIMIT_EXCEEDED ) {
43
- alert ( "You have attempted to queue too many files.\n" + ( message === 0 ? "You have reached the upload limit." : "You may select " + ( message > 1 ? "up to " + message + " files." : "one file." ) ) ) ;
44
- return ;
45
- }
46
-
47
- var progress = new FileProgress ( file , this . customSettings . progressTarget ) ;
48
- progress . setError ( ) ;
49
- progress . toggleCancel ( false ) ;
50
-
51
- switch ( errorCode ) {
52
- case SWFUpload . QUEUE_ERROR . FILE_EXCEEDS_SIZE_LIMIT :
53
- progress . setStatus ( "File is too big." ) ;
54
- this . debug ( "Error Code: File too big, File name: " + file . name + ", File size: " + file . size + ", Message: " + message ) ;
55
- break ;
56
- case SWFUpload . QUEUE_ERROR . ZERO_BYTE_FILE :
57
- progress . setStatus ( "Cannot upload Zero Byte files." ) ;
58
- this . debug ( "Error Code: Zero byte file, File name: " + file . name + ", File size: " + file . size + ", Message: " + message ) ;
59
- break ;
60
- case SWFUpload . QUEUE_ERROR . INVALID_FILETYPE :
61
- progress . setStatus ( "Invalid File Type." ) ;
62
- this . debug ( "Error Code: Invalid File Type, File name: " + file . name + ", File size: " + file . size + ", Message: " + message ) ;
63
- break ;
64
- default :
65
- if ( file !== null ) {
66
- progress . setStatus ( "Unhandled Error" ) ;
67
- }
68
- this . debug ( "Error Code: " + errorCode + ", File name: " + file . name + ", File size: " + file . size + ", Message: " + message ) ;
69
- break ;
70
- }
71
- } catch ( ex ) {
42
+ try {
43
+ if ( errorCode === SWFUpload . QUEUE_ERROR . QUEUE_LIMIT_EXCEEDED ) {
44
+ alert ( "You have attempted to queue too many files.\n" + ( message === 0 ? "You have reached the upload limit." : "You may select " + ( message > 1 ? "up to " + message + " files." : "one file." ) ) ) ;
45
+ return ;
46
+ }
47
+
48
+ var progress = new FileProgress ( file , this . customSettings . progressTarget ) ;
49
+ progress . setError ( ) ;
50
+ progress . toggleCancel ( false ) ;
51
+
52
+ switch ( errorCode ) {
53
+ case SWFUpload . QUEUE_ERROR . FILE_EXCEEDS_SIZE_LIMIT :
54
+ progress . setStatus ( "File is too big." ) ;
55
+ this . debug ( "Error Code: File too big, File name: " + file . name + ", File size: " + file . size + ", Message: " + message ) ;
56
+ break ;
57
+ case SWFUpload . QUEUE_ERROR . ZERO_BYTE_FILE :
58
+ progress . setStatus ( "Cannot upload Zero Byte files." ) ;
59
+ this . debug ( "Error Code: Zero byte file, File name: " + file . name + ", File size: " + file . size + ", Message: " + message ) ;
60
+ break ;
61
+ case SWFUpload . QUEUE_ERROR . INVALID_FILETYPE :
62
+ progress . setStatus ( "Invalid File Type." ) ;
63
+ this . debug ( "Error Code: Invalid File Type, File name: " + file . name + ", File size: " + file . size + ", Message: " + message ) ;
64
+ break ;
65
+ default :
66
+ if ( file !== null ) {
67
+ progress . setStatus ( "Unhandled Error" ) ;
68
+ }
69
+ this . debug ( "Error Code: " + errorCode + ", File name: " + file . name + ", File size: " + file . size + ", Message: " + message ) ;
70
+ break ;
71
+ }
72
+ } catch ( ex ) {
72
73
this . debug ( ex ) ;
73
74
}
74
75
}
75
76
76
77
function fileDialogComplete ( numFilesSelected , numFilesQueued ) {
77
- try {
78
- if ( numFilesSelected > 0 ) {
79
- document . getElementById ( this . customSettings . cancelButtonId ) . disabled = false ;
80
- }
81
- $ ( '#fsUploadProgress' ) . show ( ) ;
78
+ try {
79
+ if ( numFilesSelected > 0 ) {
80
+ document . getElementById ( this . customSettings . cancelButtonId ) . disabled = false ;
81
+ }
82
+ $ ( '#fsUploadProgress' ) . show ( ) ;
82
83
$ ( '#dropFileZone' ) . hide ( ) ;
83
- /* I want auto start the upload and I can do that here */
84
- //this.startUpload();
85
- } catch ( ex ) {
84
+ /* I want auto start the upload and I can do that here */
85
+ //this.startUpload();
86
+ } catch ( ex ) {
86
87
this . debug ( ex ) ;
87
- }
88
+ }
88
89
}
89
90
90
91
function uploadStart ( file ) {
91
- try {
92
- /* I don't want to do any file validation or anything, I'll just update the UI and
93
- return true to indicate that the upload should start.
94
- It's important to update the UI here because in Linux no uploadProgress events are called. The best
95
- we can do is say we are uploading.
96
- */
97
- var progress = new FileProgress ( file , this . customSettings . progressTarget ) ;
98
- progress . setStatus ( "Uploading..." ) ;
99
- progress . toggleCancel ( true , this ) ;
100
- }
101
- catch ( ex ) { }
102
-
103
- return true ;
92
+ try {
93
+ /* I don't want to do any file validation or anything, I'll just update the UI and
94
+ return true to indicate that the upload should start.
95
+ It's important to update the UI here because in Linux no uploadProgress events are called. The best
96
+ we can do is say we are uploading.
97
+ */
98
+ var progress = new FileProgress ( file , this . customSettings . progressTarget ) ;
99
+ progress . setStatus ( "Uploading..." ) ;
100
+ progress . toggleCancel ( true , this ) ;
101
+ }
102
+ catch ( ex ) { }
103
+
104
+ return true ;
104
105
}
105
106
106
107
function uploadProgress ( file , bytesLoaded , bytesTotal ) {
107
- try {
108
- var percent = Math . ceil ( ( bytesLoaded / bytesTotal ) * 100 ) ;
109
-
110
- var progress = new FileProgress ( file , this . customSettings . progressTarget ) ;
111
- progress . setProgress ( percent ) ;
112
- progress . setStatus ( "Uploading..." ) ;
113
- } catch ( ex ) {
114
- this . debug ( ex ) ;
115
- }
108
+ try {
109
+ var percent = Math . ceil ( ( bytesLoaded / bytesTotal ) * 100 ) ;
110
+
111
+ var progress = new FileProgress ( file , this . customSettings . progressTarget ) ;
112
+ progress . setProgress ( percent ) ;
113
+ progress . setStatus ( "Uploading..." ) ;
114
+ } catch ( ex ) {
115
+ this . debug ( ex ) ;
116
+ }
116
117
}
117
118
118
119
function uploadSuccess ( file , serverData ) {
119
- try {
120
- var progress = new FileProgress ( file , this . customSettings . progressTarget ) ;
121
- progress . setComplete ( ) ;
122
- progress . setStatus ( "Complete." ) ;
123
- progress . toggleCancel ( false ) ;
124
-
125
- } catch ( ex ) {
126
- this . debug ( ex ) ;
127
- }
120
+ try {
121
+ var progress = new FileProgress ( file , this . customSettings . progressTarget ) ;
122
+ progress . setComplete ( ) ;
123
+ progress . setStatus ( "Complete." ) ;
124
+ progress . toggleCancel ( false ) ;
125
+
126
+ } catch ( ex ) {
127
+ this . debug ( ex ) ;
128
+ }
128
129
}
129
130
130
131
function uploadError ( file , errorCode , message ) {
131
- try {
132
- var progress = new FileProgress ( file , this . customSettings . progressTarget ) ;
133
- progress . setError ( ) ;
134
- progress . toggleCancel ( false ) ;
135
-
136
- switch ( errorCode ) {
137
- case SWFUpload . UPLOAD_ERROR . HTTP_ERROR :
138
- progress . setStatus ( "Upload Error: " + message ) ;
139
- this . debug ( "Error Code: HTTP Error, File name: " + file . name + ", Message: " + message ) ;
140
- break ;
141
- case SWFUpload . UPLOAD_ERROR . UPLOAD_FAILED :
142
- progress . setStatus ( "Upload Failed." ) ;
143
- this . debug ( "Error Code: Upload Failed, File name: " + file . name + ", File size: " + file . size + ", Message: " + message ) ;
144
- break ;
145
- case SWFUpload . UPLOAD_ERROR . IO_ERROR :
146
- progress . setStatus ( "Server (IO) Error" ) ;
147
- this . debug ( "Error Code: IO Error, File name: " + file . name + ", Message: " + message ) ;
148
- break ;
149
- case SWFUpload . UPLOAD_ERROR . SECURITY_ERROR :
150
- progress . setStatus ( "Security Error" ) ;
151
- this . debug ( "Error Code: Security Error, File name: " + file . name + ", Message: " + message ) ;
152
- break ;
153
- case SWFUpload . UPLOAD_ERROR . UPLOAD_LIMIT_EXCEEDED :
154
- progress . setStatus ( "Upload limit exceeded." ) ;
155
- this . debug ( "Error Code: Upload Limit Exceeded, File name: " + file . name + ", File size: " + file . size + ", Message: " + message ) ;
156
- break ;
157
- case SWFUpload . UPLOAD_ERROR . FILE_VALIDATION_FAILED :
158
- progress . setStatus ( "Failed Validation. Upload skipped." ) ;
159
- this . debug ( "Error Code: File Validation Failed, File name: " + file . name + ", File size: " + file . size + ", Message: " + message ) ;
160
- break ;
161
- case SWFUpload . UPLOAD_ERROR . FILE_CANCELLED :
162
- // If there aren't any files left (they were all cancelled) disable the cancel button
163
- if ( this . getStats ( ) . files_queued === 0 ) {
164
- document . getElementById ( this . customSettings . cancelButtonId ) . disabled = true ;
165
- }
166
- progress . setStatus ( "Cancelled" ) ;
167
- progress . setCancelled ( ) ;
168
- break ;
169
- case SWFUpload . UPLOAD_ERROR . UPLOAD_STOPPED :
170
- progress . setStatus ( "Stopped" ) ;
171
- break ;
172
- default :
173
- progress . setStatus ( "Unhandled Error: " + errorCode ) ;
174
- this . debug ( "Error Code: " + errorCode + ", File name: " + file . name + ", File size: " + file . size + ", Message: " + message ) ;
175
- break ;
176
- }
177
- } catch ( ex ) {
132
+ try {
133
+ var progress = new FileProgress ( file , this . customSettings . progressTarget ) ;
134
+ progress . setError ( ) ;
135
+ progress . toggleCancel ( false ) ;
136
+
137
+ switch ( errorCode ) {
138
+ case SWFUpload . UPLOAD_ERROR . HTTP_ERROR :
139
+ progress . setStatus ( "Upload Error: " + message ) ;
140
+ this . debug ( "Error Code: HTTP Error, File name: " + file . name + ", Message: " + message ) ;
141
+ break ;
142
+ case SWFUpload . UPLOAD_ERROR . UPLOAD_FAILED :
143
+ progress . setStatus ( "Upload Failed." ) ;
144
+ this . debug ( "Error Code: Upload Failed, File name: " + file . name + ", File size: " + file . size + ", Message: " + message ) ;
145
+ break ;
146
+ case SWFUpload . UPLOAD_ERROR . IO_ERROR :
147
+ progress . setStatus ( "Server (IO) Error" ) ;
148
+ this . debug ( "Error Code: IO Error, File name: " + file . name + ", Message: " + message ) ;
149
+ break ;
150
+ case SWFUpload . UPLOAD_ERROR . SECURITY_ERROR :
151
+ progress . setStatus ( "Security Error" ) ;
152
+ this . debug ( "Error Code: Security Error, File name: " + file . name + ", Message: " + message ) ;
153
+ break ;
154
+ case SWFUpload . UPLOAD_ERROR . UPLOAD_LIMIT_EXCEEDED :
155
+ progress . setStatus ( "Upload limit exceeded." ) ;
156
+ this . debug ( "Error Code: Upload Limit Exceeded, File name: " + file . name + ", File size: " + file . size + ", Message: " + message ) ;
157
+ break ;
158
+ case SWFUpload . UPLOAD_ERROR . FILE_VALIDATION_FAILED :
159
+ progress . setStatus ( "Failed Validation. Upload skipped." ) ;
160
+ this . debug ( "Error Code: File Validation Failed, File name: " + file . name + ", File size: " + file . size + ", Message: " + message ) ;
161
+ break ;
162
+ case SWFUpload . UPLOAD_ERROR . FILE_CANCELLED :
163
+ // If there aren't any files left (they were all cancelled) disable the cancel button
164
+ if ( this . getStats ( ) . files_queued === 0 ) {
165
+ document . getElementById ( this . customSettings . cancelButtonId ) . disabled = true ;
166
+ }
167
+ progress . setStatus ( "Cancelled" ) ;
168
+ progress . setCancelled ( ) ;
169
+ break ;
170
+ case SWFUpload . UPLOAD_ERROR . UPLOAD_STOPPED :
171
+ progress . setStatus ( "Stopped" ) ;
172
+ break ;
173
+ default :
174
+ progress . setStatus ( "Unhandled Error: " + errorCode ) ;
175
+ this . debug ( "Error Code: " + errorCode + ", File name: " + file . name + ", File size: " + file . size + ", Message: " + message ) ;
176
+ break ;
177
+ }
178
+ } catch ( ex ) {
178
179
this . debug ( ex ) ;
179
180
}
180
181
}
181
182
182
183
function uploadComplete ( file ) {
183
- if ( this . getStats ( ) . files_queued === 0 ) {
184
- document . getElementById ( this . customSettings . cancelButtonId ) . disabled = true ;
184
+ if ( this . getStats ( ) . files_queued === 0 ) {
185
+ document . getElementById ( this . customSettings . cancelButtonId ) . disabled = true ;
185
186
186
- }
187
+ }
187
188
$ ( '.uploadedSimple' ) . val ( parseInt ( $ ( '.uploadedSimple' ) . val ( ) ) + 1 ) ;
188
- updateUploadedCount ( ) ;
189
+ this . customSettings . pageObj . updateUploadedCount ( ) ;
189
190
}
190
191
191
192
// This event comes from the Queue Plugin
0 commit comments