Skip to content

Commit 29722ed

Browse files
committed
Updated to latest version
1 parent f1d9d80 commit 29722ed

File tree

5 files changed

+99
-38
lines changed

5 files changed

+99
-38
lines changed

vendor/assets/javascripts/jquery-fileupload/cors/jquery.xdr-transport.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* jQuery XDomainRequest Transport Plugin 1.1.1
2+
* jQuery XDomainRequest Transport Plugin 1.1.2
33
* https://github.com/blueimp/jQuery-File-Upload
44
*
55
* Copyright 2011, Sebastian Tschan
@@ -26,7 +26,7 @@
2626
}
2727
}(function ($) {
2828
'use strict';
29-
if (window.XDomainRequest && $.ajaxSettings.xhr().withCredentials === undefined) {
29+
if (window.XDomainRequest && !$.support.cors) {
3030
$.ajaxTransport(function (s) {
3131
if (s.crossDomain && s.async) {
3232
if (s.timeout) {

vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-ip.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* jQuery File Upload Image Processing Plugin 1.0.5
2+
* jQuery File Upload Image Processing Plugin 1.0.6
33
* https://github.com/blueimp/jQuery-File-Upload
44
*
55
* Copyright 2012, Sebastian Tschan
@@ -112,9 +112,10 @@
112112
resize: function (data) {
113113
var that = this,
114114
options = $.extend({}, this.options, data),
115-
resizeAll = $.type(options.resizeSourceMaxFileSize) !== 'number';
115+
resizeAll = $.type(options.resizeSourceMaxFileSize) !== 'number',
116+
isXHRUpload = this._isXHRUpload(options);
116117
$.each(data.files, function (index, file) {
117-
if (that._resizeSupport &&
118+
if (isXHRUpload && that._resizeSupport &&
118119
(options.resizeMaxWidth || options.resizeMaxHeight ||
119120
options.resizeMinWidth || options.resizeMinHeight) &&
120121
(resizeAll || file.size < options.resizeSourceMaxFileSize) &&

vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-ui.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* jQuery File Upload User Interface Plugin 6.6.2
2+
* jQuery File Upload User Interface Plugin 6.6.3
33
* https://github.com/blueimp/jQuery-File-Upload
44
*
55
* Copyright 2010, Sebastian Tschan
@@ -81,9 +81,9 @@
8181
var that = $(this).data('fileupload'),
8282
options = that.options,
8383
files = data.files;
84-
that._adjustMaxNumberOfFiles(-files.length);
85-
data.isAdjusted = true;
8684
$(this).fileupload('resize', data).done(data, function () {
85+
that._adjustMaxNumberOfFiles(-files.length);
86+
data.isAdjusted = true;
8787
data.files.valid = data.isValidated = that._validate(files);
8888
data.context = that._renderUpload(files)
8989
.appendTo(options.filesContainer)

vendor/assets/javascripts/jquery-fileupload/jquery.fileupload.js

Lines changed: 79 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* jQuery File Upload Plugin 5.8.1
2+
* jQuery File Upload Plugin 5.10.0
33
* https://github.com/blueimp/jQuery-File-Upload
44
*
55
* Copyright 2010, Sebastian Tschan
@@ -10,7 +10,7 @@
1010
*/
1111

1212
/*jslint nomen: true, unparam: true, regexp: true */
13-
/*global define, window, document, XMLHttpRequestUpload, Blob, File, FormData, location */
13+
/*global define, window, document, Blob, FormData, location */
1414

1515
(function (factory) {
1616
'use strict';
@@ -27,6 +27,12 @@
2727
}(function ($) {
2828
'use strict';
2929

30+
// The FileReader API is not actually used, but works as feature detection,
31+
// as e.g. Safari supports XHR file uploads via the FormData API,
32+
// but not non-multipart XHR file uploads:
33+
$.support.xhrFileUpload = !!(window.XMLHttpRequestUpload && window.FileReader);
34+
$.support.xhrFormDataFileUpload = !!window.FormData;
35+
3036
// The fileupload widget listens for change events on file input fields defined
3137
// via fileInput setting and paste or drop events of the given dropZone.
3238
// In addition to the default jQuery Widget methods, the fileupload widget
@@ -57,7 +63,8 @@
5763
replaceFileInput: true,
5864
// The parameter name for the file form data (the request argument name).
5965
// If undefined or empty, the name property of the file input field is
60-
// used, or "files[]" if the file input name property is also empty:
66+
// used, or "files[]" if the file input name property is also empty,
67+
// can be a string or an array of strings:
6168
paramName: undefined,
6269
// By default, each file of a selection is uploaded using an individual
6370
// request for XHR type uploads. Set to false to upload file
@@ -165,13 +172,18 @@
165172
},
166173

167174
// A list of options that require a refresh after assigning a new value:
168-
_refreshOptionsList: ['namespace', 'dropZone', 'fileInput'],
175+
_refreshOptionsList: [
176+
'namespace',
177+
'dropZone',
178+
'fileInput',
179+
'multipart',
180+
'forceIframeTransport'
181+
],
169182

170183
_isXHRUpload: function (options) {
171-
var undef = 'undefined';
172184
return !options.forceIframeTransport &&
173-
typeof XMLHttpRequestUpload !== undef && typeof File !== undef &&
174-
(!options.multipart || typeof FormData !== undef);
185+
((!options.multipart && $.support.xhrFileUpload) ||
186+
$.support.xhrFormDataFileUpload);
175187
},
176188

177189
_getFormData: function (options) {
@@ -245,8 +257,11 @@
245257

246258
_initXHRData: function (options) {
247259
var formData,
248-
file = options.files[0];
249-
if (!options.multipart || options.blob) {
260+
file = options.files[0],
261+
// Ignore non-multipart setting if not supported:
262+
multipart = options.multipart || !$.support.xhrFileUpload,
263+
paramName = options.paramName[0];
264+
if (!multipart || options.blob) {
250265
// For non-multipart uploads and chunked uploads,
251266
// file meta data is not part of the request body,
252267
// so we transmit this data as part of the HTTP headers.
@@ -262,13 +277,13 @@
262277
// Non-chunked non-multipart upload:
263278
options.contentType = file.type;
264279
options.data = file;
265-
} else if (!options.multipart) {
280+
} else if (!multipart) {
266281
// Chunked non-multipart upload:
267282
options.contentType = 'application/octet-stream';
268283
options.data = options.blob;
269284
}
270285
}
271-
if (options.multipart && typeof FormData !== 'undefined') {
286+
if (multipart && $.support.xhrFormDataFileUpload) {
272287
if (options.postMessage) {
273288
// window.postMessage does not allow sending FormData
274289
// objects, so we just add the File/Blob objects to
@@ -277,13 +292,13 @@
277292
formData = this._getFormData(options);
278293
if (options.blob) {
279294
formData.push({
280-
name: options.paramName,
295+
name: paramName,
281296
value: options.blob
282297
});
283298
} else {
284299
$.each(options.files, function (index, file) {
285300
formData.push({
286-
name: options.paramName,
301+
name: options.paramName[index] || paramName,
287302
value: file
288303
});
289304
});
@@ -298,14 +313,18 @@
298313
});
299314
}
300315
if (options.blob) {
301-
formData.append(options.paramName, options.blob, file.name);
316+
formData.append(paramName, options.blob, file.name);
302317
} else {
303318
$.each(options.files, function (index, file) {
304319
// File objects are also Blob instances.
305320
// This check allows the tests to run with
306321
// dummy objects:
307322
if (file instanceof Blob) {
308-
formData.append(options.paramName, file, file.name);
323+
formData.append(
324+
options.paramName[index] || paramName,
325+
file,
326+
file.name
327+
);
309328
}
310329
});
311330
}
@@ -349,16 +368,36 @@
349368
}
350369
},
351370

371+
_getParamName: function (options) {
372+
var fileInput = $(options.fileInput),
373+
paramName = options.paramName;
374+
if (!paramName) {
375+
paramName = [];
376+
fileInput.each(function () {
377+
var input = $(this),
378+
name = input.prop('name') || 'files[]',
379+
i = (input.prop('files') || [1]).length;
380+
while (i) {
381+
paramName.push(name);
382+
i -= 1;
383+
}
384+
});
385+
if (!paramName.length) {
386+
paramName = [fileInput.prop('name') || 'files[]'];
387+
}
388+
} else if (!$.isArray(paramName)) {
389+
paramName = [paramName];
390+
}
391+
return paramName;
392+
},
393+
352394
_initFormSettings: function (options) {
353395
// Retrieve missing options from the input field and the
354396
// associated form, if available:
355397
if (!options.form || !options.form.length) {
356398
options.form = $(options.fileInput.prop('form'));
357399
}
358-
if (!options.paramName) {
359-
options.paramName = options.fileInput.prop('name') ||
360-
'files[]';
361-
}
400+
options.paramName = this._getParamName(options);
362401
if (!options.url) {
363402
options.url = options.form.prop('action') || location.href;
364403
}
@@ -621,21 +660,34 @@
621660
result = true,
622661
options = $.extend({}, this.options, data),
623662
limit = options.limitMultiFileUploads,
663+
paramName = this._getParamName(options),
664+
paramNameSet,
665+
paramNameSlice,
624666
fileSet,
625667
i;
626668
if (!(options.singleFileUploads || limit) ||
627669
!this._isXHRUpload(options)) {
628670
fileSet = [data.files];
671+
paramNameSet = [paramName];
629672
} else if (!options.singleFileUploads && limit) {
630673
fileSet = [];
674+
paramNameSet = [];
631675
for (i = 0; i < data.files.length; i += limit) {
632676
fileSet.push(data.files.slice(i, i + limit));
677+
paramNameSlice = paramName.slice(i, i + limit);
678+
if (!paramNameSlice.length) {
679+
paramNameSlice = paramName;
680+
}
681+
paramNameSet.push(paramNameSlice);
633682
}
683+
} else {
684+
paramNameSet = paramName;
634685
}
635686
data.originalFiles = data.files;
636687
$.each(fileSet || data.files, function (index, element) {
637-
var files = fileSet ? element : [element],
638-
newData = $.extend({}, data, {files: files});
688+
var newData = $.extend({}, data);
689+
newData.files = fileSet ? element : [element];
690+
newData.paramName = paramNameSet[index];
639691
newData.submit = function () {
640692
newData.jqXHR = this.jqXHR =
641693
(that._trigger('submit', e, this) !== false) &&
@@ -748,10 +800,12 @@
748800

749801
_initEventHandlers: function () {
750802
var ns = this.options.namespace;
751-
this.options.dropZone
752-
.bind('dragover.' + ns, {fileupload: this}, this._onDragOver)
753-
.bind('drop.' + ns, {fileupload: this}, this._onDrop)
754-
.bind('paste.' + ns, {fileupload: this}, this._onPaste);
803+
if (this._isXHRUpload(this.options)) {
804+
this.options.dropZone
805+
.bind('dragover.' + ns, {fileupload: this}, this._onDragOver)
806+
.bind('drop.' + ns, {fileupload: this}, this._onDrop)
807+
.bind('paste.' + ns, {fileupload: this}, this._onPaste);
808+
}
755809
this.options.fileInput
756810
.bind('change.' + ns, {fileupload: this}, this._onChange);
757811
},

vendor/assets/javascripts/jquery-fileupload/jquery.iframe-transport.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* jQuery Iframe Transport Plugin 1.3
2+
* jQuery Iframe Transport Plugin 1.4
33
* https://github.com/blueimp/jQuery-File-Upload
44
*
55
* Copyright 2011, Sebastian Tschan
@@ -30,7 +30,8 @@
3030
// The iframe transport accepts three additional options:
3131
// options.fileInput: a jQuery collection of file input fields
3232
// options.paramName: the parameter name for the file form data,
33-
// overrides the name property of the file input field(s)
33+
// overrides the name property of the file input field(s),
34+
// can be a string or an array of strings.
3435
// options.formData: an array of objects with name and value properties,
3536
// equivalent to the return data of .serializeArray(), e.g.:
3637
// [{name: 'a', value: 1}, {name: 'b', value: 2}]
@@ -50,7 +51,9 @@
5051
'<iframe src="javascript:false;" name="iframe-transport-' +
5152
(counter += 1) + '"></iframe>'
5253
).bind('load', function () {
53-
var fileInputClones;
54+
var fileInputClones,
55+
paramNames = $.isArray(options.paramName) ?
56+
options.paramName : [options.paramName];
5457
iframe
5558
.unbind('load')
5659
.bind('load', function () {
@@ -101,8 +104,11 @@
101104
return fileInputClones[index];
102105
});
103106
if (options.paramName) {
104-
options.fileInput.each(function () {
105-
$(this).prop('name', options.paramName);
107+
options.fileInput.each(function (index) {
108+
$(this).prop(
109+
'name',
110+
paramNames[index] || options.paramName
111+
);
106112
});
107113
}
108114
// Appending the file input fields to the hidden form

0 commit comments

Comments
 (0)