rails-jquery-fileupload 1.0.2

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.
Files changed (27) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +67 -0
  3. data/Rakefile +15 -0
  4. data/lib/jquery/fileupload/rails/engine.rb +8 -0
  5. data/lib/jquery/fileupload/rails/middleware.rb +59 -0
  6. data/lib/jquery/fileupload/rails/upload.rb +3 -0
  7. data/lib/jquery/fileupload/rails/version.rb +7 -0
  8. data/lib/rails-jquery-fileupload.rb +8 -0
  9. data/vendor/assets/images/loading.gif +0 -0
  10. data/vendor/assets/javascripts/jquery-fileupload/all.js +13 -0
  11. data/vendor/assets/javascripts/jquery-fileupload/basic.js +4 -0
  12. data/vendor/assets/javascripts/jquery-fileupload/cors/jquery.postmessage-transport.js +117 -0
  13. data/vendor/assets/javascripts/jquery-fileupload/cors/jquery.xdr-transport.js +87 -0
  14. data/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-audio.js +106 -0
  15. data/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-image.js +309 -0
  16. data/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-process.js +172 -0
  17. data/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-ui.js +699 -0
  18. data/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-validate.js +119 -0
  19. data/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-video.js +106 -0
  20. data/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload.js +1420 -0
  21. data/vendor/assets/javascripts/jquery-fileupload/jquery.iframe-transport.js +214 -0
  22. data/vendor/assets/javascripts/jquery-fileupload/locale.js +29 -0
  23. data/vendor/assets/javascripts/jquery-fileupload/vendor/canvas-to-blob.js +95 -0
  24. data/vendor/assets/javascripts/jquery-fileupload/vendor/jquery.ui.widget.js +530 -0
  25. data/vendor/assets/javascripts/jquery-fileupload/vendor/load-image.js +1446 -0
  26. data/vendor/assets/javascripts/jquery-fileupload/vendor/tmpl.js +87 -0
  27. metadata +111 -0
@@ -0,0 +1,699 @@
1
+ /*
2
+ * jQuery File Upload User Interface Plugin 9.4.1
3
+ * https://github.com/blueimp/jQuery-File-Upload
4
+ *
5
+ * Copyright 2010, Sebastian Tschan
6
+ * https://blueimp.net
7
+ *
8
+ * Licensed under the MIT license:
9
+ * http://www.opensource.org/licenses/MIT
10
+ */
11
+
12
+ /* jshint nomen:false */
13
+ /* global define, window */
14
+
15
+ (function (factory) {
16
+ 'use strict';
17
+ if (typeof define === 'function' && define.amd) {
18
+ // Register as an anonymous AMD module:
19
+ define([
20
+ 'jquery',
21
+ 'tmpl',
22
+ './jquery.fileupload-image',
23
+ './jquery.fileupload-audio',
24
+ './jquery.fileupload-video',
25
+ './jquery.fileupload-validate'
26
+ ], factory);
27
+ } else {
28
+ // Browser globals:
29
+ factory(
30
+ window.jQuery,
31
+ window.tmpl
32
+ );
33
+ }
34
+ }(function ($, tmpl) {
35
+ 'use strict';
36
+
37
+ $.blueimp.fileupload.prototype._specialOptions.push(
38
+ 'filesContainer',
39
+ 'uploadTemplateId',
40
+ 'downloadTemplateId'
41
+ );
42
+
43
+ // The UI version extends the file upload widget
44
+ // and adds complete user interface interaction:
45
+ $.widget('blueimp.fileupload', $.blueimp.fileupload, {
46
+
47
+ options: {
48
+ // By default, files added to the widget are uploaded as soon
49
+ // as the user clicks on the start buttons. To enable automatic
50
+ // uploads, set the following option to true:
51
+ autoUpload: false,
52
+ // The ID of the upload template:
53
+ uploadTemplateId: 'template-upload',
54
+ // The ID of the download template:
55
+ downloadTemplateId: 'template-download',
56
+ // The container for the list of files. If undefined, it is set to
57
+ // an element with class "files" inside of the widget element:
58
+ filesContainer: undefined,
59
+ // By default, files are appended to the files container.
60
+ // Set the following option to true, to prepend files instead:
61
+ prependFiles: false,
62
+ // The expected data type of the upload response, sets the dataType
63
+ // option of the $.ajax upload requests:
64
+ dataType: 'json',
65
+
66
+ // Function returning the current number of files,
67
+ // used by the maxNumberOfFiles validation:
68
+ getNumberOfFiles: function () {
69
+ return this.filesContainer.children()
70
+ .not('.processing').length;
71
+ },
72
+
73
+ // Callback to retrieve the list of files from the server response:
74
+ getFilesFromResponse: function (data) {
75
+ if (data.result && $.isArray(data.result.files)) {
76
+ return data.result.files;
77
+ }
78
+ return [];
79
+ },
80
+
81
+ // The add callback is invoked as soon as files are added to the fileupload
82
+ // widget (via file input selection, drag & drop or add API call).
83
+ // See the basic file upload widget for more information:
84
+ add: function (e, data) {
85
+ if (e.isDefaultPrevented()) {
86
+ return false;
87
+ }
88
+ var $this = $(this),
89
+ that = $this.data('blueimp-fileupload') ||
90
+ $this.data('fileupload'),
91
+ options = that.options;
92
+ data.context = that._renderUpload(data.files)
93
+ .data('data', data)
94
+ .addClass('processing');
95
+ options.filesContainer[
96
+ options.prependFiles ? 'prepend' : 'append'
97
+ ](data.context);
98
+ that._forceReflow(data.context);
99
+ $.when(
100
+ that._transition(data.context),
101
+ data.process(function () {
102
+ return $this.fileupload('process', data);
103
+ })
104
+ ).always(function () {
105
+ data.context.each(function (index) {
106
+ $(this).find('.size').text(
107
+ that._formatFileSize(data.files[index].size)
108
+ );
109
+ }).removeClass('processing');
110
+ that._renderPreviews(data);
111
+ }).done(function () {
112
+ data.context.find('.start').prop('disabled', false);
113
+ if ((that._trigger('added', e, data) !== false) &&
114
+ (options.autoUpload || data.autoUpload) &&
115
+ data.autoUpload !== false) {
116
+ data.submit();
117
+ }
118
+ }).fail(function () {
119
+ if (data.files.error) {
120
+ data.context.each(function (index) {
121
+ var error = data.files[index].error;
122
+ if (error) {
123
+ $(this).find('.error').text(error);
124
+ }
125
+ });
126
+ }
127
+ });
128
+ },
129
+ // Callback for the start of each file upload request:
130
+ send: function (e, data) {
131
+ if (e.isDefaultPrevented()) {
132
+ return false;
133
+ }
134
+ var that = $(this).data('blueimp-fileupload') ||
135
+ $(this).data('fileupload');
136
+ if (data.context && data.dataType &&
137
+ data.dataType.substr(0, 6) === 'iframe') {
138
+ // Iframe Transport does not support progress events.
139
+ // In lack of an indeterminate progress bar, we set
140
+ // the progress to 100%, showing the full animated bar:
141
+ data.context
142
+ .find('.progress').addClass(
143
+ !$.support.transition && 'progress-animated'
144
+ )
145
+ .attr('aria-valuenow', 100)
146
+ .children().first().css(
147
+ 'width',
148
+ '100%'
149
+ );
150
+ }
151
+ return that._trigger('sent', e, data);
152
+ },
153
+ // Callback for successful uploads:
154
+ done: function (e, data) {
155
+ if (e.isDefaultPrevented()) {
156
+ return false;
157
+ }
158
+ var that = $(this).data('blueimp-fileupload') ||
159
+ $(this).data('fileupload'),
160
+ getFilesFromResponse = data.getFilesFromResponse ||
161
+ that.options.getFilesFromResponse,
162
+ files = getFilesFromResponse(data),
163
+ template,
164
+ deferred;
165
+ if (data.context) {
166
+ data.context.each(function (index) {
167
+ var file = files[index] ||
168
+ {error: 'Empty file upload result'};
169
+ deferred = that._addFinishedDeferreds();
170
+ that._transition($(this)).done(
171
+ function () {
172
+ var node = $(this);
173
+ template = that._renderDownload([file])
174
+ .replaceAll(node);
175
+ that._forceReflow(template);
176
+ that._transition(template).done(
177
+ function () {
178
+ data.context = $(this);
179
+ that._trigger('completed', e, data);
180
+ that._trigger('finished', e, data);
181
+ deferred.resolve();
182
+ }
183
+ );
184
+ }
185
+ );
186
+ });
187
+ } else {
188
+ template = that._renderDownload(files)[
189
+ that.options.prependFiles ? 'prependTo' : 'appendTo'
190
+ ](that.options.filesContainer);
191
+ that._forceReflow(template);
192
+ deferred = that._addFinishedDeferreds();
193
+ that._transition(template).done(
194
+ function () {
195
+ data.context = $(this);
196
+ that._trigger('completed', e, data);
197
+ that._trigger('finished', e, data);
198
+ deferred.resolve();
199
+ }
200
+ );
201
+ }
202
+ },
203
+ // Callback for failed (abort or error) uploads:
204
+ fail: function (e, data) {
205
+ if (e.isDefaultPrevented()) {
206
+ return false;
207
+ }
208
+ var that = $(this).data('blueimp-fileupload') ||
209
+ $(this).data('fileupload'),
210
+ template,
211
+ deferred;
212
+ if (data.context) {
213
+ data.context.each(function (index) {
214
+ if (data.errorThrown !== 'abort') {
215
+ var file = data.files[index];
216
+ file.error = file.error || data.errorThrown ||
217
+ true;
218
+ deferred = that._addFinishedDeferreds();
219
+ that._transition($(this)).done(
220
+ function () {
221
+ var node = $(this);
222
+ template = that._renderDownload([file])
223
+ .replaceAll(node);
224
+ that._forceReflow(template);
225
+ that._transition(template).done(
226
+ function () {
227
+ data.context = $(this);
228
+ that._trigger('failed', e, data);
229
+ that._trigger('finished', e, data);
230
+ deferred.resolve();
231
+ }
232
+ );
233
+ }
234
+ );
235
+ } else {
236
+ deferred = that._addFinishedDeferreds();
237
+ that._transition($(this)).done(
238
+ function () {
239
+ $(this).remove();
240
+ that._trigger('failed', e, data);
241
+ that._trigger('finished', e, data);
242
+ deferred.resolve();
243
+ }
244
+ );
245
+ }
246
+ });
247
+ } else if (data.errorThrown !== 'abort') {
248
+ data.context = that._renderUpload(data.files)[
249
+ that.options.prependFiles ? 'prependTo' : 'appendTo'
250
+ ](that.options.filesContainer)
251
+ .data('data', data);
252
+ that._forceReflow(data.context);
253
+ deferred = that._addFinishedDeferreds();
254
+ that._transition(data.context).done(
255
+ function () {
256
+ data.context = $(this);
257
+ that._trigger('failed', e, data);
258
+ that._trigger('finished', e, data);
259
+ deferred.resolve();
260
+ }
261
+ );
262
+ } else {
263
+ that._trigger('failed', e, data);
264
+ that._trigger('finished', e, data);
265
+ that._addFinishedDeferreds().resolve();
266
+ }
267
+ },
268
+ // Callback for upload progress events:
269
+ progress: function (e, data) {
270
+ if (e.isDefaultPrevented()) {
271
+ return false;
272
+ }
273
+ var progress = Math.floor(data.loaded / data.total * 100);
274
+ if (data.context) {
275
+ data.context.each(function () {
276
+ $(this).find('.progress')
277
+ .attr('aria-valuenow', progress)
278
+ .children().first().css(
279
+ 'width',
280
+ progress + '%'
281
+ );
282
+ });
283
+ }
284
+ },
285
+ // Callback for global upload progress events:
286
+ progressall: function (e, data) {
287
+ if (e.isDefaultPrevented()) {
288
+ return false;
289
+ }
290
+ var $this = $(this),
291
+ progress = Math.floor(data.loaded / data.total * 100),
292
+ globalProgressNode = $this.find('.fileupload-progress'),
293
+ extendedProgressNode = globalProgressNode
294
+ .find('.progress-extended');
295
+ if (extendedProgressNode.length) {
296
+ extendedProgressNode.html(
297
+ ($this.data('blueimp-fileupload') || $this.data('fileupload'))
298
+ ._renderExtendedProgress(data)
299
+ );
300
+ }
301
+ globalProgressNode
302
+ .find('.progress')
303
+ .attr('aria-valuenow', progress)
304
+ .children().first().css(
305
+ 'width',
306
+ progress + '%'
307
+ );
308
+ },
309
+ // Callback for uploads start, equivalent to the global ajaxStart event:
310
+ start: function (e) {
311
+ if (e.isDefaultPrevented()) {
312
+ return false;
313
+ }
314
+ var that = $(this).data('blueimp-fileupload') ||
315
+ $(this).data('fileupload');
316
+ that._resetFinishedDeferreds();
317
+ that._transition($(this).find('.fileupload-progress')).done(
318
+ function () {
319
+ that._trigger('started', e);
320
+ }
321
+ );
322
+ },
323
+ // Callback for uploads stop, equivalent to the global ajaxStop event:
324
+ stop: function (e) {
325
+ if (e.isDefaultPrevented()) {
326
+ return false;
327
+ }
328
+ var that = $(this).data('blueimp-fileupload') ||
329
+ $(this).data('fileupload'),
330
+ deferred = that._addFinishedDeferreds();
331
+ $.when.apply($, that._getFinishedDeferreds())
332
+ .done(function () {
333
+ that._trigger('stopped', e);
334
+ });
335
+ that._transition($(this).find('.fileupload-progress')).done(
336
+ function () {
337
+ $(this).find('.progress')
338
+ .attr('aria-valuenow', '0')
339
+ .children().first().css('width', '0%');
340
+ $(this).find('.progress-extended').html(' ');
341
+ deferred.resolve();
342
+ }
343
+ );
344
+ },
345
+ processstart: function (e) {
346
+ if (e.isDefaultPrevented()) {
347
+ return false;
348
+ }
349
+ $(this).addClass('fileupload-processing');
350
+ },
351
+ processstop: function (e) {
352
+ if (e.isDefaultPrevented()) {
353
+ return false;
354
+ }
355
+ $(this).removeClass('fileupload-processing');
356
+ },
357
+ // Callback for file deletion:
358
+ destroy: function (e, data) {
359
+ if (e.isDefaultPrevented()) {
360
+ return false;
361
+ }
362
+ var that = $(this).data('blueimp-fileupload') ||
363
+ $(this).data('fileupload'),
364
+ removeNode = function () {
365
+ that._transition(data.context).done(
366
+ function () {
367
+ $(this).remove();
368
+ that._trigger('destroyed', e, data);
369
+ }
370
+ );
371
+ };
372
+ if (data.url) {
373
+ data.dataType = data.dataType || that.options.dataType;
374
+ $.ajax(data).done(removeNode);
375
+ } else {
376
+ removeNode();
377
+ }
378
+ }
379
+ },
380
+
381
+ _resetFinishedDeferreds: function () {
382
+ this._finishedUploads = [];
383
+ },
384
+
385
+ _addFinishedDeferreds: function (deferred) {
386
+ if (!deferred) {
387
+ deferred = $.Deferred();
388
+ }
389
+ this._finishedUploads.push(deferred);
390
+ return deferred;
391
+ },
392
+
393
+ _getFinishedDeferreds: function () {
394
+ return this._finishedUploads;
395
+ },
396
+
397
+ // Link handler, that allows to download files
398
+ // by drag & drop of the links to the desktop:
399
+ _enableDragToDesktop: function () {
400
+ var link = $(this),
401
+ url = link.prop('href'),
402
+ name = link.prop('download'),
403
+ type = 'application/octet-stream';
404
+ link.bind('dragstart', function (e) {
405
+ try {
406
+ e.originalEvent.dataTransfer.setData(
407
+ 'DownloadURL',
408
+ [type, name, url].join(':')
409
+ );
410
+ } catch (ignore) {}
411
+ });
412
+ },
413
+
414
+ _formatFileSize: function (bytes) {
415
+ if (typeof bytes !== 'number') {
416
+ return '';
417
+ }
418
+ if (bytes >= 1000000000) {
419
+ return (bytes / 1000000000).toFixed(2) + ' GB';
420
+ }
421
+ if (bytes >= 1000000) {
422
+ return (bytes / 1000000).toFixed(2) + ' MB';
423
+ }
424
+ return (bytes / 1000).toFixed(2) + ' KB';
425
+ },
426
+
427
+ _formatBitrate: function (bits) {
428
+ if (typeof bits !== 'number') {
429
+ return '';
430
+ }
431
+ if (bits >= 1000000000) {
432
+ return (bits / 1000000000).toFixed(2) + ' Gbit/s';
433
+ }
434
+ if (bits >= 1000000) {
435
+ return (bits / 1000000).toFixed(2) + ' Mbit/s';
436
+ }
437
+ if (bits >= 1000) {
438
+ return (bits / 1000).toFixed(2) + ' kbit/s';
439
+ }
440
+ return bits.toFixed(2) + ' bit/s';
441
+ },
442
+
443
+ _formatTime: function (seconds) {
444
+ var date = new Date(seconds * 1000),
445
+ days = Math.floor(seconds / 86400);
446
+ days = days ? days + 'd ' : '';
447
+ return days +
448
+ ('0' + date.getUTCHours()).slice(-2) + ':' +
449
+ ('0' + date.getUTCMinutes()).slice(-2) + ':' +
450
+ ('0' + date.getUTCSeconds()).slice(-2);
451
+ },
452
+
453
+ _formatPercentage: function (floatValue) {
454
+ return (floatValue * 100).toFixed(2) + ' %';
455
+ },
456
+
457
+ _renderExtendedProgress: function (data) {
458
+ return this._formatBitrate(data.bitrate) + ' | ' +
459
+ this._formatTime(
460
+ (data.total - data.loaded) * 8 / data.bitrate
461
+ ) + ' | ' +
462
+ this._formatPercentage(
463
+ data.loaded / data.total
464
+ ) + ' | ' +
465
+ this._formatFileSize(data.loaded) + ' / ' +
466
+ this._formatFileSize(data.total);
467
+ },
468
+
469
+ _renderTemplate: function (func, files) {
470
+ if (!func) {
471
+ return $();
472
+ }
473
+ var result = func({
474
+ files: files,
475
+ formatFileSize: this._formatFileSize,
476
+ options: this.options
477
+ });
478
+ if (result instanceof $) {
479
+ return result;
480
+ }
481
+ return $(this.options.templatesContainer).html(result).children();
482
+ },
483
+
484
+ _renderPreviews: function (data) {
485
+ data.context.find('.preview').each(function (index, elm) {
486
+ $(elm).append(data.files[index].preview);
487
+ });
488
+ },
489
+
490
+ _renderUpload: function (files) {
491
+ return this._renderTemplate(
492
+ this.options.uploadTemplate,
493
+ files
494
+ );
495
+ },
496
+
497
+ _renderDownload: function (files) {
498
+ return this._renderTemplate(
499
+ this.options.downloadTemplate,
500
+ files
501
+ ).find('a[download]').each(this._enableDragToDesktop).end();
502
+ },
503
+
504
+ _startHandler: function (e) {
505
+ e.preventDefault();
506
+ var button = $(e.currentTarget),
507
+ template = button.closest('.template-upload'),
508
+ data = template.data('data');
509
+ button.prop('disabled', true);
510
+ if (data && data.submit) {
511
+ data.submit();
512
+ }
513
+ },
514
+
515
+ _cancelHandler: function (e) {
516
+ e.preventDefault();
517
+ var template = $(e.currentTarget)
518
+ .closest('.template-upload,.template-download'),
519
+ data = template.data('data') || {};
520
+ data.context = data.context || template;
521
+ if (data.abort) {
522
+ data.abort();
523
+ } else {
524
+ data.errorThrown = 'abort';
525
+ this._trigger('fail', e, data);
526
+ }
527
+ },
528
+
529
+ _deleteHandler: function (e) {
530
+ e.preventDefault();
531
+ var button = $(e.currentTarget);
532
+ this._trigger('destroy', e, $.extend({
533
+ context: button.closest('.template-download'),
534
+ type: 'DELETE'
535
+ }, button.data()));
536
+ },
537
+
538
+ _forceReflow: function (node) {
539
+ return $.support.transition && node.length &&
540
+ node[0].offsetWidth;
541
+ },
542
+
543
+ _transition: function (node) {
544
+ var dfd = $.Deferred();
545
+ if ($.support.transition && node.hasClass('fade') && node.is(':visible')) {
546
+ node.bind(
547
+ $.support.transition.end,
548
+ function (e) {
549
+ // Make sure we don't respond to other transitions events
550
+ // in the container element, e.g. from button elements:
551
+ if (e.target === node[0]) {
552
+ node.unbind($.support.transition.end);
553
+ dfd.resolveWith(node);
554
+ }
555
+ }
556
+ ).toggleClass('in');
557
+ } else {
558
+ node.toggleClass('in');
559
+ dfd.resolveWith(node);
560
+ }
561
+ return dfd;
562
+ },
563
+
564
+ _initButtonBarEventHandlers: function () {
565
+ var fileUploadButtonBar = this.element.find('.fileupload-buttonbar'),
566
+ filesList = this.options.filesContainer;
567
+ this._on(fileUploadButtonBar.find('.start'), {
568
+ click: function (e) {
569
+ e.preventDefault();
570
+ filesList.find('.start').click();
571
+ }
572
+ });
573
+ this._on(fileUploadButtonBar.find('.cancel'), {
574
+ click: function (e) {
575
+ e.preventDefault();
576
+ filesList.find('.cancel').click();
577
+ }
578
+ });
579
+ this._on(fileUploadButtonBar.find('.delete'), {
580
+ click: function (e) {
581
+ e.preventDefault();
582
+ filesList.find('.toggle:checked')
583
+ .closest('.template-download')
584
+ .find('.delete').click();
585
+ fileUploadButtonBar.find('.toggle')
586
+ .prop('checked', false);
587
+ }
588
+ });
589
+ this._on(fileUploadButtonBar.find('.toggle'), {
590
+ change: function (e) {
591
+ filesList.find('.toggle').prop(
592
+ 'checked',
593
+ $(e.currentTarget).is(':checked')
594
+ );
595
+ }
596
+ });
597
+ },
598
+
599
+ _destroyButtonBarEventHandlers: function () {
600
+ this._off(
601
+ this.element.find('.fileupload-buttonbar')
602
+ .find('.start, .cancel, .delete'),
603
+ 'click'
604
+ );
605
+ this._off(
606
+ this.element.find('.fileupload-buttonbar .toggle'),
607
+ 'change.'
608
+ );
609
+ },
610
+
611
+ _initEventHandlers: function () {
612
+ this._super();
613
+ this._on(this.options.filesContainer, {
614
+ 'click .start': this._startHandler,
615
+ 'click .cancel': this._cancelHandler,
616
+ 'click .delete': this._deleteHandler
617
+ });
618
+ this._initButtonBarEventHandlers();
619
+ },
620
+
621
+ _destroyEventHandlers: function () {
622
+ this._destroyButtonBarEventHandlers();
623
+ this._off(this.options.filesContainer, 'click');
624
+ this._super();
625
+ },
626
+
627
+ _enableFileInputButton: function () {
628
+ this.element.find('.fileinput-button input')
629
+ .prop('disabled', false)
630
+ .parent().removeClass('disabled');
631
+ },
632
+
633
+ _disableFileInputButton: function () {
634
+ this.element.find('.fileinput-button input')
635
+ .prop('disabled', true)
636
+ .parent().addClass('disabled');
637
+ },
638
+
639
+ _initTemplates: function () {
640
+ var options = this.options;
641
+ options.templatesContainer = this.document[0].createElement(
642
+ options.filesContainer.prop('nodeName')
643
+ );
644
+ if (tmpl) {
645
+ if (options.uploadTemplateId) {
646
+ options.uploadTemplate = tmpl(options.uploadTemplateId);
647
+ }
648
+ if (options.downloadTemplateId) {
649
+ options.downloadTemplate = tmpl(options.downloadTemplateId);
650
+ }
651
+ }
652
+ },
653
+
654
+ _initFilesContainer: function () {
655
+ var options = this.options;
656
+ if (options.filesContainer === undefined) {
657
+ options.filesContainer = this.element.find('.files');
658
+ } else if (!(options.filesContainer instanceof $)) {
659
+ options.filesContainer = $(options.filesContainer);
660
+ }
661
+ },
662
+
663
+ _initSpecialOptions: function () {
664
+ this._super();
665
+ this._initFilesContainer();
666
+ this._initTemplates();
667
+ },
668
+
669
+ _create: function () {
670
+ this._super();
671
+ this._resetFinishedDeferreds();
672
+ if (!$.support.fileInput) {
673
+ this._disableFileInputButton();
674
+ }
675
+ },
676
+
677
+ enable: function () {
678
+ var wasDisabled = false;
679
+ if (this.options.disabled) {
680
+ wasDisabled = true;
681
+ }
682
+ this._super();
683
+ if (wasDisabled) {
684
+ this.element.find('input, button').prop('disabled', false);
685
+ this._enableFileInputButton();
686
+ }
687
+ },
688
+
689
+ disable: function () {
690
+ if (!this.options.disabled) {
691
+ this.element.find('input, button').prop('disabled', true);
692
+ this._disableFileInputButton();
693
+ }
694
+ this._super();
695
+ }
696
+
697
+ });
698
+
699
+ }));