forked from Wavyzz/dolibarr
Fix: update jquery fileupload
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* jQuery File Upload User Interface Plugin 6.9.1
|
||||
* jQuery File Upload User Interface Plugin 6.9.4
|
||||
* https://github.com/blueimp/jQuery-File-Upload
|
||||
*
|
||||
* Copyright 2010, Sebastian Tschan
|
||||
@@ -89,7 +89,7 @@
|
||||
files = data.files;
|
||||
$(this).fileupload('process', data).done(function () {
|
||||
that._adjustMaxNumberOfFiles(-files.length);
|
||||
data.isAdjusted = true;
|
||||
data.maxNumberOfFilesAdjusted = true;
|
||||
data.files.valid = data.isValidated = that._validate(files);
|
||||
data.context = that._renderUpload(files).data('data', data);
|
||||
options.filesContainer[
|
||||
@@ -112,8 +112,9 @@
|
||||
send: function (e, data) {
|
||||
var that = $(this).data('fileupload');
|
||||
if (!data.isValidated) {
|
||||
if (!data.isAdjusted) {
|
||||
if (!data.maxNumberOfFilesAdjusted) {
|
||||
that._adjustMaxNumberOfFiles(-data.files.length);
|
||||
data.maxNumberOfFilesAdjusted = true;
|
||||
}
|
||||
if (!that._validate(data.files)) {
|
||||
return false;
|
||||
@@ -151,7 +152,6 @@
|
||||
function () {
|
||||
var node = $(this);
|
||||
template = that._renderDownload([file])
|
||||
.css('height', node.height())
|
||||
.replaceAll(node);
|
||||
that._forceReflow(template);
|
||||
that._transition(template).done(
|
||||
@@ -164,6 +164,17 @@
|
||||
);
|
||||
});
|
||||
} else {
|
||||
if ($.isArray(data.result)) {
|
||||
$.each(data.result, function (index, file) {
|
||||
if (data.maxNumberOfFilesAdjusted && file.error) {
|
||||
that._adjustMaxNumberOfFiles(1);
|
||||
} else if (!data.maxNumberOfFilesAdjusted &&
|
||||
!file.error) {
|
||||
that._adjustMaxNumberOfFiles(-1);
|
||||
}
|
||||
});
|
||||
data.maxNumberOfFilesAdjusted = true;
|
||||
}
|
||||
template = that._renderDownload(data.result)
|
||||
.appendTo(that.options.filesContainer);
|
||||
that._forceReflow(template);
|
||||
@@ -179,7 +190,9 @@
|
||||
fail: function (e, data) {
|
||||
var that = $(this).data('fileupload'),
|
||||
template;
|
||||
that._adjustMaxNumberOfFiles(data.files.length);
|
||||
if (data.maxNumberOfFilesAdjusted) {
|
||||
that._adjustMaxNumberOfFiles(data.files.length);
|
||||
}
|
||||
if (data.context) {
|
||||
data.context.each(function (index) {
|
||||
if (data.errorThrown !== 'abort') {
|
||||
@@ -210,7 +223,6 @@
|
||||
}
|
||||
});
|
||||
} else if (data.errorThrown !== 'abort') {
|
||||
that._adjustMaxNumberOfFiles(-data.files.length);
|
||||
data.context = that._renderUpload(data.files)
|
||||
.appendTo(that.options.filesContainer)
|
||||
.data('data', data);
|
||||
@@ -664,10 +676,32 @@
|
||||
}
|
||||
},
|
||||
|
||||
_stringToRegExp: function (str) {
|
||||
var parts = str.split('/'),
|
||||
modifiers = parts.pop();
|
||||
parts.shift();
|
||||
return new RegExp(parts.join('/'), modifiers);
|
||||
},
|
||||
|
||||
_initRegExpOptions: function () {
|
||||
var options = this.options;
|
||||
if ($.type(options.acceptFileTypes) === 'string') {
|
||||
options.acceptFileTypes = this._stringToRegExp(
|
||||
options.acceptFileTypes
|
||||
);
|
||||
}
|
||||
if ($.type(options.previewSourceFileTypes) === 'string') {
|
||||
options.previewSourceFileTypes = this._stringToRegExp(
|
||||
options.previewSourceFileTypes
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
_initSpecialOptions: function () {
|
||||
parentWidget.prototype._initSpecialOptions.call(this);
|
||||
this._initFilesContainer();
|
||||
this._initTemplates();
|
||||
this._initRegExpOptions();
|
||||
},
|
||||
|
||||
_create: function () {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* jQuery File Upload Plugin 5.11.2
|
||||
* jQuery File Upload Plugin 5.13
|
||||
* https://github.com/blueimp/jQuery-File-Upload
|
||||
*
|
||||
* Copyright 2010, Sebastian Tschan
|
||||
@@ -530,6 +530,10 @@
|
||||
ub + i * mcs,
|
||||
ub + (i + 1) * mcs
|
||||
);
|
||||
// Expose the chunk index:
|
||||
o.chunkIndex = i;
|
||||
// Expose the number of chunks:
|
||||
o.chunksNumber = n;
|
||||
// Store the current chunk size, as the blob itself
|
||||
// will be dereferenced after data processing:
|
||||
o.chunkSize = o.blob.size;
|
||||
@@ -776,19 +780,30 @@
|
||||
}
|
||||
},
|
||||
|
||||
_onChange: function (e) {
|
||||
var that = e.data.fileupload,
|
||||
data = {
|
||||
files: $.each($.makeArray(e.target.files), that._normalizeFile),
|
||||
fileInput: $(e.target),
|
||||
form: $(e.target.form)
|
||||
};
|
||||
if (!data.files.length) {
|
||||
_getFileInputFiles: function (fileInput) {
|
||||
fileInput = $(fileInput);
|
||||
var files = $.each($.makeArray(fileInput.prop('files')), this._normalizeFile),
|
||||
value;
|
||||
if (!files.length) {
|
||||
value = fileInput.prop('value');
|
||||
if (!value) {
|
||||
return [];
|
||||
}
|
||||
// If the files property is not available, the browser does not
|
||||
// support the File API and we add a pseudo File object with
|
||||
// the input value as name with path information removed:
|
||||
data.files = [{name: e.target.value.replace(/^.*\\/, '')}];
|
||||
files = [{name: value.replace(/^.*\\/, '')}];
|
||||
}
|
||||
return files;
|
||||
},
|
||||
|
||||
_onChange: function (e) {
|
||||
var that = e.data.fileupload,
|
||||
data = {
|
||||
fileInput: $(e.target),
|
||||
form: $(e.target.form)
|
||||
};
|
||||
data.files = that._getFileInputFiles(data.fileInput);
|
||||
if (that.options.replaceFileInput) {
|
||||
that._replaceFileInput(data.fileInput);
|
||||
}
|
||||
@@ -838,7 +853,7 @@
|
||||
return false;
|
||||
}
|
||||
if (dataTransfer) {
|
||||
dataTransfer.dropEffect = dataTransfer.effectAllowed = 'copy';
|
||||
dataTransfer.dropEffect = 'copy';
|
||||
}
|
||||
e.preventDefault();
|
||||
},
|
||||
@@ -925,7 +940,11 @@
|
||||
if (!data || this.options.disabled) {
|
||||
return;
|
||||
}
|
||||
data.files = $.each($.makeArray(data.files), this._normalizeFile);
|
||||
if (data.fileInput && !data.files) {
|
||||
data.files = this._getFileInputFiles(data.fileInput);
|
||||
} else {
|
||||
data.files = $.each($.makeArray(data.files), this._normalizeFile);
|
||||
}
|
||||
this._onAdd(null, data);
|
||||
},
|
||||
|
||||
@@ -936,7 +955,11 @@
|
||||
// The method returns a Promise object for the file upload call.
|
||||
send: function (data) {
|
||||
if (data && !this.options.disabled) {
|
||||
data.files = $.each($.makeArray(data.files), this._normalizeFile);
|
||||
if (data.fileInput && !data.files) {
|
||||
data.files = this._getFileInputFiles(data.fileInput);
|
||||
} else {
|
||||
data.files = $.each($.makeArray(data.files), this._normalizeFile);
|
||||
}
|
||||
if (data.files.length) {
|
||||
return this._onSend(null, data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user