activeadmin-dropzone 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d97b4f4b536980cf8ca4c1bad76c96d9b7e1f89c
4
+ data.tar.gz: 0f8776b15c3c42df1fadbb0214da6c1182100a8c
5
+ SHA512:
6
+ metadata.gz: 878d522c64800c5c94dd341ab4e71afa8c6fbc3c38f54147285f7f3318a9412c2c7acab45d03227921c02cd47e6c112d45c791554662d58ff88e7bbd41c8ba79
7
+ data.tar.gz: 579226d9ec31de2843353bb6dcccbde5e1fa83c3fd1c7eb8f2f626da3edc8705f4f3cad26f43adb982502dc20c582c1aa800201b1845e5610a3e0c6fe2a8f2e9
data/.DS_Store ADDED
Binary file
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "http://rubygems.org"
2
+
3
+ group :development do
4
+ gem 'jeweler'
5
+ gem 'simplecov-rcov'
6
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,58 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ addressable (2.3.5)
5
+ builder (3.2.2)
6
+ docile (1.1.1)
7
+ faraday (0.8.8)
8
+ multipart-post (~> 1.2.0)
9
+ git (1.2.6)
10
+ github_api (0.10.1)
11
+ addressable
12
+ faraday (~> 0.8.1)
13
+ hashie (>= 1.2)
14
+ multi_json (~> 1.4)
15
+ nokogiri (~> 1.5.2)
16
+ oauth2
17
+ hashie (2.0.5)
18
+ highline (1.6.20)
19
+ httpauth (0.2.0)
20
+ jeweler (1.8.8)
21
+ builder
22
+ bundler (~> 1.0)
23
+ git (>= 1.2.5)
24
+ github_api (= 0.10.1)
25
+ highline (>= 1.6.15)
26
+ nokogiri (= 1.5.10)
27
+ rake
28
+ rdoc
29
+ jwt (0.1.8)
30
+ multi_json (>= 1.5)
31
+ multi_json (1.8.2)
32
+ multi_xml (0.5.5)
33
+ multipart-post (1.2.0)
34
+ nokogiri (1.5.10)
35
+ oauth2 (0.9.2)
36
+ faraday (~> 0.8)
37
+ httpauth (~> 0.2)
38
+ jwt (~> 0.1.4)
39
+ multi_json (~> 1.0)
40
+ multi_xml (~> 0.5)
41
+ rack (~> 1.2)
42
+ rack (1.5.2)
43
+ rake (10.1.1)
44
+ rdoc (4.0.0)
45
+ simplecov (0.8.2)
46
+ docile (~> 1.1.0)
47
+ multi_json
48
+ simplecov-html (~> 0.8.0)
49
+ simplecov-html (0.8.0)
50
+ simplecov-rcov (0.2.3)
51
+ simplecov (>= 0.4.1)
52
+
53
+ PLATFORMS
54
+ ruby
55
+
56
+ DEPENDENCIES
57
+ jeweler
58
+ simplecov-rcov
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Maxim Gladkov
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # activeadmin-dropzone
2
+
3
+ Easy to use integration of drag&drop files upload via [dropzone.js](http://www.dropzonejs.com) for [ActiveAdmin](http://www.activeadmin.info).
4
+
5
+ ## Requirements
6
+
7
+ * [ActiveAdmin](http://www.activeadmin.info);
8
+ * [Paperclip](https://github.com/thoughtbot/paperclip) gem;
9
+ * ActiveRecord;
10
+ * Separate models for file's container and files.
11
+
12
+ ## Install
13
+
14
+ Add line to your Gemfile:
15
+
16
+ gem 'activeadmin-dropzone', '~0.0.1'
17
+
18
+ Add `dropzone` to your file container's class:
19
+
20
+ class Post
21
+ dropzone :images
22
+ end
23
+
24
+ Add `dropzone_item` to your file's class:
25
+
26
+ class Image
27
+ dropzone_item
28
+ end
29
+
30
+ Add `input` to your ActiveAdmin form:
31
+
32
+ f.input :images, as: :dropzone
33
+
34
+ ## Configuration
35
+
36
+ You can customize columns used for upload by passing `Hash` to the `dropzone_item` method. Here are the default values:
37
+
38
+ dropzone_item title: :title,
39
+ position: :position,
40
+ data: :data,
41
+ file_size: :file_size,
42
+ url: :url
43
+
44
+ ## Contributing to activeadmin-dropzone
45
+
46
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
47
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
48
+ * Fork the project.
49
+ * Start a feature/bugfix branch.
50
+ * Commit and push until you are happy with your contribution.
51
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
52
+
53
+ ## Copyright
54
+
55
+ Copyright (c) 2014 Maxim Gladkov. See LICENSE.txt for
56
+ further details.
data/Rakefile ADDED
@@ -0,0 +1,37 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "activeadmin-dropzone"
18
+ gem.homepage = "http://maximgladkov.com/blog/activeadmin-dropzone-gem"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Easy to use integration of drag&drop files upload via dropzone.js for ActiveAdmin}
21
+ gem.email = "contact@maximgladkov.com"
22
+ gem.authors = ["Maxim Gladkov"]
23
+ # dependencies defined in Gemfile
24
+ end
25
+ Jeweler::RubygemsDotOrgTasks.new
26
+
27
+ task :default => :test
28
+
29
+ require 'rdoc/task'
30
+ Rake::RDocTask.new do |rdoc|
31
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
32
+
33
+ rdoc.rdoc_dir = 'rdoc'
34
+ rdoc.title = "activeadmin-dropzone #{version}"
35
+ rdoc.rdoc_files.include('README*')
36
+ rdoc.rdoc_files.include('lib/**/*.rb')
37
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,70 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "activeadmin-dropzone"
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Maxim Gladkov"]
12
+ s.date = "2014-02-25"
13
+ s.email = "contact@maximgladkov.com"
14
+ s.extra_rdoc_files = [
15
+ "LICENSE.txt",
16
+ "README.md"
17
+ ]
18
+ s.files = [
19
+ ".DS_Store",
20
+ ".document",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.md",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "activeadmin-dropzone.gemspec",
28
+ "app/.DS_Store",
29
+ "app/assets/.DS_Store",
30
+ "app/assets/images/.DS_Store",
31
+ "app/assets/javascripts/activeadmin-dropzone.js",
32
+ "app/assets/javascripts/dropzone.js",
33
+ "app/assets/stylesheets/activeadmin-dropzone.css.scss",
34
+ "app/assets/stylesheets/dropzone.css",
35
+ "app/controllers/dropzone_controller.rb",
36
+ "app/helpers/active_admin/views_helper.rb",
37
+ "app/inputs/dropzone_input.rb",
38
+ "app/views/application/_dropzone.html.erb",
39
+ "config/locales/en.yml",
40
+ "config/locales/ru.yml",
41
+ "config/routes.rb",
42
+ "lib/.DS_Store",
43
+ "lib/activeadmin-dropzone.rb",
44
+ "lib/activeadmin-dropzone/active_record/dropzone.rb",
45
+ "lib/activeadmin-dropzone/engine.rb",
46
+ "test/helper.rb",
47
+ "test/test_activeadmin-dropzone.rb"
48
+ ]
49
+ s.homepage = "http://maximgladkov.com/blog/activeadmin-dropzone-gem"
50
+ s.licenses = ["MIT"]
51
+ s.require_paths = ["lib"]
52
+ s.rubygems_version = "2.0.3"
53
+ s.summary = "Easy to use integration of drag&drop files upload via dropzone.js for ActiveAdmin"
54
+
55
+ if s.respond_to? :specification_version then
56
+ s.specification_version = 4
57
+
58
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
59
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
60
+ s.add_development_dependency(%q<simplecov-rcov>, [">= 0"])
61
+ else
62
+ s.add_dependency(%q<jeweler>, [">= 0"])
63
+ s.add_dependency(%q<simplecov-rcov>, [">= 0"])
64
+ end
65
+ else
66
+ s.add_dependency(%q<jeweler>, [">= 0"])
67
+ s.add_dependency(%q<simplecov-rcov>, [">= 0"])
68
+ end
69
+ end
70
+
data/app/.DS_Store ADDED
Binary file
Binary file
Binary file
@@ -0,0 +1 @@
1
+ //= require dropzone
@@ -0,0 +1,1758 @@
1
+ ;(function(){
2
+
3
+ /**
4
+ * Require the given path.
5
+ *
6
+ * @param {String} path
7
+ * @return {Object} exports
8
+ * @api public
9
+ */
10
+
11
+ function require(path, parent, orig) {
12
+ var resolved = require.resolve(path);
13
+
14
+ // lookup failed
15
+ if (null == resolved) {
16
+ orig = orig || path;
17
+ parent = parent || 'root';
18
+ var err = new Error('Failed to require "' + orig + '" from "' + parent + '"');
19
+ err.path = orig;
20
+ err.parent = parent;
21
+ err.require = true;
22
+ throw err;
23
+ }
24
+
25
+ var module = require.modules[resolved];
26
+
27
+ // perform real require()
28
+ // by invoking the module's
29
+ // registered function
30
+ if (!module.exports) {
31
+ module.exports = {};
32
+ module.client = module.component = true;
33
+ module.call(this, module.exports, require.relative(resolved), module);
34
+ }
35
+
36
+ return module.exports;
37
+ }
38
+
39
+ /**
40
+ * Registered modules.
41
+ */
42
+
43
+ require.modules = {};
44
+
45
+ /**
46
+ * Registered aliases.
47
+ */
48
+
49
+ require.aliases = {};
50
+
51
+ /**
52
+ * Resolve `path`.
53
+ *
54
+ * Lookup:
55
+ *
56
+ * - PATH/index.js
57
+ * - PATH.js
58
+ * - PATH
59
+ *
60
+ * @param {String} path
61
+ * @return {String} path or null
62
+ * @api private
63
+ */
64
+
65
+ require.resolve = function(path) {
66
+ if (path.charAt(0) === '/') path = path.slice(1);
67
+
68
+ var paths = [
69
+ path,
70
+ path + '.js',
71
+ path + '.json',
72
+ path + '/index.js',
73
+ path + '/index.json'
74
+ ];
75
+
76
+ for (var i = 0; i < paths.length; i++) {
77
+ var path = paths[i];
78
+ if (require.modules.hasOwnProperty(path)) return path;
79
+ if (require.aliases.hasOwnProperty(path)) return require.aliases[path];
80
+ }
81
+ };
82
+
83
+ /**
84
+ * Normalize `path` relative to the current path.
85
+ *
86
+ * @param {String} curr
87
+ * @param {String} path
88
+ * @return {String}
89
+ * @api private
90
+ */
91
+
92
+ require.normalize = function(curr, path) {
93
+ var segs = [];
94
+
95
+ if ('.' != path.charAt(0)) return path;
96
+
97
+ curr = curr.split('/');
98
+ path = path.split('/');
99
+
100
+ for (var i = 0; i < path.length; ++i) {
101
+ if ('..' == path[i]) {
102
+ curr.pop();
103
+ } else if ('.' != path[i] && '' != path[i]) {
104
+ segs.push(path[i]);
105
+ }
106
+ }
107
+
108
+ return curr.concat(segs).join('/');
109
+ };
110
+
111
+ /**
112
+ * Register module at `path` with callback `definition`.
113
+ *
114
+ * @param {String} path
115
+ * @param {Function} definition
116
+ * @api private
117
+ */
118
+
119
+ require.register = function(path, definition) {
120
+ require.modules[path] = definition;
121
+ };
122
+
123
+ /**
124
+ * Alias a module definition.
125
+ *
126
+ * @param {String} from
127
+ * @param {String} to
128
+ * @api private
129
+ */
130
+
131
+ require.alias = function(from, to) {
132
+ if (!require.modules.hasOwnProperty(from)) {
133
+ throw new Error('Failed to alias "' + from + '", it does not exist');
134
+ }
135
+ require.aliases[to] = from;
136
+ };
137
+
138
+ /**
139
+ * Return a require function relative to the `parent` path.
140
+ *
141
+ * @param {String} parent
142
+ * @return {Function}
143
+ * @api private
144
+ */
145
+
146
+ require.relative = function(parent) {
147
+ var p = require.normalize(parent, '..');
148
+
149
+ /**
150
+ * lastIndexOf helper.
151
+ */
152
+
153
+ function lastIndexOf(arr, obj) {
154
+ var i = arr.length;
155
+ while (i--) {
156
+ if (arr[i] === obj) return i;
157
+ }
158
+ return -1;
159
+ }
160
+
161
+ /**
162
+ * The relative require() itself.
163
+ */
164
+
165
+ function localRequire(path) {
166
+ var resolved = localRequire.resolve(path);
167
+ return require(resolved, parent, path);
168
+ }
169
+
170
+ /**
171
+ * Resolve relative to the parent.
172
+ */
173
+
174
+ localRequire.resolve = function(path) {
175
+ var c = path.charAt(0);
176
+ if ('/' == c) return path.slice(1);
177
+ if ('.' == c) return require.normalize(p, path);
178
+
179
+ // resolve deps by returning
180
+ // the dep in the nearest "deps"
181
+ // directory
182
+ var segs = parent.split('/');
183
+ var i = lastIndexOf(segs, 'deps') + 1;
184
+ if (!i) i = 0;
185
+ path = segs.slice(0, i + 1).join('/') + '/deps/' + path;
186
+ return path;
187
+ };
188
+
189
+ /**
190
+ * Check if module is defined at `path`.
191
+ */
192
+
193
+ localRequire.exists = function(path) {
194
+ return require.modules.hasOwnProperty(localRequire.resolve(path));
195
+ };
196
+
197
+ return localRequire;
198
+ };
199
+ require.register("component-emitter/index.js", function(exports, require, module){
200
+
201
+ /**
202
+ * Expose `Emitter`.
203
+ */
204
+
205
+ module.exports = Emitter;
206
+
207
+ /**
208
+ * Initialize a new `Emitter`.
209
+ *
210
+ * @api public
211
+ */
212
+
213
+ function Emitter(obj) {
214
+ if (obj) return mixin(obj);
215
+ };
216
+
217
+ /**
218
+ * Mixin the emitter properties.
219
+ *
220
+ * @param {Object} obj
221
+ * @return {Object}
222
+ * @api private
223
+ */
224
+
225
+ function mixin(obj) {
226
+ for (var key in Emitter.prototype) {
227
+ obj[key] = Emitter.prototype[key];
228
+ }
229
+ return obj;
230
+ }
231
+
232
+ /**
233
+ * Listen on the given `event` with `fn`.
234
+ *
235
+ * @param {String} event
236
+ * @param {Function} fn
237
+ * @return {Emitter}
238
+ * @api public
239
+ */
240
+
241
+ Emitter.prototype.on = function(event, fn){
242
+ this._callbacks = this._callbacks || {};
243
+ (this._callbacks[event] = this._callbacks[event] || [])
244
+ .push(fn);
245
+ return this;
246
+ };
247
+
248
+ /**
249
+ * Adds an `event` listener that will be invoked a single
250
+ * time then automatically removed.
251
+ *
252
+ * @param {String} event
253
+ * @param {Function} fn
254
+ * @return {Emitter}
255
+ * @api public
256
+ */
257
+
258
+ Emitter.prototype.once = function(event, fn){
259
+ var self = this;
260
+ this._callbacks = this._callbacks || {};
261
+
262
+ function on() {
263
+ self.off(event, on);
264
+ fn.apply(this, arguments);
265
+ }
266
+
267
+ fn._off = on;
268
+ this.on(event, on);
269
+ return this;
270
+ };
271
+
272
+ /**
273
+ * Remove the given callback for `event` or all
274
+ * registered callbacks.
275
+ *
276
+ * @param {String} event
277
+ * @param {Function} fn
278
+ * @return {Emitter}
279
+ * @api public
280
+ */
281
+
282
+ Emitter.prototype.off =
283
+ Emitter.prototype.removeListener =
284
+ Emitter.prototype.removeAllListeners = function(event, fn){
285
+ this._callbacks = this._callbacks || {};
286
+ var callbacks = this._callbacks[event];
287
+ if (!callbacks) return this;
288
+
289
+ // remove all handlers
290
+ if (1 == arguments.length) {
291
+ delete this._callbacks[event];
292
+ return this;
293
+ }
294
+
295
+ // remove specific handler
296
+ var i = callbacks.indexOf(fn._off || fn);
297
+ if (~i) callbacks.splice(i, 1);
298
+ return this;
299
+ };
300
+
301
+ /**
302
+ * Emit `event` with the given args.
303
+ *
304
+ * @param {String} event
305
+ * @param {Mixed} ...
306
+ * @return {Emitter}
307
+ */
308
+
309
+ Emitter.prototype.emit = function(event){
310
+ this._callbacks = this._callbacks || {};
311
+ var args = [].slice.call(arguments, 1)
312
+ , callbacks = this._callbacks[event];
313
+
314
+ if (callbacks) {
315
+ callbacks = callbacks.slice(0);
316
+ for (var i = 0, len = callbacks.length; i < len; ++i) {
317
+ callbacks[i].apply(this, args);
318
+ }
319
+ }
320
+
321
+ return this;
322
+ };
323
+
324
+ /**
325
+ * Return array of callbacks for `event`.
326
+ *
327
+ * @param {String} event
328
+ * @return {Array}
329
+ * @api public
330
+ */
331
+
332
+ Emitter.prototype.listeners = function(event){
333
+ this._callbacks = this._callbacks || {};
334
+ return this._callbacks[event] || [];
335
+ };
336
+
337
+ /**
338
+ * Check if this emitter has `event` handlers.
339
+ *
340
+ * @param {String} event
341
+ * @return {Boolean}
342
+ * @api public
343
+ */
344
+
345
+ Emitter.prototype.hasListeners = function(event){
346
+ return !! this.listeners(event).length;
347
+ };
348
+
349
+ });
350
+ require.register("dropzone/index.js", function(exports, require, module){
351
+
352
+
353
+ /**
354
+ * Exposing dropzone
355
+ */
356
+ module.exports = require("./lib/dropzone.js");
357
+
358
+ });
359
+ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
360
+ /*
361
+ #
362
+ # More info at [www.dropzonejs.com](http://www.dropzonejs.com)
363
+ #
364
+ # Copyright (c) 2012, Matias Meno
365
+ #
366
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
367
+ # of this software and associated documentation files (the "Software"), to deal
368
+ # in the Software without restriction, including without limitation the rights
369
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
370
+ # copies of the Software, and to permit persons to whom the Software is
371
+ # furnished to do so, subject to the following conditions:
372
+ #
373
+ # The above copyright notice and this permission notice shall be included in
374
+ # all copies or substantial portions of the Software.
375
+ #
376
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
377
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
378
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
379
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
380
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
381
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
382
+ # THE SOFTWARE.
383
+ #
384
+ */
385
+
386
+
387
+ (function() {
388
+ var Dropzone, Em, camelize, contentLoaded, noop, without,
389
+ __hasProp = {}.hasOwnProperty,
390
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
391
+ __slice = [].slice;
392
+
393
+ Em = typeof Emitter !== "undefined" && Emitter !== null ? Emitter : require("emitter");
394
+
395
+ noop = function() {};
396
+
397
+ Dropzone = (function(_super) {
398
+ var extend;
399
+
400
+ __extends(Dropzone, _super);
401
+
402
+ /*
403
+ This is a list of all available events you can register on a dropzone object.
404
+
405
+ You can register an event handler like this:
406
+
407
+ dropzone.on("dragEnter", function() { });
408
+ */
409
+
410
+
411
+ Dropzone.prototype.events = ["drop", "dragstart", "dragend", "dragenter", "dragover", "dragleave", "selectedfiles", "addedfile", "removedfile", "thumbnail", "error", "errormultiple", "processing", "processingmultiple", "uploadprogress", "totaluploadprogress", "sending", "sendingmultiple", "success", "successmultiple", "canceled", "canceledmultiple", "complete", "completemultiple", "reset", "maxfilesexceeded"];
412
+
413
+ Dropzone.prototype.defaultOptions = {
414
+ url: null,
415
+ method: "post",
416
+ withCredentials: false,
417
+ parallelUploads: 2,
418
+ uploadMultiple: false,
419
+ maxFilesize: 256,
420
+ paramName: "file",
421
+ createImageThumbnails: true,
422
+ maxThumbnailFilesize: 10,
423
+ thumbnailWidth: 100,
424
+ thumbnailHeight: 100,
425
+ maxFiles: null,
426
+ params: {},
427
+ clickable: true,
428
+ ignoreHiddenFiles: true,
429
+ acceptedFiles: null,
430
+ acceptedMimeTypes: null,
431
+ autoProcessQueue: true,
432
+ addRemoveLinks: false,
433
+ previewsContainer: null,
434
+ dictDefaultMessage: "Drop files here to upload",
435
+ dictFallbackMessage: "Your browser does not support drag'n'drop file uploads.",
436
+ dictFallbackText: "Please use the fallback form below to upload your files like in the olden days.",
437
+ dictFileTooBig: "File is too big ({{filesize}}MB). Max filesize: {{maxFilesize}}MB.",
438
+ dictInvalidFileType: "You can't upload files of this type.",
439
+ dictResponseError: "Server responded with {{statusCode}} code.",
440
+ dictCancelUpload: "Cancel upload",
441
+ dictCancelUploadConfirmation: "Are you sure you want to cancel this upload?",
442
+ dictRemoveFile: "Remove file",
443
+ dictRemoveFileConfirmation: null,
444
+ dictMaxFilesExceeded: "You can only upload {{maxFiles}} files.",
445
+ accept: function(file, done) {
446
+ return done();
447
+ },
448
+ init: function() {
449
+ return noop;
450
+ },
451
+ forceFallback: false,
452
+ fallback: function() {
453
+ var child, messageElement, span, _i, _len, _ref;
454
+ this.element.className = "" + this.element.className + " dz-browser-not-supported";
455
+ _ref = this.element.getElementsByTagName("div");
456
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
457
+ child = _ref[_i];
458
+ if (/(^| )dz-message($| )/.test(child.className)) {
459
+ messageElement = child;
460
+ child.className = "dz-message";
461
+ continue;
462
+ }
463
+ }
464
+ if (!messageElement) {
465
+ messageElement = Dropzone.createElement("<div class=\"dz-message\"><span></span></div>");
466
+ this.element.appendChild(messageElement);
467
+ }
468
+ span = messageElement.getElementsByTagName("span")[0];
469
+ if (span) {
470
+ span.textContent = this.options.dictFallbackMessage;
471
+ }
472
+ return this.element.appendChild(this.getFallbackForm());
473
+ },
474
+ resize: function(file) {
475
+ var info, srcRatio, trgRatio;
476
+ info = {
477
+ srcX: 0,
478
+ srcY: 0,
479
+ srcWidth: file.width,
480
+ srcHeight: file.height
481
+ };
482
+ srcRatio = file.width / file.height;
483
+ trgRatio = this.options.thumbnailWidth / this.options.thumbnailHeight;
484
+ if (file.height < this.options.thumbnailHeight || file.width < this.options.thumbnailWidth) {
485
+ info.trgHeight = info.srcHeight;
486
+ info.trgWidth = info.srcWidth;
487
+ } else {
488
+ if (srcRatio > trgRatio) {
489
+ info.srcHeight = file.height;
490
+ info.srcWidth = info.srcHeight * trgRatio;
491
+ } else {
492
+ info.srcWidth = file.width;
493
+ info.srcHeight = info.srcWidth / trgRatio;
494
+ }
495
+ }
496
+ info.srcX = (file.width - info.srcWidth) / 2;
497
+ info.srcY = (file.height - info.srcHeight) / 2;
498
+ return info;
499
+ },
500
+ /*
501
+ Those functions register themselves to the events on init and handle all
502
+ the user interface specific stuff. Overwriting them won't break the upload
503
+ but can break the way it's displayed.
504
+ You can overwrite them if you don't like the default behavior. If you just
505
+ want to add an additional event handler, register it on the dropzone object
506
+ and don't overwrite those options.
507
+ */
508
+
509
+ drop: function(e) {
510
+ return this.element.classList.remove("dz-drag-hover");
511
+ },
512
+ dragstart: noop,
513
+ dragend: function(e) {
514
+ return this.element.classList.remove("dz-drag-hover");
515
+ },
516
+ dragenter: function(e) {
517
+ return this.element.classList.add("dz-drag-hover");
518
+ },
519
+ dragover: function(e) {
520
+ return this.element.classList.add("dz-drag-hover");
521
+ },
522
+ dragleave: function(e) {
523
+ return this.element.classList.remove("dz-drag-hover");
524
+ },
525
+ selectedfiles: function(files) {
526
+ if (this.element === this.previewsContainer) {
527
+ return this.element.classList.add("dz-started");
528
+ }
529
+ },
530
+ reset: function() {
531
+ return this.element.classList.remove("dz-started");
532
+ },
533
+ addedfile: function(file) {
534
+ var _this = this;
535
+ file.previewElement = Dropzone.createElement(this.options.previewTemplate);
536
+ file.previewTemplate = file.previewElement;
537
+ this.previewsContainer.appendChild(file.previewElement);
538
+ file.previewElement.querySelector("[data-dz-name]").textContent = file.name;
539
+ file.previewElement.querySelector("[data-dz-size]").innerHTML = this.filesize(file.size);
540
+ if (this.options.addRemoveLinks) {
541
+ file._removeLink = Dropzone.createElement("<a class=\"dz-remove\" href=\"javascript:undefined;\">" + this.options.dictRemoveFile + "</a>");
542
+ file._removeLink.addEventListener("click", function(e) {
543
+ e.preventDefault();
544
+ e.stopPropagation();
545
+ if (file.status === Dropzone.UPLOADING) {
546
+ return Dropzone.confirm(_this.options.dictCancelUploadConfirmation, function() {
547
+ return _this.removeFile(file);
548
+ });
549
+ } else {
550
+ if (_this.options.dictRemoveFileConfirmation) {
551
+ return Dropzone.confirm(_this.options.dictRemoveFileConfirmation, function() {
552
+ return _this.removeFile(file);
553
+ });
554
+ } else {
555
+ return _this.removeFile(file);
556
+ }
557
+ }
558
+ });
559
+ file.previewElement.appendChild(file._removeLink);
560
+ }
561
+ return this._updateMaxFilesReachedClass();
562
+ },
563
+ removedfile: function(file) {
564
+ var _ref;
565
+ if ((_ref = file.previewElement) != null) {
566
+ _ref.parentNode.removeChild(file.previewElement);
567
+ }
568
+ return this._updateMaxFilesReachedClass();
569
+ },
570
+ thumbnail: function(file, dataUrl) {
571
+ var thumbnailElement;
572
+ file.previewElement.classList.remove("dz-file-preview");
573
+ file.previewElement.classList.add("dz-image-preview");
574
+ thumbnailElement = file.previewElement.querySelector("[data-dz-thumbnail]");
575
+ thumbnailElement.alt = file.name;
576
+ return thumbnailElement.src = dataUrl;
577
+ },
578
+ error: function(file, message) {
579
+ file.previewElement.classList.add("dz-error");
580
+ return file.previewElement.querySelector("[data-dz-errormessage]").textContent = message;
581
+ },
582
+ errormultiple: noop,
583
+ processing: function(file) {
584
+ file.previewElement.classList.add("dz-processing");
585
+ if (file._removeLink) {
586
+ return file._removeLink.textContent = this.options.dictCancelUpload;
587
+ }
588
+ },
589
+ processingmultiple: noop,
590
+ uploadprogress: function(file, progress, bytesSent) {
591
+ return file.previewElement.querySelector("[data-dz-uploadprogress]").style.width = "" + progress + "%";
592
+ },
593
+ totaluploadprogress: noop,
594
+ sending: noop,
595
+ sendingmultiple: noop,
596
+ success: function(file) {
597
+ return file.previewElement.classList.add("dz-success");
598
+ },
599
+ successmultiple: noop,
600
+ canceled: function(file) {
601
+ return this.emit("error", file, "Upload canceled.");
602
+ },
603
+ canceledmultiple: noop,
604
+ complete: function(file) {
605
+ if (file._removeLink) {
606
+ return file._removeLink.textContent = this.options.dictRemoveFile;
607
+ }
608
+ },
609
+ completemultiple: noop,
610
+ maxfilesexceeded: noop,
611
+ previewTemplate: "<div class=\"dz-preview dz-file-preview\">\n <div class=\"dz-details\">\n <div class=\"dz-filename\"><span data-dz-name></span></div>\n <div class=\"dz-size\" data-dz-size></div>\n <img data-dz-thumbnail />\n </div>\n <div class=\"dz-progress\"><span class=\"dz-upload\" data-dz-uploadprogress></span></div>\n <div class=\"dz-success-mark\"><span>✔</span></div>\n <div class=\"dz-error-mark\"><span>✘</span></div>\n <div class=\"dz-error-message\"><span data-dz-errormessage></span></div>\n</div>"
612
+ };
613
+
614
+ extend = function() {
615
+ var key, object, objects, target, val, _i, _len;
616
+ target = arguments[0], objects = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
617
+ for (_i = 0, _len = objects.length; _i < _len; _i++) {
618
+ object = objects[_i];
619
+ for (key in object) {
620
+ val = object[key];
621
+ target[key] = val;
622
+ }
623
+ }
624
+ return target;
625
+ };
626
+
627
+ function Dropzone(element, options) {
628
+ var elementOptions, fallback, _ref;
629
+ this.element = element;
630
+ this.version = Dropzone.version;
631
+ this.defaultOptions.previewTemplate = this.defaultOptions.previewTemplate.replace(/\n*/g, "");
632
+ this.clickableElements = [];
633
+ this.listeners = [];
634
+ this.files = [];
635
+ if (typeof this.element === "string") {
636
+ this.element = document.querySelector(this.element);
637
+ }
638
+ if (!(this.element && (this.element.nodeType != null))) {
639
+ throw new Error("Invalid dropzone element.");
640
+ }
641
+ if (this.element.dropzone) {
642
+ throw new Error("Dropzone already attached.");
643
+ }
644
+ Dropzone.instances.push(this);
645
+ element.dropzone = this;
646
+ elementOptions = (_ref = Dropzone.optionsForElement(this.element)) != null ? _ref : {};
647
+ this.options = extend({}, this.defaultOptions, elementOptions, options != null ? options : {});
648
+ if (this.options.forceFallback || !Dropzone.isBrowserSupported()) {
649
+ return this.options.fallback.call(this);
650
+ }
651
+ if (this.options.url == null) {
652
+ this.options.url = this.element.getAttribute("action");
653
+ }
654
+ if (!this.options.url) {
655
+ throw new Error("No URL provided.");
656
+ }
657
+ if (this.options.acceptedFiles && this.options.acceptedMimeTypes) {
658
+ throw new Error("You can't provide both 'acceptedFiles' and 'acceptedMimeTypes'. 'acceptedMimeTypes' is deprecated.");
659
+ }
660
+ if (this.options.acceptedMimeTypes) {
661
+ this.options.acceptedFiles = this.options.acceptedMimeTypes;
662
+ delete this.options.acceptedMimeTypes;
663
+ }
664
+ this.options.method = this.options.method.toUpperCase();
665
+ if ((fallback = this.getExistingFallback()) && fallback.parentNode) {
666
+ fallback.parentNode.removeChild(fallback);
667
+ }
668
+ if (this.options.previewsContainer) {
669
+ this.previewsContainer = Dropzone.getElement(this.options.previewsContainer, "previewsContainer");
670
+ } else {
671
+ this.previewsContainer = this.element;
672
+ }
673
+ if (this.options.clickable) {
674
+ if (this.options.clickable === true) {
675
+ this.clickableElements = [this.element];
676
+ } else {
677
+ this.clickableElements = Dropzone.getElements(this.options.clickable, "clickable");
678
+ }
679
+ }
680
+ this.init();
681
+ }
682
+
683
+ Dropzone.prototype.getAcceptedFiles = function() {
684
+ var file, _i, _len, _ref, _results;
685
+ _ref = this.files;
686
+ _results = [];
687
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
688
+ file = _ref[_i];
689
+ if (file.accepted) {
690
+ _results.push(file);
691
+ }
692
+ }
693
+ return _results;
694
+ };
695
+
696
+ Dropzone.prototype.getRejectedFiles = function() {
697
+ var file, _i, _len, _ref, _results;
698
+ _ref = this.files;
699
+ _results = [];
700
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
701
+ file = _ref[_i];
702
+ if (!file.accepted) {
703
+ _results.push(file);
704
+ }
705
+ }
706
+ return _results;
707
+ };
708
+
709
+ Dropzone.prototype.getQueuedFiles = function() {
710
+ var file, _i, _len, _ref, _results;
711
+ _ref = this.files;
712
+ _results = [];
713
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
714
+ file = _ref[_i];
715
+ if (file.status === Dropzone.QUEUED) {
716
+ _results.push(file);
717
+ }
718
+ }
719
+ return _results;
720
+ };
721
+
722
+ Dropzone.prototype.getUploadingFiles = function() {
723
+ var file, _i, _len, _ref, _results;
724
+ _ref = this.files;
725
+ _results = [];
726
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
727
+ file = _ref[_i];
728
+ if (file.status === Dropzone.UPLOADING) {
729
+ _results.push(file);
730
+ }
731
+ }
732
+ return _results;
733
+ };
734
+
735
+ Dropzone.prototype.init = function() {
736
+ var eventName, noPropagation, setupHiddenFileInput, _i, _len, _ref, _ref1,
737
+ _this = this;
738
+ if (this.element.tagName === "form") {
739
+ this.element.setAttribute("enctype", "multipart/form-data");
740
+ }
741
+ if (this.element.classList.contains("dropzone") && !this.element.querySelector(".dz-message")) {
742
+ this.element.appendChild(Dropzone.createElement("<div class=\"dz-default dz-message\"><span>" + this.options.dictDefaultMessage + "</span></div>"));
743
+ }
744
+ if (this.clickableElements.length) {
745
+ setupHiddenFileInput = function() {
746
+ if (_this.hiddenFileInput) {
747
+ document.body.removeChild(_this.hiddenFileInput);
748
+ }
749
+ _this.hiddenFileInput = document.createElement("input");
750
+ _this.hiddenFileInput.setAttribute("type", "file");
751
+ _this.hiddenFileInput.setAttribute("multiple", "multiple");
752
+ if (_this.options.acceptedFiles != null) {
753
+ _this.hiddenFileInput.setAttribute("accept", _this.options.acceptedFiles);
754
+ }
755
+ _this.hiddenFileInput.style.visibility = "hidden";
756
+ _this.hiddenFileInput.style.position = "absolute";
757
+ _this.hiddenFileInput.style.top = "0";
758
+ _this.hiddenFileInput.style.left = "0";
759
+ _this.hiddenFileInput.style.height = "0";
760
+ _this.hiddenFileInput.style.width = "0";
761
+ document.body.appendChild(_this.hiddenFileInput);
762
+ return _this.hiddenFileInput.addEventListener("change", function() {
763
+ var files;
764
+ files = _this.hiddenFileInput.files;
765
+ if (files.length) {
766
+ _this.emit("selectedfiles", files);
767
+ _this.handleFiles(files);
768
+ }
769
+ return setupHiddenFileInput();
770
+ });
771
+ };
772
+ setupHiddenFileInput();
773
+ }
774
+ this.URL = (_ref = window.URL) != null ? _ref : window.webkitURL;
775
+ _ref1 = this.events;
776
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
777
+ eventName = _ref1[_i];
778
+ this.on(eventName, this.options[eventName]);
779
+ }
780
+ this.on("uploadprogress", function() {
781
+ return _this.updateTotalUploadProgress();
782
+ });
783
+ this.on("removedfile", function() {
784
+ return _this.updateTotalUploadProgress();
785
+ });
786
+ this.on("canceled", function(file) {
787
+ return _this.emit("complete", file);
788
+ });
789
+ noPropagation = function(e) {
790
+ e.stopPropagation();
791
+ if (e.preventDefault) {
792
+ return e.preventDefault();
793
+ } else {
794
+ return e.returnValue = false;
795
+ }
796
+ };
797
+ this.listeners = [
798
+ {
799
+ element: this.element,
800
+ events: {
801
+ "dragstart": function(e) {
802
+ return _this.emit("dragstart", e);
803
+ },
804
+ "dragenter": function(e) {
805
+ noPropagation(e);
806
+ return _this.emit("dragenter", e);
807
+ },
808
+ "dragover": function(e) {
809
+ noPropagation(e);
810
+ return _this.emit("dragover", e);
811
+ },
812
+ "dragleave": function(e) {
813
+ return _this.emit("dragleave", e);
814
+ },
815
+ "drop": function(e) {
816
+ noPropagation(e);
817
+ return _this.drop(e);
818
+ },
819
+ "dragend": function(e) {
820
+ return _this.emit("dragend", e);
821
+ }
822
+ }
823
+ }
824
+ ];
825
+ this.clickableElements.forEach(function(clickableElement) {
826
+ return _this.listeners.push({
827
+ element: clickableElement,
828
+ events: {
829
+ "click": function(evt) {
830
+ if ((clickableElement !== _this.element) || (evt.target === _this.element || Dropzone.elementInside(evt.target, _this.element.querySelector(".dz-message")))) {
831
+ return _this.hiddenFileInput.click();
832
+ }
833
+ }
834
+ }
835
+ });
836
+ });
837
+ this.enable();
838
+ return this.options.init.call(this);
839
+ };
840
+
841
+ Dropzone.prototype.destroy = function() {
842
+ var _ref;
843
+ this.disable();
844
+ this.removeAllFiles(true);
845
+ if ((_ref = this.hiddenFileInput) != null ? _ref.parentNode : void 0) {
846
+ this.hiddenFileInput.parentNode.removeChild(this.hiddenFileInput);
847
+ this.hiddenFileInput = null;
848
+ }
849
+ return delete this.element.dropzone;
850
+ };
851
+
852
+ Dropzone.prototype.updateTotalUploadProgress = function() {
853
+ var acceptedFiles, file, totalBytes, totalBytesSent, totalUploadProgress, _i, _len, _ref;
854
+ totalBytesSent = 0;
855
+ totalBytes = 0;
856
+ acceptedFiles = this.getAcceptedFiles();
857
+ if (acceptedFiles.length) {
858
+ _ref = this.getAcceptedFiles();
859
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
860
+ file = _ref[_i];
861
+ totalBytesSent += file.upload.bytesSent;
862
+ totalBytes += file.upload.total;
863
+ }
864
+ totalUploadProgress = 100 * totalBytesSent / totalBytes;
865
+ } else {
866
+ totalUploadProgress = 100;
867
+ }
868
+ return this.emit("totaluploadprogress", totalUploadProgress, totalBytes, totalBytesSent);
869
+ };
870
+
871
+ Dropzone.prototype.getFallbackForm = function() {
872
+ var existingFallback, fields, fieldsString, form;
873
+ if (existingFallback = this.getExistingFallback()) {
874
+ return existingFallback;
875
+ }
876
+ fieldsString = "<div class=\"dz-fallback\">";
877
+ if (this.options.dictFallbackText) {
878
+ fieldsString += "<p>" + this.options.dictFallbackText + "</p>";
879
+ }
880
+ fieldsString += "<input type=\"file\" name=\"" + this.options.paramName + (this.options.uploadMultiple ? "[]" : "") + "\" " + (this.options.uploadMultiple ? 'multiple="multiple"' : void 0) + " /><button type=\"submit\">Upload!</button></div>";
881
+ fields = Dropzone.createElement(fieldsString);
882
+ if (this.element.tagName !== "FORM") {
883
+ form = Dropzone.createElement("<form action=\"" + this.options.url + "\" enctype=\"multipart/form-data\" method=\"" + this.options.method + "\"></form>");
884
+ form.appendChild(fields);
885
+ } else {
886
+ this.element.setAttribute("enctype", "multipart/form-data");
887
+ this.element.setAttribute("method", this.options.method);
888
+ }
889
+ return form != null ? form : fields;
890
+ };
891
+
892
+ Dropzone.prototype.getExistingFallback = function() {
893
+ var fallback, getFallback, tagName, _i, _len, _ref;
894
+ getFallback = function(elements) {
895
+ var el, _i, _len;
896
+ for (_i = 0, _len = elements.length; _i < _len; _i++) {
897
+ el = elements[_i];
898
+ if (/(^| )fallback($| )/.test(el.className)) {
899
+ return el;
900
+ }
901
+ }
902
+ };
903
+ _ref = ["div", "form"];
904
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
905
+ tagName = _ref[_i];
906
+ if (fallback = getFallback(this.element.getElementsByTagName(tagName))) {
907
+ return fallback;
908
+ }
909
+ }
910
+ };
911
+
912
+ Dropzone.prototype.setupEventListeners = function() {
913
+ var elementListeners, event, listener, _i, _len, _ref, _results;
914
+ _ref = this.listeners;
915
+ _results = [];
916
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
917
+ elementListeners = _ref[_i];
918
+ _results.push((function() {
919
+ var _ref1, _results1;
920
+ _ref1 = elementListeners.events;
921
+ _results1 = [];
922
+ for (event in _ref1) {
923
+ listener = _ref1[event];
924
+ _results1.push(elementListeners.element.addEventListener(event, listener, false));
925
+ }
926
+ return _results1;
927
+ })());
928
+ }
929
+ return _results;
930
+ };
931
+
932
+ Dropzone.prototype.removeEventListeners = function() {
933
+ var elementListeners, event, listener, _i, _len, _ref, _results;
934
+ _ref = this.listeners;
935
+ _results = [];
936
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
937
+ elementListeners = _ref[_i];
938
+ _results.push((function() {
939
+ var _ref1, _results1;
940
+ _ref1 = elementListeners.events;
941
+ _results1 = [];
942
+ for (event in _ref1) {
943
+ listener = _ref1[event];
944
+ _results1.push(elementListeners.element.removeEventListener(event, listener, false));
945
+ }
946
+ return _results1;
947
+ })());
948
+ }
949
+ return _results;
950
+ };
951
+
952
+ Dropzone.prototype.disable = function() {
953
+ var file, _i, _len, _ref, _results;
954
+ this.clickableElements.forEach(function(element) {
955
+ return element.classList.remove("dz-clickable");
956
+ });
957
+ this.removeEventListeners();
958
+ _ref = this.files;
959
+ _results = [];
960
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
961
+ file = _ref[_i];
962
+ _results.push(this.cancelUpload(file));
963
+ }
964
+ return _results;
965
+ };
966
+
967
+ Dropzone.prototype.enable = function() {
968
+ this.clickableElements.forEach(function(element) {
969
+ return element.classList.add("dz-clickable");
970
+ });
971
+ return this.setupEventListeners();
972
+ };
973
+
974
+ Dropzone.prototype.filesize = function(size) {
975
+ var string;
976
+ if (size >= 100000000000) {
977
+ size = size / 100000000000;
978
+ string = "TB";
979
+ } else if (size >= 100000000) {
980
+ size = size / 100000000;
981
+ string = "GB";
982
+ } else if (size >= 100000) {
983
+ size = size / 100000;
984
+ string = "MB";
985
+ } else if (size >= 100) {
986
+ size = size / 100;
987
+ string = "KB";
988
+ } else {
989
+ size = size * 10;
990
+ string = "b";
991
+ }
992
+ return "<strong>" + (Math.round(size) / 10) + "</strong> " + string;
993
+ };
994
+
995
+ Dropzone.prototype._updateMaxFilesReachedClass = function() {
996
+ if (this.options.maxFiles && this.getAcceptedFiles().length >= this.options.maxFiles) {
997
+ return this.element.classList.add("dz-max-files-reached");
998
+ } else {
999
+ return this.element.classList.remove("dz-max-files-reached");
1000
+ }
1001
+ };
1002
+
1003
+ Dropzone.prototype.drop = function(e) {
1004
+ var files, items;
1005
+ if (!e.dataTransfer) {
1006
+ return;
1007
+ }
1008
+ this.emit("drop", e);
1009
+ files = e.dataTransfer.files;
1010
+ this.emit("selectedfiles", files);
1011
+ if (files.length) {
1012
+ items = e.dataTransfer.items;
1013
+ if (items && items.length && ((items[0].webkitGetAsEntry != null) || (items[0].getAsEntry != null))) {
1014
+ this.handleItems(items);
1015
+ } else {
1016
+ this.handleFiles(files);
1017
+ }
1018
+ }
1019
+ };
1020
+
1021
+ Dropzone.prototype.handleFiles = function(files) {
1022
+ var file, _i, _len, _results;
1023
+ _results = [];
1024
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
1025
+ file = files[_i];
1026
+ _results.push(this.addFile(file));
1027
+ }
1028
+ return _results;
1029
+ };
1030
+
1031
+ Dropzone.prototype.handleItems = function(items) {
1032
+ var entry, item, _i, _len;
1033
+ for (_i = 0, _len = items.length; _i < _len; _i++) {
1034
+ item = items[_i];
1035
+ if (item.webkitGetAsEntry != null) {
1036
+ entry = item.webkitGetAsEntry();
1037
+ if (entry.isFile) {
1038
+ this.addFile(item.getAsFile());
1039
+ } else if (entry.isDirectory) {
1040
+ this.addDirectory(entry, entry.name);
1041
+ }
1042
+ } else {
1043
+ this.addFile(item.getAsFile());
1044
+ }
1045
+ }
1046
+ };
1047
+
1048
+ Dropzone.prototype.accept = function(file, done) {
1049
+ if (file.size > this.options.maxFilesize * 1024 * 1024) {
1050
+ return done(this.options.dictFileTooBig.replace("{{filesize}}", Math.round(file.size / 1024 / 10.24) / 100).replace("{{maxFilesize}}", this.options.maxFilesize));
1051
+ } else if (!Dropzone.isValidFile(file, this.options.acceptedFiles)) {
1052
+ return done(this.options.dictInvalidFileType);
1053
+ } else if (this.options.maxFiles && this.getAcceptedFiles().length >= this.options.maxFiles) {
1054
+ done(this.options.dictMaxFilesExceeded.replace("{{maxFiles}}", this.options.maxFiles));
1055
+ return this.emit("maxfilesexceeded", file);
1056
+ } else {
1057
+ return this.options.accept.call(this, file, done);
1058
+ }
1059
+ };
1060
+
1061
+ Dropzone.prototype.addFile = function(file) {
1062
+ var _this = this;
1063
+ file.upload = {
1064
+ progress: 0,
1065
+ total: file.size,
1066
+ bytesSent: 0
1067
+ };
1068
+ this.files.push(file);
1069
+ file.status = Dropzone.ADDED;
1070
+ this.emit("addedfile", file);
1071
+ if (this.options.createImageThumbnails && file.type.match(/image.*/) && file.size <= this.options.maxThumbnailFilesize * 1024 * 1024) {
1072
+ this.createThumbnail(file);
1073
+ }
1074
+ return this.accept(file, function(error) {
1075
+ if (error) {
1076
+ file.accepted = false;
1077
+ return _this._errorProcessing([file], error);
1078
+ } else {
1079
+ return _this.enqueueFile(file);
1080
+ }
1081
+ });
1082
+ };
1083
+
1084
+ Dropzone.prototype.enqueueFiles = function(files) {
1085
+ var file, _i, _len;
1086
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
1087
+ file = files[_i];
1088
+ this.enqueueFile(file);
1089
+ }
1090
+ return null;
1091
+ };
1092
+
1093
+ Dropzone.prototype.enqueueFile = function(file) {
1094
+ var _this = this;
1095
+ file.accepted = true;
1096
+ if (file.status === Dropzone.ADDED) {
1097
+ file.status = Dropzone.QUEUED;
1098
+ if (this.options.autoProcessQueue) {
1099
+ return setTimeout((function() {
1100
+ return _this.processQueue();
1101
+ }), 1);
1102
+ }
1103
+ } else {
1104
+ throw new Error("This file can't be queued because it has already been processed or was rejected.");
1105
+ }
1106
+ };
1107
+
1108
+ Dropzone.prototype.addDirectory = function(entry, path) {
1109
+ var dirReader, entriesReader,
1110
+ _this = this;
1111
+ dirReader = entry.createReader();
1112
+ entriesReader = function(entries) {
1113
+ var _i, _len;
1114
+ for (_i = 0, _len = entries.length; _i < _len; _i++) {
1115
+ entry = entries[_i];
1116
+ if (entry.isFile) {
1117
+ entry.file(function(file) {
1118
+ if (_this.options.ignoreHiddenFiles && file.name.substring(0, 1) === '.') {
1119
+ return;
1120
+ }
1121
+ file.fullPath = "" + path + "/" + file.name;
1122
+ return _this.addFile(file);
1123
+ });
1124
+ } else if (entry.isDirectory) {
1125
+ _this.addDirectory(entry, "" + path + "/" + entry.name);
1126
+ }
1127
+ }
1128
+ };
1129
+ return dirReader.readEntries(entriesReader, function(error) {
1130
+ return typeof console !== "undefined" && console !== null ? typeof console.log === "function" ? console.log(error) : void 0 : void 0;
1131
+ });
1132
+ };
1133
+
1134
+ Dropzone.prototype.removeFile = function(file) {
1135
+ if (file.status === Dropzone.UPLOADING) {
1136
+ this.cancelUpload(file);
1137
+ }
1138
+ this.files = without(this.files, file);
1139
+ this.emit("removedfile", file);
1140
+ if (this.files.length === 0) {
1141
+ return this.emit("reset");
1142
+ }
1143
+ };
1144
+
1145
+ Dropzone.prototype.removeAllFiles = function(cancelIfNecessary) {
1146
+ var file, _i, _len, _ref;
1147
+ if (cancelIfNecessary == null) {
1148
+ cancelIfNecessary = false;
1149
+ }
1150
+ _ref = this.files.slice();
1151
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1152
+ file = _ref[_i];
1153
+ if (file.status !== Dropzone.UPLOADING || cancelIfNecessary) {
1154
+ this.removeFile(file);
1155
+ }
1156
+ }
1157
+ return null;
1158
+ };
1159
+
1160
+ Dropzone.prototype.createThumbnail = function(file) {
1161
+ var fileReader,
1162
+ _this = this;
1163
+ fileReader = new FileReader;
1164
+ fileReader.onload = function() {
1165
+ var img;
1166
+ img = new Image;
1167
+ img.onload = function() {
1168
+ var canvas, ctx, resizeInfo, thumbnail, _ref, _ref1, _ref2, _ref3;
1169
+ file.width = img.width;
1170
+ file.height = img.height;
1171
+ resizeInfo = _this.options.resize.call(_this, file);
1172
+ if (resizeInfo.trgWidth == null) {
1173
+ resizeInfo.trgWidth = _this.options.thumbnailWidth;
1174
+ }
1175
+ if (resizeInfo.trgHeight == null) {
1176
+ resizeInfo.trgHeight = _this.options.thumbnailHeight;
1177
+ }
1178
+ canvas = document.createElement("canvas");
1179
+ ctx = canvas.getContext("2d");
1180
+ canvas.width = resizeInfo.trgWidth;
1181
+ canvas.height = resizeInfo.trgHeight;
1182
+ ctx.drawImage(img, (_ref = resizeInfo.srcX) != null ? _ref : 0, (_ref1 = resizeInfo.srcY) != null ? _ref1 : 0, resizeInfo.srcWidth, resizeInfo.srcHeight, (_ref2 = resizeInfo.trgX) != null ? _ref2 : 0, (_ref3 = resizeInfo.trgY) != null ? _ref3 : 0, resizeInfo.trgWidth, resizeInfo.trgHeight);
1183
+ thumbnail = canvas.toDataURL("image/png");
1184
+ return _this.emit("thumbnail", file, thumbnail);
1185
+ };
1186
+ return img.src = fileReader.result;
1187
+ };
1188
+ return fileReader.readAsDataURL(file);
1189
+ };
1190
+
1191
+ Dropzone.prototype.processQueue = function() {
1192
+ var i, parallelUploads, processingLength, queuedFiles;
1193
+ parallelUploads = this.options.parallelUploads;
1194
+ processingLength = this.getUploadingFiles().length;
1195
+ i = processingLength;
1196
+ if (processingLength >= parallelUploads) {
1197
+ return;
1198
+ }
1199
+ queuedFiles = this.getQueuedFiles();
1200
+ if (!(queuedFiles.length > 0)) {
1201
+ return;
1202
+ }
1203
+ if (this.options.uploadMultiple) {
1204
+ return this.processFiles(queuedFiles.slice(0, parallelUploads - processingLength));
1205
+ } else {
1206
+ while (i < parallelUploads) {
1207
+ if (!queuedFiles.length) {
1208
+ return;
1209
+ }
1210
+ this.processFile(queuedFiles.shift());
1211
+ i++;
1212
+ }
1213
+ }
1214
+ };
1215
+
1216
+ Dropzone.prototype.processFile = function(file) {
1217
+ return this.processFiles([file]);
1218
+ };
1219
+
1220
+ Dropzone.prototype.processFiles = function(files) {
1221
+ var file, _i, _len;
1222
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
1223
+ file = files[_i];
1224
+ file.processing = true;
1225
+ file.status = Dropzone.UPLOADING;
1226
+ this.emit("processing", file);
1227
+ }
1228
+ if (this.options.uploadMultiple) {
1229
+ this.emit("processingmultiple", files);
1230
+ }
1231
+ return this.uploadFiles(files);
1232
+ };
1233
+
1234
+ Dropzone.prototype._getFilesWithXhr = function(xhr) {
1235
+ var file, files;
1236
+ return files = (function() {
1237
+ var _i, _len, _ref, _results;
1238
+ _ref = this.files;
1239
+ _results = [];
1240
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1241
+ file = _ref[_i];
1242
+ if (file.xhr === xhr) {
1243
+ _results.push(file);
1244
+ }
1245
+ }
1246
+ return _results;
1247
+ }).call(this);
1248
+ };
1249
+
1250
+ Dropzone.prototype.cancelUpload = function(file) {
1251
+ var groupedFile, groupedFiles, _i, _j, _len, _len1, _ref;
1252
+ if (file.status === Dropzone.UPLOADING) {
1253
+ groupedFiles = this._getFilesWithXhr(file.xhr);
1254
+ for (_i = 0, _len = groupedFiles.length; _i < _len; _i++) {
1255
+ groupedFile = groupedFiles[_i];
1256
+ groupedFile.status = Dropzone.CANCELED;
1257
+ }
1258
+ file.xhr.abort();
1259
+ for (_j = 0, _len1 = groupedFiles.length; _j < _len1; _j++) {
1260
+ groupedFile = groupedFiles[_j];
1261
+ this.emit("canceled", groupedFile);
1262
+ }
1263
+ if (this.options.uploadMultiple) {
1264
+ this.emit("canceledmultiple", groupedFiles);
1265
+ }
1266
+ } else if ((_ref = file.status) === Dropzone.ADDED || _ref === Dropzone.QUEUED) {
1267
+ file.status = Dropzone.CANCELED;
1268
+ this.emit("canceled", file);
1269
+ if (this.options.uploadMultiple) {
1270
+ this.emit("canceledmultiple", [file]);
1271
+ }
1272
+ }
1273
+ if (this.options.autoProcessQueue) {
1274
+ return this.processQueue();
1275
+ }
1276
+ };
1277
+
1278
+ Dropzone.prototype.uploadFile = function(file) {
1279
+ return this.uploadFiles([file]);
1280
+ };
1281
+
1282
+ Dropzone.prototype.uploadFiles = function(files) {
1283
+ var file, formData, handleError, headerName, headerValue, headers, input, inputName, inputType, key, progressObj, response, updateProgress, value, xhr, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2, _ref3,
1284
+ _this = this;
1285
+ xhr = new XMLHttpRequest();
1286
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
1287
+ file = files[_i];
1288
+ file.xhr = xhr;
1289
+ }
1290
+ xhr.open(this.options.method, this.options.url, true);
1291
+ xhr.withCredentials = !!this.options.withCredentials;
1292
+ response = null;
1293
+ handleError = function() {
1294
+ var _j, _len1, _results;
1295
+ _results = [];
1296
+ for (_j = 0, _len1 = files.length; _j < _len1; _j++) {
1297
+ file = files[_j];
1298
+ _results.push(_this._errorProcessing(files, response || _this.options.dictResponseError.replace("{{statusCode}}", xhr.status), xhr));
1299
+ }
1300
+ return _results;
1301
+ };
1302
+ updateProgress = function(e) {
1303
+ var allFilesFinished, progress, _j, _k, _l, _len1, _len2, _len3, _results;
1304
+ if (e != null) {
1305
+ progress = 100 * e.loaded / e.total;
1306
+ for (_j = 0, _len1 = files.length; _j < _len1; _j++) {
1307
+ file = files[_j];
1308
+ file.upload = {
1309
+ progress: progress,
1310
+ total: e.total,
1311
+ bytesSent: e.loaded
1312
+ };
1313
+ }
1314
+ } else {
1315
+ allFilesFinished = true;
1316
+ progress = 100;
1317
+ for (_k = 0, _len2 = files.length; _k < _len2; _k++) {
1318
+ file = files[_k];
1319
+ if (!(file.upload.progress === 100 && file.upload.bytesSent === file.upload.total)) {
1320
+ allFilesFinished = false;
1321
+ }
1322
+ file.upload.progress = progress;
1323
+ file.upload.bytesSent = file.upload.total;
1324
+ }
1325
+ if (allFilesFinished) {
1326
+ return;
1327
+ }
1328
+ }
1329
+ _results = [];
1330
+ for (_l = 0, _len3 = files.length; _l < _len3; _l++) {
1331
+ file = files[_l];
1332
+ _results.push(_this.emit("uploadprogress", file, progress, file.upload.bytesSent));
1333
+ }
1334
+ return _results;
1335
+ };
1336
+ xhr.onload = function(e) {
1337
+ var _ref;
1338
+ if (files[0].status === Dropzone.CANCELED) {
1339
+ return;
1340
+ }
1341
+ if (xhr.readyState !== 4) {
1342
+ return;
1343
+ }
1344
+ response = xhr.responseText;
1345
+ if (xhr.getResponseHeader("content-type") && ~xhr.getResponseHeader("content-type").indexOf("application/json")) {
1346
+ try {
1347
+ response = JSON.parse(response);
1348
+ } catch (_error) {
1349
+ e = _error;
1350
+ response = "Invalid JSON response from server.";
1351
+ }
1352
+ }
1353
+ updateProgress();
1354
+ if (!((200 <= (_ref = xhr.status) && _ref < 300))) {
1355
+ return handleError();
1356
+ } else {
1357
+ return _this._finished(files, response, e);
1358
+ }
1359
+ };
1360
+ xhr.onerror = function() {
1361
+ if (files[0].status === Dropzone.CANCELED) {
1362
+ return;
1363
+ }
1364
+ return handleError();
1365
+ };
1366
+ progressObj = (_ref = xhr.upload) != null ? _ref : xhr;
1367
+ progressObj.onprogress = updateProgress;
1368
+ headers = {
1369
+ "Accept": "application/json",
1370
+ "Cache-Control": "no-cache",
1371
+ "X-Requested-With": "XMLHttpRequest"
1372
+ };
1373
+ if (this.options.headers) {
1374
+ extend(headers, this.options.headers);
1375
+ }
1376
+ for (headerName in headers) {
1377
+ headerValue = headers[headerName];
1378
+ xhr.setRequestHeader(headerName, headerValue);
1379
+ }
1380
+ formData = new FormData();
1381
+ if (this.options.params) {
1382
+ _ref1 = this.options.params;
1383
+ for (key in _ref1) {
1384
+ value = _ref1[key];
1385
+ formData.append(key, value);
1386
+ }
1387
+ }
1388
+ for (_j = 0, _len1 = files.length; _j < _len1; _j++) {
1389
+ file = files[_j];
1390
+ this.emit("sending", file, xhr, formData);
1391
+ }
1392
+ if (this.options.uploadMultiple) {
1393
+ this.emit("sendingmultiple", files, xhr, formData);
1394
+ }
1395
+ if (this.element.tagName === "FORM") {
1396
+ _ref2 = this.element.querySelectorAll("input, textarea, select, button");
1397
+ for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
1398
+ input = _ref2[_k];
1399
+ inputName = input.getAttribute("name");
1400
+ inputType = input.getAttribute("type");
1401
+ if (!inputType || ((_ref3 = inputType.toLowerCase()) !== "checkbox" && _ref3 !== "radio") || input.checked) {
1402
+ formData.append(inputName, input.value);
1403
+ }
1404
+ }
1405
+ }
1406
+ for (_l = 0, _len3 = files.length; _l < _len3; _l++) {
1407
+ file = files[_l];
1408
+ formData.append("" + this.options.paramName + (this.options.uploadMultiple ? "[]" : ""), file, file.name);
1409
+ }
1410
+ return xhr.send(formData);
1411
+ };
1412
+
1413
+ Dropzone.prototype._finished = function(files, responseText, e) {
1414
+ var file, _i, _len;
1415
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
1416
+ file = files[_i];
1417
+ file.status = Dropzone.SUCCESS;
1418
+ this.emit("success", file, responseText, e);
1419
+ this.emit("complete", file);
1420
+ }
1421
+ if (this.options.uploadMultiple) {
1422
+ this.emit("successmultiple", files, responseText, e);
1423
+ this.emit("completemultiple", files);
1424
+ }
1425
+ if (this.options.autoProcessQueue) {
1426
+ return this.processQueue();
1427
+ }
1428
+ };
1429
+
1430
+ Dropzone.prototype._errorProcessing = function(files, message, xhr) {
1431
+ var file, _i, _len;
1432
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
1433
+ file = files[_i];
1434
+ file.status = Dropzone.ERROR;
1435
+ this.emit("error", file, message, xhr);
1436
+ this.emit("complete", file);
1437
+ }
1438
+ if (this.options.uploadMultiple) {
1439
+ this.emit("errormultiple", files, message, xhr);
1440
+ this.emit("completemultiple", files);
1441
+ }
1442
+ if (this.options.autoProcessQueue) {
1443
+ return this.processQueue();
1444
+ }
1445
+ };
1446
+
1447
+ return Dropzone;
1448
+
1449
+ })(Em);
1450
+
1451
+ Dropzone.version = "3.7.1";
1452
+
1453
+ Dropzone.options = {};
1454
+
1455
+ Dropzone.optionsForElement = function(element) {
1456
+ if (element.id) {
1457
+ return Dropzone.options[camelize(element.id)];
1458
+ } else {
1459
+ return void 0;
1460
+ }
1461
+ };
1462
+
1463
+ Dropzone.instances = [];
1464
+
1465
+ Dropzone.forElement = function(element) {
1466
+ if (typeof element === "string") {
1467
+ element = document.querySelector(element);
1468
+ }
1469
+ if ((element != null ? element.dropzone : void 0) == null) {
1470
+ throw new Error("No Dropzone found for given element. This is probably because you're trying to access it before Dropzone had the time to initialize. Use the `init` option to setup any additional observers on your Dropzone.");
1471
+ }
1472
+ return element.dropzone;
1473
+ };
1474
+
1475
+ Dropzone.autoDiscover = true;
1476
+
1477
+ Dropzone.discover = function() {
1478
+ var checkElements, dropzone, dropzones, _i, _len, _results;
1479
+ if (document.querySelectorAll) {
1480
+ dropzones = document.querySelectorAll(".dropzone");
1481
+ } else {
1482
+ dropzones = [];
1483
+ checkElements = function(elements) {
1484
+ var el, _i, _len, _results;
1485
+ _results = [];
1486
+ for (_i = 0, _len = elements.length; _i < _len; _i++) {
1487
+ el = elements[_i];
1488
+ if (/(^| )dropzone($| )/.test(el.className)) {
1489
+ _results.push(dropzones.push(el));
1490
+ } else {
1491
+ _results.push(void 0);
1492
+ }
1493
+ }
1494
+ return _results;
1495
+ };
1496
+ checkElements(document.getElementsByTagName("div"));
1497
+ checkElements(document.getElementsByTagName("form"));
1498
+ }
1499
+ _results = [];
1500
+ for (_i = 0, _len = dropzones.length; _i < _len; _i++) {
1501
+ dropzone = dropzones[_i];
1502
+ if (Dropzone.optionsForElement(dropzone) !== false) {
1503
+ _results.push(new Dropzone(dropzone));
1504
+ } else {
1505
+ _results.push(void 0);
1506
+ }
1507
+ }
1508
+ return _results;
1509
+ };
1510
+
1511
+ Dropzone.blacklistedBrowsers = [/opera.*Macintosh.*version\/12/i];
1512
+
1513
+ Dropzone.isBrowserSupported = function() {
1514
+ var capableBrowser, regex, _i, _len, _ref;
1515
+ capableBrowser = true;
1516
+ if (window.File && window.FileReader && window.FileList && window.Blob && window.FormData && document.querySelector) {
1517
+ if (!("classList" in document.createElement("a"))) {
1518
+ capableBrowser = false;
1519
+ } else {
1520
+ _ref = Dropzone.blacklistedBrowsers;
1521
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1522
+ regex = _ref[_i];
1523
+ if (regex.test(navigator.userAgent)) {
1524
+ capableBrowser = false;
1525
+ continue;
1526
+ }
1527
+ }
1528
+ }
1529
+ } else {
1530
+ capableBrowser = false;
1531
+ }
1532
+ return capableBrowser;
1533
+ };
1534
+
1535
+ without = function(list, rejectedItem) {
1536
+ var item, _i, _len, _results;
1537
+ _results = [];
1538
+ for (_i = 0, _len = list.length; _i < _len; _i++) {
1539
+ item = list[_i];
1540
+ if (item !== rejectedItem) {
1541
+ _results.push(item);
1542
+ }
1543
+ }
1544
+ return _results;
1545
+ };
1546
+
1547
+ camelize = function(str) {
1548
+ return str.replace(/[\-_](\w)/g, function(match) {
1549
+ return match[1].toUpperCase();
1550
+ });
1551
+ };
1552
+
1553
+ Dropzone.createElement = function(string) {
1554
+ var div;
1555
+ div = document.createElement("div");
1556
+ div.innerHTML = string;
1557
+ return div.childNodes[0];
1558
+ };
1559
+
1560
+ Dropzone.elementInside = function(element, container) {
1561
+ if (element === container) {
1562
+ return true;
1563
+ }
1564
+ while (element = element.parentNode) {
1565
+ if (element === container) {
1566
+ return true;
1567
+ }
1568
+ }
1569
+ return false;
1570
+ };
1571
+
1572
+ Dropzone.getElement = function(el, name) {
1573
+ var element;
1574
+ if (typeof el === "string") {
1575
+ element = document.querySelector(el);
1576
+ } else if (el.nodeType != null) {
1577
+ element = el;
1578
+ }
1579
+ if (element == null) {
1580
+ throw new Error("Invalid `" + name + "` option provided. Please provide a CSS selector or a plain HTML element.");
1581
+ }
1582
+ return element;
1583
+ };
1584
+
1585
+ Dropzone.getElements = function(els, name) {
1586
+ var e, el, elements, _i, _j, _len, _len1, _ref;
1587
+ if (els instanceof Array) {
1588
+ elements = [];
1589
+ try {
1590
+ for (_i = 0, _len = els.length; _i < _len; _i++) {
1591
+ el = els[_i];
1592
+ elements.push(this.getElement(el, name));
1593
+ }
1594
+ } catch (_error) {
1595
+ e = _error;
1596
+ elements = null;
1597
+ }
1598
+ } else if (typeof els === "string") {
1599
+ elements = [];
1600
+ _ref = document.querySelectorAll(els);
1601
+ for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
1602
+ el = _ref[_j];
1603
+ elements.push(el);
1604
+ }
1605
+ } else if (els.nodeType != null) {
1606
+ elements = [els];
1607
+ }
1608
+ if (!((elements != null) && elements.length)) {
1609
+ throw new Error("Invalid `" + name + "` option provided. Please provide a CSS selector, a plain HTML element or a list of those.");
1610
+ }
1611
+ return elements;
1612
+ };
1613
+
1614
+ Dropzone.confirm = function(question, accepted, rejected) {
1615
+ if (window.confirm(question)) {
1616
+ return accepted();
1617
+ } else if (rejected != null) {
1618
+ return rejected();
1619
+ }
1620
+ };
1621
+
1622
+ Dropzone.isValidFile = function(file, acceptedFiles) {
1623
+ var baseMimeType, mimeType, validType, _i, _len;
1624
+ if (!acceptedFiles) {
1625
+ return true;
1626
+ }
1627
+ acceptedFiles = acceptedFiles.split(",");
1628
+ mimeType = file.type;
1629
+ baseMimeType = mimeType.replace(/\/.*$/, "");
1630
+ for (_i = 0, _len = acceptedFiles.length; _i < _len; _i++) {
1631
+ validType = acceptedFiles[_i];
1632
+ validType = validType.trim();
1633
+ if (validType.charAt(0) === ".") {
1634
+ if (file.name.indexOf(validType, file.name.length - validType.length) !== -1) {
1635
+ return true;
1636
+ }
1637
+ } else if (/\/\*$/.test(validType)) {
1638
+ if (baseMimeType === validType.replace(/\/.*$/, "")) {
1639
+ return true;
1640
+ }
1641
+ } else {
1642
+ if (mimeType === validType) {
1643
+ return true;
1644
+ }
1645
+ }
1646
+ }
1647
+ return false;
1648
+ };
1649
+
1650
+ if (typeof jQuery !== "undefined" && jQuery !== null) {
1651
+ jQuery.fn.dropzone = function(options) {
1652
+ return this.each(function() {
1653
+ return new Dropzone(this, options);
1654
+ });
1655
+ };
1656
+ }
1657
+
1658
+ if (typeof module !== "undefined" && module !== null) {
1659
+ module.exports = Dropzone;
1660
+ } else {
1661
+ window.Dropzone = Dropzone;
1662
+ }
1663
+
1664
+ Dropzone.ADDED = "added";
1665
+
1666
+ Dropzone.QUEUED = "queued";
1667
+
1668
+ Dropzone.ACCEPTED = Dropzone.QUEUED;
1669
+
1670
+ Dropzone.UPLOADING = "uploading";
1671
+
1672
+ Dropzone.PROCESSING = Dropzone.UPLOADING;
1673
+
1674
+ Dropzone.CANCELED = "canceled";
1675
+
1676
+ Dropzone.ERROR = "error";
1677
+
1678
+ Dropzone.SUCCESS = "success";
1679
+
1680
+ /*
1681
+ # contentloaded.js
1682
+ #
1683
+ # Author: Diego Perini (diego.perini at gmail.com)
1684
+ # Summary: cross-browser wrapper for DOMContentLoaded
1685
+ # Updated: 20101020
1686
+ # License: MIT
1687
+ # Version: 1.2
1688
+ #
1689
+ # URL:
1690
+ # http://javascript.nwbox.com/ContentLoaded/
1691
+ # http://javascript.nwbox.com/ContentLoaded/MIT-LICENSE
1692
+ */
1693
+
1694
+
1695
+ contentLoaded = function(win, fn) {
1696
+ var add, doc, done, init, poll, pre, rem, root, top;
1697
+ done = false;
1698
+ top = true;
1699
+ doc = win.document;
1700
+ root = doc.documentElement;
1701
+ add = (doc.addEventListener ? "addEventListener" : "attachEvent");
1702
+ rem = (doc.addEventListener ? "removeEventListener" : "detachEvent");
1703
+ pre = (doc.addEventListener ? "" : "on");
1704
+ init = function(e) {
1705
+ if (e.type === "readystatechange" && doc.readyState !== "complete") {
1706
+ return;
1707
+ }
1708
+ (e.type === "load" ? win : doc)[rem](pre + e.type, init, false);
1709
+ if (!done && (done = true)) {
1710
+ return fn.call(win, e.type || e);
1711
+ }
1712
+ };
1713
+ poll = function() {
1714
+ var e;
1715
+ try {
1716
+ root.doScroll("left");
1717
+ } catch (_error) {
1718
+ e = _error;
1719
+ setTimeout(poll, 50);
1720
+ return;
1721
+ }
1722
+ return init("poll");
1723
+ };
1724
+ if (doc.readyState !== "complete") {
1725
+ if (doc.createEventObject && root.doScroll) {
1726
+ try {
1727
+ top = !win.frameElement;
1728
+ } catch (_error) {}
1729
+ if (top) {
1730
+ poll();
1731
+ }
1732
+ }
1733
+ doc[add](pre + "DOMContentLoaded", init, false);
1734
+ doc[add](pre + "readystatechange", init, false);
1735
+ return win[add](pre + "load", init, false);
1736
+ }
1737
+ };
1738
+
1739
+ Dropzone._autoDiscoverFunction = function() {
1740
+ if (Dropzone.autoDiscover) {
1741
+ return Dropzone.discover();
1742
+ }
1743
+ };
1744
+
1745
+ contentLoaded(window, Dropzone._autoDiscoverFunction);
1746
+
1747
+ }).call(this);
1748
+
1749
+ });
1750
+ require.alias("component-emitter/index.js", "dropzone/deps/emitter/index.js");
1751
+ require.alias("component-emitter/index.js", "emitter/index.js");
1752
+ if (typeof exports == "object") {
1753
+ module.exports = require("dropzone");
1754
+ } else if (typeof define == "function" && define.amd) {
1755
+ define(function(){ return require("dropzone"); });
1756
+ } else {
1757
+ this["Dropzone"] = require("dropzone");
1758
+ }})();