Fix: update jquery fileupload

This commit is contained in:
Regis Houssin
2012-08-06 18:43:34 +02:00
parent d830041441
commit 58878cdb6f
2 changed files with 76 additions and 19 deletions

View File

@@ -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);
}