better-jquery-fileupload-rails 1.0.0

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