jquery-file-upload 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +18 -0
  3. data/Gemfile +14 -0
  4. data/LICENSE +21 -0
  5. data/README.md +12 -0
  6. data/app/assets/images/jquery-file-upload/loading.gif +0 -0
  7. data/app/assets/images/jquery-file-upload/progressbar.gif +0 -0
  8. data/app/assets/javascripts/jquery-file-upload/cors/jquery.postmessage-transport.js +120 -0
  9. data/app/assets/javascripts/jquery-file-upload/cors/jquery.xdr-transport.js +89 -0
  10. data/app/assets/javascripts/jquery-file-upload/jquery.fileupload-image.js +321 -0
  11. data/app/assets/javascripts/jquery-file-upload/jquery.fileupload-jquery-ui.js +155 -0
  12. data/app/assets/javascripts/jquery-file-upload/jquery.fileupload-process.js +175 -0
  13. data/app/assets/javascripts/jquery-file-upload/jquery.fileupload-ui.js +710 -0
  14. data/app/assets/javascripts/jquery-file-upload/jquery.fileupload-validate.js +122 -0
  15. data/app/assets/javascripts/jquery-file-upload/jquery.fileupload.js +1466 -0
  16. data/app/assets/javascripts/jquery-file-upload/jquery.iframe-transport.js +217 -0
  17. data/app/assets/javascripts/jquery-file-upload/vendor/jquery.ui.widget.js +563 -0
  18. data/app/assets/javascripts/jquery-file-upload.js.coffee +1 -0
  19. data/app/assets/javascripts/jquery.fileupload-angular.js +429 -0
  20. data/app/assets/javascripts/jquery.fileupload-audio.js +112 -0
  21. data/app/assets/javascripts/jquery.fileupload-video.js +112 -0
  22. data/app/assets/stylesheets/jquery-file-upload/jquery.fileupload-noscript.css +22 -0
  23. data/app/assets/stylesheets/jquery-file-upload/jquery.fileupload-ui-noscript.css +17 -0
  24. data/app/assets/stylesheets/jquery-file-upload/jquery.fileupload-ui.css +57 -0
  25. data/app/assets/stylesheets/jquery-file-upload/jquery.fileupload.css +36 -0
  26. data/app/views/jquery-file-upload/basic_plus_ui/_download.html.erb +43 -0
  27. data/app/views/jquery-file-upload/basic_plus_ui/_form.html.slim +38 -0
  28. data/app/views/jquery-file-upload/basic_plus_ui/_upload.html.erb +32 -0
  29. data/jquery-file-upload.gemspec +19 -0
  30. data/lib/jquery-file-upload/configuration.rb +13 -0
  31. data/lib/jquery-file-upload/engine.rb +6 -0
  32. data/lib/jquery-file-upload/version.rb +3 -0
  33. data/lib/jquery-file-upload.rb +15 -0
  34. metadata +89 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b1de4cf848fe3fe243c28064f338d53c396196a6
4
+ data.tar.gz: 769c309170db49666d4870df6248f6bc29a1878e
5
+ SHA512:
6
+ metadata.gz: 6ab79cb653a5d63b0e7a9b91634821ec510f7ac680c34c9029fb9b18e9ee902151b39341787d2848c5e29908482fab5a0989de46a267f606e6bc6626614cb027
7
+ data.tar.gz: 48e9bc79b8ce7539ff51bd6250de1333a0e4b7e2cf3f19b442592c19fc7f1b8ebf982297eaa174283623472dff4e7621ef3e4d96521af773b6b1cd380b9b73ba
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Declare your gem's dependencies in jquery_file_upload_rails.gemspec.
4
+ # Bundler will treat runtime dependencies like base dependencies, and
5
+ # development dependencies will be added by default to the :development group.
6
+ gemspec
7
+
8
+ # Declare any dependencies that are still in development here instead of in
9
+ # your gemspec. These might include edge Rails or gems from your path or
10
+ # Git. Remember to move these dependencies to your gemspec before releasing
11
+ # your gem to rubygems.org.
12
+
13
+ # To use debugger
14
+ # gem 'debugger'
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 mikestephens
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,12 @@
1
+ JQuery File Upload
2
+ =================
3
+
4
+ #### Configuration
5
+
6
+ Create a new file called `/config/initializers/rails_jquery_file_upload.rb`
7
+
8
+ RailsJqueryFileUpload.configure do |config|
9
+ config.video_upload = true | false # For including the video javascript. Default is false.
10
+ config.audio_upload = true | false # For including the audio javascript. Default is false.
11
+ config.angular_js = true | false # For including the angular javascript. Default is false.
12
+ end
@@ -0,0 +1,120 @@
1
+ /*
2
+ * jQuery postMessage Transport Plugin 1.1.2
3
+ * https://github.com/blueimp/jQuery-File-Upload
4
+ *
5
+ * Copyright 2011, Sebastian Tschan
6
+ * https://blueimp.net
7
+ *
8
+ * Licensed under the MIT license:
9
+ * http://www.opensource.org/licenses/MIT
10
+ */
11
+
12
+ /* global define, require, window, document */
13
+
14
+ (function (factory) {
15
+ 'use strict';
16
+ if (typeof define === 'function' && define.amd) {
17
+ // Register as an anonymous AMD module:
18
+ define(['jquery'], factory);
19
+ } else if (typeof exports === 'object') {
20
+ // Node/CommonJS:
21
+ factory(require('jquery'));
22
+ } else {
23
+ // Browser globals:
24
+ factory(window.jQuery);
25
+ }
26
+ }(function ($) {
27
+ 'use strict';
28
+
29
+ var counter = 0,
30
+ names = [
31
+ 'accepts',
32
+ 'cache',
33
+ 'contents',
34
+ 'contentType',
35
+ 'crossDomain',
36
+ 'data',
37
+ 'dataType',
38
+ 'headers',
39
+ 'ifModified',
40
+ 'mimeType',
41
+ 'password',
42
+ 'processData',
43
+ 'timeout',
44
+ 'traditional',
45
+ 'type',
46
+ 'url',
47
+ 'username'
48
+ ],
49
+ convert = function (p) {
50
+ return p;
51
+ };
52
+
53
+ $.ajaxSetup({
54
+ converters: {
55
+ 'postmessage text': convert,
56
+ 'postmessage json': convert,
57
+ 'postmessage html': convert
58
+ }
59
+ });
60
+
61
+ $.ajaxTransport('postmessage', function (options) {
62
+ if (options.postMessage && window.postMessage) {
63
+ var iframe,
64
+ loc = $('<a>').prop('href', options.postMessage)[0],
65
+ target = loc.protocol + '//' + loc.host,
66
+ xhrUpload = options.xhr().upload;
67
+ return {
68
+ send: function (_, completeCallback) {
69
+ counter += 1;
70
+ var message = {
71
+ id: 'postmessage-transport-' + counter
72
+ },
73
+ eventName = 'message.' + message.id;
74
+ iframe = $(
75
+ '<iframe style="display:none;" src="' +
76
+ options.postMessage + '" name="' +
77
+ message.id + '"></iframe>'
78
+ ).bind('load', function () {
79
+ $.each(names, function (i, name) {
80
+ message[name] = options[name];
81
+ });
82
+ message.dataType = message.dataType.replace('postmessage ', '');
83
+ $(window).bind(eventName, function (e) {
84
+ e = e.originalEvent;
85
+ var data = e.data,
86
+ ev;
87
+ if (e.origin === target && data.id === message.id) {
88
+ if (data.type === 'progress') {
89
+ ev = document.createEvent('Event');
90
+ ev.initEvent(data.type, false, true);
91
+ $.extend(ev, data);
92
+ xhrUpload.dispatchEvent(ev);
93
+ } else {
94
+ completeCallback(
95
+ data.status,
96
+ data.statusText,
97
+ {postmessage: data.result},
98
+ data.headers
99
+ );
100
+ iframe.remove();
101
+ $(window).unbind(eventName);
102
+ }
103
+ }
104
+ });
105
+ iframe[0].contentWindow.postMessage(
106
+ message,
107
+ target
108
+ );
109
+ }).appendTo(document.body);
110
+ },
111
+ abort: function () {
112
+ if (iframe) {
113
+ iframe.remove();
114
+ }
115
+ }
116
+ };
117
+ }
118
+ });
119
+
120
+ }));
@@ -0,0 +1,89 @@
1
+ /*
2
+ * jQuery XDomainRequest Transport Plugin 1.1.4
3
+ * https://github.com/blueimp/jQuery-File-Upload
4
+ *
5
+ * Copyright 2011, Sebastian Tschan
6
+ * https://blueimp.net
7
+ *
8
+ * Licensed under the MIT license:
9
+ * http://www.opensource.org/licenses/MIT
10
+ *
11
+ * Based on Julian Aubourg's ajaxHooks xdr.js:
12
+ * https://github.com/jaubourg/ajaxHooks/
13
+ */
14
+
15
+ /* global define, require, window, XDomainRequest */
16
+
17
+ (function (factory) {
18
+ 'use strict';
19
+ if (typeof define === 'function' && define.amd) {
20
+ // Register as an anonymous AMD module:
21
+ define(['jquery'], factory);
22
+ } else if (typeof exports === 'object') {
23
+ // Node/CommonJS:
24
+ factory(require('jquery'));
25
+ } else {
26
+ // Browser globals:
27
+ factory(window.jQuery);
28
+ }
29
+ }(function ($) {
30
+ 'use strict';
31
+ if (window.XDomainRequest && !$.support.cors) {
32
+ $.ajaxTransport(function (s) {
33
+ if (s.crossDomain && s.async) {
34
+ if (s.timeout) {
35
+ s.xdrTimeout = s.timeout;
36
+ delete s.timeout;
37
+ }
38
+ var xdr;
39
+ return {
40
+ send: function (headers, completeCallback) {
41
+ var addParamChar = /\?/.test(s.url) ? '&' : '?';
42
+ function callback(status, statusText, responses, responseHeaders) {
43
+ xdr.onload = xdr.onerror = xdr.ontimeout = $.noop;
44
+ xdr = null;
45
+ completeCallback(status, statusText, responses, responseHeaders);
46
+ }
47
+ xdr = new XDomainRequest();
48
+ // XDomainRequest only supports GET and POST:
49
+ if (s.type === 'DELETE') {
50
+ s.url = s.url + addParamChar + '_method=DELETE';
51
+ s.type = 'POST';
52
+ } else if (s.type === 'PUT') {
53
+ s.url = s.url + addParamChar + '_method=PUT';
54
+ s.type = 'POST';
55
+ } else if (s.type === 'PATCH') {
56
+ s.url = s.url + addParamChar + '_method=PATCH';
57
+ s.type = 'POST';
58
+ }
59
+ xdr.open(s.type, s.url);
60
+ xdr.onload = function () {
61
+ callback(
62
+ 200,
63
+ 'OK',
64
+ {text: xdr.responseText},
65
+ 'Content-Type: ' + xdr.contentType
66
+ );
67
+ };
68
+ xdr.onerror = function () {
69
+ callback(404, 'Not Found');
70
+ };
71
+ if (s.xdrTimeout) {
72
+ xdr.ontimeout = function () {
73
+ callback(0, 'timeout');
74
+ };
75
+ xdr.timeout = s.xdrTimeout;
76
+ }
77
+ xdr.send((s.hasContent && s.data) || null);
78
+ },
79
+ abort: function () {
80
+ if (xdr) {
81
+ xdr.onerror = $.noop();
82
+ xdr.abort();
83
+ }
84
+ }
85
+ };
86
+ }
87
+ });
88
+ }
89
+ }));
@@ -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
+ }));