|
1 | 1 | /* |
2 | | - * jQuery File Upload Plugin 5.28 |
| 2 | + * jQuery File Upload Plugin 5.28.1 |
3 | 3 | * https://github.com/blueimp/jQuery-File-Upload |
4 | 4 | * |
5 | 5 | * Copyright 2010, Sebastian Tschan |
|
262 | 262 | }, |
263 | 263 |
|
264 | 264 | _initProgressObject: function (obj) { |
265 | | - obj._progress = { |
| 265 | + var progress = { |
266 | 266 | loaded: 0, |
267 | 267 | total: 0, |
268 | 268 | bitrate: 0 |
269 | 269 | }; |
| 270 | + if (obj._progress) { |
| 271 | + $.extend(obj._progress, progress); |
| 272 | + } else { |
| 273 | + obj._progress = progress; |
| 274 | + } |
| 275 | + }, |
| 276 | + |
| 277 | + _initResponseObject: function (obj) { |
| 278 | + var prop; |
| 279 | + if (obj._response) { |
| 280 | + for (prop in obj._response) { |
| 281 | + if (obj._response.hasOwnProperty(prop)) { |
| 282 | + delete obj._response[prop]; |
| 283 | + } |
| 284 | + } |
| 285 | + } else { |
| 286 | + obj._response = {}; |
| 287 | + } |
270 | 288 | }, |
271 | 289 |
|
272 | 290 | _onProgress: function (e, data) { |
|
683 | 701 | this._progress.bitrate = 0; |
684 | 702 | } |
685 | 703 | // Make sure the container objects for the .response() and |
686 | | - // .progress() methods on the data object are available. |
687 | | - // They are set in the add callback, but files might have |
688 | | - // been sent via send API call: |
689 | | - if (!data._response) { |
690 | | - data._response = {}; |
691 | | - } |
692 | | - if (!data._progress) { |
693 | | - data._progress = {}; |
694 | | - } |
| 704 | + // .progress() methods on the data object are available |
| 705 | + // and reset to their initial state: |
| 706 | + this._initResponseObject(data); |
| 707 | + this._initProgressObject(data); |
695 | 708 | data._progress.loaded = data.loaded = data.uploadedBytes || 0; |
696 | 709 | data._progress.total = data.total = this._getTotal(data.files) || 1; |
697 | 710 | data._progress.bitrate = data.bitrate = 0; |
|
853 | 866 | var newData = $.extend({}, data); |
854 | 867 | newData.files = fileSet ? element : [element]; |
855 | 868 | newData.paramName = paramNameSet[index]; |
856 | | - newData._response = {}; |
| 869 | + that._initResponseObject(newData); |
857 | 870 | that._initProgressObject(newData); |
858 | 871 | that._addConvenienceMethods(e, newData); |
859 | 872 | result = that._trigger('add', e, newData); |
|
0 commit comments