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
|
* https://github.com/blueimp/jQuery-File-Upload
|
||||||
*
|
*
|
||||||
* Copyright 2010, Sebastian Tschan
|
* Copyright 2010, Sebastian Tschan
|
||||||
@@ -89,7 +89,7 @@
|
|||||||
files = data.files;
|
files = data.files;
|
||||||
$(this).fileupload('process', data).done(function () {
|
$(this).fileupload('process', data).done(function () {
|
||||||
that._adjustMaxNumberOfFiles(-files.length);
|
that._adjustMaxNumberOfFiles(-files.length);
|
||||||
data.isAdjusted = true;
|
data.maxNumberOfFilesAdjusted = true;
|
||||||
data.files.valid = data.isValidated = that._validate(files);
|
data.files.valid = data.isValidated = that._validate(files);
|
||||||
data.context = that._renderUpload(files).data('data', data);
|
data.context = that._renderUpload(files).data('data', data);
|
||||||
options.filesContainer[
|
options.filesContainer[
|
||||||
@@ -112,8 +112,9 @@
|
|||||||
send: function (e, data) {
|
send: function (e, data) {
|
||||||
var that = $(this).data('fileupload');
|
var that = $(this).data('fileupload');
|
||||||
if (!data.isValidated) {
|
if (!data.isValidated) {
|
||||||
if (!data.isAdjusted) {
|
if (!data.maxNumberOfFilesAdjusted) {
|
||||||
that._adjustMaxNumberOfFiles(-data.files.length);
|
that._adjustMaxNumberOfFiles(-data.files.length);
|
||||||
|
data.maxNumberOfFilesAdjusted = true;
|
||||||
}
|
}
|
||||||
if (!that._validate(data.files)) {
|
if (!that._validate(data.files)) {
|
||||||
return false;
|
return false;
|
||||||
@@ -151,7 +152,6 @@
|
|||||||
function () {
|
function () {
|
||||||
var node = $(this);
|
var node = $(this);
|
||||||
template = that._renderDownload([file])
|
template = that._renderDownload([file])
|
||||||
.css('height', node.height())
|
|
||||||
.replaceAll(node);
|
.replaceAll(node);
|
||||||
that._forceReflow(template);
|
that._forceReflow(template);
|
||||||
that._transition(template).done(
|
that._transition(template).done(
|
||||||
@@ -164,6 +164,17 @@
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
} else {
|
} 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)
|
template = that._renderDownload(data.result)
|
||||||
.appendTo(that.options.filesContainer);
|
.appendTo(that.options.filesContainer);
|
||||||
that._forceReflow(template);
|
that._forceReflow(template);
|
||||||
@@ -179,7 +190,9 @@
|
|||||||
fail: function (e, data) {
|
fail: function (e, data) {
|
||||||
var that = $(this).data('fileupload'),
|
var that = $(this).data('fileupload'),
|
||||||
template;
|
template;
|
||||||
that._adjustMaxNumberOfFiles(data.files.length);
|
if (data.maxNumberOfFilesAdjusted) {
|
||||||
|
that._adjustMaxNumberOfFiles(data.files.length);
|
||||||
|
}
|
||||||
if (data.context) {
|
if (data.context) {
|
||||||
data.context.each(function (index) {
|
data.context.each(function (index) {
|
||||||
if (data.errorThrown !== 'abort') {
|
if (data.errorThrown !== 'abort') {
|
||||||
@@ -210,7 +223,6 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (data.errorThrown !== 'abort') {
|
} else if (data.errorThrown !== 'abort') {
|
||||||
that._adjustMaxNumberOfFiles(-data.files.length);
|
|
||||||
data.context = that._renderUpload(data.files)
|
data.context = that._renderUpload(data.files)
|
||||||
.appendTo(that.options.filesContainer)
|
.appendTo(that.options.filesContainer)
|
||||||
.data('data', data);
|
.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 () {
|
_initSpecialOptions: function () {
|
||||||
parentWidget.prototype._initSpecialOptions.call(this);
|
parentWidget.prototype._initSpecialOptions.call(this);
|
||||||
this._initFilesContainer();
|
this._initFilesContainer();
|
||||||
this._initTemplates();
|
this._initTemplates();
|
||||||
|
this._initRegExpOptions();
|
||||||
},
|
},
|
||||||
|
|
||||||
_create: function () {
|
_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
|
* https://github.com/blueimp/jQuery-File-Upload
|
||||||
*
|
*
|
||||||
* Copyright 2010, Sebastian Tschan
|
* Copyright 2010, Sebastian Tschan
|
||||||
@@ -530,6 +530,10 @@
|
|||||||
ub + i * mcs,
|
ub + i * mcs,
|
||||||
ub + (i + 1) * 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
|
// Store the current chunk size, as the blob itself
|
||||||
// will be dereferenced after data processing:
|
// will be dereferenced after data processing:
|
||||||
o.chunkSize = o.blob.size;
|
o.chunkSize = o.blob.size;
|
||||||
@@ -776,19 +780,30 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_onChange: function (e) {
|
_getFileInputFiles: function (fileInput) {
|
||||||
var that = e.data.fileupload,
|
fileInput = $(fileInput);
|
||||||
data = {
|
var files = $.each($.makeArray(fileInput.prop('files')), this._normalizeFile),
|
||||||
files: $.each($.makeArray(e.target.files), that._normalizeFile),
|
value;
|
||||||
fileInput: $(e.target),
|
if (!files.length) {
|
||||||
form: $(e.target.form)
|
value = fileInput.prop('value');
|
||||||
};
|
if (!value) {
|
||||||
if (!data.files.length) {
|
return [];
|
||||||
|
}
|
||||||
// If the files property is not available, the browser does not
|
// If the files property is not available, the browser does not
|
||||||
// support the File API and we add a pseudo File object with
|
// support the File API and we add a pseudo File object with
|
||||||
// the input value as name with path information removed:
|
// 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) {
|
if (that.options.replaceFileInput) {
|
||||||
that._replaceFileInput(data.fileInput);
|
that._replaceFileInput(data.fileInput);
|
||||||
}
|
}
|
||||||
@@ -838,7 +853,7 @@
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (dataTransfer) {
|
if (dataTransfer) {
|
||||||
dataTransfer.dropEffect = dataTransfer.effectAllowed = 'copy';
|
dataTransfer.dropEffect = 'copy';
|
||||||
}
|
}
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
},
|
},
|
||||||
@@ -925,7 +940,11 @@
|
|||||||
if (!data || this.options.disabled) {
|
if (!data || this.options.disabled) {
|
||||||
return;
|
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);
|
this._onAdd(null, data);
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -936,7 +955,11 @@
|
|||||||
// The method returns a Promise object for the file upload call.
|
// The method returns a Promise object for the file upload call.
|
||||||
send: function (data) {
|
send: function (data) {
|
||||||
if (data && !this.options.disabled) {
|
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) {
|
if (data.files.length) {
|
||||||
return this._onSend(null, data);
|
return this._onSend(null, data);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user