diff options
author | Mario Vavti <mario@mariovavti.com> | 2018-10-22 09:45:20 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2018-10-22 09:45:20 +0200 |
commit | 71195895ba98f2af86b3739f2992473a587aa099 (patch) | |
tree | eedacaac419bef8dc66fed887d6639a04bad044f /library/blueimp_upload/js/jquery.fileupload.js | |
parent | ea850e58d219a756189532bbb3e9ec8d85e9ba6a (diff) | |
download | volse-hubzilla-71195895ba98f2af86b3739f2992473a587aa099.tar.gz volse-hubzilla-71195895ba98f2af86b3739f2992473a587aa099.tar.bz2 volse-hubzilla-71195895ba98f2af86b3739f2992473a587aa099.zip |
update blueimp_upload to version 9.23
Diffstat (limited to 'library/blueimp_upload/js/jquery.fileupload.js')
-rw-r--r-- | library/blueimp_upload/js/jquery.fileupload.js | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/library/blueimp_upload/js/jquery.fileupload.js b/library/blueimp_upload/js/jquery.fileupload.js index 5ff151b53..700f9013c 100644 --- a/library/blueimp_upload/js/jquery.fileupload.js +++ b/library/blueimp_upload/js/jquery.fileupload.js @@ -43,7 +43,7 @@ '|(Kindle/(1\\.0|2\\.[05]|3\\.0))' ).test(window.navigator.userAgent) || // Feature detection for all other devices: - $('<input type="file">').prop('disabled')); + $('<input type="file"/>').prop('disabled')); // The FileReader API is not actually used, but works as feature detection, // as some Safari versions (5?) support XHR file uploads via the FormData API, @@ -261,6 +261,9 @@ // Callback for dragover events of the dropZone(s): // dragover: function (e) {}, // .bind('fileuploaddragover', func); + // Callback before the start of each chunk upload request (before form data initialization): + // chunkbeforesend: function (e, data) {}, // .bind('fileuploadchunkbeforesend', func); + // Callback for the start of each chunk upload request: // chunksend: function (e, data) {}, // .bind('fileuploadchunksend', func); @@ -434,6 +437,13 @@ } }, + _deinitProgressListener: function (options) { + var xhr = options.xhr ? options.xhr() : $.ajaxSettings.xhr(); + if (xhr.upload) { + $(xhr.upload).unbind('progress'); + } + }, + _isInstanceOf: function (type, obj) { // Cross-frame instanceof check return Object.prototype.toString.call(obj) === '[object ' + type + ']'; @@ -453,7 +463,7 @@ } if (!multipart || options.blob || !this._isInstanceOf('File', file)) { options.headers['Content-Disposition'] = 'attachment; filename="' + - encodeURI(file.name) + '"'; + encodeURI(file.uploadName || file.name) + '"'; } if (!multipart) { options.contentType = file.type || 'application/octet-stream'; @@ -489,7 +499,11 @@ }); } if (options.blob) { - formData.append(paramName, options.blob, file.name); + formData.append( + paramName, + options.blob, + file.uploadName || file.name + ); } else { $.each(options.files, function (index, file) { // This check allows the tests to run with @@ -730,7 +744,7 @@ promise = dfd.promise(), jqXHR, upload; - if (!(this._isXHRUpload(options) && slice && (ub || mcs < fs)) || + if (!(this._isXHRUpload(options) && slice && (ub || ($.type(mcs) === 'function' ? mcs(options) : mcs) < fs)) || options.data) { return false; } @@ -753,7 +767,7 @@ o.blob = slice.call( file, ub, - ub + mcs, + ub + ($.type(mcs) === 'function' ? mcs(o) : mcs), file.type ); // Store the current chunk size, as the blob itself @@ -762,6 +776,8 @@ // Expose the chunk bytes position range: o.contentRange = 'bytes ' + ub + '-' + (ub + o.chunkSize - 1) + '/' + fs; + // Trigger chunkbeforesend to allow form data to be updated for this chunk + that._trigger('chunkbeforesend', null, o); // Process the upload data (the blob and potential form data): that._initXHRData(o); // Add progress listeners for this chunk upload: @@ -808,6 +824,9 @@ o.context, [jqXHR, textStatus, errorThrown] ); + }) + .always(function () { + that._deinitProgressListener(o); }); }; this._enhancePromise(promise); @@ -909,6 +928,7 @@ }).fail(function (jqXHR, textStatus, errorThrown) { that._onFail(jqXHR, textStatus, errorThrown, options); }).always(function (jqXHRorResult, textStatus, jqXHRorError) { + that._deinitProgressListener(options); that._onAlways( jqXHRorResult, textStatus, @@ -1126,7 +1146,7 @@ dirReader = entry.createReader(); readEntries(); } else { - // Return an empy list for file system items + // Return an empty list for file system items // other than files or directories: dfd.resolve([]); } |