|
1 | 1 | /* |
2 | | - * jQuery File Upload Plugin 5.23 |
| 2 | + * jQuery File Upload Plugin 5.24 |
3 | 3 | * https://github.com/blueimp/jQuery-File-Upload |
4 | 4 | * |
5 | 5 | * Copyright 2010, Sebastian Tschan |
|
485 | 485 | return options; |
486 | 486 | }, |
487 | 487 |
|
| 488 | + // jQuery 1.6 doesn't provide .state(), |
| 489 | + // while jQuery 1.8+ removed .isRejected() and .isResolved(): |
| 490 | + _getDeferredState: function (deferred) { |
| 491 | + if (deferred.state) { |
| 492 | + return deferred.state(); |
| 493 | + } |
| 494 | + if (deferred.isResolved()) { |
| 495 | + return 'resolved'; |
| 496 | + } |
| 497 | + if (deferred.isRejected()) { |
| 498 | + return 'rejected'; |
| 499 | + } |
| 500 | + return 'pending'; |
| 501 | + }, |
| 502 | + |
488 | 503 | // Maps jqXHR callbacks to the equivalent |
489 | 504 | // methods of the given Promise object: |
490 | 505 | _enhancePromise: function (promise) { |
|
715 | 730 | options.limitConcurrentUploads > that._sending) { |
716 | 731 | // Start the next queued upload, |
717 | 732 | // that has not been aborted: |
718 | | - var nextSlot = that._slots.shift(), |
719 | | - isPending; |
| 733 | + var nextSlot = that._slots.shift(); |
720 | 734 | while (nextSlot) { |
721 | | - // jQuery 1.6 doesn't provide .state(), |
722 | | - // while jQuery 1.8+ removed .isRejected(): |
723 | | - isPending = nextSlot.state ? |
724 | | - nextSlot.state() === 'pending' : |
725 | | - !nextSlot.isRejected(); |
726 | | - if (isPending) { |
| 735 | + if (that._getDeferredState(nextSlot) === 'pending') { |
727 | 736 | nextSlot.resolve(); |
728 | 737 | break; |
729 | 738 | } |
|
806 | 815 | return this.jqXHR.abort(); |
807 | 816 | } |
808 | 817 | }; |
| 818 | + newData.state = function () { |
| 819 | + if (this.jqXHR) { |
| 820 | + return that._getDeferredState(this.jqXHR); |
| 821 | + } |
| 822 | + }; |
809 | 823 | result = that._trigger('add', e, newData); |
810 | 824 | return result; |
811 | 825 | }); |
|
0 commit comments