jquery-fileupload-rails 0.4.0 → 0.4.1
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.
- data/lib/jquery/fileupload/rails/version.rb +1 -1
- data/vendor/assets/javascripts/jquery-fileupload/cors/jquery.postmessage-transport.js +0 -0
- data/vendor/assets/javascripts/jquery-fileupload/cors/jquery.xdr-transport.js +7 -5
- data/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-fp.js +0 -0
- data/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-ui.js +92 -24
- data/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload.js +85 -29
- data/vendor/assets/javascripts/jquery-fileupload/jquery.iframe-transport.js +20 -14
- data/vendor/assets/javascripts/jquery-fileupload/vendor/jquery.ui.widget.js +49 -47
- data/vendor/assets/stylesheets/{jquery.fileupload-ui.css.erb → jquery.fileupload-ui.scss} +2 -2
- metadata +3 -3
File without changes
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* jQuery XDomainRequest Transport Plugin 1.1.
|
2
|
+
* jQuery XDomainRequest Transport Plugin 1.1.3
|
3
3
|
* https://github.com/blueimp/jQuery-File-Upload
|
4
4
|
*
|
5
5
|
* Copyright 2011, Sebastian Tschan
|
@@ -36,6 +36,7 @@
|
|
36
36
|
var xdr;
|
37
37
|
return {
|
38
38
|
send: function (headers, completeCallback) {
|
39
|
+
var addParamChar = /\?/.test(s.url) ? '&' : '?';
|
39
40
|
function callback(status, statusText, responses, responseHeaders) {
|
40
41
|
xdr.onload = xdr.onerror = xdr.ontimeout = $.noop;
|
41
42
|
xdr = null;
|
@@ -44,12 +45,13 @@
|
|
44
45
|
xdr = new XDomainRequest();
|
45
46
|
// XDomainRequest only supports GET and POST:
|
46
47
|
if (s.type === 'DELETE') {
|
47
|
-
s.url = s.url +
|
48
|
-
'_method=DELETE';
|
48
|
+
s.url = s.url + addParamChar + '_method=DELETE';
|
49
49
|
s.type = 'POST';
|
50
50
|
} else if (s.type === 'PUT') {
|
51
|
-
s.url = s.url +
|
52
|
-
|
51
|
+
s.url = s.url + addParamChar + '_method=PUT';
|
52
|
+
s.type = 'POST';
|
53
|
+
} else if (s.type === 'PATCH') {
|
54
|
+
s.url = s.url + addParamChar + '_method=PATCH';
|
53
55
|
s.type = 'POST';
|
54
56
|
}
|
55
57
|
xdr.open(s.type, s.url);
|
File without changes
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* jQuery File Upload User Interface Plugin
|
2
|
+
* jQuery File Upload User Interface Plugin 7.3
|
3
3
|
* https://github.com/blueimp/jQuery-File-Upload
|
4
4
|
*
|
5
5
|
* Copyright 2010, Sebastian Tschan
|
@@ -83,7 +83,8 @@
|
|
83
83
|
// widget (via file input selection, drag & drop or add API call).
|
84
84
|
// See the basic file upload widget for more information:
|
85
85
|
add: function (e, data) {
|
86
|
-
var that = $(this).data('fileupload')
|
86
|
+
var that = $(this).data('blueimp-fileupload') ||
|
87
|
+
$(this).data('fileupload'),
|
87
88
|
options = that.options,
|
88
89
|
files = data.files;
|
89
90
|
$(this).fileupload('process', data).done(function () {
|
@@ -94,7 +95,7 @@
|
|
94
95
|
options.filesContainer[
|
95
96
|
options.prependFiles ? 'prepend' : 'append'
|
96
97
|
](data.context);
|
97
|
-
that._renderPreviews(
|
98
|
+
that._renderPreviews(data);
|
98
99
|
that._forceReflow(data.context);
|
99
100
|
that._transition(data.context).done(
|
100
101
|
function () {
|
@@ -109,7 +110,8 @@
|
|
109
110
|
},
|
110
111
|
// Callback for the start of each file upload request:
|
111
112
|
send: function (e, data) {
|
112
|
-
var that = $(this).data('fileupload')
|
113
|
+
var that = $(this).data('blueimp-fileupload') ||
|
114
|
+
$(this).data('fileupload');
|
113
115
|
if (!data.isValidated) {
|
114
116
|
if (!data.maxNumberOfFilesAdjusted) {
|
115
117
|
that._adjustMaxNumberOfFiles(-data.files.length);
|
@@ -138,13 +140,16 @@
|
|
138
140
|
},
|
139
141
|
// Callback for successful uploads:
|
140
142
|
done: function (e, data) {
|
141
|
-
var that = $(this).data('fileupload')
|
142
|
-
|
143
|
+
var that = $(this).data('blueimp-fileupload') ||
|
144
|
+
$(this).data('fileupload'),
|
145
|
+
files = that._getFilesFromResponse(data),
|
146
|
+
template,
|
147
|
+
deferred;
|
143
148
|
if (data.context) {
|
144
149
|
data.context.each(function (index) {
|
145
|
-
var file =
|
146
|
-
|
147
|
-
|
150
|
+
var file = files[index] ||
|
151
|
+
{error: 'Empty file upload result'},
|
152
|
+
deferred = that._addFinishedDeferreds();
|
148
153
|
if (file.error) {
|
149
154
|
that._adjustMaxNumberOfFiles(1);
|
150
155
|
}
|
@@ -158,14 +163,16 @@
|
|
158
163
|
function () {
|
159
164
|
data.context = $(this);
|
160
165
|
that._trigger('completed', e, data);
|
166
|
+
that._trigger('finished', e, data);
|
167
|
+
deferred.resolve();
|
161
168
|
}
|
162
169
|
);
|
163
170
|
}
|
164
171
|
);
|
165
172
|
});
|
166
173
|
} else {
|
167
|
-
if (
|
168
|
-
$.each(
|
174
|
+
if (files.length) {
|
175
|
+
$.each(files, function (index, file) {
|
169
176
|
if (data.maxNumberOfFilesAdjusted && file.error) {
|
170
177
|
that._adjustMaxNumberOfFiles(1);
|
171
178
|
} else if (!data.maxNumberOfFilesAdjusted &&
|
@@ -175,21 +182,26 @@
|
|
175
182
|
});
|
176
183
|
data.maxNumberOfFilesAdjusted = true;
|
177
184
|
}
|
178
|
-
template = that._renderDownload(
|
185
|
+
template = that._renderDownload(files)
|
179
186
|
.appendTo(that.options.filesContainer);
|
180
187
|
that._forceReflow(template);
|
188
|
+
deferred = that._addFinishedDeferreds();
|
181
189
|
that._transition(template).done(
|
182
190
|
function () {
|
183
191
|
data.context = $(this);
|
184
192
|
that._trigger('completed', e, data);
|
193
|
+
that._trigger('finished', e, data);
|
194
|
+
deferred.resolve();
|
185
195
|
}
|
186
196
|
);
|
187
197
|
}
|
188
198
|
},
|
189
199
|
// Callback for failed (abort or error) uploads:
|
190
200
|
fail: function (e, data) {
|
191
|
-
var that = $(this).data('fileupload')
|
192
|
-
|
201
|
+
var that = $(this).data('blueimp-fileupload') ||
|
202
|
+
$(this).data('fileupload'),
|
203
|
+
template,
|
204
|
+
deferred;
|
193
205
|
if (data.maxNumberOfFilesAdjusted) {
|
194
206
|
that._adjustMaxNumberOfFiles(data.files.length);
|
195
207
|
}
|
@@ -199,6 +211,7 @@
|
|
199
211
|
var file = data.files[index];
|
200
212
|
file.error = file.error || data.errorThrown ||
|
201
213
|
true;
|
214
|
+
deferred = that._addFinishedDeferreds();
|
202
215
|
that._transition($(this)).done(
|
203
216
|
function () {
|
204
217
|
var node = $(this);
|
@@ -209,15 +222,20 @@
|
|
209
222
|
function () {
|
210
223
|
data.context = $(this);
|
211
224
|
that._trigger('failed', e, data);
|
225
|
+
that._trigger('finished', e, data);
|
226
|
+
deferred.resolve();
|
212
227
|
}
|
213
228
|
);
|
214
229
|
}
|
215
230
|
);
|
216
231
|
} else {
|
232
|
+
deferred = that._addFinishedDeferreds();
|
217
233
|
that._transition($(this)).done(
|
218
234
|
function () {
|
219
235
|
$(this).remove();
|
220
236
|
that._trigger('failed', e, data);
|
237
|
+
that._trigger('finished', e, data);
|
238
|
+
deferred.resolve();
|
221
239
|
}
|
222
240
|
);
|
223
241
|
}
|
@@ -227,14 +245,19 @@
|
|
227
245
|
.appendTo(that.options.filesContainer)
|
228
246
|
.data('data', data);
|
229
247
|
that._forceReflow(data.context);
|
248
|
+
deferred = that._addFinishedDeferreds();
|
230
249
|
that._transition(data.context).done(
|
231
250
|
function () {
|
232
251
|
data.context = $(this);
|
233
252
|
that._trigger('failed', e, data);
|
253
|
+
that._trigger('finished', e, data);
|
254
|
+
deferred.resolve();
|
234
255
|
}
|
235
256
|
);
|
236
257
|
} else {
|
237
258
|
that._trigger('failed', e, data);
|
259
|
+
that._trigger('finished', e, data);
|
260
|
+
that._addFinishedDeferreds().resolve();
|
238
261
|
}
|
239
262
|
},
|
240
263
|
// Callback for upload progress events:
|
@@ -258,7 +281,8 @@
|
|
258
281
|
.find('.progress-extended');
|
259
282
|
if (extendedProgressNode.length) {
|
260
283
|
extendedProgressNode.html(
|
261
|
-
$this.data('fileupload').
|
284
|
+
($this.data('blueimp-fileupload') || $this.data('fileupload'))
|
285
|
+
._renderExtendedProgress(data)
|
262
286
|
);
|
263
287
|
}
|
264
288
|
globalProgressNode
|
@@ -271,7 +295,9 @@
|
|
271
295
|
},
|
272
296
|
// Callback for uploads start, equivalent to the global ajaxStart event:
|
273
297
|
start: function (e) {
|
274
|
-
var that = $(this).data('fileupload')
|
298
|
+
var that = $(this).data('blueimp-fileupload') ||
|
299
|
+
$(this).data('fileupload');
|
300
|
+
that._resetFinishedDeferreds();
|
275
301
|
that._transition($(this).find('.fileupload-progress')).done(
|
276
302
|
function () {
|
277
303
|
that._trigger('started', e);
|
@@ -280,20 +306,27 @@
|
|
280
306
|
},
|
281
307
|
// Callback for uploads stop, equivalent to the global ajaxStop event:
|
282
308
|
stop: function (e) {
|
283
|
-
var that = $(this).data('fileupload')
|
309
|
+
var that = $(this).data('blueimp-fileupload') ||
|
310
|
+
$(this).data('fileupload'),
|
311
|
+
deferred = that._addFinishedDeferreds();
|
312
|
+
$.when.apply($, that._getFinishedDeferreds())
|
313
|
+
.done(function () {
|
314
|
+
that._trigger('stopped', e);
|
315
|
+
});
|
284
316
|
that._transition($(this).find('.fileupload-progress')).done(
|
285
317
|
function () {
|
286
318
|
$(this).find('.progress')
|
287
319
|
.attr('aria-valuenow', '0')
|
288
320
|
.find('.bar').css('width', '0%');
|
289
321
|
$(this).find('.progress-extended').html(' ');
|
290
|
-
|
322
|
+
deferred.resolve();
|
291
323
|
}
|
292
324
|
);
|
293
325
|
},
|
294
326
|
// Callback for file deletion:
|
295
327
|
destroy: function (e, data) {
|
296
|
-
var that = $(this).data('fileupload')
|
328
|
+
var that = $(this).data('blueimp-fileupload') ||
|
329
|
+
$(this).data('fileupload');
|
297
330
|
if (data.url) {
|
298
331
|
$.ajax(data);
|
299
332
|
that._adjustMaxNumberOfFiles(1);
|
@@ -307,6 +340,29 @@
|
|
307
340
|
}
|
308
341
|
},
|
309
342
|
|
343
|
+
_resetFinishedDeferreds: function () {
|
344
|
+
this._finishedUploads = [];
|
345
|
+
},
|
346
|
+
|
347
|
+
_addFinishedDeferreds: function (deferred) {
|
348
|
+
if (!deferred) {
|
349
|
+
deferred = $.Deferred();
|
350
|
+
}
|
351
|
+
this._finishedUploads.push(deferred);
|
352
|
+
return deferred;
|
353
|
+
},
|
354
|
+
|
355
|
+
_getFinishedDeferreds: function () {
|
356
|
+
return this._finishedUploads;
|
357
|
+
},
|
358
|
+
|
359
|
+
_getFilesFromResponse: function (data) {
|
360
|
+
if (data.result && $.isArray(data.result.files)) {
|
361
|
+
return data.result.files;
|
362
|
+
}
|
363
|
+
return [];
|
364
|
+
},
|
365
|
+
|
310
366
|
// Link handler, that allows to download files
|
311
367
|
// by drag & drop of the links to the desktop:
|
312
368
|
_enableDragToDesktop: function () {
|
@@ -361,7 +417,7 @@
|
|
361
417
|
if (bits >= 1000) {
|
362
418
|
return (bits / 1000).toFixed(2) + ' kbit/s';
|
363
419
|
}
|
364
|
-
return bits + ' bit/s';
|
420
|
+
return bits.toFixed(2) + ' bit/s';
|
365
421
|
},
|
366
422
|
|
367
423
|
_formatTime: function (seconds) {
|
@@ -472,18 +528,22 @@
|
|
472
528
|
)) || dfd.resolveWith(node)) && dfd;
|
473
529
|
},
|
474
530
|
|
475
|
-
_renderPreviews: function (
|
531
|
+
_renderPreviews: function (data) {
|
476
532
|
var that = this,
|
477
533
|
options = this.options;
|
478
|
-
|
479
|
-
var file = files[index];
|
534
|
+
data.context.find('.preview span').each(function (index, element) {
|
535
|
+
var file = data.files[index];
|
480
536
|
if (options.previewSourceFileTypes.test(file.type) &&
|
481
537
|
($.type(options.previewSourceMaxFileSize) !== 'number' ||
|
482
538
|
file.size < options.previewSourceMaxFileSize)) {
|
483
539
|
that._processingQueue = that._processingQueue.pipe(function () {
|
484
|
-
var dfd = $.Deferred()
|
540
|
+
var dfd = $.Deferred(),
|
541
|
+
ev = $.Event('previewdone', {
|
542
|
+
target: element
|
543
|
+
});
|
485
544
|
that._renderPreview(file, $(element)).done(
|
486
545
|
function () {
|
546
|
+
that._trigger(ev.type, ev, data);
|
487
547
|
dfd.resolveWith(that);
|
488
548
|
}
|
489
549
|
);
|
@@ -691,6 +751,13 @@
|
|
691
751
|
this._initRegExpOptions();
|
692
752
|
},
|
693
753
|
|
754
|
+
_setOption: function (key, value) {
|
755
|
+
this._super(key, value);
|
756
|
+
if (key === 'maxNumberOfFiles') {
|
757
|
+
this._adjustMaxNumberOfFiles(0);
|
758
|
+
}
|
759
|
+
},
|
760
|
+
|
694
761
|
_create: function () {
|
695
762
|
this._super();
|
696
763
|
this._refreshOptionsList.push(
|
@@ -704,6 +771,7 @@
|
|
704
771
|
return this._processingQueue;
|
705
772
|
};
|
706
773
|
}
|
774
|
+
this._resetFinishedDeferreds();
|
707
775
|
},
|
708
776
|
|
709
777
|
enable: function () {
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* jQuery File Upload Plugin 5.
|
2
|
+
* jQuery File Upload Plugin 5.21
|
3
3
|
* https://github.com/blueimp/jQuery-File-Upload
|
4
4
|
*
|
5
5
|
* Copyright 2010, Sebastian Tschan
|
@@ -10,7 +10,7 @@
|
|
10
10
|
*/
|
11
11
|
|
12
12
|
/*jslint nomen: true, unparam: true, regexp: true */
|
13
|
-
/*global define, window, document, Blob, FormData, location */
|
13
|
+
/*global define, window, document, File, Blob, FormData, location */
|
14
14
|
|
15
15
|
(function (factory) {
|
16
16
|
'use strict';
|
@@ -33,6 +33,21 @@
|
|
33
33
|
$.support.xhrFileUpload = !!(window.XMLHttpRequestUpload && window.FileReader);
|
34
34
|
$.support.xhrFormDataFileUpload = !!window.FormData;
|
35
35
|
|
36
|
+
// The form.elements propHook is added to filter serialized elements
|
37
|
+
// to not include file inputs in jQuery 1.9.0.
|
38
|
+
// This hooks directly into jQuery.fn.serializeArray.
|
39
|
+
// For more info, see http://bugs.jquery.com/ticket/13306
|
40
|
+
$.propHooks.elements = {
|
41
|
+
get: function (form) {
|
42
|
+
if ($.nodeName(form, 'form')) {
|
43
|
+
return $.grep(form.elements, function (elem) {
|
44
|
+
return !$.nodeName(elem, 'input') || elem.type !== 'file';
|
45
|
+
});
|
46
|
+
}
|
47
|
+
return null;
|
48
|
+
}
|
49
|
+
};
|
50
|
+
|
36
51
|
// The fileupload widget listens for change events on file input fields defined
|
37
52
|
// via fileInput setting and paste or drop events of the given dropZone.
|
38
53
|
// In addition to the default jQuery Widget methods, the fileupload widget
|
@@ -140,33 +155,58 @@
|
|
140
155
|
},
|
141
156
|
|
142
157
|
// Other callbacks:
|
158
|
+
|
143
159
|
// Callback for the submit event of each file upload:
|
144
160
|
// submit: function (e, data) {}, // .bind('fileuploadsubmit', func);
|
161
|
+
|
145
162
|
// Callback for the start of each file upload request:
|
146
163
|
// send: function (e, data) {}, // .bind('fileuploadsend', func);
|
164
|
+
|
147
165
|
// Callback for successful uploads:
|
148
166
|
// done: function (e, data) {}, // .bind('fileuploaddone', func);
|
167
|
+
|
149
168
|
// Callback for failed (abort or error) uploads:
|
150
169
|
// fail: function (e, data) {}, // .bind('fileuploadfail', func);
|
170
|
+
|
151
171
|
// Callback for completed (success, abort or error) requests:
|
152
172
|
// always: function (e, data) {}, // .bind('fileuploadalways', func);
|
173
|
+
|
153
174
|
// Callback for upload progress events:
|
154
175
|
// progress: function (e, data) {}, // .bind('fileuploadprogress', func);
|
176
|
+
|
155
177
|
// Callback for global upload progress events:
|
156
178
|
// progressall: function (e, data) {}, // .bind('fileuploadprogressall', func);
|
179
|
+
|
157
180
|
// Callback for uploads start, equivalent to the global ajaxStart event:
|
158
181
|
// start: function (e) {}, // .bind('fileuploadstart', func);
|
182
|
+
|
159
183
|
// Callback for uploads stop, equivalent to the global ajaxStop event:
|
160
184
|
// stop: function (e) {}, // .bind('fileuploadstop', func);
|
185
|
+
|
161
186
|
// Callback for change events of the fileInput(s):
|
162
187
|
// change: function (e, data) {}, // .bind('fileuploadchange', func);
|
188
|
+
|
163
189
|
// Callback for paste events to the pasteZone(s):
|
164
190
|
// paste: function (e, data) {}, // .bind('fileuploadpaste', func);
|
191
|
+
|
165
192
|
// Callback for drop events of the dropZone(s):
|
166
193
|
// drop: function (e, data) {}, // .bind('fileuploaddrop', func);
|
194
|
+
|
167
195
|
// Callback for dragover events of the dropZone(s):
|
168
196
|
// dragover: function (e) {}, // .bind('fileuploaddragover', func);
|
169
197
|
|
198
|
+
// Callback for the start of each chunk upload request:
|
199
|
+
// chunksend: function (e, data) {}, // .bind('fileuploadchunksend', func);
|
200
|
+
|
201
|
+
// Callback for successful chunk uploads:
|
202
|
+
// chunkdone: function (e, data) {}, // .bind('fileuploadchunkdone', func);
|
203
|
+
|
204
|
+
// Callback for failed (abort or error) chunk uploads:
|
205
|
+
// chunkfail: function (e, data) {}, // .bind('fileuploadchunkfail', func);
|
206
|
+
|
207
|
+
// Callback for completed (success, abort or error) chunk upload requests:
|
208
|
+
// chunkalways: function (e, data) {}, // .bind('fileuploadchunkalways', func);
|
209
|
+
|
170
210
|
// The plugin options are used as settings object for the ajax calls.
|
171
211
|
// The following are jQuery ajax settings required for the file uploads:
|
172
212
|
processData: false,
|
@@ -209,10 +249,10 @@
|
|
209
249
|
if (typeof options.formData === 'function') {
|
210
250
|
return options.formData(options.form);
|
211
251
|
}
|
212
|
-
|
252
|
+
if ($.isArray(options.formData)) {
|
213
253
|
return options.formData;
|
214
254
|
}
|
215
|
-
|
255
|
+
if (options.formData) {
|
216
256
|
formData = [];
|
217
257
|
$.each(options.formData, function (name, value) {
|
218
258
|
formData.push({name: name, value: value});
|
@@ -341,14 +381,15 @@
|
|
341
381
|
if (options.blob) {
|
342
382
|
options.headers['Content-Disposition'] = 'attachment; filename="' +
|
343
383
|
encodeURI(file.name) + '"';
|
344
|
-
options.headers['Content-Description'] = encodeURI(file.type);
|
345
384
|
formData.append(paramName, options.blob, file.name);
|
346
385
|
} else {
|
347
386
|
$.each(options.files, function (index, file) {
|
348
|
-
//
|
387
|
+
// Files are also Blob instances, but some browsers
|
388
|
+
// (Firefox 3.6) support the File API but not Blobs.
|
349
389
|
// This check allows the tests to run with
|
350
390
|
// dummy objects:
|
351
|
-
if (file instanceof Blob)
|
391
|
+
if ((window.Blob && file instanceof Blob) ||
|
392
|
+
(window.File && file instanceof File)) {
|
352
393
|
formData.append(
|
353
394
|
options.paramName[index] || paramName,
|
354
395
|
file,
|
@@ -438,7 +479,8 @@
|
|
438
479
|
// The HTTP request method must be "POST" or "PUT":
|
439
480
|
options.type = (options.type || options.form.prop('method') || '')
|
440
481
|
.toUpperCase();
|
441
|
-
if (options.type !== 'POST' && options.type !== 'PUT'
|
482
|
+
if (options.type !== 'POST' && options.type !== 'PUT' &&
|
483
|
+
options.type !== 'PATCH') {
|
442
484
|
options.type = 'POST';
|
443
485
|
}
|
444
486
|
if (!options.formAcceptCharset) {
|
@@ -525,7 +567,8 @@
|
|
525
567
|
o.blob = slice.call(
|
526
568
|
file,
|
527
569
|
ub,
|
528
|
-
ub + mcs
|
570
|
+
ub + mcs,
|
571
|
+
file.type
|
529
572
|
);
|
530
573
|
// Store the current chunk size, as the blob itself
|
531
574
|
// will be dereferenced after data processing:
|
@@ -537,13 +580,15 @@
|
|
537
580
|
that._initXHRData(o);
|
538
581
|
// Add progress listeners for this chunk upload:
|
539
582
|
that._initProgressListener(o);
|
540
|
-
jqXHR = (
|
583
|
+
jqXHR = ((that._trigger('chunksend', null, o) !== false && $.ajax(o)) ||
|
584
|
+
that._getXHRPromise(false, o.context))
|
541
585
|
.done(function (result, textStatus, jqXHR) {
|
542
586
|
ub = that._getUploadedBytes(jqXHR) ||
|
543
587
|
(ub + o.chunkSize);
|
544
|
-
// Create a progress event if upload is done and
|
545
|
-
//
|
546
|
-
|
588
|
+
// Create a progress event if upload is done and no progress
|
589
|
+
// event has been invoked for this chunk, or there has been
|
590
|
+
// no progress event with loaded equaling total:
|
591
|
+
if (!o.loaded || o.loaded < o.total) {
|
547
592
|
that._onProgress($.Event('progress', {
|
548
593
|
lengthComputable: true,
|
549
594
|
loaded: ub - o.uploadedBytes,
|
@@ -551,6 +596,11 @@
|
|
551
596
|
}), o);
|
552
597
|
}
|
553
598
|
options.uploadedBytes = o.uploadedBytes = ub;
|
599
|
+
o.result = result;
|
600
|
+
o.textStatus = textStatus;
|
601
|
+
o.jqXHR = jqXHR;
|
602
|
+
that._trigger('chunkdone', null, o);
|
603
|
+
that._trigger('chunkalways', null, o);
|
554
604
|
if (ub < fs) {
|
555
605
|
// File upload not yet complete,
|
556
606
|
// continue with the next chunk:
|
@@ -563,6 +613,11 @@
|
|
563
613
|
}
|
564
614
|
})
|
565
615
|
.fail(function (jqXHR, textStatus, errorThrown) {
|
616
|
+
o.jqXHR = jqXHR;
|
617
|
+
o.textStatus = textStatus;
|
618
|
+
o.errorThrown = errorThrown;
|
619
|
+
that._trigger('chunkfail', null, o);
|
620
|
+
that._trigger('chunkalways', null, o);
|
566
621
|
dfd.rejectWith(
|
567
622
|
o.context,
|
568
623
|
[jqXHR, textStatus, errorThrown]
|
@@ -593,12 +648,16 @@
|
|
593
648
|
},
|
594
649
|
|
595
650
|
_onDone: function (result, textStatus, jqXHR, options) {
|
596
|
-
if (!this._isXHRUpload(options)
|
597
|
-
|
651
|
+
if (!this._isXHRUpload(options) || !options.loaded ||
|
652
|
+
options.loaded < options.total) {
|
653
|
+
var total = this._getTotal(options.files) || 1;
|
654
|
+
// Create a progress event for each iframe load,
|
655
|
+
// or if there has been no progress event with
|
656
|
+
// loaded equaling total for XHR uploads:
|
598
657
|
this._onProgress($.Event('progress', {
|
599
658
|
lengthComputable: true,
|
600
|
-
loaded:
|
601
|
-
total:
|
659
|
+
loaded: total,
|
660
|
+
total: total
|
602
661
|
}), options);
|
603
662
|
}
|
604
663
|
options.result = result;
|
@@ -621,15 +680,9 @@
|
|
621
680
|
},
|
622
681
|
|
623
682
|
_onAlways: function (jqXHRorResult, textStatus, jqXHRorError, options) {
|
683
|
+
// jqXHRorResult, textStatus and jqXHRorError are added to the
|
684
|
+
// options object via done and fail callbacks
|
624
685
|
this._active -= 1;
|
625
|
-
options.textStatus = textStatus;
|
626
|
-
if (jqXHRorError && jqXHRorError.always) {
|
627
|
-
options.jqXHR = jqXHRorError;
|
628
|
-
options.result = jqXHRorResult;
|
629
|
-
} else {
|
630
|
-
options.jqXHR = jqXHRorResult;
|
631
|
-
options.errorThrown = jqXHRorError;
|
632
|
-
}
|
633
686
|
this._trigger('always', null, options);
|
634
687
|
if (this._active === 0) {
|
635
688
|
// The stop callback is triggered when all uploads have
|
@@ -758,7 +811,8 @@
|
|
758
811
|
that._onSend(e, this);
|
759
812
|
return this.jqXHR;
|
760
813
|
};
|
761
|
-
|
814
|
+
result = that._trigger('add', e, newData);
|
815
|
+
return result;
|
762
816
|
});
|
763
817
|
return result;
|
764
818
|
},
|
@@ -949,10 +1003,12 @@
|
|
949
1003
|
},
|
950
1004
|
|
951
1005
|
_onDrop: function (e) {
|
952
|
-
e.preventDefault();
|
953
1006
|
var that = this,
|
954
1007
|
dataTransfer = e.dataTransfer = e.originalEvent.dataTransfer,
|
955
1008
|
data = {};
|
1009
|
+
if (dataTransfer && dataTransfer.files && dataTransfer.files.length) {
|
1010
|
+
e.preventDefault();
|
1011
|
+
}
|
956
1012
|
this._getDroppedFiles(dataTransfer).always(function (files) {
|
957
1013
|
data.files = files;
|
958
1014
|
if (that._trigger('drop', e, data) !== false) {
|
@@ -966,10 +1022,10 @@
|
|
966
1022
|
if (this._trigger('dragover', e) === false) {
|
967
1023
|
return false;
|
968
1024
|
}
|
969
|
-
if (dataTransfer) {
|
1025
|
+
if (dataTransfer && $.inArray('Files', dataTransfer.types) !== -1) {
|
970
1026
|
dataTransfer.dropEffect = 'copy';
|
1027
|
+
e.preventDefault();
|
971
1028
|
}
|
972
|
-
e.preventDefault();
|
973
1029
|
},
|
974
1030
|
|
975
1031
|
_initEventHandlers: function () {
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* jQuery Iframe Transport Plugin 1.
|
2
|
+
* jQuery Iframe Transport Plugin 1.6.1
|
3
3
|
* https://github.com/blueimp/jQuery-File-Upload
|
4
4
|
*
|
5
5
|
* Copyright 2011, Sebastian Tschan
|
@@ -36,13 +36,26 @@
|
|
36
36
|
// equivalent to the return data of .serializeArray(), e.g.:
|
37
37
|
// [{name: 'a', value: 1}, {name: 'b', value: 2}]
|
38
38
|
$.ajaxTransport('iframe', function (options) {
|
39
|
-
if (options.async
|
39
|
+
if (options.async) {
|
40
40
|
var form,
|
41
|
-
iframe
|
41
|
+
iframe,
|
42
|
+
addParamChar;
|
42
43
|
return {
|
43
44
|
send: function (_, completeCallback) {
|
44
45
|
form = $('<form style="display:none;"></form>');
|
45
46
|
form.attr('accept-charset', options.formAcceptCharset);
|
47
|
+
addParamChar = /\?/.test(options.url) ? '&' : '?';
|
48
|
+
// XDomainRequest only supports GET and POST:
|
49
|
+
if (options.type === 'DELETE') {
|
50
|
+
options.url = options.url + addParamChar + '_method=DELETE';
|
51
|
+
options.type = 'POST';
|
52
|
+
} else if (options.type === 'PUT') {
|
53
|
+
options.url = options.url + addParamChar + '_method=PUT';
|
54
|
+
options.type = 'POST';
|
55
|
+
} else if (options.type === 'PATCH') {
|
56
|
+
options.url = options.url + addParamChar + '_method=PATCH';
|
57
|
+
options.type = 'POST';
|
58
|
+
}
|
46
59
|
// javascript:false as initial iframe src
|
47
60
|
// prevents warning popups on HTTPS in IE6.
|
48
61
|
// IE versions below IE8 cannot set the name property of
|
@@ -96,13 +109,6 @@
|
|
96
109
|
.val(field.value)
|
97
110
|
.appendTo(form);
|
98
111
|
});
|
99
|
-
// Add a hidden `X-Requested-With` field with the value `IFrame` to the
|
100
|
-
// form, to help server-side code to determine that the upload happened
|
101
|
-
// through this transport.
|
102
|
-
$('<input type="hidden" />')
|
103
|
-
.prop('name', 'X-Requested-With')
|
104
|
-
.val('IFrame')
|
105
|
-
.appendTo(form);
|
106
112
|
}
|
107
113
|
if (options.fileInput && options.fileInput.length &&
|
108
114
|
options.type === 'POST') {
|
@@ -162,16 +168,16 @@
|
|
162
168
|
$.ajaxSetup({
|
163
169
|
converters: {
|
164
170
|
'iframe text': function (iframe) {
|
165
|
-
return $(iframe[0].body).text();
|
171
|
+
return iframe && $(iframe[0].body).text();
|
166
172
|
},
|
167
173
|
'iframe json': function (iframe) {
|
168
|
-
return $.parseJSON($(iframe[0].body).text());
|
174
|
+
return iframe && $.parseJSON($(iframe[0].body).text());
|
169
175
|
},
|
170
176
|
'iframe html': function (iframe) {
|
171
|
-
return $(iframe[0].body).html();
|
177
|
+
return iframe && $(iframe[0].body).html();
|
172
178
|
},
|
173
179
|
'iframe script': function (iframe) {
|
174
|
-
return $.globalEval($(iframe[0].body).text());
|
180
|
+
return iframe && $.globalEval($(iframe[0].body).text());
|
175
181
|
}
|
176
182
|
}
|
177
183
|
});
|
@@ -1,8 +1,8 @@
|
|
1
1
|
/*
|
2
|
-
* jQuery UI Widget 1.
|
2
|
+
* jQuery UI Widget 1.10.0+amd
|
3
3
|
* https://github.com/blueimp/jQuery-File-Upload
|
4
4
|
*
|
5
|
-
* Copyright
|
5
|
+
* Copyright 2013 jQuery Foundation and other contributors
|
6
6
|
* Released under the MIT license.
|
7
7
|
* http://jquery.org/license
|
8
8
|
*
|
@@ -34,6 +34,9 @@ $.cleanData = function( elems ) {
|
|
34
34
|
|
35
35
|
$.widget = function( name, base, prototype ) {
|
36
36
|
var fullName, existingConstructor, constructor, basePrototype,
|
37
|
+
// proxiedPrototype allows the provided prototype to remain unmodified
|
38
|
+
// so that it can be used as a mixin for multiple widgets (#8876)
|
39
|
+
proxiedPrototype = {},
|
37
40
|
namespace = name.split( "." )[ 0 ];
|
38
41
|
|
39
42
|
name = name.split( "." )[ 1 ];
|
@@ -80,43 +83,43 @@ $.widget = function( name, base, prototype ) {
|
|
80
83
|
// inheriting from
|
81
84
|
basePrototype.options = $.widget.extend( {}, basePrototype.options );
|
82
85
|
$.each( prototype, function( prop, value ) {
|
83
|
-
if (
|
84
|
-
|
85
|
-
|
86
|
-
return base.prototype[ prop ].apply( this, arguments );
|
87
|
-
},
|
88
|
-
_superApply = function( args ) {
|
89
|
-
return base.prototype[ prop ].apply( this, args );
|
90
|
-
};
|
91
|
-
return function() {
|
92
|
-
var __super = this._super,
|
93
|
-
__superApply = this._superApply,
|
94
|
-
returnValue;
|
95
|
-
|
96
|
-
this._super = _super;
|
97
|
-
this._superApply = _superApply;
|
98
|
-
|
99
|
-
returnValue = value.apply( this, arguments );
|
100
|
-
|
101
|
-
this._super = __super;
|
102
|
-
this._superApply = __superApply;
|
103
|
-
|
104
|
-
return returnValue;
|
105
|
-
};
|
106
|
-
})();
|
86
|
+
if ( !$.isFunction( value ) ) {
|
87
|
+
proxiedPrototype[ prop ] = value;
|
88
|
+
return;
|
107
89
|
}
|
90
|
+
proxiedPrototype[ prop ] = (function() {
|
91
|
+
var _super = function() {
|
92
|
+
return base.prototype[ prop ].apply( this, arguments );
|
93
|
+
},
|
94
|
+
_superApply = function( args ) {
|
95
|
+
return base.prototype[ prop ].apply( this, args );
|
96
|
+
};
|
97
|
+
return function() {
|
98
|
+
var __super = this._super,
|
99
|
+
__superApply = this._superApply,
|
100
|
+
returnValue;
|
101
|
+
|
102
|
+
this._super = _super;
|
103
|
+
this._superApply = _superApply;
|
104
|
+
|
105
|
+
returnValue = value.apply( this, arguments );
|
106
|
+
|
107
|
+
this._super = __super;
|
108
|
+
this._superApply = __superApply;
|
109
|
+
|
110
|
+
return returnValue;
|
111
|
+
};
|
112
|
+
})();
|
108
113
|
});
|
109
114
|
constructor.prototype = $.widget.extend( basePrototype, {
|
110
115
|
// TODO: remove support for widgetEventPrefix
|
111
116
|
// always use the name + a colon as the prefix, e.g., draggable:start
|
112
117
|
// don't prefix for widgets that aren't DOM-based
|
113
|
-
widgetEventPrefix: basePrototype.widgetEventPrefix
|
114
|
-
},
|
118
|
+
widgetEventPrefix: existingConstructor ? basePrototype.widgetEventPrefix : name
|
119
|
+
}, proxiedPrototype, {
|
115
120
|
constructor: constructor,
|
116
121
|
namespace: namespace,
|
117
122
|
widgetName: name,
|
118
|
-
// TODO remove widgetBaseClass, see #8155
|
119
|
-
widgetBaseClass: fullName,
|
120
123
|
widgetFullName: fullName
|
121
124
|
});
|
122
125
|
|
@@ -169,7 +172,7 @@ $.widget.extend = function( target ) {
|
|
169
172
|
};
|
170
173
|
|
171
174
|
$.widget.bridge = function( name, object ) {
|
172
|
-
var fullName = object.prototype.widgetFullName;
|
175
|
+
var fullName = object.prototype.widgetFullName || name;
|
173
176
|
$.fn[ name ] = function( options ) {
|
174
177
|
var isMethodCall = typeof options === "string",
|
175
178
|
args = slice.call( arguments, 1 ),
|
@@ -205,7 +208,7 @@ $.widget.bridge = function( name, object ) {
|
|
205
208
|
if ( instance ) {
|
206
209
|
instance.option( options || {} )._init();
|
207
210
|
} else {
|
208
|
-
new object( options, this );
|
211
|
+
$.data( this, fullName, new object( options, this ) );
|
209
212
|
}
|
210
213
|
});
|
211
214
|
}
|
@@ -242,11 +245,8 @@ $.Widget.prototype = {
|
|
242
245
|
this.focusable = $();
|
243
246
|
|
244
247
|
if ( element !== this ) {
|
245
|
-
// 1.9 BC for #7810
|
246
|
-
// TODO remove dual storage
|
247
|
-
$.data( element, this.widgetName, this );
|
248
248
|
$.data( element, this.widgetFullName, this );
|
249
|
-
this._on( this.element, {
|
249
|
+
this._on( true, this.element, {
|
250
250
|
remove: function( event ) {
|
251
251
|
if ( event.target === element ) {
|
252
252
|
this.destroy();
|
@@ -370,9 +370,17 @@ $.Widget.prototype = {
|
|
370
370
|
return this._setOption( "disabled", true );
|
371
371
|
},
|
372
372
|
|
373
|
-
_on: function( element, handlers ) {
|
373
|
+
_on: function( suppressDisabledCheck, element, handlers ) {
|
374
374
|
var delegateElement,
|
375
375
|
instance = this;
|
376
|
+
|
377
|
+
// no suppressDisabledCheck flag, shuffle arguments
|
378
|
+
if ( typeof suppressDisabledCheck !== "boolean" ) {
|
379
|
+
handlers = element;
|
380
|
+
element = suppressDisabledCheck;
|
381
|
+
suppressDisabledCheck = false;
|
382
|
+
}
|
383
|
+
|
376
384
|
// no element argument, shuffle and use this.element
|
377
385
|
if ( !handlers ) {
|
378
386
|
handlers = element;
|
@@ -389,8 +397,9 @@ $.Widget.prototype = {
|
|
389
397
|
// allow widgets to customize the disabled handling
|
390
398
|
// - disabled as an array instead of boolean
|
391
399
|
// - disabled class as method for disabling individual parts
|
392
|
-
if (
|
393
|
-
|
400
|
+
if ( !suppressDisabledCheck &&
|
401
|
+
( instance.options.disabled === true ||
|
402
|
+
$( this ).hasClass( "ui-state-disabled" ) ) ) {
|
394
403
|
return;
|
395
404
|
}
|
396
405
|
return ( typeof handler === "string" ? instance[ handler ] : handler )
|
@@ -502,7 +511,7 @@ $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
|
|
502
511
|
if ( options.delay ) {
|
503
512
|
element.delay( options.delay );
|
504
513
|
}
|
505
|
-
if ( hasOptions && $.effects &&
|
514
|
+
if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
|
506
515
|
element[ method ]( options );
|
507
516
|
} else if ( effectName !== method && element[ effectName ] ) {
|
508
517
|
element[ effectName ]( options.duration, options.easing, callback );
|
@@ -518,11 +527,4 @@ $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
|
|
518
527
|
};
|
519
528
|
});
|
520
529
|
|
521
|
-
// DEPRECATED
|
522
|
-
if ( $.uiBackCompat !== false ) {
|
523
|
-
$.Widget.prototype._getCreateOptions = function() {
|
524
|
-
return $.metadata && $.metadata.get( this.element[0] )[ this.widgetName ];
|
525
|
-
};
|
526
|
-
}
|
527
|
-
|
528
530
|
}));
|
@@ -37,7 +37,7 @@
|
|
37
37
|
width: 200px;
|
38
38
|
}
|
39
39
|
.progress-animated .bar {
|
40
|
-
background: url(
|
40
|
+
background: image-url('progressbar.gif') !important;
|
41
41
|
filter: none;
|
42
42
|
}
|
43
43
|
.fileupload-loading {
|
@@ -45,7 +45,7 @@
|
|
45
45
|
left: 50%;
|
46
46
|
width: 128px;
|
47
47
|
height: 128px;
|
48
|
-
background: url(
|
48
|
+
background: image-url('loading.gif') center no-repeat;
|
49
49
|
display: none;
|
50
50
|
}
|
51
51
|
.fileupload-processing .fileupload-loading {
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jquery-fileupload-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
@@ -87,7 +87,7 @@ files:
|
|
87
87
|
- vendor/assets/javascripts/jquery-fileupload/vendor/jquery.ui.widget.js
|
88
88
|
- vendor/assets/javascripts/jquery-fileupload/vendor/load-image.js
|
89
89
|
- vendor/assets/javascripts/jquery-fileupload/vendor/tmpl.js
|
90
|
-
- vendor/assets/stylesheets/jquery.fileupload-ui.
|
90
|
+
- vendor/assets/stylesheets/jquery.fileupload-ui.scss
|
91
91
|
- Rakefile
|
92
92
|
- README.md
|
93
93
|
homepage: https://github.com/tors/jquery-fileupload-rails
|