|
84 | 84 | this.id = Math.random().toString(36).substr(2); |
85 | 85 | }; |
86 | 86 |
|
87 | | - DmUploaderFile.prototype.upload = function () { |
| 87 | + DmUploaderFile.prototype.upload = function () |
| 88 | + { |
88 | 89 | var file = this; |
89 | 90 |
|
90 | 91 | if (!file.canUpload()) { |
|
135 | 136 | return true; |
136 | 137 | }; |
137 | 138 |
|
138 | | - DmUploaderFile.prototype.onSuccess = function (data) { |
| 139 | + DmUploaderFile.prototype.onSuccess = function (data) |
| 140 | + { |
139 | 141 | this.status = FileStatus.COMPLETED; |
140 | 142 | this.widget.settings.onUploadSuccess.call(this.widget.element, this.id, data); |
141 | 143 | }; |
142 | 144 |
|
143 | | - DmUploaderFile.prototype.onError = function (xhr, status, errMsg) { |
| 145 | + DmUploaderFile.prototype.onError = function (xhr, status, errMsg) |
| 146 | + { |
144 | 147 | // If the status is: cancelled (by the user) don't invoke the error callback |
145 | 148 | if (this.status !== FileStatus.CANCELLED) { |
146 | 149 | this.status = FileStatus.FAILED; |
147 | 150 | this.widget.settings.onUploadError.call(this.widget.element, this.id, xhr, status, errMsg); |
148 | 151 | } |
149 | 152 | }; |
150 | 153 |
|
151 | | - DmUploaderFile.prototype.onComplete = function () { |
| 154 | + DmUploaderFile.prototype.onComplete = function () |
| 155 | + { |
152 | 156 | this.widget.activeFiles--; |
153 | 157 |
|
154 | 158 | if (this.status !== FileStatus.CANCELLED) { |
|
162 | 166 | } |
163 | 167 | }; |
164 | 168 |
|
165 | | - DmUploaderFile.prototype.getXhr = function () { |
| 169 | + DmUploaderFile.prototype.getXhr = function () |
| 170 | + { |
166 | 171 | var file = this; |
167 | 172 | var xhrobj = $.ajaxSettings.xhr(); |
168 | 173 |
|
|
182 | 187 | return xhrobj; |
183 | 188 | }; |
184 | 189 |
|
185 | | - DmUploaderFile.prototype.cancel = function (abort) { |
| 190 | + DmUploaderFile.prototype.cancel = function (abort) |
| 191 | + { |
186 | 192 | // The abort flag is to track if we are calling this function directly (using the cancel Method, by id) |
187 | 193 | // or the call comes from the 'gobal' method aka cancelAll. |
188 | 194 | // THis mean that we don't want to trigger the cancel event on file that isn't uploading, UNLESS directly doing it |
|
206 | 212 | return true; |
207 | 213 | }; |
208 | 214 |
|
209 | | - DmUploaderFile.prototype.canUpload = function () { |
| 215 | + DmUploaderFile.prototype.canUpload = function () |
| 216 | + { |
210 | 217 | return ( |
211 | 218 | this.status === FileStatus.PENDING || |
212 | 219 | this.status === FileStatus.FAILED |
|
230 | 237 | return this; |
231 | 238 | }; |
232 | 239 |
|
233 | | - DmUploader.prototype.checkSupport = function () { |
| 240 | + DmUploader.prototype.checkSupport = function () |
| 241 | + { |
234 | 242 | // This one is mandatory for all modes |
235 | 243 | if (typeof window.FormData === "undefined") { |
236 | 244 | return false; |
|
250 | 258 | return !$("<input type=\"file\" />").prop("disabled"); |
251 | 259 | }; |
252 | 260 |
|
253 | | - DmUploader.prototype.init = function () { |
| 261 | + DmUploader.prototype.init = function () |
| 262 | + { |
254 | 263 | var widget = this; |
255 | 264 |
|
256 | 265 | // Queue vars |
|
303 | 312 | return this; |
304 | 313 | }; |
305 | 314 |
|
306 | | - DmUploader.prototype.initDnD = function () { |
| 315 | + DmUploader.prototype.initDnD = function () |
| 316 | + { |
307 | 317 | var widget = this; |
308 | 318 |
|
309 | 319 | // -- Now our own Drop |
|
392 | 402 | }); |
393 | 403 | }; |
394 | 404 |
|
395 | | - DmUploader.prototype.initPaste = function () { |
| 405 | + DmUploader.prototype.initPaste = function () |
| 406 | + { |
396 | 407 | var widget = this; |
397 | 408 | $(document).on("paste." + pluginName, function (evt) { |
398 | 409 | evt.preventDefault(); |
|
413 | 424 |
|
414 | 425 | }; |
415 | 426 |
|
416 | | - DmUploader.prototype.releaseEvents = function () { |
| 427 | + DmUploader.prototype.releaseEvents = function () |
| 428 | + { |
417 | 429 | // Leave everyone ALONE ;_; |
418 | 430 |
|
419 | 431 | this.element.off("." + pluginName); |
|
424 | 436 | } |
425 | 437 | }; |
426 | 438 |
|
427 | | - DmUploader.prototype.validateFile = function (file) { |
| 439 | + DmUploader.prototype.validateFile = function (file) |
| 440 | + { |
428 | 441 | // Check file size |
429 | 442 | if ((this.settings.maxFileSize > 0) && |
430 | 443 | (file.size > this.settings.maxFileSize)) { |
|
457 | 470 | return new DmUploaderFile(file, this); |
458 | 471 | }; |
459 | 472 |
|
460 | | - DmUploader.prototype.addFiles = function (files) { |
| 473 | + DmUploader.prototype.addFiles = function (files) |
| 474 | + { |
461 | 475 | var nFiles = 0; |
462 | 476 |
|
463 | 477 | for (var i = 0; i < files.length; i++) { |
|
496 | 510 | return this; |
497 | 511 | }; |
498 | 512 |
|
499 | | - DmUploader.prototype.processQueue = function () { |
| 513 | + DmUploader.prototype.processQueue = function () |
| 514 | + { |
500 | 515 | this.queuePos++; |
501 | 516 |
|
502 | 517 | if (this.queuePos >= this.queue.length) { |
|
518 | 533 | return this.queue[this.queuePos].upload(); |
519 | 534 | }; |
520 | 535 |
|
521 | | - DmUploader.prototype.restartQueue = function () { |
| 536 | + DmUploader.prototype.restartQueue = function () |
| 537 | + { |
522 | 538 | this.queuePos = -1; |
523 | 539 | this.queueRunning = false; |
524 | 540 |
|
525 | 541 | this.processQueue(); |
526 | 542 | }; |
527 | 543 |
|
528 | | - DmUploader.prototype.findById = function (id) { |
| 544 | + DmUploader.prototype.findById = function (id) |
| 545 | + { |
529 | 546 | var r = false; |
530 | 547 |
|
531 | 548 | for (var i = 0; i < this.queue.length; i++) { |
|
538 | 555 | return r; |
539 | 556 | }; |
540 | 557 |
|
541 | | - DmUploader.prototype.cancelAll = function () { |
| 558 | + DmUploader.prototype.cancelAll = function () |
| 559 | + { |
542 | 560 | var queueWasRunning = this.queueRunning; |
543 | 561 | this.queueRunning = false; |
544 | 562 |
|
|
552 | 570 | } |
553 | 571 | }; |
554 | 572 |
|
555 | | - DmUploader.prototype.startAll = function () { |
| 573 | + DmUploader.prototype.startAll = function () |
| 574 | + { |
556 | 575 | if (this.settings.queue) { |
557 | 576 | // Resume queue |
558 | 577 | this.restartQueue(); |
|
0 commit comments