jquery.fileupload-rails 1.5.1 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MjcxMzNlMTc1MjdhY2VjNGQyOWZjYmE3OWZjZTAzYWMzMGJhZTY1Mw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NzgzMjg0NDY4YWIwNmM4MTUwOGE1MGI3NzViYTIxMWZlYzczMGU3Yg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MmRkNmNhOTE1MjcwMjA3NWI2Y2YwM2UzYzYxYmRlOGY3ODJhZWE5YWJmMGE2
|
10
|
+
NjZhM2MwYjJjMTA0MGYxNzk0OGFiNjkwMjc5OTQ2MmYyOWE0NmNmMjVkNzE5
|
11
|
+
YzA3MmYxMGRlNjZiZmE3NTMwNTczZWE5NWFkMDM2NjBjOTEyMTI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzFjMjU0YWU4MDViNGRhNDM1NzUzYmYzMmVhMDM3NTFjMjBjNzEyNTE4OTEx
|
14
|
+
OWFjYzNmNzJjYTE3NjUwNDNhOTE4MGE3MTM4MDg0NjE5N2U0NzI1NjhjNmM4
|
15
|
+
MWNiMzlhNjE2ZTljNTBjZDA5ZGM0ZjM1MDRmNjJkMDA0M2UzNzc=
|
data/Readme.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
//= require jquery.iframe-transport
|
3
3
|
|
4
4
|
/*
|
5
|
-
* jQuery File Upload Plugin 5.
|
5
|
+
* jQuery File Upload Plugin 5.32.2
|
6
6
|
* https://github.com/blueimp/jQuery-File-Upload
|
7
7
|
*
|
8
8
|
* Copyright 2010, Sebastian Tschan
|
@@ -13,7 +13,7 @@
|
|
13
13
|
*/
|
14
14
|
|
15
15
|
/*jslint nomen: true, unparam: true, regexp: true */
|
16
|
-
/*global define, window, document, File, Blob, FormData
|
16
|
+
/*global define, window, document, location, File, Blob, FormData */
|
17
17
|
|
18
18
|
(function (factory) {
|
19
19
|
'use strict';
|
@@ -30,12 +30,28 @@
|
|
30
30
|
}(function ($) {
|
31
31
|
'use strict';
|
32
32
|
|
33
|
+
// Detect file input support, based on
|
34
|
+
// http://viljamis.com/blog/2012/file-upload-support-on-mobile/
|
35
|
+
$.support.fileInput = !(new RegExp(
|
36
|
+
// Handle devices which give false positives for the feature detection:
|
37
|
+
'(Android (1\\.[0156]|2\\.[01]))' +
|
38
|
+
'|(Windows Phone (OS 7|8\\.0))|(XBLWP)|(ZuneWP)|(WPDesktop)' +
|
39
|
+
'|(w(eb)?OSBrowser)|(webOS)' +
|
40
|
+
'|(Kindle/(1\\.0|2\\.[05]|3\\.0))'
|
41
|
+
).test(window.navigator.userAgent) ||
|
42
|
+
// Feature detection for all other devices:
|
43
|
+
$('<input type="file">').prop('disabled'));
|
44
|
+
|
33
45
|
// The FileReader API is not actually used, but works as feature detection,
|
34
46
|
// as e.g. Safari supports XHR file uploads via the FormData API,
|
35
47
|
// but not non-multipart XHR file uploads:
|
36
48
|
$.support.xhrFileUpload = !!(window.XMLHttpRequestUpload && window.FileReader);
|
37
49
|
$.support.xhrFormDataFileUpload = !!window.FormData;
|
38
50
|
|
51
|
+
// Detect support for Blob slicing (required for chunked uploads):
|
52
|
+
$.support.blobSlice = window.Blob && (Blob.prototype.slice ||
|
53
|
+
Blob.prototype.webkitSlice || Blob.prototype.mozSlice);
|
54
|
+
|
39
55
|
// The fileupload widget listens for change events on file input fields defined
|
40
56
|
// via fileInput setting and paste or drop events of the given dropZone.
|
41
57
|
// In addition to the default jQuery Widget methods, the fileupload widget
|
@@ -147,13 +163,16 @@
|
|
147
163
|
// The add callback is invoked as soon as files are added to the fileupload
|
148
164
|
// widget (via file input selection, drag & drop, paste or add API call).
|
149
165
|
// If the singleFileUploads option is enabled, this callback will be
|
150
|
-
// called once for each file in the selection for XHR file
|
166
|
+
// called once for each file in the selection for XHR file uploads, else
|
151
167
|
// once for each file selection.
|
168
|
+
//
|
152
169
|
// The upload starts when the submit method is invoked on the data parameter.
|
153
170
|
// The data object contains a files property holding the added files
|
154
|
-
// and allows to override plugin options as well as define ajax settings.
|
171
|
+
// and allows you to override plugin options as well as define ajax settings.
|
172
|
+
//
|
155
173
|
// Listeners for this callback can also be bound the following way:
|
156
174
|
// .bind('fileuploadadd', func);
|
175
|
+
//
|
157
176
|
// data.submit() returns a Promise object and allows to attach additional
|
158
177
|
// handlers using jQuery's Deferred callbacks:
|
159
178
|
// data.submit().done(func).fail(func).always(func);
|
@@ -236,6 +255,11 @@
|
|
236
255
|
'forceIframeTransport'
|
237
256
|
],
|
238
257
|
|
258
|
+
_blobSlice: $.support.blobSlice && function () {
|
259
|
+
var slice = this.slice || this.webkitSlice || this.mozSlice;
|
260
|
+
return slice.apply(this, arguments);
|
261
|
+
},
|
262
|
+
|
239
263
|
_BitrateTimer: function () {
|
240
264
|
this.timestamp = ((Date.now) ? Date.now() : (new Date()).getTime());
|
241
265
|
this.loaded = 0;
|
@@ -382,9 +406,11 @@
|
|
382
406
|
if (options.contentRange) {
|
383
407
|
options.headers['Content-Range'] = options.contentRange;
|
384
408
|
}
|
385
|
-
if (!multipart) {
|
409
|
+
if (!multipart || options.blob || !this._isInstanceOf('File', file)) {
|
386
410
|
options.headers['Content-Disposition'] = 'attachment; filename="' +
|
387
411
|
encodeURI(file.name) + '"';
|
412
|
+
}
|
413
|
+
if (!multipart) {
|
388
414
|
options.contentType = file.type;
|
389
415
|
options.data = options.blob || file;
|
390
416
|
} else if ($.support.xhrFormDataFileUpload) {
|
@@ -417,8 +443,6 @@
|
|
417
443
|
});
|
418
444
|
}
|
419
445
|
if (options.blob) {
|
420
|
-
options.headers['Content-Disposition'] = 'attachment; filename="' +
|
421
|
-
encodeURI(file.name) + '"';
|
422
446
|
formData.append(paramName, options.blob, file.name);
|
423
447
|
} else {
|
424
448
|
$.each(options.files, function (index, file) {
|
@@ -442,13 +466,13 @@
|
|
442
466
|
},
|
443
467
|
|
444
468
|
_initIframeSettings: function (options) {
|
469
|
+
var targetHost = $('<a></a>').prop('href', options.url).prop('host');
|
445
470
|
// Setting the dataType to iframe enables the iframe transport:
|
446
471
|
options.dataType = 'iframe ' + (options.dataType || '');
|
447
472
|
// The iframe transport accepts a serialized array as form data:
|
448
473
|
options.formData = this._getFormData(options);
|
449
474
|
// Add redirect url to form data on cross-domain uploads:
|
450
|
-
if (options.redirect &&
|
451
|
-
.prop('host') !== location.host) {
|
475
|
+
if (options.redirect && targetHost && targetHost !== location.host) {
|
452
476
|
options.formData.push({
|
453
477
|
name: options.redirectParamName || 'redirect',
|
454
478
|
value: options.redirect
|
@@ -630,12 +654,13 @@
|
|
630
654
|
// should be uploaded in chunks, but does not invoke any
|
631
655
|
// upload requests:
|
632
656
|
_chunkedUpload: function (options, testOnly) {
|
657
|
+
options.uploadedBytes = options.uploadedBytes || 0;
|
633
658
|
var that = this,
|
634
659
|
file = options.files[0],
|
635
660
|
fs = file.size,
|
636
|
-
ub = options.uploadedBytes
|
661
|
+
ub = options.uploadedBytes,
|
637
662
|
mcs = options.maxChunkSize || fs,
|
638
|
-
slice =
|
663
|
+
slice = this._blobSlice,
|
639
664
|
dfd = $.Deferred(),
|
640
665
|
promise = dfd.promise(),
|
641
666
|
jqXHR,
|
@@ -684,7 +709,7 @@
|
|
684
709
|
// Create a progress event if no final progress event
|
685
710
|
// with loaded equaling total has been triggered
|
686
711
|
// for this chunk:
|
687
|
-
if (o._progress.loaded
|
712
|
+
if (currentLoaded + o.chunkSize - o._progress.loaded) {
|
688
713
|
that._onProgress($.Event('progress', {
|
689
714
|
lengthComputable: true,
|
690
715
|
loaded: ub - o.uploadedBytes,
|
@@ -853,7 +878,8 @@
|
|
853
878
|
this._slots.push(slot);
|
854
879
|
pipe = slot.pipe(send);
|
855
880
|
} else {
|
856
|
-
|
881
|
+
this._sequence = this._sequence.pipe(send, send);
|
882
|
+
pipe = this._sequence;
|
857
883
|
}
|
858
884
|
// Return the piped Promise object, enhanced with an abort method,
|
859
885
|
// which is delegated to the jqXHR object of the current upload,
|
@@ -1103,9 +1129,9 @@
|
|
1103
1129
|
},
|
1104
1130
|
|
1105
1131
|
_onDrop: function (e) {
|
1132
|
+
e.dataTransfer = e.originalEvent && e.originalEvent.dataTransfer;
|
1106
1133
|
var that = this,
|
1107
|
-
dataTransfer = e.dataTransfer
|
1108
|
-
e.originalEvent.dataTransfer,
|
1134
|
+
dataTransfer = e.dataTransfer,
|
1109
1135
|
data = {};
|
1110
1136
|
if (dataTransfer && dataTransfer.files && dataTransfer.files.length) {
|
1111
1137
|
e.preventDefault();
|
@@ -1119,8 +1145,8 @@
|
|
1119
1145
|
},
|
1120
1146
|
|
1121
1147
|
_onDragOver: function (e) {
|
1122
|
-
|
1123
|
-
|
1148
|
+
e.dataTransfer = e.originalEvent && e.originalEvent.dataTransfer;
|
1149
|
+
var dataTransfer = e.dataTransfer;
|
1124
1150
|
if (dataTransfer) {
|
1125
1151
|
if (this._trigger('dragover', e) === false) {
|
1126
1152
|
return false;
|
@@ -1142,9 +1168,11 @@
|
|
1142
1168
|
paste: this._onPaste
|
1143
1169
|
});
|
1144
1170
|
}
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1171
|
+
if ($.support.fileInput) {
|
1172
|
+
this._on(this.options.fileInput, {
|
1173
|
+
change: this._onChange
|
1174
|
+
});
|
1175
|
+
}
|
1148
1176
|
},
|
1149
1177
|
|
1150
1178
|
_destroyEventHandlers: function () {
|
@@ -1278,6 +1306,10 @@
|
|
1278
1306
|
if (aborted) {
|
1279
1307
|
return;
|
1280
1308
|
}
|
1309
|
+
if (!files.length) {
|
1310
|
+
dfd.reject();
|
1311
|
+
return;
|
1312
|
+
}
|
1281
1313
|
data.files = files;
|
1282
1314
|
jqXHR = that._onSend(null, data).then(
|
1283
1315
|
function (result, textStatus, jqXHR) {
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* jQuery Iframe Transport Plugin 1.
|
2
|
+
* jQuery Iframe Transport Plugin 1.7
|
3
3
|
* https://github.com/blueimp/jQuery-File-Upload
|
4
4
|
*
|
5
5
|
* Copyright 2011, Sebastian Tschan
|
@@ -61,9 +61,10 @@
|
|
61
61
|
// IE versions below IE8 cannot set the name property of
|
62
62
|
// elements that have already been added to the DOM,
|
63
63
|
// so we set the name along with the iframe HTML markup:
|
64
|
+
counter += 1;
|
64
65
|
iframe = $(
|
65
66
|
'<iframe src="javascript:false;" name="iframe-transport-' +
|
66
|
-
|
67
|
+
counter + '"></iframe>'
|
67
68
|
).bind('load', function () {
|
68
69
|
var fileInputClones,
|
69
70
|
paramNames = $.isArray(options.paramName) ?
|
@@ -96,7 +97,12 @@
|
|
96
97
|
// (happens on form submits to iframe targets):
|
97
98
|
$('<iframe src="javascript:false;"></iframe>')
|
98
99
|
.appendTo(form);
|
99
|
-
|
100
|
+
window.setTimeout(function () {
|
101
|
+
// Removing the form in a setTimeout call
|
102
|
+
// allows Chrome's developer tools to display
|
103
|
+
// the response result
|
104
|
+
form.remove();
|
105
|
+
}, 0);
|
100
106
|
});
|
101
107
|
form
|
102
108
|
.prop('target', iframe.prop('name'))
|
@@ -164,7 +170,15 @@
|
|
164
170
|
});
|
165
171
|
|
166
172
|
// The iframe transport returns the iframe content document as response.
|
167
|
-
// The following adds converters from iframe to text, json, html,
|
173
|
+
// The following adds converters from iframe to text, json, html, xml
|
174
|
+
// and script.
|
175
|
+
// Please note that the Content-Type for JSON responses has to be text/plain
|
176
|
+
// or text/html, if the browser doesn't include application/json in the
|
177
|
+
// Accept header, else IE will show a download dialog.
|
178
|
+
// The Content-Type for XML responses on the other hand has to be always
|
179
|
+
// application/xml or text/xml, so IE properly parses the XML response.
|
180
|
+
// See also
|
181
|
+
// https://github.com/blueimp/jQuery-File-Upload/wiki/Setup#content-type-negotiation
|
168
182
|
$.ajaxSetup({
|
169
183
|
converters: {
|
170
184
|
'iframe text': function (iframe) {
|
@@ -176,6 +190,12 @@
|
|
176
190
|
'iframe html': function (iframe) {
|
177
191
|
return iframe && $(iframe[0].body).html();
|
178
192
|
},
|
193
|
+
'iframe xml': function (iframe) {
|
194
|
+
var xmlDoc = iframe && iframe[0];
|
195
|
+
return xmlDoc && $.isXMLDoc(xmlDoc) ? xmlDoc :
|
196
|
+
$.parseXML((xmlDoc.XMLDocument && xmlDoc.XMLDocument.xml) ||
|
197
|
+
$(xmlDoc.body).html());
|
198
|
+
},
|
179
199
|
'iframe script': function (iframe) {
|
180
200
|
return iframe && $.globalEval($(iframe[0].body).text());
|
181
201
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jquery.fileupload-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Semyon Perepelitsa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-05
|
11
|
+
date: 2013-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
prerelease: false
|