aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/blueimp/jquery-file-upload/js/jquery.fileupload.js
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2020-05-07 15:22:25 +0000
committerMario <mario@mariovavti.com>2020-05-07 15:22:25 +0000
commitdbfe748d274f6843fc91a3071df7be45c4ab5b00 (patch)
tree3b59194620f319b16a88dcc2aa5bacbea1c3d188 /vendor/blueimp/jquery-file-upload/js/jquery.fileupload.js
parent4ee809bed6ea023ad9e2888eedd65e083d4c1e3e (diff)
downloadvolse-hubzilla-dbfe748d274f6843fc91a3071df7be45c4ab5b00.tar.gz
volse-hubzilla-dbfe748d274f6843fc91a3071df7be45c4ab5b00.tar.bz2
volse-hubzilla-dbfe748d274f6843fc91a3071df7be45c4ab5b00.zip
composer updates
Diffstat (limited to 'vendor/blueimp/jquery-file-upload/js/jquery.fileupload.js')
-rw-r--r--vendor/blueimp/jquery-file-upload/js/jquery.fileupload.js294
1 files changed, 140 insertions, 154 deletions
diff --git a/vendor/blueimp/jquery-file-upload/js/jquery.fileupload.js b/vendor/blueimp/jquery-file-upload/js/jquery.fileupload.js
index d4d32570c..f75cf2b10 100644
--- a/vendor/blueimp/jquery-file-upload/js/jquery.fileupload.js
+++ b/vendor/blueimp/jquery-file-upload/js/jquery.fileupload.js
@@ -12,7 +12,7 @@
/* global define, require */
/* eslint-disable new-cap */
-(function(factory) {
+(function (factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module:
@@ -24,7 +24,7 @@
// Browser globals:
factory(window.jQuery);
}
-})(function($) {
+})(function ($) {
'use strict';
// Detect file input support, based on
@@ -64,7 +64,7 @@
*/
function getDragHandler(type) {
var isDragOver = type === 'dragover';
- return function(e) {
+ return function (e) {
e.dataTransfer = e.originalEvent && e.originalEvent.dataTransfer;
var dataTransfer = e.dataTransfer;
if (
@@ -185,11 +185,11 @@
// Translation function, gets the message key to be translated
// and an object with context specific data as arguments:
- i18n: function(message, context) {
+ i18n: function (message, context) {
// eslint-disable-next-line no-param-reassign
message = this.messages[message] || message.toString();
if (context) {
- $.each(context, function(key, value) {
+ $.each(context, function (key, value) {
// eslint-disable-next-line no-param-reassign
message = message.replace('{' + key + '}', value);
});
@@ -202,7 +202,7 @@
// value properties, a function returning such an array, a FormData
// object (for XHR file uploads), or a simple object.
// The form of the first fileInput is given as parameter to the function:
- formData: function(form) {
+ formData: function (form) {
return form.serializeArray();
},
@@ -217,12 +217,12 @@
// and allows you to override plugin options as well as define ajax settings.
//
// Listeners for this callback can also be bound the following way:
- // .bind('fileuploadadd', func);
+ // .on('fileuploadadd', func);
//
// data.submit() returns a Promise object and allows to attach additional
// handlers using jQuery's Deferred callbacks:
// data.submit().done(func).fail(func).always(func);
- add: function(e, data) {
+ add: function (e, data) {
if (e.isDefaultPrevented()) {
return false;
}
@@ -231,7 +231,7 @@
(data.autoUpload !== false &&
$(this).fileupload('option', 'autoUpload'))
) {
- data.process().done(function() {
+ data.process().done(function () {
data.submit();
});
}
@@ -240,58 +240,58 @@
// Other callbacks:
// Callback for the submit event of each file upload:
- // submit: function (e, data) {}, // .bind('fileuploadsubmit', func);
+ // submit: function (e, data) {}, // .on('fileuploadsubmit', func);
// Callback for the start of each file upload request:
- // send: function (e, data) {}, // .bind('fileuploadsend', func);
+ // send: function (e, data) {}, // .on('fileuploadsend', func);
// Callback for successful uploads:
- // done: function (e, data) {}, // .bind('fileuploaddone', func);
+ // done: function (e, data) {}, // .on('fileuploaddone', func);
// Callback for failed (abort or error) uploads:
- // fail: function (e, data) {}, // .bind('fileuploadfail', func);
+ // fail: function (e, data) {}, // .on('fileuploadfail', func);
// Callback for completed (success, abort or error) requests:
- // always: function (e, data) {}, // .bind('fileuploadalways', func);
+ // always: function (e, data) {}, // .on('fileuploadalways', func);
// Callback for upload progress events:
- // progress: function (e, data) {}, // .bind('fileuploadprogress', func);
+ // progress: function (e, data) {}, // .on('fileuploadprogress', func);
// Callback for global upload progress events:
- // progressall: function (e, data) {}, // .bind('fileuploadprogressall', func);
+ // progressall: function (e, data) {}, // .on('fileuploadprogressall', func);
// Callback for uploads start, equivalent to the global ajaxStart event:
- // start: function (e) {}, // .bind('fileuploadstart', func);
+ // start: function (e) {}, // .on('fileuploadstart', func);
// Callback for uploads stop, equivalent to the global ajaxStop event:
- // stop: function (e) {}, // .bind('fileuploadstop', func);
+ // stop: function (e) {}, // .on('fileuploadstop', func);
// Callback for change events of the fileInput(s):
- // change: function (e, data) {}, // .bind('fileuploadchange', func);
+ // change: function (e, data) {}, // .on('fileuploadchange', func);
// Callback for paste events to the pasteZone(s):
- // paste: function (e, data) {}, // .bind('fileuploadpaste', func);
+ // paste: function (e, data) {}, // .on('fileuploadpaste', func);
// Callback for drop events of the dropZone(s):
- // drop: function (e, data) {}, // .bind('fileuploaddrop', func);
+ // drop: function (e, data) {}, // .on('fileuploaddrop', func);
// Callback for dragover events of the dropZone(s):
- // dragover: function (e) {}, // .bind('fileuploaddragover', func);
+ // dragover: function (e) {}, // .on('fileuploaddragover', func);
// Callback before the start of each chunk upload request (before form data initialization):
- // chunkbeforesend: function (e, data) {}, // .bind('fileuploadchunkbeforesend', func);
+ // chunkbeforesend: function (e, data) {}, // .on('fileuploadchunkbeforesend', func);
// Callback for the start of each chunk upload request:
- // chunksend: function (e, data) {}, // .bind('fileuploadchunksend', func);
+ // chunksend: function (e, data) {}, // .on('fileuploadchunksend', func);
// Callback for successful chunk uploads:
- // chunkdone: function (e, data) {}, // .bind('fileuploadchunkdone', func);
+ // chunkdone: function (e, data) {}, // .on('fileuploadchunkdone', func);
// Callback for failed (abort or error) chunk uploads:
- // chunkfail: function (e, data) {}, // .bind('fileuploadchunkfail', func);
+ // chunkfail: function (e, data) {}, // .on('fileuploadchunkfail', func);
// Callback for completed (success, abort or error) chunk upload requests:
- // chunkalways: function (e, data) {}, // .bind('fileuploadchunkalways', func);
+ // chunkalways: function (e, data) {}, // .on('fileuploadchunkalways', func);
// The plugin options are used as settings object for the ajax calls.
// The following are jQuery ajax settings required for the file uploads:
@@ -313,16 +313,16 @@
_blobSlice:
$.support.blobSlice &&
- function() {
+ function () {
var slice = this.slice || this.webkitSlice || this.mozSlice;
return slice.apply(this, arguments);
},
- _BitrateTimer: function() {
+ _BitrateTimer: function () {
this.timestamp = Date.now ? Date.now() : new Date().getTime();
this.loaded = 0;
this.bitrate = 0;
- this.getBitrate = function(now, loaded, interval) {
+ this.getBitrate = function (now, loaded, interval) {
var timeDiff = now - this.timestamp;
if (!this.bitrate || !interval || timeDiff > interval) {
this.bitrate = (loaded - this.loaded) * (1000 / timeDiff) * 8;
@@ -333,7 +333,7 @@
};
},
- _isXHRUpload: function(options) {
+ _isXHRUpload: function (options) {
return (
!options.forceIframeTransport &&
((!options.multipart && $.support.xhrFileUpload) ||
@@ -341,7 +341,7 @@
);
},
- _getFormData: function(options) {
+ _getFormData: function (options) {
var formData;
if ($.type(options.formData) === 'function') {
return options.formData(options.form);
@@ -351,7 +351,7 @@
}
if ($.type(options.formData) === 'object') {
formData = [];
- $.each(options.formData, function(name, value) {
+ $.each(options.formData, function (name, value) {
formData.push({ name: name, value: value });
});
return formData;
@@ -359,15 +359,15 @@
return [];
},
- _getTotal: function(files) {
+ _getTotal: function (files) {
var total = 0;
- $.each(files, function(index, file) {
+ $.each(files, function (index, file) {
total += file.size || 1;
});
return total;
},
- _initProgressObject: function(obj) {
+ _initProgressObject: function (obj) {
var progress = {
loaded: 0,
total: 0,
@@ -380,7 +380,7 @@
}
},
- _initResponseObject: function(obj) {
+ _initResponseObject: function (obj) {
var prop;
if (obj._response) {
for (prop in obj._response) {
@@ -393,7 +393,7 @@
}
},
- _onProgress: function(e, data) {
+ _onProgress: function (e, data) {
if (e.lengthComputable) {
var now = Date.now ? Date.now() : new Date().getTime(),
loaded;
@@ -442,13 +442,13 @@
}
},
- _initProgressListener: function(options) {
+ _initProgressListener: function (options) {
var that = this,
xhr = options.xhr ? options.xhr() : $.ajaxSettings.xhr();
// Accesss to the native XHR object is required to add event listeners
// for the upload progress event:
if (xhr.upload) {
- $(xhr.upload).bind('progress', function(e) {
+ $(xhr.upload).on('progress', function (e) {
var oe = e.originalEvent;
// Make sure the progress event properties get copied over:
e.lengthComputable = oe.lengthComputable;
@@ -456,30 +456,30 @@
e.total = oe.total;
that._onProgress(e, options);
});
- options.xhr = function() {
+ options.xhr = function () {
return xhr;
};
}
},
- _deinitProgressListener: function(options) {
+ _deinitProgressListener: function (options) {
var xhr = options.xhr ? options.xhr() : $.ajaxSettings.xhr();
if (xhr.upload) {
- $(xhr.upload).unbind('progress');
+ $(xhr.upload).off('progress');
}
},
- _isInstanceOf: function(type, obj) {
+ _isInstanceOf: function (type, obj) {
// Cross-frame instanceof check
return Object.prototype.toString.call(obj) === '[object ' + type + ']';
},
- _getUniqueFilename: function(name, map) {
+ _getUniqueFilename: function (name, map) {
// eslint-disable-next-line no-param-reassign
name = String(name);
if (map[name]) {
// eslint-disable-next-line no-param-reassign
- name = name.replace(/(?: \(([\d]+)\))?(\.[^.]+)?$/, function(
+ name = name.replace(/(?: \(([\d]+)\))?(\.[^.]+)?$/, function (
_,
p1,
p2
@@ -494,7 +494,7 @@
return name;
},
- _initXHRData: function(options) {
+ _initXHRData: function (options) {
var that = this,
formData,
file = options.files[0],
@@ -530,7 +530,7 @@
value: options.blob
});
} else {
- $.each(options.files, function(index, file) {
+ $.each(options.files, function (index, file) {
formData.push({
name:
($.type(options.paramName) === 'array' &&
@@ -545,7 +545,7 @@
formData = options.formData;
} else {
formData = new FormData();
- $.each(this._getFormData(options), function(index, field) {
+ $.each(this._getFormData(options), function (index, field) {
formData.append(field.name, field.value);
});
}
@@ -556,7 +556,7 @@
file.uploadName || file.name
);
} else {
- $.each(options.files, function(index, file) {
+ $.each(options.files, function (index, file) {
// This check allows the tests to run with
// dummy objects:
if (
@@ -587,10 +587,8 @@
options.blob = null;
},
- _initIframeSettings: function(options) {
- var targetHost = $('<a></a>')
- .prop('href', options.url)
- .prop('host');
+ _initIframeSettings: function (options) {
+ var targetHost = $('<a></a>').prop('href', options.url).prop('host');
// Setting the dataType to iframe enables the iframe transport:
options.dataType = 'iframe ' + (options.dataType || '');
// The iframe transport accepts a serialized array as form data:
@@ -604,7 +602,7 @@
}
},
- _initDataSettings: function(options) {
+ _initDataSettings: function (options) {
if (this._isXHRUpload(options)) {
if (!this._chunkedUpload(options, true)) {
if (!options.data) {
@@ -622,12 +620,12 @@
}
},
- _getParamName: function(options) {
+ _getParamName: function (options) {
var fileInput = $(options.fileInput),
paramName = options.paramName;
if (!paramName) {
paramName = [];
- fileInput.each(function() {
+ fileInput.each(function () {
var input = $(this),
name = input.prop('name') || 'files[]',
i = (input.prop('files') || [1]).length;
@@ -645,7 +643,7 @@
return paramName;
},
- _initFormSettings: function(options) {
+ _initFormSettings: function (options) {
// Retrieve missing options from the input field and the
// associated form, if available:
if (!options.form || !options.form.length) {
@@ -679,7 +677,7 @@
}
},
- _getAJAXSettings: function(data) {
+ _getAJAXSettings: function (data) {
var options = $.extend({}, this.options, data);
this._initFormSettings(options);
this._initDataSettings(options);
@@ -688,7 +686,7 @@
// jQuery 1.6 doesn't provide .state(),
// while jQuery 1.8+ removed .isRejected() and .isResolved():
- _getDeferredState: function(deferred) {
+ _getDeferredState: function (deferred) {
if (deferred.state) {
return deferred.state();
}
@@ -703,7 +701,7 @@
// Maps jqXHR callbacks to the equivalent
// methods of the given Promise object:
- _enhancePromise: function(promise) {
+ _enhancePromise: function (promise) {
promise.success = promise.done;
promise.error = promise.fail;
promise.complete = promise.always;
@@ -712,7 +710,7 @@
// Creates and returns a Promise object enhanced with
// the jqXHR methods abort, success, error and complete:
- _getXHRPromise: function(resolveOrReject, context, args) {
+ _getXHRPromise: function (resolveOrReject, context, args) {
var dfd = $.Deferred(),
promise = dfd.promise();
// eslint-disable-next-line no-param-reassign
@@ -727,23 +725,19 @@
},
// Adds convenience methods to the data callback argument:
- _addConvenienceMethods: function(e, data) {
+ _addConvenienceMethods: function (e, data) {
var that = this,
- getPromise = function(args) {
- return $.Deferred()
- .resolveWith(that, args)
- .promise();
+ getPromise = function (args) {
+ return $.Deferred().resolveWith(that, args).promise();
};
- data.process = function(resolveFunc, rejectFunc) {
+ data.process = function (resolveFunc, rejectFunc) {
if (resolveFunc || rejectFunc) {
data._processQueue = this._processQueue = (
this._processQueue || getPromise([this])
)
- .then(function() {
+ .then(function () {
if (data.errorThrown) {
- return $.Deferred()
- .rejectWith(that, [data])
- .promise();
+ return $.Deferred().rejectWith(that, [data]).promise();
}
return getPromise(arguments);
})
@@ -751,7 +745,7 @@
}
return this._processQueue || getPromise([this]);
};
- data.submit = function() {
+ data.submit = function () {
if (this.state() !== 'pending') {
data.jqXHR = this.jqXHR =
that._trigger(
@@ -762,7 +756,7 @@
}
return this.jqXHR || that._getXHRPromise();
};
- data.abort = function() {
+ data.abort = function () {
if (this.jqXHR) {
return this.jqXHR.abort();
}
@@ -770,7 +764,7 @@
that._trigger('fail', null, this);
return that._getXHRPromise(false);
};
- data.state = function() {
+ data.state = function () {
if (this.jqXHR) {
return that._getDeferredState(this.jqXHR);
}
@@ -778,24 +772,24 @@
return that._getDeferredState(this._processQueue);
}
};
- data.processing = function() {
+ data.processing = function () {
return (
!this.jqXHR &&
this._processQueue &&
that._getDeferredState(this._processQueue) === 'pending'
);
};
- data.progress = function() {
+ data.progress = function () {
return this._progress;
};
- data.response = function() {
+ data.response = function () {
return this._response;
};
},
// Parses the Range header from the server response
// and returns the uploaded bytes:
- _getUploadedBytes: function(jqXHR) {
+ _getUploadedBytes: function (jqXHR) {
var range = jqXHR.getResponseHeader('Range'),
parts = range && range.split('-'),
upperBytesPos = parts && parts.length > 1 && parseInt(parts[1], 10);
@@ -807,7 +801,7 @@
// If the second parameter is true, only tests if the file
// should be uploaded in chunks, but does not invoke any
// upload requests:
- _chunkedUpload: function(options, testOnly) {
+ _chunkedUpload: function (options, testOnly) {
options.uploadedBytes = options.uploadedBytes || 0;
var that = this,
file = options.files[0],
@@ -841,7 +835,7 @@
]);
}
// The chunk upload method:
- upload = function() {
+ upload = function () {
// Clone the options object for each chunk upload:
var o = $.extend({}, options),
currentLoaded = o._progress.loaded;
@@ -867,7 +861,7 @@
(that._trigger('chunksend', null, o) !== false && $.ajax(o)) ||
that._getXHRPromise(false, o.context)
)
- .done(function(result, textStatus, jqXHR) {
+ .done(function (result, textStatus, jqXHR) {
ub = that._getUploadedBytes(jqXHR) || ub + o.chunkSize;
// Create a progress event if no final progress event
// with loaded equaling total has been triggered
@@ -896,7 +890,7 @@
dfd.resolveWith(o.context, [result, textStatus, jqXHR]);
}
})
- .fail(function(jqXHR, textStatus, errorThrown) {
+ .fail(function (jqXHR, textStatus, errorThrown) {
o.jqXHR = jqXHR;
o.textStatus = textStatus;
o.errorThrown = errorThrown;
@@ -904,19 +898,19 @@
that._trigger('chunkalways', null, o);
dfd.rejectWith(o.context, [jqXHR, textStatus, errorThrown]);
})
- .always(function() {
+ .always(function () {
that._deinitProgressListener(o);
});
};
this._enhancePromise(promise);
- promise.abort = function() {
+ promise.abort = function () {
return jqXHR.abort();
};
upload();
return promise;
},
- _beforeSend: function(e, data) {
+ _beforeSend: function (e, data) {
if (this._active === 0) {
// the start callback is triggered when an upload starts
// and no other uploads are currently running,
@@ -942,7 +936,7 @@
this._progress.total += data.total;
},
- _onDone: function(result, textStatus, jqXHR, options) {
+ _onDone: function (result, textStatus, jqXHR, options) {
var total = options._progress.total,
response = options._response;
if (options._progress.loaded < total) {
@@ -963,7 +957,7 @@
this._trigger('done', null, options);
},
- _onFail: function(jqXHR, textStatus, errorThrown, options) {
+ _onFail: function (jqXHR, textStatus, errorThrown, options) {
var response = options._response;
if (options.recalculateProgress) {
// Remove the failed (error or abort) file upload from
@@ -977,13 +971,13 @@
this._trigger('fail', null, options);
},
- _onAlways: function(jqXHRorResult, textStatus, jqXHRorError, options) {
+ _onAlways: function (jqXHRorResult, textStatus, jqXHRorError, options) {
// jqXHRorResult, textStatus and jqXHRorError are added to the
// options object via done and fail callbacks
this._trigger('always', null, options);
},
- _onSend: function(e, data) {
+ _onSend: function (e, data) {
if (!data.submit) {
this._addConvenienceMethods(e, data);
}
@@ -993,7 +987,7 @@
slot,
pipe,
options = that._getAJAXSettings(data),
- send = function() {
+ send = function () {
that._sending += 1;
// Set timer for bitrate progress calculation:
options._bitrateTimer = new that._BitrateTimer();
@@ -1010,13 +1004,13 @@
that._chunkedUpload(options) ||
$.ajax(options)
)
- .done(function(result, textStatus, jqXHR) {
+ .done(function (result, textStatus, jqXHR) {
that._onDone(result, textStatus, jqXHR, options);
})
- .fail(function(jqXHR, textStatus, errorThrown) {
+ .fail(function (jqXHR, textStatus, errorThrown) {
that._onFail(jqXHR, textStatus, errorThrown, options);
})
- .always(function(jqXHRorResult, textStatus, jqXHRorError) {
+ .always(function (jqXHRorResult, textStatus, jqXHRorError) {
that._deinitProgressListener(options);
that._onAlways(
jqXHRorResult,
@@ -1066,7 +1060,7 @@
// Return the piped Promise object, enhanced with an abort method,
// which is delegated to the jqXHR object of the current upload,
// and jqXHR callbacks mapped to the equivalent Promise methods:
- pipe.abort = function() {
+ pipe.abort = function () {
aborted = [undefined, 'abort', 'abort'];
if (!jqXHR) {
if (slot) {
@@ -1081,7 +1075,7 @@
return send();
},
- _onAdd: function(e, data) {
+ _onAdd: function (e, data) {
var that = this,
result = true,
options = $.extend({}, this.options, data),
@@ -1144,7 +1138,7 @@
paramNameSet = paramName;
}
data.originalFiles = files;
- $.each(fileSet || files, function(index, element) {
+ $.each(fileSet || files, function (index, element) {
var newData = $.extend({}, data);
newData.files = fileSet ? element : [element];
newData.paramName = paramNameSet[index];
@@ -1161,15 +1155,13 @@
return result;
},
- _replaceFileInput: function(data) {
+ _replaceFileInput: function (data) {
var input = data.fileInput,
inputClone = input.clone(true),
restoreFocus = input.is(document.activeElement);
// Add a reference for the new cloned file input to the data argument:
data.fileInputClone = inputClone;
- $('<form></form>')
- .append(inputClone)[0]
- .reset();
+ $('<form></form>').append(inputClone)[0].reset();
// Detaching allows to insert the fileInput on another form
// without loosing the file input value:
input.after(inputClone).detach();
@@ -1179,11 +1171,11 @@
inputClone.focus();
}
// Avoid memory leaks with the detached file input:
- $.cleanData(input.unbind('remove'));
+ $.cleanData(input.off('remove'));
// Replace the original file input element in the fileInput
// elements set with the clone, which has been copied including
// event handlers:
- this.options.fileInput = this.options.fileInput.map(function(i, el) {
+ this.options.fileInput = this.options.fileInput.map(function (i, el) {
if (el === input[0]) {
return inputClone[0];
}
@@ -1196,12 +1188,12 @@
}
},
- _handleFileTreeEntry: function(entry, path) {
+ _handleFileTreeEntry: function (entry, path) {
var that = this,
dfd = $.Deferred(),
entries = [],
dirReader,
- errorHandler = function(e) {
+ errorHandler = function (e) {
if (e && !e.entry) {
e.entry = entry;
}
@@ -1211,16 +1203,16 @@
// to be returned together in one set:
dfd.resolve([e]);
},
- successHandler = function(entries) {
+ successHandler = function (entries) {
that
._handleFileTreeEntries(entries, path + entry.name + '/')
- .done(function(files) {
+ .done(function (files) {
dfd.resolve(files);
})
.fail(errorHandler);
},
- readEntries = function() {
- dirReader.readEntries(function(results) {
+ readEntries = function () {
+ dirReader.readEntries(function (results) {
if (!results.length) {
successHandler(entries);
} else {
@@ -1237,7 +1229,7 @@
entry._file.relativePath = path;
dfd.resolve(entry._file);
} else {
- entry.file(function(file) {
+ entry.file(function (file) {
file.relativePath = path;
dfd.resolve(file);
}, errorHandler);
@@ -1253,21 +1245,21 @@
return dfd.promise();
},
- _handleFileTreeEntries: function(entries, path) {
+ _handleFileTreeEntries: function (entries, path) {
var that = this;
return $.when
.apply(
$,
- $.map(entries, function(entry) {
+ $.map(entries, function (entry) {
return that._handleFileTreeEntry(entry, path);
})
)
- .then(function() {
+ .then(function () {
return Array.prototype.concat.apply([], arguments);
});
},
- _getDroppedFiles: function(dataTransfer) {
+ _getDroppedFiles: function (dataTransfer) {
// eslint-disable-next-line no-param-reassign
dataTransfer = dataTransfer || {};
var items = dataTransfer.items;
@@ -1277,7 +1269,7 @@
(items[0].webkitGetAsEntry || items[0].getAsEntry)
) {
return this._handleFileTreeEntries(
- $.map(items, function(item) {
+ $.map(items, function (item) {
var entry;
if (item.webkitGetAsEntry) {
entry = item.webkitGetAsEntry();
@@ -1291,12 +1283,10 @@
})
);
}
- return $.Deferred()
- .resolve($.makeArray(dataTransfer.files))
- .promise();
+ return $.Deferred().resolve($.makeArray(dataTransfer.files)).promise();
},
- _getSingleFileInputFiles: function(fileInput) {
+ _getSingleFileInputFiles: function (fileInput) {
// eslint-disable-next-line no-param-reassign
fileInput = $(fileInput);
var entries =
@@ -1310,9 +1300,7 @@
if (!files.length) {
value = fileInput.prop('value');
if (!value) {
- return $.Deferred()
- .resolve([])
- .promise();
+ return $.Deferred().resolve([]).promise();
}
// If the files property is not available, the browser does not
// support the File API and we add a pseudo File object with
@@ -1320,34 +1308,32 @@
files = [{ name: value.replace(/^.*\\/, '') }];
} else if (files[0].name === undefined && files[0].fileName) {
// File normalization for Safari 4 and Firefox 3:
- $.each(files, function(index, file) {
+ $.each(files, function (index, file) {
file.name = file.fileName;
file.size = file.fileSize;
});
}
- return $.Deferred()
- .resolve(files)
- .promise();
+ return $.Deferred().resolve(files).promise();
},
- _getFileInputFiles: function(fileInput) {
+ _getFileInputFiles: function (fileInput) {
if (!(fileInput instanceof $) || fileInput.length === 1) {
return this._getSingleFileInputFiles(fileInput);
}
return $.when
.apply($, $.map(fileInput, this._getSingleFileInputFiles))
- .then(function() {
+ .then(function () {
return Array.prototype.concat.apply([], arguments);
});
},
- _onChange: function(e) {
+ _onChange: function (e) {
var that = this,
data = {
fileInput: $(e.target),
form: $(e.target.form)
};
- this._getFileInputFiles(data.fileInput).always(function(files) {
+ this._getFileInputFiles(data.fileInput).always(function (files) {
data.files = files;
if (that.options.replaceFileInput) {
that._replaceFileInput(data);
@@ -1364,14 +1350,14 @@
});
},
- _onPaste: function(e) {
+ _onPaste: function (e) {
var items =
e.originalEvent &&
e.originalEvent.clipboardData &&
e.originalEvent.clipboardData.items,
data = { files: [] };
if (items && items.length) {
- $.each(items, function(index, item) {
+ $.each(items, function (index, item) {
var file = item.getAsFile && item.getAsFile();
if (file) {
data.files.push(file);
@@ -1389,14 +1375,14 @@
}
},
- _onDrop: function(e) {
+ _onDrop: function (e) {
e.dataTransfer = e.originalEvent && e.originalEvent.dataTransfer;
var that = this,
dataTransfer = e.dataTransfer,
data = {};
if (dataTransfer && dataTransfer.files && dataTransfer.files.length) {
e.preventDefault();
- this._getDroppedFiles(dataTransfer).always(function(files) {
+ this._getDroppedFiles(dataTransfer).always(function (files) {
data.files = files;
if (
that._trigger(
@@ -1417,7 +1403,7 @@
_onDragLeave: getDragHandler('dragleave'),
- _initEventHandlers: function() {
+ _initEventHandlers: function () {
if (this._isXHRUpload(this.options)) {
this._on(this.options.dropZone, {
dragover: this._onDragOver,
@@ -1438,17 +1424,17 @@
}
},
- _destroyEventHandlers: function() {
+ _destroyEventHandlers: function () {
this._off(this.options.dropZone, 'dragenter dragleave dragover drop');
this._off(this.options.pasteZone, 'paste');
this._off(this.options.fileInput, 'change');
},
- _destroy: function() {
+ _destroy: function () {
this._destroyEventHandlers();
},
- _setOption: function(key, value) {
+ _setOption: function (key, value) {
var reinit = $.inArray(key, this._specialOptions) !== -1;
if (reinit) {
this._destroyEventHandlers();
@@ -1460,7 +1446,7 @@
}
},
- _initSpecialOptions: function() {
+ _initSpecialOptions: function () {
var options = this.options;
if (options.fileInput === undefined) {
options.fileInput = this.element.is('input[type="file"]')
@@ -1477,14 +1463,14 @@
}
},
- _getRegExp: function(str) {
+ _getRegExp: function (str) {
var parts = str.split('/'),
modifiers = parts.pop();
parts.shift();
return new RegExp(parts.join('/'), modifiers);
},
- _isRegExpOption: function(key, value) {
+ _isRegExpOption: function (key, value) {
return (
key !== 'url' &&
$.type(value) === 'string' &&
@@ -1492,17 +1478,17 @@
);
},
- _initDataAttributes: function() {
+ _initDataAttributes: function () {
var that = this,
options = this.options,
data = this.element.data();
// Initialize options set via HTML5 data-attributes:
- $.each(this.element[0].attributes, function(index, attr) {
+ $.each(this.element[0].attributes, function (index, attr) {
var key = attr.name.toLowerCase(),
value;
if (/^data-/.test(key)) {
// Convert hyphen-ated key to camelCase:
- key = key.slice(5).replace(/-[a-z]/g, function(str) {
+ key = key.slice(5).replace(/-[a-z]/g, function (str) {
return str.charAt(1).toUpperCase();
});
value = data[key];
@@ -1514,7 +1500,7 @@
});
},
- _create: function() {
+ _create: function () {
this._initDataAttributes();
this._initSpecialOptions();
this._slots = [];
@@ -1526,7 +1512,7 @@
// This method is exposed to the widget API and allows to query
// the number of active uploads:
- active: function() {
+ active: function () {
return this._active;
},
@@ -1534,7 +1520,7 @@
// the widget upload progress.
// It returns an object with loaded, total and bitrate properties
// for the running uploads:
- progress: function() {
+ progress: function () {
return this._progress;
},
@@ -1542,13 +1528,13 @@
// using the fileupload API. The data parameter accepts an object which
// must have a files property and can contain additional options:
// .fileupload('add', {files: filesList});
- add: function(data) {
+ add: function (data) {
var that = this;
if (!data || this.options.disabled) {
return;
}
if (data.fileInput && !data.files) {
- this._getFileInputFiles(data.fileInput).always(function(files) {
+ this._getFileInputFiles(data.fileInput).always(function (files) {
data.files = files;
that._onAdd(null, data);
});
@@ -1563,7 +1549,7 @@
// must have a files or fileInput property and can contain additional options:
// .fileupload('send', {files: filesList});
// The method returns a Promise object for the file upload call.
- send: function(data) {
+ send: function (data) {
if (data && !this.options.disabled) {
if (data.fileInput && !data.files) {
var that = this,
@@ -1571,7 +1557,7 @@
promise = dfd.promise(),
jqXHR,
aborted;
- promise.abort = function() {
+ promise.abort = function () {
aborted = true;
if (jqXHR) {
return jqXHR.abort();
@@ -1579,7 +1565,7 @@
dfd.reject(null, 'abort', 'abort');
return promise;
};
- this._getFileInputFiles(data.fileInput).always(function(files) {
+ this._getFileInputFiles(data.fileInput).always(function (files) {
if (aborted) {
return;
}
@@ -1590,10 +1576,10 @@
data.files = files;
jqXHR = that._onSend(null, data);
jqXHR.then(
- function(result, textStatus, jqXHR) {
+ function (result, textStatus, jqXHR) {
dfd.resolve(result, textStatus, jqXHR);
},
- function(jqXHR, textStatus, errorThrown) {
+ function (jqXHR, textStatus, errorThrown) {
dfd.reject(jqXHR, textStatus, errorThrown);
}
);