glebtv-rails-uploader 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +17 -10
  3. data/{vendor → app}/assets/images/uploader/but_del_tag2.png +0 -0
  4. data/{vendor → app}/assets/images/uploader/ico_attach.png +0 -0
  5. data/{vendor → app}/assets/images/uploader/preloader.gif +0 -0
  6. data/{vendor → app}/assets/images/uploader/progressBarFillBg.png +0 -0
  7. data/app/assets/javascripts/uploader/application.js +2 -2
  8. data/app/assets/javascripts/uploader/canvas-to-blob.js +95 -0
  9. data/app/assets/javascripts/uploader/jquery.fileupload-angular.js +348 -0
  10. data/app/assets/javascripts/uploader/jquery.fileupload-process.js +158 -0
  11. data/app/assets/javascripts/uploader/jquery.fileupload-resize.js +212 -0
  12. data/{vendor → app}/assets/javascripts/uploader/jquery.fileupload-ui.js +265 -269
  13. data/app/assets/javascripts/uploader/jquery.fileupload-validate.js +116 -0
  14. data/{vendor → app}/assets/javascripts/uploader/jquery.fileupload.js +655 -258
  15. data/{vendor → app}/assets/javascripts/uploader/jquery.iframe-transport.js +29 -9
  16. data/app/assets/javascripts/uploader/jquery.ui.widget.js +530 -0
  17. data/app/assets/javascripts/uploader/load-image.js +381 -0
  18. data/{vendor → app}/assets/javascripts/uploader/locales/en.js +0 -0
  19. data/{vendor → app}/assets/javascripts/uploader/locales/ru.js +0 -0
  20. data/{vendor → app}/assets/javascripts/uploader/locales/uk.js +0 -0
  21. data/app/assets/javascripts/uploader/rails_admin.js +26 -24
  22. data/app/assets/javascripts/uploader/tmpl.js +86 -0
  23. data/{vendor → app}/assets/stylesheets/uploader/default.css +0 -0
  24. data/{vendor → app}/assets/stylesheets/uploader/jquery.fileupload-ui.css +0 -0
  25. data/app/controllers/uploader/attachments_controller.rb +13 -10
  26. data/app/views/rails_admin/main/_form_rails_uploader.haml +9 -9
  27. data/app/views/uploader/default/_container.html.erb +1 -2
  28. data/app/views/uploader/default/_download.html.erb +1 -1
  29. data/lib/uploader/asset.rb +2 -2
  30. data/lib/uploader/engine.rb +4 -4
  31. data/lib/uploader/fileuploads.rb +18 -18
  32. data/lib/uploader/helpers/field_tag.rb +16 -17
  33. data/lib/uploader/helpers/form_builder.rb +1 -1
  34. data/lib/uploader/helpers/form_tag_helper.rb +1 -1
  35. data/lib/uploader/hooks/formtastic.rb +1 -2
  36. data/lib/uploader/rails_admin/field.rb +27 -27
  37. data/lib/uploader/version.rb +1 -1
  38. metadata +115 -131
  39. data/vendor/assets/javascripts/uploader/jquery.fileupload-ip.js +0 -160
  40. data/vendor/assets/javascripts/uploader/jquery.ui.widget.js +0 -282
  41. data/vendor/assets/javascripts/uploader/load-image.min.js +0 -1
  42. data/vendor/assets/javascripts/uploader/tmpl.min.js +0 -1
@@ -1,3 +1,3 @@
1
1
  module Uploader
2
- VERSION = "0.1.3".freeze
2
+ VERSION = "0.2.0".freeze
3
3
  end
metadata CHANGED
@@ -1,52 +1,46 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glebtv-rails-uploader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - GlebTv
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-28 00:00:00.000000000 Z
11
+ date: 2013-06-04 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: sqlite3
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: carrierwave
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rails
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - '='
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - '='
60
53
  - !ruby/object:Gem::Version
@@ -62,39 +55,34 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: mini_magick
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: jquery-rails
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: rspec-rails
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
87
  - - ~>
100
88
  - !ruby/object:Gem::Version
@@ -102,7 +90,6 @@ dependencies:
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
94
  - - ~>
108
95
  - !ruby/object:Gem::Version
@@ -110,7 +97,6 @@ dependencies:
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: factory_girl_rails
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
101
  - - ~>
116
102
  - !ruby/object:Gem::Version
@@ -118,7 +104,6 @@ dependencies:
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
108
  - - ~>
124
109
  - !ruby/object:Gem::Version
@@ -126,33 +111,29 @@ dependencies:
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: database_cleaner
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
- - - ! '>='
115
+ - - '>='
132
116
  - !ruby/object:Gem::Version
133
117
  version: '0'
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
- - - ! '>='
122
+ - - '>='
140
123
  - !ruby/object:Gem::Version
141
124
  version: '0'
142
125
  - !ruby/object:Gem::Dependency
143
126
  name: fuubar
144
127
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
128
  requirements:
147
- - - ! '>='
129
+ - - '>='
148
130
  - !ruby/object:Gem::Version
149
131
  version: '0'
150
132
  type: :development
151
133
  prerelease: false
152
134
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
135
  requirements:
155
- - - ! '>='
136
+ - - '>='
156
137
  - !ruby/object:Gem::Version
157
138
  version: '0'
158
139
  description: Rails HTML5 FileUpload helpers
@@ -162,155 +143,158 @@ extensions: []
162
143
  extra_rdoc_files:
163
144
  - README.md
164
145
  files:
165
- - app/views/uploader/default/_download.html.erb
146
+ - app/views/rails_admin/main/_form_rails_uploader.haml
166
147
  - app/views/uploader/default/_container.html.erb
167
148
  - app/views/uploader/default/_upload.html.erb
168
- - app/views/rails_admin/main/_form_rails_uploader.haml
169
- - app/assets/stylesheets/uploader/application.css
170
- - app/assets/javascripts/uploader/application.js
171
- - app/assets/javascripts/uploader/rails_admin.js
149
+ - app/views/uploader/default/_download.html.erb
172
150
  - app/controllers/uploader/attachments_controller.rb
151
+ - app/assets/javascripts/uploader/load-image.js
152
+ - app/assets/javascripts/uploader/jquery.iframe-transport.js
153
+ - app/assets/javascripts/uploader/jquery.fileupload.js
154
+ - app/assets/javascripts/uploader/rails_admin.js
155
+ - app/assets/javascripts/uploader/jquery.ui.widget.js
156
+ - app/assets/javascripts/uploader/tmpl.js
157
+ - app/assets/javascripts/uploader/jquery.fileupload-ui.js
158
+ - app/assets/javascripts/uploader/jquery.fileupload-validate.js
159
+ - app/assets/javascripts/uploader/jquery.fileupload-angular.js
160
+ - app/assets/javascripts/uploader/jquery.fileupload-process.js
161
+ - app/assets/javascripts/uploader/locales/ru.js
162
+ - app/assets/javascripts/uploader/locales/en.js
163
+ - app/assets/javascripts/uploader/locales/uk.js
164
+ - app/assets/javascripts/uploader/jquery.fileupload-resize.js
165
+ - app/assets/javascripts/uploader/canvas-to-blob.js
166
+ - app/assets/javascripts/uploader/application.js
167
+ - app/assets/images/uploader/ico_attach.png
168
+ - app/assets/images/uploader/preloader.gif
169
+ - app/assets/images/uploader/progressBarFillBg.png
170
+ - app/assets/images/uploader/but_del_tag2.png
171
+ - app/assets/stylesheets/uploader/jquery.fileupload-ui.css
172
+ - app/assets/stylesheets/uploader/application.css
173
+ - app/assets/stylesheets/uploader/default.css
174
+ - lib/glebtv-rails-uploader.rb
175
+ - lib/file_size_validator.rb
176
+ - lib/uploader.rb
177
+ - lib/uploader/version.rb
178
+ - lib/uploader/helpers/form_tag_helper.rb
173
179
  - lib/uploader/helpers/form_builder.rb
174
180
  - lib/uploader/helpers/field_tag.rb
175
- - lib/uploader/helpers/form_tag_helper.rb
176
- - lib/uploader/asset.rb
177
- - lib/uploader/fileuploads.rb
181
+ - lib/uploader/hooks/simple_form.rb
178
182
  - lib/uploader/hooks/formtastic.rb
179
183
  - lib/uploader/hooks/active_record.rb
180
- - lib/uploader/hooks/simple_form.rb
184
+ - lib/uploader/asset.rb
181
185
  - lib/uploader/rails_admin/field.rb
186
+ - lib/uploader/fileuploads.rb
182
187
  - lib/uploader/engine.rb
183
- - lib/uploader/version.rb
184
- - lib/glebtv-rails-uploader.rb
185
- - lib/uploader.rb
186
- - lib/file_size_validator.rb
188
+ - config/routes.rb
187
189
  - config/locales/ru.yml
188
190
  - config/locales/en.yml
189
191
  - config/locales/uk.yml
190
- - config/routes.rb
191
- - vendor/assets/stylesheets/uploader/jquery.fileupload-ui.css
192
- - vendor/assets/stylesheets/uploader/default.css
193
- - vendor/assets/javascripts/uploader/jquery.fileupload-ui.js
194
- - vendor/assets/javascripts/uploader/load-image.min.js
195
- - vendor/assets/javascripts/uploader/locales/uk.js
196
- - vendor/assets/javascripts/uploader/locales/en.js
197
- - vendor/assets/javascripts/uploader/locales/ru.js
198
- - vendor/assets/javascripts/uploader/jquery.fileupload.js
199
- - vendor/assets/javascripts/uploader/tmpl.min.js
200
- - vendor/assets/javascripts/uploader/jquery.iframe-transport.js
201
- - vendor/assets/javascripts/uploader/jquery.fileupload-ip.js
202
- - vendor/assets/javascripts/uploader/jquery.ui.widget.js
203
- - vendor/assets/images/uploader/progressBarFillBg.png
204
- - vendor/assets/images/uploader/ico_attach.png
205
- - vendor/assets/images/uploader/but_del_tag2.png
206
- - vendor/assets/images/uploader/preloader.gif
207
192
  - MIT-LICENSE
208
193
  - Rakefile
209
194
  - README.md
195
+ - spec/requests/attachments_controller_spec.rb
196
+ - spec/spec_helper.rb
197
+ - spec/fileuploads_spec.rb
198
+ - spec/factories/assets.rb
199
+ - spec/factories/articles.rb
200
+ - spec/factories/files/rails.png
201
+ - spec/uploader_spec.rb
210
202
  - spec/dummy/script/rails
211
- - spec/dummy/db/migrate/20120508093416_create_assets.rb
212
- - spec/dummy/db/migrate/20120508093830_create_articles.rb
213
- - spec/dummy/Rakefile
214
- - spec/dummy/README.rdoc
215
- - spec/dummy/public/favicon.ico
216
203
  - spec/dummy/public/404.html
217
204
  - spec/dummy/public/422.html
218
205
  - spec/dummy/public/500.html
219
- - spec/dummy/config/boot.rb
220
- - spec/dummy/config/environments/development.rb
221
- - spec/dummy/config/environments/production.rb
222
- - spec/dummy/config/environments/test.rb
223
- - spec/dummy/config/database.yml
224
- - spec/dummy/config/locales/en.yml
206
+ - spec/dummy/public/favicon.ico
207
+ - spec/dummy/app/uploaders/picture_uploader.rb
208
+ - spec/dummy/app/helpers/application_helper.rb
209
+ - spec/dummy/app/views/layouts/application.html.erb
210
+ - spec/dummy/app/controllers/application_controller.rb
211
+ - spec/dummy/app/models/picture.rb
212
+ - spec/dummy/app/models/asset.rb
213
+ - spec/dummy/app/models/article.rb
214
+ - spec/dummy/app/assets/javascripts/application.js
215
+ - spec/dummy/app/assets/stylesheets/application.css
216
+ - spec/dummy/db/migrate/20120508093830_create_articles.rb
217
+ - spec/dummy/db/migrate/20120508093416_create_assets.rb
218
+ - spec/dummy/config.ru
225
219
  - spec/dummy/config/routes.rb
220
+ - spec/dummy/config/application.rb
221
+ - spec/dummy/config/initializers/mime_types.rb
226
222
  - spec/dummy/config/initializers/inflections.rb
227
223
  - spec/dummy/config/initializers/backtrace_silencers.rb
228
- - spec/dummy/config/initializers/secret_token.rb
229
- - spec/dummy/config/initializers/mime_types.rb
230
224
  - spec/dummy/config/initializers/session_store.rb
225
+ - spec/dummy/config/initializers/secret_token.rb
231
226
  - spec/dummy/config/initializers/wrap_parameters.rb
232
- - spec/dummy/config/application.rb
227
+ - spec/dummy/config/locales/en.yml
228
+ - spec/dummy/config/database.yml
229
+ - spec/dummy/config/environments/test.rb
230
+ - spec/dummy/config/environments/production.rb
231
+ - spec/dummy/config/environments/development.rb
232
+ - spec/dummy/config/boot.rb
233
233
  - spec/dummy/config/environment.rb
234
- - spec/dummy/app/helpers/application_helper.rb
235
- - spec/dummy/app/models/picture.rb
236
- - spec/dummy/app/models/article.rb
237
- - spec/dummy/app/models/asset.rb
238
- - spec/dummy/app/views/layouts/application.html.erb
239
- - spec/dummy/app/uploaders/picture_uploader.rb
240
- - spec/dummy/app/assets/stylesheets/application.css
241
- - spec/dummy/app/assets/javascripts/application.js
242
- - spec/dummy/app/controllers/application_controller.rb
243
- - spec/dummy/config.ru
244
- - spec/factories/articles.rb
245
- - spec/factories/files/rails.png
246
- - spec/factories/assets.rb
247
- - spec/requests/attachments_controller_spec.rb
248
- - spec/spec_helper.rb
249
- - spec/uploader_spec.rb
250
- - spec/fileuploads_spec.rb
234
+ - spec/dummy/README.rdoc
235
+ - spec/dummy/Rakefile
251
236
  homepage: https://github.com/glebtv/rails-uploader
252
237
  licenses: []
238
+ metadata: {}
253
239
  post_install_message:
254
240
  rdoc_options: []
255
241
  require_paths:
256
242
  - lib
257
243
  required_ruby_version: !ruby/object:Gem::Requirement
258
- none: false
259
244
  requirements:
260
- - - ! '>='
245
+ - - '>='
261
246
  - !ruby/object:Gem::Version
262
247
  version: '0'
263
248
  required_rubygems_version: !ruby/object:Gem::Requirement
264
- none: false
265
249
  requirements:
266
- - - ! '>='
250
+ - - '>='
267
251
  - !ruby/object:Gem::Version
268
252
  version: '0'
269
253
  requirements: []
270
254
  rubyforge_project: rails-uploader
271
- rubygems_version: 1.8.25
255
+ rubygems_version: 2.0.3
272
256
  signing_key:
273
- specification_version: 3
257
+ specification_version: 4
274
258
  summary: Rails file upload implementation with jQuery-File-Upload
275
259
  test_files:
260
+ - spec/requests/attachments_controller_spec.rb
261
+ - spec/spec_helper.rb
262
+ - spec/fileuploads_spec.rb
263
+ - spec/factories/assets.rb
264
+ - spec/factories/articles.rb
265
+ - spec/factories/files/rails.png
266
+ - spec/uploader_spec.rb
276
267
  - spec/dummy/script/rails
277
- - spec/dummy/db/migrate/20120508093416_create_assets.rb
278
- - spec/dummy/db/migrate/20120508093830_create_articles.rb
279
- - spec/dummy/Rakefile
280
- - spec/dummy/README.rdoc
281
- - spec/dummy/public/favicon.ico
282
268
  - spec/dummy/public/404.html
283
269
  - spec/dummy/public/422.html
284
270
  - spec/dummy/public/500.html
285
- - spec/dummy/config/boot.rb
286
- - spec/dummy/config/environments/development.rb
287
- - spec/dummy/config/environments/production.rb
288
- - spec/dummy/config/environments/test.rb
289
- - spec/dummy/config/database.yml
290
- - spec/dummy/config/locales/en.yml
271
+ - spec/dummy/public/favicon.ico
272
+ - spec/dummy/app/uploaders/picture_uploader.rb
273
+ - spec/dummy/app/helpers/application_helper.rb
274
+ - spec/dummy/app/views/layouts/application.html.erb
275
+ - spec/dummy/app/controllers/application_controller.rb
276
+ - spec/dummy/app/models/picture.rb
277
+ - spec/dummy/app/models/asset.rb
278
+ - spec/dummy/app/models/article.rb
279
+ - spec/dummy/app/assets/javascripts/application.js
280
+ - spec/dummy/app/assets/stylesheets/application.css
281
+ - spec/dummy/db/migrate/20120508093830_create_articles.rb
282
+ - spec/dummy/db/migrate/20120508093416_create_assets.rb
283
+ - spec/dummy/config.ru
291
284
  - spec/dummy/config/routes.rb
285
+ - spec/dummy/config/application.rb
286
+ - spec/dummy/config/initializers/mime_types.rb
292
287
  - spec/dummy/config/initializers/inflections.rb
293
288
  - spec/dummy/config/initializers/backtrace_silencers.rb
294
- - spec/dummy/config/initializers/secret_token.rb
295
- - spec/dummy/config/initializers/mime_types.rb
296
289
  - spec/dummy/config/initializers/session_store.rb
290
+ - spec/dummy/config/initializers/secret_token.rb
297
291
  - spec/dummy/config/initializers/wrap_parameters.rb
298
- - spec/dummy/config/application.rb
292
+ - spec/dummy/config/locales/en.yml
293
+ - spec/dummy/config/database.yml
294
+ - spec/dummy/config/environments/test.rb
295
+ - spec/dummy/config/environments/production.rb
296
+ - spec/dummy/config/environments/development.rb
297
+ - spec/dummy/config/boot.rb
299
298
  - spec/dummy/config/environment.rb
300
- - spec/dummy/app/helpers/application_helper.rb
301
- - spec/dummy/app/models/picture.rb
302
- - spec/dummy/app/models/article.rb
303
- - spec/dummy/app/models/asset.rb
304
- - spec/dummy/app/views/layouts/application.html.erb
305
- - spec/dummy/app/uploaders/picture_uploader.rb
306
- - spec/dummy/app/assets/stylesheets/application.css
307
- - spec/dummy/app/assets/javascripts/application.js
308
- - spec/dummy/app/controllers/application_controller.rb
309
- - spec/dummy/config.ru
310
- - spec/factories/articles.rb
311
- - spec/factories/files/rails.png
312
- - spec/factories/assets.rb
313
- - spec/requests/attachments_controller_spec.rb
314
- - spec/spec_helper.rb
315
- - spec/uploader_spec.rb
316
- - spec/fileuploads_spec.rb
299
+ - spec/dummy/README.rdoc
300
+ - spec/dummy/Rakefile
@@ -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
- }));