jquery-fileupload-rails 0.4.1 → 0.4.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 (37) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +38 -16
  3. data/{vendor → app}/assets/images/loading.gif +0 -0
  4. data/{vendor → app}/assets/images/progressbar.gif +0 -0
  5. data/app/assets/javascripts/jquery-fileupload/angularjs.js +12 -0
  6. data/app/assets/javascripts/jquery-fileupload/basic-plus.js +11 -0
  7. data/app/assets/javascripts/jquery-fileupload/basic.js +3 -0
  8. data/{vendor → app}/assets/javascripts/jquery-fileupload/cors/jquery.postmessage-transport.js +4 -4
  9. data/{vendor → app}/assets/javascripts/jquery-fileupload/cors/jquery.xdr-transport.js +1 -2
  10. data/app/assets/javascripts/jquery-fileupload/index.js +13 -0
  11. data/app/assets/javascripts/jquery-fileupload/jquery-ui.js +13 -0
  12. data/app/assets/javascripts/jquery-fileupload/jquery.fileupload-angular.js +429 -0
  13. data/app/assets/javascripts/jquery-fileupload/jquery.fileupload-audio.js +106 -0
  14. data/app/assets/javascripts/jquery-fileupload/jquery.fileupload-image.js +315 -0
  15. data/app/assets/javascripts/jquery-fileupload/jquery.fileupload-jquery-ui.js +152 -0
  16. data/app/assets/javascripts/jquery-fileupload/jquery.fileupload-process.js +172 -0
  17. data/{vendor → app}/assets/javascripts/jquery-fileupload/jquery.fileupload-ui.js +178 -273
  18. data/app/assets/javascripts/jquery-fileupload/jquery.fileupload-validate.js +119 -0
  19. data/app/assets/javascripts/jquery-fileupload/jquery.fileupload-video.js +106 -0
  20. data/{vendor → app}/assets/javascripts/jquery-fileupload/jquery.fileupload.js +481 -188
  21. data/{vendor → app}/assets/javascripts/jquery-fileupload/jquery.iframe-transport.js +43 -14
  22. data/{vendor → app}/assets/javascripts/jquery-fileupload/locale.js +0 -0
  23. data/{vendor → app}/assets/javascripts/jquery-fileupload/vendor/canvas-to-blob.js +9 -5
  24. data/{vendor → app}/assets/javascripts/jquery-fileupload/vendor/jquery.ui.widget.js +72 -44
  25. data/app/assets/javascripts/jquery-fileupload/vendor/load-image.all.min.js +1 -0
  26. data/{vendor → app}/assets/javascripts/jquery-fileupload/vendor/tmpl.js +9 -8
  27. data/app/assets/stylesheets/jquery.fileupload-noscript.scss +22 -0
  28. data/app/assets/stylesheets/jquery.fileupload-ui-noscript.scss +17 -0
  29. data/app/assets/stylesheets/jquery.fileupload-ui.scss +57 -0
  30. data/app/assets/stylesheets/jquery.fileupload.scss +36 -0
  31. data/lib/jquery/fileupload/rails/version.rb +1 -1
  32. metadata +43 -39
  33. data/vendor/assets/javascripts/jquery-fileupload/basic.js +0 -4
  34. data/vendor/assets/javascripts/jquery-fileupload/index.js +0 -9
  35. data/vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-fp.js +0 -223
  36. data/vendor/assets/javascripts/jquery-fileupload/vendor/load-image.js +0 -121
  37. data/vendor/assets/stylesheets/jquery.fileupload-ui.scss +0 -84
@@ -0,0 +1,106 @@
1
+ /*
2
+ * jQuery File Upload Audio Preview Plugin 1.0.3
3
+ * https://github.com/blueimp/jQuery-File-Upload
4
+ *
5
+ * Copyright 2013, 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, 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
+ './jquery.fileupload-process'
23
+ ], factory);
24
+ } else {
25
+ // Browser globals:
26
+ factory(
27
+ window.jQuery,
28
+ window.loadImage
29
+ );
30
+ }
31
+ }(function ($, loadImage) {
32
+ 'use strict';
33
+
34
+ // Prepend to the default processQueue:
35
+ $.blueimp.fileupload.prototype.options.processQueue.unshift(
36
+ {
37
+ action: 'loadAudio',
38
+ // Use the action as prefix for the "@" options:
39
+ prefix: true,
40
+ fileTypes: '@',
41
+ maxFileSize: '@',
42
+ disabled: '@disableAudioPreview'
43
+ },
44
+ {
45
+ action: 'setAudio',
46
+ name: '@audioPreviewName',
47
+ disabled: '@disableAudioPreview'
48
+ }
49
+ );
50
+
51
+ // The File Upload Audio Preview plugin extends the fileupload widget
52
+ // with audio preview functionality:
53
+ $.widget('blueimp.fileupload', $.blueimp.fileupload, {
54
+
55
+ options: {
56
+ // The regular expression for the types of audio files to load,
57
+ // matched against the file type:
58
+ loadAudioFileTypes: /^audio\/.*$/
59
+ },
60
+
61
+ _audioElement: document.createElement('audio'),
62
+
63
+ processActions: {
64
+
65
+ // Loads the audio file given via data.files and data.index
66
+ // as audio element if the browser supports playing it.
67
+ // Accepts the options fileTypes (regular expression)
68
+ // and maxFileSize (integer) to limit the files to load:
69
+ loadAudio: function (data, options) {
70
+ if (options.disabled) {
71
+ return data;
72
+ }
73
+ var file = data.files[data.index],
74
+ url,
75
+ audio;
76
+ if (this._audioElement.canPlayType &&
77
+ this._audioElement.canPlayType(file.type) &&
78
+ ($.type(options.maxFileSize) !== 'number' ||
79
+ file.size <= options.maxFileSize) &&
80
+ (!options.fileTypes ||
81
+ options.fileTypes.test(file.type))) {
82
+ url = loadImage.createObjectURL(file);
83
+ if (url) {
84
+ audio = this._audioElement.cloneNode(false);
85
+ audio.src = url;
86
+ audio.controls = true;
87
+ data.audio = audio;
88
+ return data;
89
+ }
90
+ }
91
+ return data;
92
+ },
93
+
94
+ // Sets the audio element as a property of the file object:
95
+ setAudio: function (data, options) {
96
+ if (data.audio && !options.disabled) {
97
+ data.files[data.index][options.name || 'preview'] = data.audio;
98
+ }
99
+ return data;
100
+ }
101
+
102
+ }
103
+
104
+ });
105
+
106
+ }));
@@ -0,0 +1,315 @@
1
+ /*
2
+ * jQuery File Upload Image Preview & Resize Plugin 1.7.2
3
+ * https://github.com/blueimp/jQuery-File-Upload
4
+ *
5
+ * Copyright 2013, 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, Blob */
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
+ 'load-image-meta',
23
+ 'load-image-exif',
24
+ 'load-image-ios',
25
+ 'canvas-to-blob',
26
+ './jquery.fileupload-process'
27
+ ], factory);
28
+ } else {
29
+ // Browser globals:
30
+ factory(
31
+ window.jQuery,
32
+ window.loadImage
33
+ );
34
+ }
35
+ }(function ($, loadImage) {
36
+ 'use strict';
37
+
38
+ // Prepend to the default processQueue:
39
+ $.blueimp.fileupload.prototype.options.processQueue.unshift(
40
+ {
41
+ action: 'loadImageMetaData',
42
+ disableImageHead: '@',
43
+ disableExif: '@',
44
+ disableExifThumbnail: '@',
45
+ disableExifSub: '@',
46
+ disableExifGps: '@',
47
+ disabled: '@disableImageMetaDataLoad'
48
+ },
49
+ {
50
+ action: 'loadImage',
51
+ // Use the action as prefix for the "@" options:
52
+ prefix: true,
53
+ fileTypes: '@',
54
+ maxFileSize: '@',
55
+ noRevoke: '@',
56
+ disabled: '@disableImageLoad'
57
+ },
58
+ {
59
+ action: 'resizeImage',
60
+ // Use "image" as prefix for the "@" options:
61
+ prefix: 'image',
62
+ maxWidth: '@',
63
+ maxHeight: '@',
64
+ minWidth: '@',
65
+ minHeight: '@',
66
+ crop: '@',
67
+ orientation: '@',
68
+ forceResize: '@',
69
+ disabled: '@disableImageResize'
70
+ },
71
+ {
72
+ action: 'saveImage',
73
+ quality: '@imageQuality',
74
+ type: '@imageType',
75
+ disabled: '@disableImageResize'
76
+ },
77
+ {
78
+ action: 'saveImageMetaData',
79
+ disabled: '@disableImageMetaDataSave'
80
+ },
81
+ {
82
+ action: 'resizeImage',
83
+ // Use "preview" as prefix for the "@" options:
84
+ prefix: 'preview',
85
+ maxWidth: '@',
86
+ maxHeight: '@',
87
+ minWidth: '@',
88
+ minHeight: '@',
89
+ crop: '@',
90
+ orientation: '@',
91
+ thumbnail: '@',
92
+ canvas: '@',
93
+ disabled: '@disableImagePreview'
94
+ },
95
+ {
96
+ action: 'setImage',
97
+ name: '@imagePreviewName',
98
+ disabled: '@disableImagePreview'
99
+ },
100
+ {
101
+ action: 'deleteImageReferences',
102
+ disabled: '@disableImageReferencesDeletion'
103
+ }
104
+ );
105
+
106
+ // The File Upload Resize plugin extends the fileupload widget
107
+ // with image resize functionality:
108
+ $.widget('blueimp.fileupload', $.blueimp.fileupload, {
109
+
110
+ options: {
111
+ // The regular expression for the types of images to load:
112
+ // matched against the file type:
113
+ loadImageFileTypes: /^image\/(gif|jpeg|png|svg\+xml)$/,
114
+ // The maximum file size of images to load:
115
+ loadImageMaxFileSize: 10000000, // 10MB
116
+ // The maximum width of resized images:
117
+ imageMaxWidth: 1920,
118
+ // The maximum height of resized images:
119
+ imageMaxHeight: 1080,
120
+ // Defines the image orientation (1-8) or takes the orientation
121
+ // value from Exif data if set to true:
122
+ imageOrientation: false,
123
+ // Define if resized images should be cropped or only scaled:
124
+ imageCrop: false,
125
+ // Disable the resize image functionality by default:
126
+ disableImageResize: true,
127
+ // The maximum width of the preview images:
128
+ previewMaxWidth: 80,
129
+ // The maximum height of the preview images:
130
+ previewMaxHeight: 80,
131
+ // Defines the preview orientation (1-8) or takes the orientation
132
+ // value from Exif data if set to true:
133
+ previewOrientation: true,
134
+ // Create the preview using the Exif data thumbnail:
135
+ previewThumbnail: true,
136
+ // Define if preview images should be cropped or only scaled:
137
+ previewCrop: false,
138
+ // Define if preview images should be resized as canvas elements:
139
+ previewCanvas: true
140
+ },
141
+
142
+ processActions: {
143
+
144
+ // Loads the image given via data.files and data.index
145
+ // as img element, if the browser supports the File API.
146
+ // Accepts the options fileTypes (regular expression)
147
+ // and maxFileSize (integer) to limit the files to load:
148
+ loadImage: function (data, options) {
149
+ if (options.disabled) {
150
+ return data;
151
+ }
152
+ var that = this,
153
+ file = data.files[data.index],
154
+ dfd = $.Deferred();
155
+ if (($.type(options.maxFileSize) === 'number' &&
156
+ file.size > options.maxFileSize) ||
157
+ (options.fileTypes &&
158
+ !options.fileTypes.test(file.type)) ||
159
+ !loadImage(
160
+ file,
161
+ function (img) {
162
+ if (img.src) {
163
+ data.img = img;
164
+ }
165
+ dfd.resolveWith(that, [data]);
166
+ },
167
+ options
168
+ )) {
169
+ return data;
170
+ }
171
+ return dfd.promise();
172
+ },
173
+
174
+ // Resizes the image given as data.canvas or data.img
175
+ // and updates data.canvas or data.img with the resized image.
176
+ // Also stores the resized image as preview property.
177
+ // Accepts the options maxWidth, maxHeight, minWidth,
178
+ // minHeight, canvas and crop:
179
+ resizeImage: function (data, options) {
180
+ if (options.disabled || !(data.canvas || data.img)) {
181
+ return data;
182
+ }
183
+ options = $.extend({canvas: true}, options);
184
+ var that = this,
185
+ dfd = $.Deferred(),
186
+ img = (options.canvas && data.canvas) || data.img,
187
+ resolve = function (newImg) {
188
+ if (newImg && (newImg.width !== img.width ||
189
+ newImg.height !== img.height ||
190
+ options.forceResize)) {
191
+ data[newImg.getContext ? 'canvas' : 'img'] = newImg;
192
+ }
193
+ data.preview = newImg;
194
+ dfd.resolveWith(that, [data]);
195
+ },
196
+ thumbnail;
197
+ if (data.exif) {
198
+ if (options.orientation === true) {
199
+ options.orientation = data.exif.get('Orientation');
200
+ }
201
+ if (options.thumbnail) {
202
+ thumbnail = data.exif.get('Thumbnail');
203
+ if (thumbnail) {
204
+ loadImage(thumbnail, resolve, options);
205
+ return dfd.promise();
206
+ }
207
+ }
208
+ // Prevent orienting the same image twice:
209
+ if (data.orientation) {
210
+ delete options.orientation;
211
+ } else {
212
+ data.orientation = options.orientation;
213
+ }
214
+ }
215
+ if (img) {
216
+ resolve(loadImage.scale(img, options));
217
+ return dfd.promise();
218
+ }
219
+ return data;
220
+ },
221
+
222
+ // Saves the processed image given as data.canvas
223
+ // inplace at data.index of data.files:
224
+ saveImage: function (data, options) {
225
+ if (!data.canvas || options.disabled) {
226
+ return data;
227
+ }
228
+ var that = this,
229
+ file = data.files[data.index],
230
+ dfd = $.Deferred();
231
+ if (data.canvas.toBlob) {
232
+ data.canvas.toBlob(
233
+ function (blob) {
234
+ if (!blob.name) {
235
+ if (file.type === blob.type) {
236
+ blob.name = file.name;
237
+ } else if (file.name) {
238
+ blob.name = file.name.replace(
239
+ /\..+$/,
240
+ '.' + blob.type.substr(6)
241
+ );
242
+ }
243
+ }
244
+ // Don't restore invalid meta data:
245
+ if (file.type !== blob.type) {
246
+ delete data.imageHead;
247
+ }
248
+ // Store the created blob at the position
249
+ // of the original file in the files list:
250
+ data.files[data.index] = blob;
251
+ dfd.resolveWith(that, [data]);
252
+ },
253
+ options.type || file.type,
254
+ options.quality
255
+ );
256
+ } else {
257
+ return data;
258
+ }
259
+ return dfd.promise();
260
+ },
261
+
262
+ loadImageMetaData: function (data, options) {
263
+ if (options.disabled) {
264
+ return data;
265
+ }
266
+ var that = this,
267
+ dfd = $.Deferred();
268
+ loadImage.parseMetaData(data.files[data.index], function (result) {
269
+ $.extend(data, result);
270
+ dfd.resolveWith(that, [data]);
271
+ }, options);
272
+ return dfd.promise();
273
+ },
274
+
275
+ saveImageMetaData: function (data, options) {
276
+ if (!(data.imageHead && data.canvas &&
277
+ data.canvas.toBlob && !options.disabled)) {
278
+ return data;
279
+ }
280
+ var file = data.files[data.index],
281
+ blob = new Blob([
282
+ data.imageHead,
283
+ // Resized images always have a head size of 20 bytes,
284
+ // including the JPEG marker and a minimal JFIF header:
285
+ this._blobSlice.call(file, 20)
286
+ ], {type: file.type});
287
+ blob.name = file.name;
288
+ data.files[data.index] = blob;
289
+ return data;
290
+ },
291
+
292
+ // Sets the resized version of the image as a property of the
293
+ // file object, must be called after "saveImage":
294
+ setImage: function (data, options) {
295
+ if (data.preview && !options.disabled) {
296
+ data.files[data.index][options.name || 'preview'] = data.preview;
297
+ }
298
+ return data;
299
+ },
300
+
301
+ deleteImageReferences: function (data, options) {
302
+ if (!options.disabled) {
303
+ delete data.img;
304
+ delete data.canvas;
305
+ delete data.preview;
306
+ delete data.imageHead;
307
+ }
308
+ return data;
309
+ }
310
+
311
+ }
312
+
313
+ });
314
+
315
+ }));
@@ -0,0 +1,152 @@
1
+ /*
2
+ * jQuery File Upload jQuery UI Plugin 8.7.1
3
+ * https://github.com/blueimp/jQuery-File-Upload
4
+ *
5
+ * Copyright 2013, 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(['jquery', './jquery.fileupload-ui'], factory);
20
+ } else {
21
+ // Browser globals:
22
+ factory(window.jQuery);
23
+ }
24
+ }(function ($) {
25
+ 'use strict';
26
+
27
+ $.widget('blueimp.fileupload', $.blueimp.fileupload, {
28
+
29
+ options: {
30
+ processdone: function (e, data) {
31
+ data.context.find('.start').button('enable');
32
+ },
33
+ progress: function (e, data) {
34
+ if (data.context) {
35
+ data.context.find('.progress').progressbar(
36
+ 'option',
37
+ 'value',
38
+ parseInt(data.loaded / data.total * 100, 10)
39
+ );
40
+ }
41
+ },
42
+ progressall: function (e, data) {
43
+ var $this = $(this);
44
+ $this.find('.fileupload-progress')
45
+ .find('.progress').progressbar(
46
+ 'option',
47
+ 'value',
48
+ parseInt(data.loaded / data.total * 100, 10)
49
+ ).end()
50
+ .find('.progress-extended').each(function () {
51
+ $(this).html(
52
+ ($this.data('blueimp-fileupload') ||
53
+ $this.data('fileupload'))
54
+ ._renderExtendedProgress(data)
55
+ );
56
+ });
57
+ }
58
+ },
59
+
60
+ _renderUpload: function (func, files) {
61
+ var node = this._super(func, files),
62
+ showIconText = $(window).width() > 480;
63
+ node.find('.progress').empty().progressbar();
64
+ node.find('.start').button({
65
+ icons: {primary: 'ui-icon-circle-arrow-e'},
66
+ text: showIconText
67
+ });
68
+ node.find('.cancel').button({
69
+ icons: {primary: 'ui-icon-cancel'},
70
+ text: showIconText
71
+ });
72
+ if (node.hasClass('fade')) {
73
+ node.hide();
74
+ }
75
+ return node;
76
+ },
77
+
78
+ _renderDownload: function (func, files) {
79
+ var node = this._super(func, files),
80
+ showIconText = $(window).width() > 480;
81
+ node.find('.delete').button({
82
+ icons: {primary: 'ui-icon-trash'},
83
+ text: showIconText
84
+ });
85
+ if (node.hasClass('fade')) {
86
+ node.hide();
87
+ }
88
+ return node;
89
+ },
90
+
91
+ _startHandler: function (e) {
92
+ $(e.currentTarget).button('disable');
93
+ this._super(e);
94
+ },
95
+
96
+ _transition: function (node) {
97
+ var deferred = $.Deferred();
98
+ if (node.hasClass('fade')) {
99
+ node.fadeToggle(
100
+ this.options.transitionDuration,
101
+ this.options.transitionEasing,
102
+ function () {
103
+ deferred.resolveWith(node);
104
+ }
105
+ );
106
+ } else {
107
+ deferred.resolveWith(node);
108
+ }
109
+ return deferred;
110
+ },
111
+
112
+ _create: function () {
113
+ this._super();
114
+ this.element
115
+ .find('.fileupload-buttonbar')
116
+ .find('.fileinput-button').each(function () {
117
+ var input = $(this).find('input:file').detach();
118
+ $(this)
119
+ .button({icons: {primary: 'ui-icon-plusthick'}})
120
+ .append(input);
121
+ })
122
+ .end().find('.start')
123
+ .button({icons: {primary: 'ui-icon-circle-arrow-e'}})
124
+ .end().find('.cancel')
125
+ .button({icons: {primary: 'ui-icon-cancel'}})
126
+ .end().find('.delete')
127
+ .button({icons: {primary: 'ui-icon-trash'}})
128
+ .end().find('.progress').progressbar();
129
+ },
130
+
131
+ _destroy: function () {
132
+ this.element
133
+ .find('.fileupload-buttonbar')
134
+ .find('.fileinput-button').each(function () {
135
+ var input = $(this).find('input:file').detach();
136
+ $(this)
137
+ .button('destroy')
138
+ .append(input);
139
+ })
140
+ .end().find('.start')
141
+ .button('destroy')
142
+ .end().find('.cancel')
143
+ .button('destroy')
144
+ .end().find('.delete')
145
+ .button('destroy')
146
+ .end().find('.progress').progressbar('destroy');
147
+ this._super();
148
+ }
149
+
150
+ });
151
+
152
+ }));