jquery-fileupload-rails 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  [jQuery-File-Plugin](https://github.com/blueimp/jQuery-File-Upload) is a file upload plugin written by [Sebastian Tschan](https://github.com/blueimp). jQuery File Upload features multiple file selection, drag&drop support, progress bars and preview images for jQuery. Supports cross-domain, chunked and resumable file uploads and client-side image resizing.
4
4
 
5
- jquery-fileupload-rails is a library that integrates jQuery File Upload for Rails 3.1 Asset Pipeline.
5
+ jquery-fileupload-rails is a library that integrates jQuery File Upload for Rails 3.1 Asset Pipeline (Rails 3.2 supported).
6
6
 
7
- jquery-fileupload-rails is currently using jQuery-File-Plugin version 6.5.5.
7
+ jquery-fileupload-rails is currently using jQuery-File-Plugin version 6.9.2.
8
8
 
9
9
  ## Installing Gem
10
10
 
@@ -24,7 +24,7 @@ The snippet above will add the following js files to the mainfest file.
24
24
  //=require jquery-fileupload/vendor/tmpl
25
25
  //=require jquery-fileupload/jquery.iframe-transport
26
26
  //=require jquery-fileupload/jquery.fileupload
27
- //=require jquery-fileupload/jquery.fileupload-ip
27
+ //=require jquery-fileupload/jquery.fileupload-fp
28
28
  //=require jquery-fileupload/jquery.fileupload-ui
29
29
  //=require jquery-fileupload/locale
30
30
 
@@ -39,7 +39,7 @@ The basic setup only includes the following files:
39
39
  //=require jquery-fileupload/jquery.fileupload
40
40
 
41
41
  ## Using the stylesheet
42
-
42
+
43
43
  Require the stylesheet file to app/assets/stylesheets/application.css
44
44
 
45
45
  *= require jquery.fileupload-ui
@@ -1,7 +1,7 @@
1
1
  module JQuery
2
2
  module FileUpload
3
3
  module Rails
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.1"
5
5
  end
6
6
  end
7
7
  end
@@ -4,6 +4,6 @@
4
4
  //=require jquery-fileupload/vendor/tmpl
5
5
  //=require jquery-fileupload/jquery.iframe-transport
6
6
  //=require jquery-fileupload/jquery.fileupload
7
- //=require jquery-fileupload/jquery.fileupload-ip
7
+ //=require jquery-fileupload/jquery.fileupload-fp
8
8
  //=require jquery-fileupload/jquery.fileupload-ui
9
9
  //=require jquery-fileupload/locale
@@ -0,0 +1,219 @@
1
+ /*
2
+ * jQuery File Upload File Processing Plugin 1.0
3
+ * https://github.com/blueimp/jQuery-File-Upload
4
+ *
5
+ * Copyright 2012, Sebastian Tschan
6
+ * https://blueimp.net
7
+ *
8
+ * Licensed under the MIT license:
9
+ * http://www.opensource.org/licenses/MIT
10
+ */
11
+
12
+ /*jslint nomen: true, unparam: true, regexp: true */
13
+ /*global define, window, document */
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
+ 'load-image',
22
+ 'canvas-to-blob',
23
+ './jquery.fileupload'
24
+ ], factory);
25
+ } else {
26
+ // Browser globals:
27
+ factory(
28
+ window.jQuery,
29
+ window.loadImage
30
+ );
31
+ }
32
+ }(function ($, loadImage) {
33
+ 'use strict';
34
+
35
+ // The File Upload IP version extends the basic fileupload widget
36
+ // with file processing functionality:
37
+ $.widget('blueimpFP.fileupload', $.blueimp.fileupload, {
38
+
39
+ options: {
40
+ // The list of file processing actions:
41
+ process: [
42
+ /*
43
+ {
44
+ action: 'load',
45
+ fileTypes: /^image\/(gif|jpeg|png)$/,
46
+ maxFileSize: 20000000 // 20MB
47
+ },
48
+ {
49
+ action: 'resize',
50
+ maxWidth: 1920,
51
+ maxHeight: 1200,
52
+ minWidth: 800,
53
+ minHeight: 600
54
+ },
55
+ {
56
+ action: 'save'
57
+ }
58
+ */
59
+ ],
60
+
61
+ // The add callback is invoked as soon as files are added to the
62
+ // fileupload widget (via file input selection, drag & drop or add
63
+ // API call). See the basic file upload widget for more information:
64
+ add: function (e, data) {
65
+ $(this).fileupload('process', data).done(function () {
66
+ data.submit();
67
+ });
68
+ }
69
+ },
70
+
71
+ processActions: {
72
+ // Loads the image given via data.files and data.index
73
+ // as canvas element.
74
+ // Accepts the options fileTypes (regular expression)
75
+ // and maxFileSize (integer) to limit the files to load:
76
+ load: function (data, options) {
77
+ var that = this,
78
+ file = data.files[data.index],
79
+ dfd = $.Deferred();
80
+ if (window.HTMLCanvasElement &&
81
+ window.HTMLCanvasElement.prototype.toBlob &&
82
+ ($.type(options.maxFileSize) !== 'number' ||
83
+ file.size < options.maxFileSize) &&
84
+ (!options.fileTypes ||
85
+ options.fileTypes.test(file.type))) {
86
+ loadImage(
87
+ file,
88
+ function (canvas) {
89
+ data.canvas = canvas;
90
+ dfd.resolveWith(that, [data]);
91
+ },
92
+ {canvas: true}
93
+ );
94
+ } else {
95
+ dfd.rejectWith(that, [data]);
96
+ }
97
+ return dfd.promise();
98
+ },
99
+ // Resizes the image given as data.canvas and updates
100
+ // data.canvas with the resized image.
101
+ // Accepts the options maxWidth, maxHeight, minWidth and
102
+ // minHeight to scale the given image:
103
+ resize: function (data, options) {
104
+ if (data.canvas) {
105
+ var canvas = loadImage.scale(data.canvas, options);
106
+ if (canvas.width !== data.canvas.width ||
107
+ canvas.height !== data.canvas.height) {
108
+ data.canvas = canvas;
109
+ data.processed = true;
110
+ }
111
+ }
112
+ return data;
113
+ },
114
+ // Saves the processed image given as data.canvas
115
+ // inplace at data.index of data.files:
116
+ save: function (data, options) {
117
+ // Do nothing if no processing has happened:
118
+ if (!data.canvas || !data.processed) {
119
+ return data;
120
+ }
121
+ var that = this,
122
+ file = data.files[data.index],
123
+ name = file.name,
124
+ dfd = $.Deferred(),
125
+ callback = function (blob) {
126
+ if (!blob.name) {
127
+ if (file.type === blob.type) {
128
+ blob.name = file.name;
129
+ } else if (file.name) {
130
+ blob.name = file.name.replace(
131
+ /\..+$/,
132
+ '.' + blob.type.substr(6)
133
+ );
134
+ }
135
+ }
136
+ // Store the created blob at the position
137
+ // of the original file in the files list:
138
+ data.files[data.index] = blob;
139
+ dfd.resolveWith(that, [data]);
140
+ };
141
+ // Use canvas.mozGetAsFile directly, to retain the filename, as
142
+ // Gecko doesn't support the filename option for FormData.append:
143
+ if (data.canvas.mozGetAsFile) {
144
+ callback(data.canvas.mozGetAsFile(
145
+ (/^image\/(jpeg|png)$/.test(file.type) && name) ||
146
+ ((name && name.replace(/\..+$/, '')) ||
147
+ 'blob') + '.png',
148
+ file.type
149
+ ));
150
+ } else {
151
+ data.canvas.toBlob(callback, file.type);
152
+ }
153
+ return dfd.promise();
154
+ }
155
+ },
156
+
157
+ // Resizes the file at the given index and stores the created blob at
158
+ // the original position of the files list, returns a Promise object:
159
+ _processFile: function (files, index, options) {
160
+ var that = this,
161
+ dfd = $.Deferred().resolveWith(that, [{
162
+ files: files,
163
+ index: index
164
+ }]),
165
+ chain = dfd.promise();
166
+ that._processing += 1;
167
+ $.each(options.process, function (i, settings) {
168
+ chain = chain.pipe(function (data) {
169
+ return that.processActions[settings.action]
170
+ .call(this, data, settings);
171
+ });
172
+ });
173
+ chain.always(function () {
174
+ that._processing -= 1;
175
+ if (that._processing === 0) {
176
+ that.element
177
+ .removeClass('fileupload-processing');
178
+ }
179
+ });
180
+ if (that._processing === 1) {
181
+ that.element.addClass('fileupload-processing');
182
+ }
183
+ return chain;
184
+ },
185
+
186
+ // Processes the files given as files property of the data parameter,
187
+ // returns a Promise object that allows to bind a done handler, which
188
+ // will be invoked after processing all files (inplace) is done:
189
+ process: function (data) {
190
+ var that = this,
191
+ options = $.extend({}, this.options, data);
192
+ if (options.process && options.process.length &&
193
+ this._isXHRUpload(options)) {
194
+ $.each(data.files, function (index, file) {
195
+ that._processingQueue = that._processingQueue.pipe(
196
+ function () {
197
+ var dfd = $.Deferred();
198
+ that._processFile(data.files, index, options)
199
+ .always(function () {
200
+ dfd.resolveWith(that);
201
+ });
202
+ return dfd.promise();
203
+ }
204
+ );
205
+ });
206
+ }
207
+ return this._processingQueue;
208
+ },
209
+
210
+ _create: function () {
211
+ $.blueimp.fileupload.prototype._create.call(this);
212
+ this._processing = 0;
213
+ this._processingQueue = $.Deferred().resolveWith(this)
214
+ .promise();
215
+ }
216
+
217
+ });
218
+
219
+ }));
@@ -1,5 +1,5 @@
1
1
  /*
2
- * jQuery File Upload User Interface Plugin 6.6.3
2
+ * jQuery File Upload User Interface Plugin 6.9.3
3
3
  * https://github.com/blueimp/jQuery-File-Upload
4
4
  *
5
5
  * Copyright 2010, Sebastian Tschan
@@ -20,7 +20,7 @@
20
20
  'jquery',
21
21
  'tmpl',
22
22
  'load-image',
23
- './jquery.fileupload-ip'
23
+ './jquery.fileupload-fp'
24
24
  ], factory);
25
25
  } else {
26
26
  // Browser globals:
@@ -33,9 +33,9 @@
33
33
  }(function ($, tmpl, loadImage) {
34
34
  'use strict';
35
35
 
36
- // The UI version extends the IP (image processing) version or the basic
36
+ // The UI version extends the FP (file processing) version or the basic
37
37
  // file upload widget and adds complete user interface interaction:
38
- var parentWidget = ($.blueimpIP || $.blueimp).fileupload;
38
+ var parentWidget = ($.blueimpFP || $.blueimp).fileupload;
39
39
  $.widget('blueimpUI.fileupload', parentWidget, {
40
40
 
41
41
  options: {
@@ -70,6 +70,12 @@
70
70
  uploadTemplateId: 'template-upload',
71
71
  // The ID of the download template:
72
72
  downloadTemplateId: 'template-download',
73
+ // The container for the list of files. If undefined, it is set to
74
+ // an element with class "files" inside of the widget element:
75
+ filesContainer: undefined,
76
+ // By default, files are appended to the files container.
77
+ // Set the following option to true, to prepend files instead:
78
+ prependFiles: false,
73
79
  // The expected data type of the upload response, sets the dataType
74
80
  // option of the $.ajax upload requests:
75
81
  dataType: 'json',
@@ -81,13 +87,14 @@
81
87
  var that = $(this).data('fileupload'),
82
88
  options = that.options,
83
89
  files = data.files;
84
- $(this).fileupload('resize', data).done(data, function () {
90
+ $(this).fileupload('process', data).done(function () {
85
91
  that._adjustMaxNumberOfFiles(-files.length);
86
92
  data.isAdjusted = true;
87
93
  data.files.valid = data.isValidated = that._validate(files);
88
- data.context = that._renderUpload(files)
89
- .appendTo(options.filesContainer)
90
- .data('data', data);
94
+ data.context = that._renderUpload(files).data('data', data);
95
+ options.filesContainer[
96
+ options.prependFiles ? 'prepend' : 'append'
97
+ ](data.context);
91
98
  that._renderPreviews(files, data.context);
92
99
  that._forceReflow(data.context);
93
100
  that._transition(data.context).done(
@@ -121,9 +128,10 @@
121
128
  .find('.progress').addClass(
122
129
  !$.support.transition && 'progress-animated'
123
130
  )
131
+ .attr('aria-valuenow', 100)
124
132
  .find('.bar').css(
125
133
  'width',
126
- parseInt(100, 10) + '%'
134
+ '100%'
127
135
  );
128
136
  }
129
137
  return that._trigger('sent', e, data);
@@ -131,8 +139,7 @@
131
139
  // Callback for successful uploads:
132
140
  done: function (e, data) {
133
141
  var that = $(this).data('fileupload'),
134
- template,
135
- preview;
142
+ template;
136
143
  if (data.context) {
137
144
  data.context.each(function (index) {
138
145
  var file = ($.isArray(data.result) &&
@@ -144,7 +151,6 @@
144
151
  function () {
145
152
  var node = $(this);
146
153
  template = that._renderDownload([file])
147
- .css('height', node.height())
148
154
  .replaceAll(node);
149
155
  that._forceReflow(template);
150
156
  that._transition(template).done(
@@ -221,23 +227,39 @@
221
227
  // Callback for upload progress events:
222
228
  progress: function (e, data) {
223
229
  if (data.context) {
224
- data.context.find('.progress .bar').css(
225
- 'width',
226
- parseInt(data.loaded / data.total * 100, 10) + '%'
227
- );
230
+ var progress = parseInt(data.loaded / data.total * 100, 10);
231
+ data.context.find('.progress')
232
+ .attr('aria-valuenow', progress)
233
+ .find('.bar').css(
234
+ 'width',
235
+ progress + '%'
236
+ );
228
237
  }
229
238
  },
230
239
  // Callback for global upload progress events:
231
240
  progressall: function (e, data) {
232
- $(this).find('.fileupload-buttonbar .progress .bar').css(
233
- 'width',
234
- parseInt(data.loaded / data.total * 100, 10) + '%'
235
- );
241
+ var $this = $(this),
242
+ progress = parseInt(data.loaded / data.total * 100, 10),
243
+ globalProgressNode = $this.find('.fileupload-progress'),
244
+ extendedProgressNode = globalProgressNode
245
+ .find('.progress-extended');
246
+ if (extendedProgressNode.length) {
247
+ extendedProgressNode.html(
248
+ $this.data('fileupload')._renderExtendedProgress(data)
249
+ );
250
+ }
251
+ globalProgressNode
252
+ .find('.progress')
253
+ .attr('aria-valuenow', progress)
254
+ .find('.bar').css(
255
+ 'width',
256
+ progress + '%'
257
+ );
236
258
  },
237
259
  // Callback for uploads start, equivalent to the global ajaxStart event:
238
260
  start: function (e) {
239
261
  var that = $(this).data('fileupload');
240
- that._transition($(this).find('.fileupload-buttonbar .progress')).done(
262
+ that._transition($(this).find('.fileupload-progress')).done(
241
263
  function () {
242
264
  that._trigger('started', e);
243
265
  }
@@ -246,9 +268,12 @@
246
268
  // Callback for uploads stop, equivalent to the global ajaxStop event:
247
269
  stop: function (e) {
248
270
  var that = $(this).data('fileupload');
249
- that._transition($(this).find('.fileupload-buttonbar .progress')).done(
271
+ that._transition($(this).find('.fileupload-progress')).done(
250
272
  function () {
251
- $(this).find('.bar').css('width', '0%');
273
+ $(this).find('.progress')
274
+ .attr('aria-valuenow', '0')
275
+ .find('.bar').css('width', '0%');
276
+ $(this).find('.progress-extended').html('&nbsp;');
252
277
  that._trigger('stopped', e);
253
278
  }
254
279
  );
@@ -258,8 +283,8 @@
258
283
  var that = $(this).data('fileupload');
259
284
  if (data.url) {
260
285
  $.ajax(data);
286
+ that._adjustMaxNumberOfFiles(1);
261
287
  }
262
- that._adjustMaxNumberOfFiles(1);
263
288
  that._transition(data.context).done(
264
289
  function () {
265
290
  $(this).remove();
@@ -310,6 +335,48 @@
310
335
  return (bytes / 1000).toFixed(2) + ' KB';
311
336
  },
312
337
 
338
+ _formatBitrate: function (bits) {
339
+ if (typeof bits !== 'number') {
340
+ return '';
341
+ }
342
+ if (bits >= 1000000000) {
343
+ return (bits / 1000000000).toFixed(2) + ' Gbit/s';
344
+ }
345
+ if (bits >= 1000000) {
346
+ return (bits / 1000000).toFixed(2) + ' Mbit/s';
347
+ }
348
+ if (bits >= 1000) {
349
+ return (bits / 1000).toFixed(2) + ' kbit/s';
350
+ }
351
+ return bits + ' bit/s';
352
+ },
353
+
354
+ _formatTime: function (seconds) {
355
+ var date = new Date(seconds * 1000),
356
+ days = parseInt(seconds / 86400, 10);
357
+ days = days ? days + 'd ' : '';
358
+ return days +
359
+ ('0' + date.getUTCHours()).slice(-2) + ':' +
360
+ ('0' + date.getUTCMinutes()).slice(-2) + ':' +
361
+ ('0' + date.getUTCSeconds()).slice(-2);
362
+ },
363
+
364
+ _formatPercentage: function (floatValue) {
365
+ return (floatValue * 100).toFixed(2) + ' %';
366
+ },
367
+
368
+ _renderExtendedProgress: function (data) {
369
+ return this._formatBitrate(data.bitrate) + ' | ' +
370
+ this._formatTime(
371
+ (data.total - data.loaded) * 8 / data.bitrate
372
+ ) + ' | ' +
373
+ this._formatPercentage(
374
+ data.loaded / data.total
375
+ ) + ' | ' +
376
+ this._formatFileSize(data.loaded) + ' / ' +
377
+ this._formatFileSize(data.total);
378
+ },
379
+
313
380
  _hasError: function (file) {
314
381
  if (file.error) {
315
382
  return file.error;
@@ -368,22 +435,28 @@
368
435
  _renderPreview: function (file, node) {
369
436
  var that = this,
370
437
  options = this.options,
371
- deferred = $.Deferred();
438
+ dfd = $.Deferred();
372
439
  return ((loadImage && loadImage(
373
440
  file,
374
441
  function (img) {
375
442
  node.append(img);
376
443
  that._forceReflow(node);
377
444
  that._transition(node).done(function () {
378
- deferred.resolveWith(node);
445
+ dfd.resolveWith(node);
379
446
  });
447
+ if (!$.contains(document.body, node[0])) {
448
+ // If the element is not part of the DOM,
449
+ // transition events are not triggered,
450
+ // so we have to resolve manually:
451
+ dfd.resolveWith(node);
452
+ }
380
453
  },
381
454
  {
382
455
  maxWidth: options.previewMaxWidth,
383
456
  maxHeight: options.previewMaxHeight,
384
457
  canvas: options.previewAsCanvas
385
458
  }
386
- )) || deferred.resolveWith(node)) && deferred;
459
+ )) || dfd.resolveWith(node)) && dfd;
387
460
  },
388
461
 
389
462
  _renderPreviews: function (files, nodes) {
@@ -395,13 +468,13 @@
395
468
  ($.type(options.previewSourceMaxFileSize) !== 'number' ||
396
469
  file.size < options.previewSourceMaxFileSize)) {
397
470
  that._processingQueue = that._processingQueue.pipe(function () {
398
- var deferred = $.Deferred();
471
+ var dfd = $.Deferred();
399
472
  that._renderPreview(file, $(element)).done(
400
473
  function () {
401
- deferred.resolveWith(that);
474
+ dfd.resolveWith(that);
402
475
  }
403
476
  );
404
- return deferred.promise();
477
+ return dfd.promise();
405
478
  });
406
479
  }
407
480
  });
@@ -456,13 +529,12 @@
456
529
  },
457
530
 
458
531
  _forceReflow: function (node) {
459
- this._reflow = $.support.transition &&
460
- node.length && node[0].offsetWidth;
532
+ return $.support.transition && node.length &&
533
+ node[0].offsetWidth;
461
534
  },
462
535
 
463
536
  _transition: function (node) {
464
- var that = this,
465
- deferred = $.Deferred();
537
+ var dfd = $.Deferred();
466
538
  if ($.support.transition && node.hasClass('fade')) {
467
539
  node.bind(
468
540
  $.support.transition.end,
@@ -471,15 +543,15 @@
471
543
  // in the container element, e.g. from button elements:
472
544
  if (e.target === node[0]) {
473
545
  node.unbind($.support.transition.end);
474
- deferred.resolveWith(node);
546
+ dfd.resolveWith(node);
475
547
  }
476
548
  }
477
549
  ).toggleClass('in');
478
550
  } else {
479
551
  node.toggleClass('in');
480
- deferred.resolveWith(node);
552
+ dfd.resolveWith(node);
481
553
  }
482
- return deferred;
554
+ return dfd;
483
555
  },
484
556
 
485
557
  _initButtonBarEventHandlers: function () {
@@ -591,10 +663,32 @@
591
663
  }
592
664
  },
593
665
 
666
+ _stringToRegExp: function (str) {
667
+ var parts = str.split('/'),
668
+ modifiers = parts.pop();
669
+ parts.shift();
670
+ return new RegExp(parts.join('/'), modifiers);
671
+ },
672
+
673
+ _initRegExpOptions: function () {
674
+ var options = this.options;
675
+ if ($.type(options.acceptFileTypes) === 'string') {
676
+ options.acceptFileTypes = this._stringToRegExp(
677
+ options.acceptFileTypes
678
+ );
679
+ }
680
+ if ($.type(options.previewSourceFileTypes) === 'string') {
681
+ options.previewSourceFileTypes = this._stringToRegExp(
682
+ options.previewSourceFileTypes
683
+ );
684
+ }
685
+ },
686
+
594
687
  _initSpecialOptions: function () {
595
688
  parentWidget.prototype._initSpecialOptions.call(this);
596
689
  this._initFilesContainer();
597
690
  this._initTemplates();
691
+ this._initRegExpOptions();
598
692
  },
599
693
 
600
694
  _create: function () {
@@ -604,9 +698,9 @@
604
698
  'uploadTemplateId',
605
699
  'downloadTemplateId'
606
700
  );
607
- if (!$.blueimpIP) {
701
+ if (!$.blueimpFP) {
608
702
  this._processingQueue = $.Deferred().resolveWith(this).promise();
609
- this.resize = function () {
703
+ this.process = function () {
610
704
  return this._processingQueue;
611
705
  };
612
706
  }
@@ -1,5 +1,5 @@
1
1
  /*
2
- * jQuery File Upload Plugin 5.10.0
2
+ * jQuery File Upload Plugin 5.13
3
3
  * https://github.com/blueimp/jQuery-File-Upload
4
4
  *
5
5
  * Copyright 2010, Sebastian Tschan
@@ -109,6 +109,10 @@
109
109
  // global progress calculation. Set the following option to false to
110
110
  // prevent recalculating the global progress data:
111
111
  recalculateProgress: true,
112
+ // Interval in milliseconds to calculate and trigger progress events:
113
+ progressInterval: 100,
114
+ // Interval in milliseconds to calculate progress bitrate:
115
+ bitrateInterval: 500,
112
116
 
113
117
  // Additional form data to be sent along with the file uploads can be set
114
118
  // using this option, which accepts an array of objects with name and
@@ -180,6 +184,21 @@
180
184
  'forceIframeTransport'
181
185
  ],
182
186
 
187
+ _BitrateTimer: function () {
188
+ this.timestamp = +(new Date());
189
+ this.loaded = 0;
190
+ this.bitrate = 0;
191
+ this.getBitrate = function (now, loaded, interval) {
192
+ var timeDiff = now - this.timestamp;
193
+ if (!this.bitrate || !interval || timeDiff > interval) {
194
+ this.bitrate = (loaded - this.loaded) * (1000 / timeDiff) * 8;
195
+ this.loaded = loaded;
196
+ this.timestamp = now;
197
+ }
198
+ return this.bitrate;
199
+ };
200
+ },
201
+
183
202
  _isXHRUpload: function (options) {
184
203
  return !options.forceIframeTransport &&
185
204
  ((!options.multipart && $.support.xhrFileUpload) ||
@@ -190,9 +209,11 @@
190
209
  var formData;
191
210
  if (typeof options.formData === 'function') {
192
211
  return options.formData(options.form);
193
- } else if ($.isArray(options.formData)) {
212
+ }
213
+ if ($.isArray(options.formData)) {
194
214
  return options.formData;
195
- } else if (options.formData) {
215
+ }
216
+ if (options.formData) {
196
217
  formData = [];
197
218
  $.each(options.formData, function (name, value) {
198
219
  formData.push({name: name, value: value});
@@ -212,15 +233,29 @@
212
233
 
213
234
  _onProgress: function (e, data) {
214
235
  if (e.lengthComputable) {
215
- var total = data.total || this._getTotal(data.files),
216
- loaded = parseInt(
217
- e.loaded / e.total * (data.chunkSize || total),
218
- 10
219
- ) + (data.uploadedBytes || 0);
236
+ var now = +(new Date()),
237
+ total,
238
+ loaded;
239
+ if (data._time && data.progressInterval &&
240
+ (now - data._time < data.progressInterval) &&
241
+ e.loaded !== e.total) {
242
+ return;
243
+ }
244
+ data._time = now;
245
+ total = data.total || this._getTotal(data.files);
246
+ loaded = parseInt(
247
+ e.loaded / e.total * (data.chunkSize || total),
248
+ 10
249
+ ) + (data.uploadedBytes || 0);
220
250
  this._loaded += loaded - (data.loaded || data.uploadedBytes || 0);
221
251
  data.lengthComputable = true;
222
252
  data.loaded = loaded;
223
253
  data.total = total;
254
+ data.bitrate = data._bitrateTimer.getBitrate(
255
+ now,
256
+ loaded,
257
+ data.bitrateInterval
258
+ );
224
259
  // Trigger a custom progress event with a total data property set
225
260
  // to the file size(s) of the current upload and a loaded data
226
261
  // property calculated accordingly:
@@ -230,7 +265,12 @@
230
265
  this._trigger('progressall', e, {
231
266
  lengthComputable: true,
232
267
  loaded: this._loaded,
233
- total: this._total
268
+ total: this._total,
269
+ bitrate: this._bitrateTimer.getBitrate(
270
+ now,
271
+ this._loaded,
272
+ data.bitrateInterval
273
+ )
234
274
  });
235
275
  }
236
276
  },
@@ -490,6 +530,10 @@
490
530
  ub + i * mcs,
491
531
  ub + (i + 1) * mcs
492
532
  );
533
+ // Expose the chunk index:
534
+ o.chunkIndex = i;
535
+ // Expose the number of chunks:
536
+ o.chunksNumber = n;
493
537
  // Store the current chunk size, as the blob itself
494
538
  // will be dereferenced after data processing:
495
539
  o.chunkSize = o.blob.size;
@@ -530,6 +574,8 @@
530
574
  // and no other uploads are currently running,
531
575
  // equivalent to the global ajaxStart event:
532
576
  this._trigger('start');
577
+ // Set timer for global bitrate progress calculation:
578
+ this._bitrateTimer = new this._BitrateTimer();
533
579
  }
534
580
  this._active += 1;
535
581
  // Initialize the global progress values:
@@ -582,6 +628,7 @@
582
628
  this._trigger('stop');
583
629
  // Reset the global progress values:
584
630
  this._loaded = this._total = 0;
631
+ this._bitrateTimer = null;
585
632
  }
586
633
  },
587
634
 
@@ -593,6 +640,8 @@
593
640
  options = that._getAJAXSettings(data),
594
641
  send = function (resolve, args) {
595
642
  that._sending += 1;
643
+ // Set timer for bitrate progress calculation:
644
+ options._bitrateTimer = new that._BitrateTimer();
596
645
  jqXHR = jqXHR || (
597
646
  (resolve !== false &&
598
647
  that._trigger('send', e, options) !== false &&
@@ -731,19 +780,30 @@
731
780
  }
732
781
  },
733
782
 
783
+ _getFileInputFiles: function (fileInput) {
784
+ fileInput = $(fileInput);
785
+ var files = $.each($.makeArray(fileInput.prop('files')), this._normalizeFile),
786
+ value;
787
+ if (!files.length) {
788
+ value = fileInput.prop('value');
789
+ if (!value) {
790
+ return [];
791
+ }
792
+ // If the files property is not available, the browser does not
793
+ // support the File API and we add a pseudo File object with
794
+ // the input value as name with path information removed:
795
+ files = [{name: value.replace(/^.*\\/, '')}];
796
+ }
797
+ return files;
798
+ },
799
+
734
800
  _onChange: function (e) {
735
801
  var that = e.data.fileupload,
736
802
  data = {
737
- files: $.each($.makeArray(e.target.files), that._normalizeFile),
738
803
  fileInput: $(e.target),
739
804
  form: $(e.target.form)
740
805
  };
741
- if (!data.files.length) {
742
- // If the files property is not available, the browser does not
743
- // support the File API and we add a pseudo File object with
744
- // the input value as name with path information removed:
745
- data.files = [{name: e.target.value.replace(/^.*\\/, '')}];
746
- }
806
+ data.files = that._getFileInputFiles(data.fileInput);
747
807
  if (that.options.replaceFileInput) {
748
808
  that._replaceFileInput(data.fileInput);
749
809
  }
@@ -793,7 +853,7 @@
793
853
  return false;
794
854
  }
795
855
  if (dataTransfer) {
796
- dataTransfer.dropEffect = dataTransfer.effectAllowed = 'copy';
856
+ dataTransfer.dropEffect = 'copy';
797
857
  }
798
858
  e.preventDefault();
799
859
  },
@@ -846,10 +906,9 @@
846
906
  },
847
907
 
848
908
  _create: function () {
849
- var options = this.options,
850
- dataOpts = $.extend({}, this.element.data());
851
- dataOpts[this.widgetName] = undefined;
852
- $.extend(options, dataOpts);
909
+ var options = this.options;
910
+ // Initialize options set via HTML5 data-attributes:
911
+ $.extend(options, $(this.element[0].cloneNode(false)).data());
853
912
  options.namespace = options.namespace || this.widgetName;
854
913
  this._initSpecialOptions();
855
914
  this._slots = [];
@@ -881,7 +940,11 @@
881
940
  if (!data || this.options.disabled) {
882
941
  return;
883
942
  }
884
- data.files = $.each($.makeArray(data.files), this._normalizeFile);
943
+ if (data.fileInput && !data.files) {
944
+ data.files = this._getFileInputFiles(data.fileInput);
945
+ } else {
946
+ data.files = $.each($.makeArray(data.files), this._normalizeFile);
947
+ }
885
948
  this._onAdd(null, data);
886
949
  },
887
950
 
@@ -892,7 +955,11 @@
892
955
  // The method returns a Promise object for the file upload call.
893
956
  send: function (data) {
894
957
  if (data && !this.options.disabled) {
895
- data.files = $.each($.makeArray(data.files), this._normalizeFile);
958
+ if (data.fileInput && !data.files) {
959
+ data.files = this._getFileInputFiles(data.fileInput);
960
+ } else {
961
+ data.files = $.each($.makeArray(data.files), this._normalizeFile);
962
+ }
896
963
  if (data.files.length) {
897
964
  return this._onSend(null, data);
898
965
  }
@@ -1,5 +1,5 @@
1
1
  /*
2
- * jQuery File Upload Plugin Localization Example 6.5
2
+ * jQuery File Upload Plugin Localization Example 6.5.1
3
3
  * https://github.com/blueimp/jQuery-File-Upload
4
4
  *
5
5
  * Copyright 2012, Sebastian Tschan
@@ -9,6 +9,8 @@
9
9
  * http://www.opensource.org/licenses/MIT
10
10
  */
11
11
 
12
+ /*global window */
13
+
12
14
  window.locale = {
13
15
  "fileupload": {
14
16
  "errors": {
@@ -1,5 +1,5 @@
1
1
  /*
2
- * JavaScript Canvas to Blob 1.0.1
2
+ * JavaScript Canvas to Blob 2.0.1
3
3
  * https://github.com/blueimp/JavaScript-Canvas-to-Blob
4
4
  *
5
5
  * Copyright 2012, Sebastian Tschan
@@ -15,71 +15,56 @@
15
15
  /*jslint nomen: true, regexp: true */
16
16
  /*global window, atob, ArrayBuffer, Uint8Array, define */
17
17
 
18
- (function ($) {
18
+ (function (window) {
19
19
  'use strict';
20
-
21
- var BlobBuilder = window.MozBlobBuilder ||
22
- window.WebKitBlobBuilder || window.BlobBuilder,
23
- blobTypes = /^image\/(jpeg|png)$/,
24
-
25
- // Converts a canvas element to a Blob or File object:
26
- canvasToBlob = function (canvas, callback, options) {
27
- options = options || {};
28
- if (canvas.toBlob) {
29
- canvas.toBlob(callback, options.type);
30
- return true;
31
- } else if (canvas.mozGetAsFile) {
32
- var name = options.name;
33
- callback(canvas.mozGetAsFile(
34
- (blobTypes.test(options.type) && name) ||
35
- ((name && name.replace(/\..+$/, '')) || 'blob') + '.png',
36
- options.type
37
- ));
38
- return true;
39
- } else if (canvas.toDataURL && BlobBuilder && window.atob &&
40
- window.ArrayBuffer && window.Uint8Array) {
41
- callback(canvasToBlob.dataURItoBlob(
42
- canvas.toDataURL(options.type)
43
- ));
44
- return true;
45
- }
46
- return false;
47
- };
48
-
49
- // Converts a dataURI to a Blob:
50
- canvasToBlob.dataURItoBlob = function (dataURI) {
51
- var byteString,
52
- arrayBuffer,
53
- intArray,
54
- i,
55
- bb,
56
- mimeString;
57
- if (dataURI.split(',')[0].indexOf('base64') >= 0) {
58
- // Convert base64 to raw binary data held in a string:
59
- byteString = atob(dataURI.split(',')[1]);
60
- } else {
61
- // Convert base64/URLEncoded data component to raw binary data:
62
- byteString = decodeURIComponent(dataURI.split(',')[1]);
20
+ var CanvasPrototype = window.HTMLCanvasElement &&
21
+ window.HTMLCanvasElement.prototype,
22
+ BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder ||
23
+ window.MozBlobBuilder || window.MSBlobBuilder,
24
+ dataURLtoBlob = BlobBuilder && window.atob && window.ArrayBuffer &&
25
+ window.Uint8Array && function (dataURI) {
26
+ var byteString,
27
+ arrayBuffer,
28
+ intArray,
29
+ i,
30
+ bb,
31
+ mimeString;
32
+ if (dataURI.split(',')[0].indexOf('base64') >= 0) {
33
+ // Convert base64 to raw binary data held in a string:
34
+ byteString = atob(dataURI.split(',')[1]);
35
+ } else {
36
+ // Convert base64/URLEncoded data component to raw binary data:
37
+ byteString = decodeURIComponent(dataURI.split(',')[1]);
38
+ }
39
+ // Write the bytes of the string to an ArrayBuffer:
40
+ arrayBuffer = new ArrayBuffer(byteString.length);
41
+ intArray = new Uint8Array(arrayBuffer);
42
+ for (i = 0; i < byteString.length; i += 1) {
43
+ intArray[i] = byteString.charCodeAt(i);
44
+ }
45
+ // Write the ArrayBuffer to a blob:
46
+ bb = new BlobBuilder();
47
+ bb.append(arrayBuffer);
48
+ // Separate out the mime component:
49
+ mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0];
50
+ return bb.getBlob(mimeString);
51
+ };
52
+ if (window.HTMLCanvasElement && !CanvasPrototype.toBlob) {
53
+ if (CanvasPrototype.mozGetAsFile) {
54
+ CanvasPrototype.toBlob = function (callback, type) {
55
+ callback(this.mozGetAsFile('blob', type));
56
+ };
57
+ } else if (CanvasPrototype.toDataURL && dataURLtoBlob) {
58
+ CanvasPrototype.toBlob = function (callback, type) {
59
+ callback(dataURLtoBlob(this.toDataURL(type)));
60
+ };
63
61
  }
64
- // Write the bytes of the string to an ArrayBuffer:
65
- arrayBuffer = new ArrayBuffer(byteString.length);
66
- intArray = new Uint8Array(arrayBuffer);
67
- for (i = 0; i < byteString.length; i += 1) {
68
- intArray[i] = byteString.charCodeAt(i);
69
- }
70
- // Write the ArrayBuffer to a blob:
71
- bb = new BlobBuilder();
72
- bb.append(arrayBuffer);
73
- // Separate out the mime component:
74
- mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0];
75
- return bb.getBlob(mimeString);
76
- };
77
-
62
+ }
78
63
  if (typeof define !== 'undefined' && define.amd) {
79
64
  define(function () {
80
- return canvasToBlob;
65
+ return dataURLtoBlob;
81
66
  });
82
67
  } else {
83
- $.canvasToBlob = canvasToBlob;
68
+ window.dataURLtoBlob = dataURLtoBlob;
84
69
  }
85
70
  }(this));
@@ -1,8 +1,8 @@
1
1
  /*
2
- * jQuery UI Widget 1.8.18+amd
2
+ * jQuery UI Widget 1.8.22+amd
3
3
  * https://github.com/blueimp/jQuery-File-Upload
4
4
  *
5
- * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
5
+ * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about)
6
6
  * Dual licensed under the MIT or GPL Version 2 licenses.
7
7
  * http://jquery.org/license
8
8
  *
@@ -1,5 +1,5 @@
1
1
  /*
2
- * JavaScript Load Image 1.1.4
2
+ * JavaScript Load Image 1.2.1
3
3
  * https://github.com/blueimp/JavaScript-Load-Image
4
4
  *
5
5
  * Copyright 2011, Sebastian Tschan
@@ -24,7 +24,7 @@
24
24
  oUrl;
25
25
  img.onerror = callback;
26
26
  img.onload = function () {
27
- if (oUrl) {
27
+ if (oUrl && !(options && options.noRevoke)) {
28
28
  loadImage.revokeObjectURL(oUrl);
29
29
  }
30
30
  callback(loadImage.scale(img, options));
@@ -40,46 +40,53 @@
40
40
  if (url) {
41
41
  img.src = url;
42
42
  return img;
43
- } else {
44
- return loadImage.readFile(file, function (url) {
45
- img.src = url;
46
- });
47
43
  }
44
+ return loadImage.readFile(file, function (url) {
45
+ img.src = url;
46
+ });
48
47
  },
48
+ // The check for URL.revokeObjectURL fixes an issue with Opera 12,
49
+ // which provides URL.createObjectURL but doesn't properly implement it:
49
50
  urlAPI = (window.createObjectURL && window) ||
50
- (window.URL && URL) || (window.webkitURL && webkitURL);
51
+ (window.URL && URL.revokeObjectURL && URL) ||
52
+ (window.webkitURL && webkitURL);
51
53
 
52
- // Scales the given image (img HTML element)
54
+ // Scales the given image (img or canvas HTML element)
53
55
  // using the given options.
54
- // Returns a canvas object if the canvas option is true
55
- // and the browser supports canvas, else the scaled image:
56
+ // Returns a canvas object if the browser supports canvas
57
+ // and the canvas option is true or a canvas object is passed
58
+ // as image, else the scaled image:
56
59
  loadImage.scale = function (img, options) {
57
60
  options = options || {};
58
61
  var canvas = document.createElement('canvas'),
62
+ width = img.width,
63
+ height = img.height,
59
64
  scale = Math.max(
60
- (options.minWidth || img.width) / img.width,
61
- (options.minHeight || img.height) / img.height
65
+ (options.minWidth || width) / width,
66
+ (options.minHeight || height) / height
62
67
  );
63
68
  if (scale > 1) {
64
- img.width = parseInt(img.width * scale, 10);
65
- img.height = parseInt(img.height * scale, 10);
69
+ width = parseInt(width * scale, 10);
70
+ height = parseInt(height * scale, 10);
66
71
  }
67
72
  scale = Math.min(
68
- (options.maxWidth || img.width) / img.width,
69
- (options.maxHeight || img.height) / img.height
73
+ (options.maxWidth || width) / width,
74
+ (options.maxHeight || height) / height
70
75
  );
71
76
  if (scale < 1) {
72
- img.width = parseInt(img.width * scale, 10);
73
- img.height = parseInt(img.height * scale, 10);
77
+ width = parseInt(width * scale, 10);
78
+ height = parseInt(height * scale, 10);
74
79
  }
75
- if (!options.canvas || !canvas.getContext) {
76
- return img;
80
+ if (img.getContext || (options.canvas && canvas.getContext)) {
81
+ canvas.width = width;
82
+ canvas.height = height;
83
+ canvas.getContext('2d')
84
+ .drawImage(img, 0, 0, width, height);
85
+ return canvas;
77
86
  }
78
- canvas.width = img.width;
79
- canvas.height = img.height;
80
- canvas.getContext('2d')
81
- .drawImage(img, 0, 0, img.width, img.height);
82
- return canvas;
87
+ img.width = width;
88
+ img.height = height;
89
+ return img;
83
90
  };
84
91
 
85
92
  loadImage.createObjectURL = function (file) {
@@ -37,7 +37,7 @@
37
37
  width: 200px;
38
38
  }
39
39
  .progress-animated .bar {
40
- background: url(../img/progressbar.gif) !important;
40
+ background: url(<%= asset_path '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(../img/loading.gif) center no-repeat;
48
+ background: url(<%= asset_path '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.3.0
4
+ version: 0.3.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: 2012-04-27 00:00:00.000000000 Z
12
+ date: 2012-07-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
@@ -77,7 +77,7 @@ files:
77
77
  - vendor/assets/javascripts/jquery-fileupload/cors/jquery.postmessage-transport.js
78
78
  - vendor/assets/javascripts/jquery-fileupload/cors/jquery.xdr-transport.js
79
79
  - vendor/assets/javascripts/jquery-fileupload/index.js
80
- - vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-ip.js
80
+ - vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-fp.js
81
81
  - vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-ui.js
82
82
  - vendor/assets/javascripts/jquery-fileupload/jquery.fileupload.js
83
83
  - vendor/assets/javascripts/jquery-fileupload/jquery.iframe-transport.js
@@ -86,7 +86,7 @@ files:
86
86
  - vendor/assets/javascripts/jquery-fileupload/vendor/jquery.ui.widget.js
87
87
  - vendor/assets/javascripts/jquery-fileupload/vendor/load-image.js
88
88
  - vendor/assets/javascripts/jquery-fileupload/vendor/tmpl.js
89
- - vendor/assets/stylesheets/jquery.fileupload-ui.css
89
+ - vendor/assets/stylesheets/jquery.fileupload-ui.css.erb
90
90
  - Rakefile
91
91
  - README.md
92
92
  homepage: https://github.com/tors/jquery-fileupload-rails
@@ -1,160 +0,0 @@
1
- /*
2
- * jQuery File Upload Image Processing Plugin 1.0.6
3
- * https://github.com/blueimp/jQuery-File-Upload
4
- *
5
- * Copyright 2012, Sebastian Tschan
6
- * https://blueimp.net
7
- *
8
- * Licensed under the MIT license:
9
- * http://www.opensource.org/licenses/MIT
10
- */
11
-
12
- /*jslint nomen: true, unparam: true, regexp: true */
13
- /*global define, window, document */
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
- 'load-image',
22
- 'canvas-to-blob',
23
- './jquery.fileupload'
24
- ], factory);
25
- } else {
26
- // Browser globals:
27
- factory(
28
- window.jQuery,
29
- window.loadImage,
30
- window.canvasToBlob
31
- );
32
- }
33
- }(function ($, loadImage, canvasToBlob) {
34
- 'use strict';
35
-
36
- // The File Upload IP version extends the basic fileupload widget
37
- // with image processing functionality:
38
- $.widget('blueimpIP.fileupload', $.blueimp.fileupload, {
39
-
40
- options: {
41
- // The regular expression to define which image files are to be
42
- // resized, given that the browser supports the operation:
43
- resizeSourceFileTypes: /^image\/(gif|jpeg|png)$/,
44
- // The maximum file size of images that are to be resized:
45
- resizeSourceMaxFileSize: 20000000, // 20MB
46
- // The maximum width of the resized images:
47
- resizeMaxWidth: undefined,
48
- // The maximum height of the resized images:
49
- resizeMaxHeight: undefined,
50
- // The minimum width of the resized images:
51
- resizeMinWidth: undefined,
52
- // The minimum height of the resized images:
53
- resizeMinHeight: undefined,
54
-
55
- // The add callback is invoked as soon as files are added to the fileupload
56
- // widget (via file input selection, drag & drop or add API call).
57
- // See the basic file upload widget for more information:
58
- add: function (e, data) {
59
- $(this).fileupload('resize', data).done(function () {
60
- data.submit();
61
- });
62
- }
63
- },
64
-
65
- // Resizes the image file at the given index and stores the created blob
66
- // at the original position of the files list, returns a Promise object:
67
- _resizeImage: function (files, index, options) {
68
- var that = this,
69
- file = files[index],
70
- deferred = $.Deferred(),
71
- canvas,
72
- blob;
73
- options = options || this.options;
74
- loadImage(
75
- file,
76
- function (img) {
77
- var width = img.width,
78
- height = img.height;
79
- canvas = loadImage.scale(img, {
80
- maxWidth: options.resizeMaxWidth,
81
- maxHeight: options.resizeMaxHeight,
82
- minWidth: options.resizeMinWidth,
83
- minHeight: options.resizeMinHeight,
84
- canvas: true
85
- });
86
- if (width !== canvas.width || height !== canvas.height) {
87
- canvasToBlob(canvas, function (blob) {
88
- if (!blob.name) {
89
- if (file.type === blob.type) {
90
- blob.name = file.name;
91
- } else if (file.name) {
92
- blob.name = file.name.replace(
93
- /\..+$/,
94
- '.' + blob.type.substr(6)
95
- );
96
- }
97
- }
98
- files[index] = blob;
99
- deferred.resolveWith(that);
100
- }, file);
101
- } else {
102
- deferred.resolveWith(that);
103
- }
104
- }
105
- );
106
- return deferred.promise();
107
- },
108
-
109
- // Resizes the images given as files property of the data parameter,
110
- // returns a Promise object that allows to bind a done handler, which
111
- // will be invoked after processing all images is done:
112
- resize: function (data) {
113
- var that = this,
114
- options = $.extend({}, this.options, data),
115
- resizeAll = $.type(options.resizeSourceMaxFileSize) !== 'number',
116
- isXHRUpload = this._isXHRUpload(options);
117
- $.each(data.files, function (index, file) {
118
- if (isXHRUpload && that._resizeSupport &&
119
- (options.resizeMaxWidth || options.resizeMaxHeight ||
120
- options.resizeMinWidth || options.resizeMinHeight) &&
121
- (resizeAll || file.size < options.resizeSourceMaxFileSize) &&
122
- options.resizeSourceFileTypes.test(file.type)) {
123
- that._processing += 1;
124
- if (that._processing === 1) {
125
- that.element.addClass('fileupload-processing');
126
- }
127
- that._processingQueue = that._processingQueue.pipe(function () {
128
- var deferred = $.Deferred();
129
- that._resizeImage(
130
- data.files,
131
- index,
132
- options
133
- ).done(function () {
134
- that._processing -= 1;
135
- if (that._processing === 0) {
136
- that.element
137
- .removeClass('fileupload-processing');
138
- }
139
- deferred.resolveWith(that);
140
- });
141
- return deferred.promise();
142
- });
143
- }
144
- });
145
- return this._processingQueue;
146
- },
147
-
148
- _create: function () {
149
- $.blueimp.fileupload.prototype._create.call(this);
150
- this._processing = 0;
151
- this._processingQueue = $.Deferred().resolveWith(this).promise();
152
- this._resizeSupport = canvasToBlob && canvasToBlob(
153
- document.createElement('canvas'),
154
- $.noop
155
- );
156
- }
157
-
158
- });
159
-
160
- }));