s3_cors_fileupload 0.2.0 → 0.2.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 (29) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -2
  3. data/Gemfile +1 -1
  4. data/Gemfile.lock +19 -19
  5. data/README.md +13 -1
  6. data/lib/generators/s3_cors_fileupload/install/templates/s3_uploads.js +1 -2
  7. data/lib/generators/s3_cors_fileupload/install/templates/source_file.rb +1 -1
  8. data/lib/generators/s3_cors_fileupload/install/templates/views/erb/_template_download.html.erb +19 -16
  9. data/lib/generators/s3_cors_fileupload/install/templates/views/erb/_template_upload.html.erb +31 -26
  10. data/lib/generators/s3_cors_fileupload/install/templates/views/erb/_template_uploaded.html.erb +18 -13
  11. data/lib/generators/s3_cors_fileupload/install/templates/views/erb/index.html.erb +1 -1
  12. data/lib/generators/s3_cors_fileupload/install/templates/views/haml/_template_download.html.haml +16 -21
  13. data/lib/generators/s3_cors_fileupload/install/templates/views/haml/_template_upload.html.haml +15 -18
  14. data/lib/generators/s3_cors_fileupload/install/templates/views/haml/_template_uploaded.html.haml +12 -13
  15. data/lib/generators/s3_cors_fileupload/install/templates/views/haml/index.html.haml +1 -1
  16. data/lib/s3_cors_fileupload/rails/form_helper.rb +16 -14
  17. data/lib/s3_cors_fileupload/version.rb +3 -3
  18. data/vendor/assets/javascripts/s3_cors_fileupload/index.js +4 -1
  19. data/vendor/assets/javascripts/s3_cors_fileupload/jquery.fileupload-image.js +213 -0
  20. data/vendor/assets/javascripts/s3_cors_fileupload/jquery.fileupload-process.js +164 -0
  21. data/vendor/assets/javascripts/s3_cors_fileupload/jquery.fileupload-ui.js +62 -228
  22. data/vendor/assets/javascripts/s3_cors_fileupload/jquery.fileupload-validate.js +116 -0
  23. data/vendor/assets/javascripts/s3_cors_fileupload/jquery.fileupload.js +212 -84
  24. data/vendor/assets/javascripts/s3_cors_fileupload/jquery.iframe-transport.js +24 -4
  25. data/vendor/assets/javascripts/s3_cors_fileupload/vendor/jquery.ui.widget.js +1 -1
  26. data/vendor/assets/javascripts/s3_cors_fileupload/vendor/load-image.js +138 -172
  27. data/vendor/assets/javascripts/s3_cors_fileupload/vendor/tmpl.js +3 -4
  28. data/vendor/assets/stylesheets/jquery.fileupload-ui.css.erb +12 -28
  29. metadata +5 -2
@@ -1,4 +1,4 @@
1
- = stylesheet_link_tag '//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css'
1
+ = stylesheet_link_tag '//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css'
2
2
 
3
3
  %div{:style => 'padding: 10px;'}
4
4
  %h2 Upload file(s)
@@ -51,39 +51,41 @@ module S3CorsFileupload
51
51
  <!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
52
52
  <div class='row fileupload-buttonbar'>
53
53
  <div class='span7'>
54
- <button class='btn btn-success fileinput-button'>
54
+ <span class='btn btn-success fileinput-button'>
55
55
  <i class='icon-plus icon-white'></i>
56
56
  <span>Add files...</span>
57
57
  ".html_safe +
58
58
  file_field_tag(:file, :multiple => true) + "
59
- </button>
60
- <button class='btn btn-primary start' type='submit'>
59
+ </span>
60
+ <button type='submit' class='btn btn-primary start'>
61
61
  <i class='icon-upload icon-white'></i>
62
62
  <span>Start upload</span>
63
63
  </button>
64
- <button class='btn btn-warning cancel' type='reset'>
64
+ <button type='reset' class='btn btn-warning cancel'>
65
65
  <i class='icon-ban-circle icon-white'></i>
66
66
  <span>Cancel upload</span>
67
67
  </button>
68
- <button class='btn btn-danger delete' type='button'>
68
+ <button type='button' class='btn btn-danger delete'>
69
69
  <i class='icon-trash icon-white'></i>
70
70
  <span>Delete</span>
71
71
  </button>
72
- <input class='toggle' type='checkbox'></input>
72
+ <input type='checkbox' class='toggle'></input>
73
+ <!-- The loading indicator is shown during file processing -->
74
+ <span class='fileupload-loading'></span>
73
75
  </div>
74
- <div class='span5'>
76
+ <!-- The global progress information -->
77
+ <div class='span5 fileupload-progress fade'>
75
78
  <!-- The global progress bar -->
76
- <div class='progress progress-success progress-striped active fade'>
77
- <div class='bar' style='width: 0%'></div>
79
+ <div class='progress progress-success progress-striped active' role='progressbar' aria-valuemin='0' aria-valuemax='100'>
80
+ <div class='bar' style='width: 0%;'></div>
78
81
  </div>
82
+ <!-- The extended global progress information -->
83
+ <div class='progress-extended'>&nbsp;</div>
79
84
  </div>
80
85
  </div>
81
- <!-- The loading indicator is shown during image processing -->
82
- <div class='fileupload-loading'></div>
83
- <br>
84
86
  <!-- The table listing the files available for upload/download -->
85
- <table class='table table-striped' id='upload_files'>
86
- <tbody class='files' data-target='#modal-gallery' data-toggle='modal-gallery'></tbody>
87
+ <table role='presentation' class='table table-striped' id='upload_files'>
88
+ <tbody class='files'></tbody>
87
89
  </table>".html_safe + (block ? capture(&block) : '')
88
90
  end
89
91
  end
@@ -1,5 +1,5 @@
1
1
  module S3CorsFileupload
2
- VERSION = '0.2.0'
3
- JQUERY_FILEUPLOAD_VERSION = '5.26'
4
- JQUERY_FILEUPLOAD_UI_VERSION = '7.4.1'
2
+ VERSION = '0.2.1'
3
+ JQUERY_FILEUPLOAD_VERSION = '5.32.0'
4
+ JQUERY_FILEUPLOAD_UI_VERSION = '8.5.0'
5
5
  end
@@ -3,4 +3,7 @@
3
3
  //= require s3_cors_fileupload/vendor/load-image
4
4
  //= require s3_cors_fileupload/jquery.iframe-transport
5
5
  //= require s3_cors_fileupload/jquery.fileupload
6
- //= require s3_cors_fileupload/jquery.fileupload-ui
6
+ //= require s3_cors_fileupload/jquery.fileupload-process
7
+ //= require s3_cors_fileupload/jquery.fileupload-image
8
+ //= require s3_cors_fileupload/jquery.fileupload-validate
9
+ //= require s3_cors_fileupload/jquery.fileupload-ui
@@ -0,0 +1,213 @@
1
+ /*
2
+ * jQuery File Upload Image Preview & Resize Plugin 1.0
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
+ /*jslint nomen: true, unparam: true, regexp: true */
13
+ /*global define, window */
14
+
15
+ (function (factory) {
16
+ 'use strict';
17
+ if (typeof define === 'function' && define.amd) {
18
+ // Register as an anonymous AMD module:
19
+ define([
20
+ 'jquery',
21
+ 'load-image',
22
+ 'canvas-to-blob',
23
+ './jquery.fileupload-process'
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
+ // Prepend to the default processQueue:
36
+ $.blueimp.fileupload.prototype.options.processQueue.unshift(
37
+ {
38
+ action: 'loadImage',
39
+ // Always trigger this action,
40
+ // even if the previous action was rejected:
41
+ always: true,
42
+ fileTypes: '@loadImageFileTypes',
43
+ maxFileSize: '@loadImageMaxFileSize',
44
+ noRevoke: '@loadImageNoRevoke',
45
+ disabled: '@disableImageLoad'
46
+ },
47
+ {
48
+ action: 'resizeImage',
49
+ maxWidth: '@imageMaxWidth',
50
+ maxHeight: '@imageMaxHeight',
51
+ minWidth: '@imageMinWidth',
52
+ minHeight: '@imageMinHeight',
53
+ crop: '@imageCrop',
54
+ disabled: '@disableImageResize'
55
+ },
56
+ {
57
+ action: 'saveImage',
58
+ disabled: '@disableImageResize'
59
+ },
60
+ {
61
+ action: 'resizeImage',
62
+ maxWidth: '@previewMaxWidth',
63
+ maxHeight: '@previewMaxHeight',
64
+ minWidth: '@previewMinWidth',
65
+ minHeight: '@previewMinHeight',
66
+ crop: '@previewCrop',
67
+ canvas: '@previewAsCanvas',
68
+ disabled: '@disableImagePreview'
69
+ },
70
+ {
71
+ action: 'setImage',
72
+ name: '@imagePreviewName',
73
+ disabled: '@disableImagePreview'
74
+ }
75
+ );
76
+
77
+ // The File Upload Resize plugin extends the fileupload widget
78
+ // with image resize functionality:
79
+ $.widget('blueimp.fileupload', $.blueimp.fileupload, {
80
+
81
+ options: {
82
+ // The regular expression for the types of images to load:
83
+ // matched against the file type:
84
+ loadImageFileTypes: /^image\/(gif|jpeg|png)$/,
85
+ // The maximum file size of images to load:
86
+ loadImageMaxFileSize: 5000000, // 5MB
87
+ // The maximum width of resized images:
88
+ imageMaxWidth: 1920,
89
+ // The maximum height of resized images:
90
+ imageMaxHeight: 1080,
91
+ // Define if resized images should be cropped or only scaled:
92
+ imageCrop: false,
93
+ // Disable the resize image functionality by default:
94
+ disableImageResize: true,
95
+ // The maximum width of the preview images:
96
+ previewMaxWidth: 80,
97
+ // The maximum height of the preview images:
98
+ previewMaxHeight: 80,
99
+ // Define if preview images should be cropped or only scaled:
100
+ previewCrop: false,
101
+ // Define if preview images should be resized as canvas elements:
102
+ previewAsCanvas: true
103
+ },
104
+
105
+ processActions: {
106
+
107
+ // Loads the image given via data.files and data.index
108
+ // as img element if the browser supports canvas.
109
+ // Accepts the options fileTypes (regular expression)
110
+ // and maxFileSize (integer) to limit the files to load:
111
+ loadImage: function (data, options) {
112
+ if (options.disabled) {
113
+ return data;
114
+ }
115
+ var that = this,
116
+ file = data.files[data.index],
117
+ dfd = $.Deferred();
118
+ if (($.type(options.maxFileSize) === 'number' &&
119
+ file.size > options.maxFileSize) ||
120
+ (options.fileTypes &&
121
+ !options.fileTypes.test(file.type)) ||
122
+ !loadImage(
123
+ file,
124
+ function (img) {
125
+ if (!img.src) {
126
+ return dfd.rejectWith(that, [data]);
127
+ }
128
+ data.img = img;
129
+ dfd.resolveWith(that, [data]);
130
+ },
131
+ options
132
+ )) {
133
+ dfd.rejectWith(that, [data]);
134
+ }
135
+ return dfd.promise();
136
+ },
137
+
138
+ // Resizes the image given as data.canvas or data.img
139
+ // and updates data.canvas or data.img with the resized image.
140
+ // Accepts the options maxWidth, maxHeight, minWidth,
141
+ // minHeight, canvas and crop:
142
+ resizeImage: function (data, options) {
143
+ options = $.extend({canvas: true}, options);
144
+ var img = (options.canvas && data.canvas) || data.img,
145
+ canvas;
146
+ if (img && !options.disabled) {
147
+ canvas = loadImage.scale(img, options);
148
+ if (canvas && (canvas.width !== img.width ||
149
+ canvas.height !== img.height)) {
150
+ data[canvas.getContext ? 'canvas' : 'img'] = canvas;
151
+ }
152
+ }
153
+ return data;
154
+ },
155
+
156
+ // Saves the processed image given as data.canvas
157
+ // inplace at data.index of data.files:
158
+ saveImage: function (data, options) {
159
+ if (!data.canvas || options.disabled) {
160
+ return data;
161
+ }
162
+ var that = this,
163
+ file = data.files[data.index],
164
+ name = file.name,
165
+ dfd = $.Deferred(),
166
+ callback = function (blob) {
167
+ if (!blob.name) {
168
+ if (file.type === blob.type) {
169
+ blob.name = file.name;
170
+ } else if (file.name) {
171
+ blob.name = file.name.replace(
172
+ /\..+$/,
173
+ '.' + blob.type.substr(6)
174
+ );
175
+ }
176
+ }
177
+ // Store the created blob at the position
178
+ // of the original file in the files list:
179
+ data.files[data.index] = blob;
180
+ dfd.resolveWith(that, [data]);
181
+ };
182
+ // Use canvas.mozGetAsFile directly, to retain the filename, as
183
+ // Gecko doesn't support the filename option for FormData.append:
184
+ if (data.canvas.mozGetAsFile) {
185
+ callback(data.canvas.mozGetAsFile(
186
+ (/^image\/(jpeg|png)$/.test(file.type) && name) ||
187
+ ((name && name.replace(/\..+$/, '')) ||
188
+ 'blob') + '.png',
189
+ file.type
190
+ ));
191
+ } else if (data.canvas.toBlob) {
192
+ data.canvas.toBlob(callback, file.type);
193
+ } else {
194
+ return data;
195
+ }
196
+ return dfd.promise();
197
+ },
198
+
199
+ // Sets the resized version of the image as a property of the
200
+ // file object, must be called after "saveImage":
201
+ setImage: function (data, options) {
202
+ var img = data.canvas || data.img;
203
+ if (img && !options.disabled) {
204
+ data.files[data.index][options.name || 'preview'] = img;
205
+ }
206
+ return data;
207
+ }
208
+
209
+ }
210
+
211
+ });
212
+
213
+ }));
@@ -0,0 +1,164 @@
1
+ /*
2
+ * jQuery File Upload Processing Plugin 1.2.2
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 */
13
+ /*global define, window */
14
+
15
+ (function (factory) {
16
+ 'use strict';
17
+ if (typeof define === 'function' && define.amd) {
18
+ // Register as an anonymous AMD module:
19
+ define([
20
+ 'jquery',
21
+ './jquery.fileupload'
22
+ ], factory);
23
+ } else {
24
+ // Browser globals:
25
+ factory(
26
+ window.jQuery
27
+ );
28
+ }
29
+ }(function ($) {
30
+ 'use strict';
31
+
32
+ var originalAdd = $.blueimp.fileupload.prototype.options.add;
33
+
34
+ // The File Upload Processing plugin extends the fileupload widget
35
+ // with file processing functionality:
36
+ $.widget('blueimp.fileupload', $.blueimp.fileupload, {
37
+
38
+ options: {
39
+ // The list of processing actions:
40
+ processQueue: [
41
+ /*
42
+ {
43
+ action: 'log',
44
+ type: 'debug'
45
+ }
46
+ */
47
+ ],
48
+ add: function (e, data) {
49
+ var $this = $(this);
50
+ data.process(function () {
51
+ return $this.fileupload('process', data);
52
+ });
53
+ originalAdd.call(this, e, data);
54
+ }
55
+ },
56
+
57
+ processActions: {
58
+ /*
59
+ log: function (data, options) {
60
+ console[options.type](
61
+ 'Processing "' + data.files[data.index].name + '"'
62
+ );
63
+ }
64
+ */
65
+ },
66
+
67
+ _processFile: function (data) {
68
+ var that = this,
69
+ dfd = $.Deferred().resolveWith(that, [data]),
70
+ chain = dfd.promise();
71
+ this._trigger('process', null, data);
72
+ $.each(data.processQueue, function (i, settings) {
73
+ var func = function (data) {
74
+ return that.processActions[settings.action].call(
75
+ that,
76
+ data,
77
+ settings
78
+ );
79
+ };
80
+ chain = chain.pipe(func, settings.always && func);
81
+ });
82
+ chain
83
+ .done(function () {
84
+ that._trigger('processdone', null, data);
85
+ that._trigger('processalways', null, data);
86
+ })
87
+ .fail(function () {
88
+ that._trigger('processfail', null, data);
89
+ that._trigger('processalways', null, data);
90
+ });
91
+ return chain;
92
+ },
93
+
94
+ // Replaces the settings of each processQueue item that
95
+ // are strings starting with an "@", using the remaining
96
+ // substring as key for the option map,
97
+ // e.g. "@autoUpload" is replaced with options.autoUpload:
98
+ _transformProcessQueue: function (options) {
99
+ var processQueue = [];
100
+ $.each(options.processQueue, function () {
101
+ var settings = {},
102
+ action = this.action,
103
+ prefix = this.prefix === true ? action : this.prefix;
104
+ $.each(this, function (key, value) {
105
+ if ($.type(value) === 'string' &&
106
+ value.charAt(0) === '@') {
107
+ settings[key] = options[
108
+ value.slice(1) || (prefix ? prefix +
109
+ key.charAt(0).toUpperCase() + key.slice(1) : key)
110
+ ];
111
+ } else {
112
+ settings[key] = value;
113
+ }
114
+
115
+ });
116
+ processQueue.push(settings);
117
+ });
118
+ options.processQueue = processQueue;
119
+ },
120
+
121
+ // Returns the number of files currently in the processsing queue:
122
+ processing: function () {
123
+ return this._processing;
124
+ },
125
+
126
+ // Processes the files given as files property of the data parameter,
127
+ // returns a Promise object that allows to bind callbacks:
128
+ process: function (data) {
129
+ var that = this,
130
+ options = $.extend({}, this.options, data);
131
+ if (options.processQueue && options.processQueue.length) {
132
+ this._transformProcessQueue(options);
133
+ if (this._processing === 0) {
134
+ this._trigger('processstart');
135
+ }
136
+ $.each(data.files, function (index) {
137
+ var opts = index ? $.extend({}, options) : options,
138
+ func = function () {
139
+ return that._processFile(opts);
140
+ };
141
+ opts.index = index;
142
+ that._processing += 1;
143
+ that._processingQueue = that._processingQueue.pipe(func, func)
144
+ .always(function () {
145
+ that._processing -= 1;
146
+ if (that._processing === 0) {
147
+ that._trigger('processstop');
148
+ }
149
+ });
150
+ });
151
+ }
152
+ return this._processingQueue;
153
+ },
154
+
155
+ _create: function () {
156
+ this._super();
157
+ this._processing = 0;
158
+ this._processingQueue = $.Deferred().resolveWith(this)
159
+ .promise();
160
+ }
161
+
162
+ });
163
+
164
+ }));