dropzone 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f384e6abc41faa908f2bbb5f2ff2ef15ae3fc560
4
+ data.tar.gz: 06d67b5bd128106faba36ae5563e3f1c2ee3e926
5
+ SHA512:
6
+ metadata.gz: c2cfa0e973efc7ac9387e6de0d068daadc1187b567ca11557dc565969f9b67c63a5290179204059387118895a777311ac166d7f5d8fade178b29750c4964ba48
7
+ data.tar.gz: cc76b9fe2faf943af0526b2a102235e94025a9279f40b397835e2454a20a44fffdc6575abcc3770950c8482fa42a277484a77122b1be19f241c9013ee3659456
@@ -0,0 +1,78 @@
1
+ class Dropzone::ProfilesController < ::ApplicationController
2
+
3
+ def info
4
+
5
+ # Load profile
6
+ profile = Dropzone.get_profile(params[:profile_id])
7
+
8
+ # Load entity
9
+ entity_class = profile["entity_class"].constantize
10
+ entity = entity_class.find(params[:entity_id])
11
+
12
+ # Load existing images
13
+ image_class = profile["image_class"].constantize
14
+ whereParams = { key: params[:profile_id] }
15
+ whereParams[entity_class.name.underscore] = entity
16
+ images = image_class.where(whereParams).map{|image| {name: image.image_file_name, size: image.image_file_size, src: image.image(:dropzone), id: image.id} }
17
+
18
+ render json: {profile: {
19
+ allowed_sizes: profile['allowed_sizes'],
20
+ allowed_types: profile['allowed_types'],
21
+ max_files: profile['max_files'],
22
+ width: profile['width'],
23
+ }, images: images, entity_id: entity.id}
24
+
25
+ end
26
+
27
+ def upload_image
28
+
29
+ # Load profile
30
+ profile = Dropzone.get_profile(params[:profile_id])
31
+
32
+ # Load entity
33
+ entity_class = profile["entity_class"].constantize
34
+ entity = entity_class.find(params[:entity_id])
35
+
36
+ # Load image
37
+ if current_user?(entity.user)
38
+
39
+ # Create image
40
+ image_class = profile["image_class"].constantize
41
+ image = image_class.new({image: params[:image]})
42
+ image.send("#{entity_class.name.underscore}=", entity)
43
+ image.key = params[:profile_id]
44
+
45
+ # Save image
46
+ if image.save
47
+ resultData = {status: 'success', id: image.id};
48
+ if image.respond_to?(:dropzone_save_response)
49
+ image.dropzone_save_response(resultData)
50
+ end
51
+ render json: resultData, status: :created
52
+ else
53
+ render json: image.errors, status: :unprocessable_entity
54
+ end
55
+ else
56
+ render json: { success: false }
57
+ end
58
+
59
+ end
60
+
61
+ def delete_image
62
+
63
+ # Load profile
64
+ profile = Dropzone.get_profile(params[:profile_id])
65
+
66
+ # Load image
67
+ image = profile["image_class"].constantize.find(params[:id])
68
+
69
+ if current_user?(image.user)
70
+ image.destroy
71
+ head :no_content
72
+ else
73
+ render json: { success: false }
74
+ end
75
+
76
+ end
77
+
78
+ end
@@ -0,0 +1 @@
1
+ works
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'dropzone'
@@ -0,0 +1,44 @@
1
+ require 'dropzone/railtie'
2
+ require 'dropzone/action_view/helpers'
3
+
4
+ module Dropzone
5
+
6
+ class Engine < ::Rails::Engine
7
+ isolate_namespace Dropzone
8
+ end
9
+
10
+ class << self
11
+ attr_accessor :configuration
12
+ end
13
+
14
+ def self.get_profile(profile)
15
+ profile = Dropzone.configuration.profiles[profile.to_s]
16
+ defaults = Dropzone.configuration.profiles["default"]
17
+ profile.reverse_merge!(defaults)
18
+ end
19
+
20
+ def self.install!
21
+ config = YAML.load_file("#{Rails.root.to_s}/config/dropzone.yml")[Rails.env]
22
+ Dropzone.configure { |c|
23
+ c.profiles = config["profiles"] || []
24
+ }
25
+
26
+ ActiveSupport.on_load :action_controller do
27
+ helper Dropzone::ActionView::Helpers
28
+ end
29
+
30
+ end
31
+
32
+ def self.configuration
33
+ @configuration ||= Configuration.new
34
+ end
35
+
36
+ def self.configure
37
+ yield(configuration)
38
+ end
39
+
40
+ class Configuration
41
+ attr_accessor :profiles
42
+ end
43
+
44
+ end
@@ -0,0 +1,11 @@
1
+ module Dropzone
2
+ module ActionView
3
+ module Helpers
4
+
5
+ def dropzone(entity, profile)
6
+ url = dropzone_engine.url_for :controller => 'dropzone/profiles', :action => 'info', :format => :json, :profile_id => profile.to_s, :entity_id => entity.id
7
+ raw("<div class='dropzone-ui' data-url='#{url}'></div>")
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ require 'rails'
2
+ module Dropzone
3
+ class Railtie < Rails::Railtie
4
+
5
+ initializer "dropzone_railtie.configure_rails_initialization" do
6
+ Dropzone.install!
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,143 @@
1
+ (function($) {
2
+
3
+ var DropzoneRailsHandler = Class.extend({
4
+
5
+ defaults: {
6
+ allowed_sizes: [],
7
+ allowed_types: ["image/png","image/jpeg","image/gif"],
8
+ max_files: 1,
9
+ width: null,
10
+ multiple: false,
11
+ onSuccess: function(file, response) {}
12
+ },
13
+ url: null,
14
+ options: null,
15
+ entityId: null,
16
+ images: [],
17
+
18
+ // variables
19
+ dropzone: null,
20
+ totalFiles: 0,
21
+
22
+ // ui
23
+ $fileManager: null,
24
+ $dropzone: null,
25
+
26
+ init: function($fileManager, options) {
27
+ var self = this;
28
+
29
+ self.$fileManager = $fileManager;
30
+ self.url = self.$fileManager.data("url");
31
+
32
+ // Load profile information
33
+ $.ajax({
34
+ url: self.url,
35
+ type: "GET",
36
+ success: function(response) {
37
+
38
+ // Save options
39
+ self.options = $.extend(true, {}, self.defaults, options, response.profile);
40
+
41
+ // Store entity
42
+ self.entityId = response.entity_id;
43
+
44
+ // Create images
45
+ self.images = response.images;
46
+
47
+ // initialize widget
48
+ self.initializeWidget();
49
+ self.initializeDropzone();
50
+
51
+ // set total files
52
+ self.totalFiles = self.images.length;
53
+
54
+ }
55
+ });
56
+
57
+ },
58
+
59
+ initializeWidget: function() {
60
+
61
+ // cleanup
62
+ this.$fileManager.html();
63
+
64
+ // add dropzone
65
+ this.$dropzone = $("<div class='filemanager-container dropzone'></div>").appendTo(this.$fileManager);
66
+
67
+ if(this.options.width) {
68
+ this.$dropzone.width(this.options.width);
69
+ }
70
+
71
+ },
72
+
73
+ initializeDropzone: function() {
74
+ var self = this;
75
+
76
+ // Initialize dropzone
77
+ this.dropzone = new Dropzone(this.$dropzone[0], {
78
+ url: this.url,
79
+ thumbnailWidth: 148,
80
+ thumbnailHeight: 148,
81
+ uploadMultiple: false,
82
+ paramName: "image",
83
+ params: {},
84
+ addRemoveLinks: true,
85
+ dictCancelUpload: "Cancel",
86
+ dictRemoveFile: "Delete",
87
+ acceptedFiles: this.options.allowed_types ? this.options.allowed_types.join(",") : "",
88
+ acceptedSizes: this.options.allowed_sizes
89
+ });
90
+
91
+ // Add existing items
92
+ for (var i = 0; i < this.images.length; i++) {
93
+ this.dropzone.emit("addedfile", this.images[i]);
94
+ this.dropzone.emit("thumbnail", this.images[i], this.images[i].src);
95
+ }
96
+
97
+ // Handle max files and size
98
+ this.dropzone.on("selectedfiles", function(files) {
99
+
100
+ // Check for max file count
101
+ if(self.totalFiles + files.length > self.options.max_files) {
102
+ MagLoft.UI.alert("Error", "You can not upload more images here.");
103
+ files.cancel = true;
104
+ return;
105
+ }
106
+
107
+ self.totalFiles += files.length;
108
+ });
109
+
110
+ // Handle deletion
111
+ this.dropzone.on("removedfile", function(file) {
112
+ if(file.id) {
113
+ self.totalFiles--;
114
+ $.ajax({
115
+ url: self.url,
116
+ data: {
117
+ id: file.id
118
+ },
119
+ type: "DELETE"
120
+ });
121
+ }else{
122
+ self.totalFiles--;
123
+ }
124
+ });
125
+
126
+ // Handle success
127
+ this.dropzone.on("success", function(file, response) {
128
+ file.id = response.id;
129
+ self.options.onSuccess(file, response);
130
+ });
131
+
132
+ }
133
+
134
+ });
135
+
136
+ // register namespace
137
+ $.extend(true, window, {
138
+ "DropzoneRails": {
139
+ "Handler": DropzoneRailsHandler
140
+ }
141
+ });
142
+
143
+ })(jQuery);
@@ -0,0 +1,25 @@
1
+ (function($) {
2
+
3
+ var DropzoneRailsManager = Class.extend({
4
+
5
+ // variables
6
+ handlers: [],
7
+
8
+ init: function(options) {
9
+ var self = this;
10
+ this.handlers = [];
11
+ $(".dropzone-ui").each(function() {
12
+ self.handlers.push(new DropzoneRails.Handler($(this), options));
13
+ });
14
+ }
15
+
16
+ });
17
+
18
+ // register namespace
19
+ $.extend(true, window, {
20
+ "DropzoneRails": {
21
+ "Manager": DropzoneRailsManager
22
+ }
23
+ });
24
+
25
+ })(jQuery);
@@ -0,0 +1,3 @@
1
+ //= require dropzone.lib
2
+ //= require dropzone-rails.handler
3
+ //= require dropzone-rails.manager
@@ -0,0 +1,1786 @@
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", "invalidsize"];
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
+ acceptedSizes: null,
431
+ acceptedMimeTypes: null,
432
+ autoProcessQueue: true,
433
+ addRemoveLinks: false,
434
+ previewsContainer: null,
435
+ dictDefaultMessage: "Drop files here to upload",
436
+ dictFallbackMessage: "Your browser does not support drag'n'drop file uploads.",
437
+ dictFallbackText: "Please use the fallback form below to upload your files like in the olden days.",
438
+ dictFileTooBig: "File is too big ({{filesize}}MB). Max filesize: {{maxFilesize}}MB.",
439
+ dictInvalidFileType: "You can't upload files of this type.",
440
+ dictResponseError: "Server responded with {{statusCode}} code.",
441
+ dictCancelUpload: "Cancel upload",
442
+ dictCancelUploadConfirmation: "Are you sure you want to cancel this upload?",
443
+ dictRemoveFile: "Remove file",
444
+ dictRemoveFileConfirmation: null,
445
+ dictMaxFilesExceeded: "You can only upload {{maxFiles}} files.",
446
+ dictInvalidSize: "The file has an invalid size (width, height).",
447
+ accept: function(file, done) {
448
+ return done();
449
+ },
450
+ init: function() {
451
+ return noop;
452
+ },
453
+ forceFallback: false,
454
+ fallback: function() {
455
+ var child, messageElement, span, _i, _len, _ref;
456
+ this.element.className = "" + this.element.className + " dz-browser-not-supported";
457
+ _ref = this.element.getElementsByTagName("div");
458
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
459
+ child = _ref[_i];
460
+ if (/(^| )dz-message($| )/.test(child.className)) {
461
+ messageElement = child;
462
+ child.className = "dz-message";
463
+ continue;
464
+ }
465
+ }
466
+ if (!messageElement) {
467
+ messageElement = Dropzone.createElement("<div class=\"dz-message\"><span></span></div>");
468
+ this.element.appendChild(messageElement);
469
+ }
470
+ span = messageElement.getElementsByTagName("span")[0];
471
+ if (span) {
472
+ span.textContent = this.options.dictFallbackMessage;
473
+ }
474
+ return this.element.appendChild(this.getFallbackForm());
475
+ },
476
+ resize: function(file) {
477
+ var info, srcRatio, trgRatio;
478
+ info = {
479
+ srcX: 0,
480
+ srcY: 0,
481
+ srcWidth: file.width,
482
+ srcHeight: file.height
483
+ };
484
+ srcRatio = file.width / file.height;
485
+ trgRatio = this.options.thumbnailWidth / this.options.thumbnailHeight;
486
+ if (file.height < this.options.thumbnailHeight || file.width < this.options.thumbnailWidth) {
487
+ info.trgHeight = info.srcHeight;
488
+ info.trgWidth = info.srcWidth;
489
+ } else {
490
+ if (srcRatio > trgRatio) {
491
+ info.srcHeight = file.height;
492
+ info.srcWidth = info.srcHeight * trgRatio;
493
+ } else {
494
+ info.srcWidth = file.width;
495
+ info.srcHeight = info.srcWidth / trgRatio;
496
+ }
497
+ }
498
+ info.srcX = (file.width - info.srcWidth) / 2;
499
+ info.srcY = (file.height - info.srcHeight) / 2;
500
+ return info;
501
+ },
502
+ /*
503
+ Those functions register themselves to the events on init and handle all
504
+ the user interface specific stuff. Overwriting them won't break the upload
505
+ but can break the way it's displayed.
506
+ You can overwrite them if you don't like the default behavior. If you just
507
+ want to add an additional event handler, register it on the dropzone object
508
+ and don't overwrite those options.
509
+ */
510
+
511
+ drop: function(e) {
512
+ return this.element.classList.remove("dz-drag-hover");
513
+ },
514
+ dragstart: noop,
515
+ dragend: function(e) {
516
+ return this.element.classList.remove("dz-drag-hover");
517
+ },
518
+ dragenter: function(e) {
519
+ return this.element.classList.add("dz-drag-hover");
520
+ },
521
+ dragover: function(e) {
522
+ return this.element.classList.add("dz-drag-hover");
523
+ },
524
+ dragleave: function(e) {
525
+ return this.element.classList.remove("dz-drag-hover");
526
+ },
527
+ selectedfiles: function(files) {
528
+ if (this.element === this.previewsContainer) {
529
+ return this.element.classList.add("dz-started");
530
+ }
531
+ },
532
+ reset: function() {
533
+ return this.element.classList.remove("dz-started");
534
+ },
535
+ addedfile: function(file) {
536
+ var _this = this;
537
+ file.previewElement = Dropzone.createElement(this.options.previewTemplate);
538
+ file.previewTemplate = file.previewElement;
539
+ this.previewsContainer.appendChild(file.previewElement);
540
+ file.previewElement.querySelector("[data-dz-name]").textContent = file.name;
541
+ file.previewElement.querySelector("[data-dz-size]").innerHTML = this.filesize(file.size);
542
+ if (this.options.addRemoveLinks) {
543
+ file._removeLink = Dropzone.createElement("<a class=\"dz-remove\" href=\"javascript:undefined;\">" + this.options.dictRemoveFile + "</a>");
544
+ file._removeLink.addEventListener("click", function(e) {
545
+ e.preventDefault();
546
+ e.stopPropagation();
547
+ if (file.status === Dropzone.UPLOADING) {
548
+ return Dropzone.confirm(_this.options.dictCancelUploadConfirmation, function() {
549
+ return _this.removeFile(file);
550
+ });
551
+ } else {
552
+ if (_this.options.dictRemoveFileConfirmation) {
553
+ return Dropzone.confirm(_this.options.dictRemoveFileConfirmation, function() {
554
+ return _this.removeFile(file);
555
+ });
556
+ } else {
557
+ return _this.removeFile(file);
558
+ }
559
+ }
560
+ });
561
+ file.previewElement.appendChild(file._removeLink);
562
+ }
563
+ return this._updateMaxFilesReachedClass();
564
+ },
565
+ removedfile: function(file) {
566
+ var _ref;
567
+ if ((_ref = file.previewElement) != null) {
568
+ _ref.parentNode.removeChild(file.previewElement);
569
+ }
570
+ return this._updateMaxFilesReachedClass();
571
+ },
572
+ thumbnail: function(file, dataUrl) {
573
+ var thumbnailElement;
574
+ file.previewElement.classList.remove("dz-file-preview");
575
+ file.previewElement.classList.add("dz-image-preview");
576
+ thumbnailElement = file.previewElement.querySelector("[data-dz-thumbnail]");
577
+ thumbnailElement.alt = file.name;
578
+ return thumbnailElement.src = dataUrl;
579
+ },
580
+ error: function(file, message) {
581
+ file.previewElement.classList.add("dz-error");
582
+ return file.previewElement.querySelector("[data-dz-errormessage]").textContent = message;
583
+ },
584
+ errormultiple: noop,
585
+ processing: function(file) {
586
+ file.previewElement.classList.add("dz-processing");
587
+ if (file._removeLink) {
588
+ return file._removeLink.textContent = this.options.dictCancelUpload;
589
+ }
590
+ },
591
+ processingmultiple: noop,
592
+ uploadprogress: function(file, progress, bytesSent) {
593
+ return file.previewElement.querySelector("[data-dz-uploadprogress]").style.width = "" + progress + "%";
594
+ },
595
+ totaluploadprogress: noop,
596
+ sending: noop,
597
+ sendingmultiple: noop,
598
+ success: function(file) {
599
+ return file.previewElement.classList.add("dz-success");
600
+ },
601
+ successmultiple: noop,
602
+ canceled: function(file) {
603
+ return this.emit("error", file, "Upload canceled.");
604
+ },
605
+ canceledmultiple: noop,
606
+ complete: function(file) {
607
+ if (file._removeLink) {
608
+ return file._removeLink.textContent = this.options.dictRemoveFile;
609
+ }
610
+ },
611
+ completemultiple: noop,
612
+ maxfilesexceeded: noop,
613
+ invalidsize: noop,
614
+ 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>"
615
+ };
616
+
617
+ extend = function() {
618
+ var key, object, objects, target, val, _i, _len;
619
+ target = arguments[0], objects = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
620
+ for (_i = 0, _len = objects.length; _i < _len; _i++) {
621
+ object = objects[_i];
622
+ for (key in object) {
623
+ val = object[key];
624
+ target[key] = val;
625
+ }
626
+ }
627
+ return target;
628
+ };
629
+
630
+ function Dropzone(element, options) {
631
+ var elementOptions, fallback, _ref;
632
+ this.element = element;
633
+ this.version = Dropzone.version;
634
+ this.defaultOptions.previewTemplate = this.defaultOptions.previewTemplate.replace(/\n*/g, "");
635
+ this.clickableElements = [];
636
+ this.listeners = [];
637
+ this.files = [];
638
+ if (typeof this.element === "string") {
639
+ this.element = document.querySelector(this.element);
640
+ }
641
+ if (!(this.element && (this.element.nodeType != null))) {
642
+ throw new Error("Invalid dropzone element.");
643
+ }
644
+ if (this.element.dropzone) {
645
+ throw new Error("Dropzone already attached.");
646
+ }
647
+ Dropzone.instances.push(this);
648
+ element.dropzone = this;
649
+ elementOptions = (_ref = Dropzone.optionsForElement(this.element)) != null ? _ref : {};
650
+ this.options = extend({}, this.defaultOptions, elementOptions, options != null ? options : {});
651
+ if (this.options.forceFallback || !Dropzone.isBrowserSupported()) {
652
+ return this.options.fallback.call(this);
653
+ }
654
+ if (this.options.url == null) {
655
+ this.options.url = this.element.getAttribute("action");
656
+ }
657
+ if (!this.options.url) {
658
+ throw new Error("No URL provided.");
659
+ }
660
+ if (this.options.acceptedFiles && this.options.acceptedMimeTypes) {
661
+ throw new Error("You can't provide both 'acceptedFiles' and 'acceptedMimeTypes'. 'acceptedMimeTypes' is deprecated.");
662
+ }
663
+ if (this.options.acceptedMimeTypes) {
664
+ this.options.acceptedFiles = this.options.acceptedMimeTypes;
665
+ delete this.options.acceptedMimeTypes;
666
+ }
667
+ this.options.method = this.options.method.toUpperCase();
668
+ if ((fallback = this.getExistingFallback()) && fallback.parentNode) {
669
+ fallback.parentNode.removeChild(fallback);
670
+ }
671
+ if (this.options.previewsContainer) {
672
+ this.previewsContainer = Dropzone.getElement(this.options.previewsContainer, "previewsContainer");
673
+ } else {
674
+ this.previewsContainer = this.element;
675
+ }
676
+ if (this.options.clickable) {
677
+ if (this.options.clickable === true) {
678
+ this.clickableElements = [this.element];
679
+ } else {
680
+ this.clickableElements = Dropzone.getElements(this.options.clickable, "clickable");
681
+ }
682
+ }
683
+ this.init();
684
+ }
685
+
686
+ Dropzone.prototype.getAcceptedFiles = function() {
687
+ var file, _i, _len, _ref, _results;
688
+ _ref = this.files;
689
+ _results = [];
690
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
691
+ file = _ref[_i];
692
+ if (file.accepted) {
693
+ _results.push(file);
694
+ }
695
+ }
696
+ return _results;
697
+ };
698
+
699
+ Dropzone.prototype.getRejectedFiles = function() {
700
+ var file, _i, _len, _ref, _results;
701
+ _ref = this.files;
702
+ _results = [];
703
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
704
+ file = _ref[_i];
705
+ if (!file.accepted) {
706
+ _results.push(file);
707
+ }
708
+ }
709
+ return _results;
710
+ };
711
+
712
+ Dropzone.prototype.getQueuedFiles = function() {
713
+ var file, _i, _len, _ref, _results;
714
+ _ref = this.files;
715
+ _results = [];
716
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
717
+ file = _ref[_i];
718
+ if (file.status === Dropzone.QUEUED) {
719
+ _results.push(file);
720
+ }
721
+ }
722
+ return _results;
723
+ };
724
+
725
+ Dropzone.prototype.getUploadingFiles = function() {
726
+ var file, _i, _len, _ref, _results;
727
+ _ref = this.files;
728
+ _results = [];
729
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
730
+ file = _ref[_i];
731
+ if (file.status === Dropzone.UPLOADING) {
732
+ _results.push(file);
733
+ }
734
+ }
735
+ return _results;
736
+ };
737
+
738
+ Dropzone.prototype.init = function() {
739
+ var eventName, noPropagation, setupHiddenFileInput, _i, _len, _ref, _ref1,
740
+ _this = this;
741
+ if (this.element.tagName === "form") {
742
+ this.element.setAttribute("enctype", "multipart/form-data");
743
+ }
744
+ if (this.element.classList.contains("dropzone") && !this.element.querySelector(".dz-message")) {
745
+ this.element.appendChild(Dropzone.createElement("<div class=\"dz-default dz-message\"><span>" + this.options.dictDefaultMessage + "</span></div>"));
746
+ }
747
+ if (this.clickableElements.length) {
748
+ setupHiddenFileInput = function() {
749
+ if (_this.hiddenFileInput) {
750
+ document.body.removeChild(_this.hiddenFileInput);
751
+ }
752
+ _this.hiddenFileInput = document.createElement("input");
753
+ _this.hiddenFileInput.setAttribute("type", "file");
754
+ _this.hiddenFileInput.setAttribute("multiple", "multiple");
755
+ if (_this.options.acceptedFiles != null) {
756
+ _this.hiddenFileInput.setAttribute("accept", _this.options.acceptedFiles);
757
+ }
758
+ _this.hiddenFileInput.style.visibility = "hidden";
759
+ _this.hiddenFileInput.style.position = "absolute";
760
+ _this.hiddenFileInput.style.top = "0";
761
+ _this.hiddenFileInput.style.left = "0";
762
+ _this.hiddenFileInput.style.height = "0";
763
+ _this.hiddenFileInput.style.width = "0";
764
+ document.body.appendChild(_this.hiddenFileInput);
765
+ return _this.hiddenFileInput.addEventListener("change", function() {
766
+ var files;
767
+ files = _this.hiddenFileInput.files;
768
+ if (files.length) {
769
+ _this.emit("selectedfiles", files);
770
+ if(files.cancel) { files = []; }
771
+ _this.handleFiles(files);
772
+ }
773
+ return setupHiddenFileInput();
774
+ });
775
+ };
776
+ setupHiddenFileInput();
777
+ }
778
+ this.URL = (_ref = window.URL) != null ? _ref : window.webkitURL;
779
+ _ref1 = this.events;
780
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
781
+ eventName = _ref1[_i];
782
+ this.on(eventName, this.options[eventName]);
783
+ }
784
+ this.on("uploadprogress", function() {
785
+ return _this.updateTotalUploadProgress();
786
+ });
787
+ this.on("removedfile", function() {
788
+ return _this.updateTotalUploadProgress();
789
+ });
790
+ this.on("canceled", function(file) {
791
+ return _this.emit("complete", file);
792
+ });
793
+ noPropagation = function(e) {
794
+ e.stopPropagation();
795
+ if (e.preventDefault) {
796
+ return e.preventDefault();
797
+ } else {
798
+ return e.returnValue = false;
799
+ }
800
+ };
801
+ this.listeners = [
802
+ {
803
+ element: this.element,
804
+ events: {
805
+ "dragstart": function(e) {
806
+ return _this.emit("dragstart", e);
807
+ },
808
+ "dragenter": function(e) {
809
+ noPropagation(e);
810
+ return _this.emit("dragenter", e);
811
+ },
812
+ "dragover": function(e) {
813
+ noPropagation(e);
814
+ return _this.emit("dragover", e);
815
+ },
816
+ "dragleave": function(e) {
817
+ return _this.emit("dragleave", e);
818
+ },
819
+ "drop": function(e) {
820
+ noPropagation(e);
821
+ return _this.drop(e);
822
+ },
823
+ "dragend": function(e) {
824
+ return _this.emit("dragend", e);
825
+ }
826
+ }
827
+ }
828
+ ];
829
+ this.clickableElements.forEach(function(clickableElement) {
830
+ return _this.listeners.push({
831
+ element: clickableElement,
832
+ events: {
833
+ "click": function(evt) {
834
+ if ((clickableElement !== _this.element) || (evt.target === _this.element || Dropzone.elementInside(evt.target, _this.element.querySelector(".dz-message")))) {
835
+ return _this.hiddenFileInput.click();
836
+ }
837
+ }
838
+ }
839
+ });
840
+ });
841
+ this.enable();
842
+ return this.options.init.call(this);
843
+ };
844
+
845
+ Dropzone.prototype.destroy = function() {
846
+ var _ref;
847
+ this.disable();
848
+ this.removeAllFiles(true);
849
+ if ((_ref = this.hiddenFileInput) != null ? _ref.parentNode : void 0) {
850
+ this.hiddenFileInput.parentNode.removeChild(this.hiddenFileInput);
851
+ this.hiddenFileInput = null;
852
+ }
853
+ return delete this.element.dropzone;
854
+ };
855
+
856
+ Dropzone.prototype.updateTotalUploadProgress = function() {
857
+ var acceptedFiles, file, totalBytes, totalBytesSent, totalUploadProgress, _i, _len, _ref;
858
+ totalBytesSent = 0;
859
+ totalBytes = 0;
860
+ acceptedFiles = this.getAcceptedFiles();
861
+ if (acceptedFiles.length) {
862
+ _ref = this.getAcceptedFiles();
863
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
864
+ file = _ref[_i];
865
+ totalBytesSent += file.upload.bytesSent;
866
+ totalBytes += file.upload.total;
867
+ }
868
+ totalUploadProgress = 100 * totalBytesSent / totalBytes;
869
+ } else {
870
+ totalUploadProgress = 100;
871
+ }
872
+ return this.emit("totaluploadprogress", totalUploadProgress, totalBytes, totalBytesSent);
873
+ };
874
+
875
+ Dropzone.prototype.getFallbackForm = function() {
876
+ var existingFallback, fields, fieldsString, form;
877
+ if (existingFallback = this.getExistingFallback()) {
878
+ return existingFallback;
879
+ }
880
+ fieldsString = "<div class=\"dz-fallback\">";
881
+ if (this.options.dictFallbackText) {
882
+ fieldsString += "<p>" + this.options.dictFallbackText + "</p>";
883
+ }
884
+ fieldsString += "<input type=\"file\" name=\"" + this.options.paramName + (this.options.uploadMultiple ? "[]" : "") + "\" " + (this.options.uploadMultiple ? 'multiple="multiple"' : void 0) + " /><button type=\"submit\">Upload!</button></div>";
885
+ fields = Dropzone.createElement(fieldsString);
886
+ if (this.element.tagName !== "FORM") {
887
+ form = Dropzone.createElement("<form action=\"" + this.options.url + "\" enctype=\"multipart/form-data\" method=\"" + this.options.method + "\"></form>");
888
+ form.appendChild(fields);
889
+ } else {
890
+ this.element.setAttribute("enctype", "multipart/form-data");
891
+ this.element.setAttribute("method", this.options.method);
892
+ }
893
+ return form != null ? form : fields;
894
+ };
895
+
896
+ Dropzone.prototype.getExistingFallback = function() {
897
+ var fallback, getFallback, tagName, _i, _len, _ref;
898
+ getFallback = function(elements) {
899
+ var el, _i, _len;
900
+ for (_i = 0, _len = elements.length; _i < _len; _i++) {
901
+ el = elements[_i];
902
+ if (/(^| )fallback($| )/.test(el.className)) {
903
+ return el;
904
+ }
905
+ }
906
+ };
907
+ _ref = ["div", "form"];
908
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
909
+ tagName = _ref[_i];
910
+ if (fallback = getFallback(this.element.getElementsByTagName(tagName))) {
911
+ return fallback;
912
+ }
913
+ }
914
+ };
915
+
916
+ Dropzone.prototype.setupEventListeners = function() {
917
+ var elementListeners, event, listener, _i, _len, _ref, _results;
918
+ _ref = this.listeners;
919
+ _results = [];
920
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
921
+ elementListeners = _ref[_i];
922
+ _results.push((function() {
923
+ var _ref1, _results1;
924
+ _ref1 = elementListeners.events;
925
+ _results1 = [];
926
+ for (event in _ref1) {
927
+ listener = _ref1[event];
928
+ _results1.push(elementListeners.element.addEventListener(event, listener, false));
929
+ }
930
+ return _results1;
931
+ })());
932
+ }
933
+ return _results;
934
+ };
935
+
936
+ Dropzone.prototype.removeEventListeners = function() {
937
+ var elementListeners, event, listener, _i, _len, _ref, _results;
938
+ _ref = this.listeners;
939
+ _results = [];
940
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
941
+ elementListeners = _ref[_i];
942
+ _results.push((function() {
943
+ var _ref1, _results1;
944
+ _ref1 = elementListeners.events;
945
+ _results1 = [];
946
+ for (event in _ref1) {
947
+ listener = _ref1[event];
948
+ _results1.push(elementListeners.element.removeEventListener(event, listener, false));
949
+ }
950
+ return _results1;
951
+ })());
952
+ }
953
+ return _results;
954
+ };
955
+
956
+ Dropzone.prototype.disable = function() {
957
+ var file, _i, _len, _ref, _results;
958
+ this.clickableElements.forEach(function(element) {
959
+ return element.classList.remove("dz-clickable");
960
+ });
961
+ this.removeEventListeners();
962
+ _ref = this.files;
963
+ _results = [];
964
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
965
+ file = _ref[_i];
966
+ _results.push(this.cancelUpload(file));
967
+ }
968
+ return _results;
969
+ };
970
+
971
+ Dropzone.prototype.enable = function() {
972
+ this.clickableElements.forEach(function(element) {
973
+ return element.classList.add("dz-clickable");
974
+ });
975
+ return this.setupEventListeners();
976
+ };
977
+
978
+ Dropzone.prototype.filesize = function(size) {
979
+ var string;
980
+ if (size >= 100000000000) {
981
+ size = size / 100000000000;
982
+ string = "TB";
983
+ } else if (size >= 100000000) {
984
+ size = size / 100000000;
985
+ string = "GB";
986
+ } else if (size >= 100000) {
987
+ size = size / 100000;
988
+ string = "MB";
989
+ } else if (size >= 100) {
990
+ size = size / 100;
991
+ string = "KB";
992
+ } else {
993
+ size = size * 10;
994
+ string = "b";
995
+ }
996
+ return "<strong>" + (Math.round(size) / 10) + "</strong> " + string;
997
+ };
998
+
999
+ Dropzone.prototype._updateMaxFilesReachedClass = function() {
1000
+ if (this.options.maxFiles && this.getAcceptedFiles().length >= this.options.maxFiles) {
1001
+ return this.element.classList.add("dz-max-files-reached");
1002
+ } else {
1003
+ return this.element.classList.remove("dz-max-files-reached");
1004
+ }
1005
+ };
1006
+
1007
+ Dropzone.prototype.drop = function(e) {
1008
+ var files, items;
1009
+ if (!e.dataTransfer) {
1010
+ return;
1011
+ }
1012
+ this.emit("drop", e);
1013
+ files = e.dataTransfer.files;
1014
+ this.emit("selectedfiles", files);
1015
+ if(files.cancel) { files = []; }
1016
+
1017
+ if (files.length) {
1018
+ items = e.dataTransfer.items;
1019
+ if (items && items.length && ((items[0].webkitGetAsEntry != null) || (items[0].getAsEntry != null))) {
1020
+ this.handleItems(items);
1021
+ } else {
1022
+ this.handleFiles(files);
1023
+ }
1024
+ }
1025
+ };
1026
+
1027
+ Dropzone.prototype.handleFiles = function(files) {
1028
+ var file, _i, _len, _results;
1029
+ _results = [];
1030
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
1031
+ file = files[_i];
1032
+ _results.push(this.addFile(file));
1033
+ }
1034
+ return _results;
1035
+ };
1036
+
1037
+ Dropzone.prototype.handleItems = function(items) {
1038
+ var entry, item, _i, _len;
1039
+ for (_i = 0, _len = items.length; _i < _len; _i++) {
1040
+ item = items[_i];
1041
+ if (item.webkitGetAsEntry != null) {
1042
+ entry = item.webkitGetAsEntry();
1043
+ if (entry.isFile) {
1044
+ this.addFile(item.getAsFile());
1045
+ } else if (entry.isDirectory) {
1046
+ this.addDirectory(entry, entry.name);
1047
+ }
1048
+ } else {
1049
+ this.addFile(item.getAsFile());
1050
+ }
1051
+ }
1052
+ };
1053
+
1054
+ Dropzone.prototype.accept = function(file, done) {
1055
+ if (file.size > this.options.maxFilesize * 1024 * 1024) {
1056
+ return done(this.options.dictFileTooBig.replace("{{filesize}}", Math.round(file.size / 1024 / 10.24) / 100).replace("{{maxFilesize}}", this.options.maxFilesize));
1057
+ } else if (!Dropzone.isValidFile(file, this.options.acceptedFiles)) {
1058
+ return done(this.options.dictInvalidFileType);
1059
+ } else if (this.options.maxFiles && this.getAcceptedFiles().length >= this.options.maxFiles) {
1060
+ done(this.options.dictMaxFilesExceeded.replace("{{maxFiles}}", this.options.maxFiles));
1061
+ return this.emit("maxfilesexceeded", file);
1062
+ } else if (!this.options.acceptedSizes || this.options.acceptedSizes.length == 0) {
1063
+ return this.options.accept.call(this, file, done);
1064
+ } else {
1065
+
1066
+ // Check file dimentsions
1067
+ var _URL = window.URL || window.webkitURL,
1068
+ img = new Image(),
1069
+ self = this;
1070
+ img.onload = function () {
1071
+
1072
+ // Check if a correct size exists
1073
+ for (var i = 0; i < self.options.acceptedSizes.length; i++) {
1074
+ if(this.width == self.options.acceptedSizes[i].width && this.height == self.options.acceptedSizes[i].height) {
1075
+ return self.options.accept.call(self, file, done);
1076
+ }
1077
+ }
1078
+
1079
+ // If no size fits, return error
1080
+ done(self.options.dictInvalidSize);
1081
+ return self.emit("invalidsize", file);
1082
+ };
1083
+ img.src = _URL.createObjectURL(file);
1084
+ }
1085
+ };
1086
+
1087
+ Dropzone.prototype.addFile = function(file) {
1088
+ var _this = this;
1089
+ file.upload = {
1090
+ progress: 0,
1091
+ total: file.size,
1092
+ bytesSent: 0
1093
+ };
1094
+ this.files.push(file);
1095
+ file.status = Dropzone.ADDED;
1096
+ this.emit("addedfile", file);
1097
+ if (this.options.createImageThumbnails && file.type.match(/image.*/) && file.size <= this.options.maxThumbnailFilesize * 1024 * 1024) {
1098
+ this.createThumbnail(file);
1099
+ }
1100
+ return this.accept(file, function(error) {
1101
+ if (error) {
1102
+ file.accepted = false;
1103
+ return _this._errorProcessing([file], error);
1104
+ } else {
1105
+ return _this.enqueueFile(file);
1106
+ }
1107
+ });
1108
+ };
1109
+
1110
+ Dropzone.prototype.enqueueFiles = function(files) {
1111
+ var file, _i, _len;
1112
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
1113
+ file = files[_i];
1114
+ this.enqueueFile(file);
1115
+ }
1116
+ return null;
1117
+ };
1118
+
1119
+ Dropzone.prototype.enqueueFile = function(file) {
1120
+ var _this = this;
1121
+ file.accepted = true;
1122
+ if (file.status === Dropzone.ADDED) {
1123
+ file.status = Dropzone.QUEUED;
1124
+ if (this.options.autoProcessQueue) {
1125
+ return setTimeout((function() {
1126
+ return _this.processQueue();
1127
+ }), 1);
1128
+ }
1129
+ } else {
1130
+ throw new Error("This file can't be queued because it has already been processed or was rejected.");
1131
+ }
1132
+ };
1133
+
1134
+ Dropzone.prototype.addDirectory = function(entry, path) {
1135
+ var dirReader, entriesReader,
1136
+ _this = this;
1137
+ dirReader = entry.createReader();
1138
+ entriesReader = function(entries) {
1139
+ var _i, _len;
1140
+ for (_i = 0, _len = entries.length; _i < _len; _i++) {
1141
+ entry = entries[_i];
1142
+ if (entry.isFile) {
1143
+ entry.file(function(file) {
1144
+ if (_this.options.ignoreHiddenFiles && file.name.substring(0, 1) === '.') {
1145
+ return;
1146
+ }
1147
+ file.fullPath = "" + path + "/" + file.name;
1148
+ return _this.addFile(file);
1149
+ });
1150
+ } else if (entry.isDirectory) {
1151
+ _this.addDirectory(entry, "" + path + "/" + entry.name);
1152
+ }
1153
+ }
1154
+ };
1155
+ return dirReader.readEntries(entriesReader, function(error) {
1156
+ return typeof console !== "undefined" && console !== null ? typeof console.log === "function" ? console.log(error) : void 0 : void 0;
1157
+ });
1158
+ };
1159
+
1160
+ Dropzone.prototype.removeFile = function(file) {
1161
+ if (file.status === Dropzone.UPLOADING) {
1162
+ this.cancelUpload(file);
1163
+ }
1164
+ this.files = without(this.files, file);
1165
+ this.emit("removedfile", file);
1166
+ if (this.files.length === 0) {
1167
+ return this.emit("reset");
1168
+ }
1169
+ };
1170
+
1171
+ Dropzone.prototype.removeAllFiles = function(cancelIfNecessary) {
1172
+ var file, _i, _len, _ref;
1173
+ if (cancelIfNecessary == null) {
1174
+ cancelIfNecessary = false;
1175
+ }
1176
+ _ref = this.files.slice();
1177
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1178
+ file = _ref[_i];
1179
+ if (file.status !== Dropzone.UPLOADING || cancelIfNecessary) {
1180
+ this.removeFile(file);
1181
+ }
1182
+ }
1183
+ return null;
1184
+ };
1185
+
1186
+ Dropzone.prototype.createThumbnail = function(file) {
1187
+ var fileReader,
1188
+ _this = this;
1189
+ fileReader = new FileReader;
1190
+ fileReader.onload = function() {
1191
+ var img;
1192
+ img = new Image;
1193
+ img.onload = function() {
1194
+ var canvas, ctx, resizeInfo, thumbnail, _ref, _ref1, _ref2, _ref3;
1195
+ file.width = img.width;
1196
+ file.height = img.height;
1197
+ resizeInfo = _this.options.resize.call(_this, file);
1198
+ if (resizeInfo.trgWidth == null) {
1199
+ resizeInfo.trgWidth = _this.options.thumbnailWidth;
1200
+ }
1201
+ if (resizeInfo.trgHeight == null) {
1202
+ resizeInfo.trgHeight = _this.options.thumbnailHeight;
1203
+ }
1204
+ canvas = document.createElement("canvas");
1205
+ ctx = canvas.getContext("2d");
1206
+ canvas.width = resizeInfo.trgWidth;
1207
+ canvas.height = resizeInfo.trgHeight;
1208
+ 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);
1209
+ thumbnail = canvas.toDataURL("image/png");
1210
+ return _this.emit("thumbnail", file, thumbnail);
1211
+ };
1212
+ return img.src = fileReader.result;
1213
+ };
1214
+ return fileReader.readAsDataURL(file);
1215
+ };
1216
+
1217
+ Dropzone.prototype.processQueue = function() {
1218
+ var i, parallelUploads, processingLength, queuedFiles;
1219
+ parallelUploads = this.options.parallelUploads;
1220
+ processingLength = this.getUploadingFiles().length;
1221
+ i = processingLength;
1222
+ if (processingLength >= parallelUploads) {
1223
+ return;
1224
+ }
1225
+ queuedFiles = this.getQueuedFiles();
1226
+ if (!(queuedFiles.length > 0)) {
1227
+ return;
1228
+ }
1229
+ if (this.options.uploadMultiple) {
1230
+ return this.processFiles(queuedFiles.slice(0, parallelUploads - processingLength));
1231
+ } else {
1232
+ while (i < parallelUploads) {
1233
+ if (!queuedFiles.length) {
1234
+ return;
1235
+ }
1236
+ this.processFile(queuedFiles.shift());
1237
+ i++;
1238
+ }
1239
+ }
1240
+ };
1241
+
1242
+ Dropzone.prototype.processFile = function(file) {
1243
+ return this.processFiles([file]);
1244
+ };
1245
+
1246
+ Dropzone.prototype.processFiles = function(files) {
1247
+ var file, _i, _len;
1248
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
1249
+ file = files[_i];
1250
+ file.processing = true;
1251
+ file.status = Dropzone.UPLOADING;
1252
+ this.emit("processing", file);
1253
+ }
1254
+ if (this.options.uploadMultiple) {
1255
+ this.emit("processingmultiple", files);
1256
+ }
1257
+ return this.uploadFiles(files);
1258
+ };
1259
+
1260
+ Dropzone.prototype._getFilesWithXhr = function(xhr) {
1261
+ var file, files;
1262
+ return files = (function() {
1263
+ var _i, _len, _ref, _results;
1264
+ _ref = this.files;
1265
+ _results = [];
1266
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1267
+ file = _ref[_i];
1268
+ if (file.xhr === xhr) {
1269
+ _results.push(file);
1270
+ }
1271
+ }
1272
+ return _results;
1273
+ }).call(this);
1274
+ };
1275
+
1276
+ Dropzone.prototype.cancelUpload = function(file) {
1277
+ var groupedFile, groupedFiles, _i, _j, _len, _len1, _ref;
1278
+ if (file.status === Dropzone.UPLOADING) {
1279
+ groupedFiles = this._getFilesWithXhr(file.xhr);
1280
+ for (_i = 0, _len = groupedFiles.length; _i < _len; _i++) {
1281
+ groupedFile = groupedFiles[_i];
1282
+ groupedFile.status = Dropzone.CANCELED;
1283
+ }
1284
+ file.xhr.abort();
1285
+ for (_j = 0, _len1 = groupedFiles.length; _j < _len1; _j++) {
1286
+ groupedFile = groupedFiles[_j];
1287
+ this.emit("canceled", groupedFile);
1288
+ }
1289
+ if (this.options.uploadMultiple) {
1290
+ this.emit("canceledmultiple", groupedFiles);
1291
+ }
1292
+ } else if ((_ref = file.status) === Dropzone.ADDED || _ref === Dropzone.QUEUED) {
1293
+ file.status = Dropzone.CANCELED;
1294
+ this.emit("canceled", file);
1295
+ if (this.options.uploadMultiple) {
1296
+ this.emit("canceledmultiple", [file]);
1297
+ }
1298
+ }
1299
+ if (this.options.autoProcessQueue) {
1300
+ return this.processQueue();
1301
+ }
1302
+ };
1303
+
1304
+ Dropzone.prototype.uploadFile = function(file) {
1305
+ return this.uploadFiles([file]);
1306
+ };
1307
+
1308
+ Dropzone.prototype.uploadFiles = function(files) {
1309
+ 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,
1310
+ _this = this;
1311
+ xhr = new XMLHttpRequest();
1312
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
1313
+ file = files[_i];
1314
+ file.xhr = xhr;
1315
+ }
1316
+ xhr.open(this.options.method, this.options.url, true);
1317
+ xhr.withCredentials = !!this.options.withCredentials;
1318
+ response = null;
1319
+ handleError = function() {
1320
+ var _j, _len1, _results;
1321
+ _results = [];
1322
+ for (_j = 0, _len1 = files.length; _j < _len1; _j++) {
1323
+ file = files[_j];
1324
+ _results.push(_this._errorProcessing(files, response || _this.options.dictResponseError.replace("{{statusCode}}", xhr.status), xhr));
1325
+ }
1326
+ return _results;
1327
+ };
1328
+ updateProgress = function(e) {
1329
+ var allFilesFinished, progress, _j, _k, _l, _len1, _len2, _len3, _results;
1330
+ if (e != null) {
1331
+ progress = 100 * e.loaded / e.total;
1332
+ for (_j = 0, _len1 = files.length; _j < _len1; _j++) {
1333
+ file = files[_j];
1334
+ file.upload = {
1335
+ progress: progress,
1336
+ total: e.total,
1337
+ bytesSent: e.loaded
1338
+ };
1339
+ }
1340
+ } else {
1341
+ allFilesFinished = true;
1342
+ progress = 100;
1343
+ for (_k = 0, _len2 = files.length; _k < _len2; _k++) {
1344
+ file = files[_k];
1345
+ if (!(file.upload.progress === 100 && file.upload.bytesSent === file.upload.total)) {
1346
+ allFilesFinished = false;
1347
+ }
1348
+ file.upload.progress = progress;
1349
+ file.upload.bytesSent = file.upload.total;
1350
+ }
1351
+ if (allFilesFinished) {
1352
+ return;
1353
+ }
1354
+ }
1355
+ _results = [];
1356
+ for (_l = 0, _len3 = files.length; _l < _len3; _l++) {
1357
+ file = files[_l];
1358
+ _results.push(_this.emit("uploadprogress", file, progress, file.upload.bytesSent));
1359
+ }
1360
+ return _results;
1361
+ };
1362
+ xhr.onload = function(e) {
1363
+ var _ref;
1364
+ if (files[0].status === Dropzone.CANCELED) {
1365
+ return;
1366
+ }
1367
+ if (xhr.readyState !== 4) {
1368
+ return;
1369
+ }
1370
+ response = xhr.responseText;
1371
+ if (xhr.getResponseHeader("content-type") && ~xhr.getResponseHeader("content-type").indexOf("application/json")) {
1372
+ try {
1373
+ response = JSON.parse(response);
1374
+ } catch (_error) {
1375
+ e = _error;
1376
+ response = "Invalid JSON response from server.";
1377
+ }
1378
+ }
1379
+ updateProgress();
1380
+ if (!((200 <= (_ref = xhr.status) && _ref < 300))) {
1381
+ return handleError();
1382
+ } else {
1383
+ return _this._finished(files, response, e);
1384
+ }
1385
+ };
1386
+ xhr.onerror = function() {
1387
+ if (files[0].status === Dropzone.CANCELED) {
1388
+ return;
1389
+ }
1390
+ return handleError();
1391
+ };
1392
+ progressObj = (_ref = xhr.upload) != null ? _ref : xhr;
1393
+ progressObj.onprogress = updateProgress;
1394
+ headers = {
1395
+ "Accept": "application/json",
1396
+ "Cache-Control": "no-cache",
1397
+ "X-Requested-With": "XMLHttpRequest"
1398
+ };
1399
+ if (this.options.headers) {
1400
+ extend(headers, this.options.headers);
1401
+ }
1402
+ for (headerName in headers) {
1403
+ headerValue = headers[headerName];
1404
+ xhr.setRequestHeader(headerName, headerValue);
1405
+ }
1406
+ formData = new FormData();
1407
+ if (this.options.params) {
1408
+ _ref1 = this.options.params;
1409
+ for (key in _ref1) {
1410
+ value = _ref1[key];
1411
+ formData.append(key, value);
1412
+ }
1413
+ }
1414
+ for (_j = 0, _len1 = files.length; _j < _len1; _j++) {
1415
+ file = files[_j];
1416
+ this.emit("sending", file, xhr, formData);
1417
+ }
1418
+ if (this.options.uploadMultiple) {
1419
+ this.emit("sendingmultiple", files, xhr, formData);
1420
+ }
1421
+ if (this.element.tagName === "FORM") {
1422
+ _ref2 = this.element.querySelectorAll("input, textarea, select, button");
1423
+ for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
1424
+ input = _ref2[_k];
1425
+ inputName = input.getAttribute("name");
1426
+ inputType = input.getAttribute("type");
1427
+ if (!inputType || ((_ref3 = inputType.toLowerCase()) !== "checkbox" && _ref3 !== "radio") || input.checked) {
1428
+ formData.append(inputName, input.value);
1429
+ }
1430
+ }
1431
+ }
1432
+ for (_l = 0, _len3 = files.length; _l < _len3; _l++) {
1433
+ file = files[_l];
1434
+ formData.append("" + this.options.paramName + (this.options.uploadMultiple ? "[]" : ""), file, file.name);
1435
+ }
1436
+ return xhr.send(formData);
1437
+ };
1438
+
1439
+ Dropzone.prototype._finished = function(files, responseText, e) {
1440
+ var file, _i, _len;
1441
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
1442
+ file = files[_i];
1443
+ file.status = Dropzone.SUCCESS;
1444
+ this.emit("success", file, responseText, e);
1445
+ this.emit("complete", file);
1446
+ }
1447
+ if (this.options.uploadMultiple) {
1448
+ this.emit("successmultiple", files, responseText, e);
1449
+ this.emit("completemultiple", files);
1450
+ }
1451
+ if (this.options.autoProcessQueue) {
1452
+ return this.processQueue();
1453
+ }
1454
+ };
1455
+
1456
+ Dropzone.prototype._errorProcessing = function(files, message, xhr) {
1457
+ var file, _i, _len;
1458
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
1459
+ file = files[_i];
1460
+ file.status = Dropzone.ERROR;
1461
+ this.emit("error", file, message, xhr);
1462
+ this.emit("complete", file);
1463
+ }
1464
+ if (this.options.uploadMultiple) {
1465
+ this.emit("errormultiple", files, message, xhr);
1466
+ this.emit("completemultiple", files);
1467
+ }
1468
+ if (this.options.autoProcessQueue) {
1469
+ return this.processQueue();
1470
+ }
1471
+ };
1472
+
1473
+ return Dropzone;
1474
+
1475
+ })(Em);
1476
+
1477
+ Dropzone.version = "3.7.1";
1478
+
1479
+ Dropzone.options = {};
1480
+
1481
+ Dropzone.optionsForElement = function(element) {
1482
+ if (element.id) {
1483
+ return Dropzone.options[camelize(element.id)];
1484
+ } else {
1485
+ return void 0;
1486
+ }
1487
+ };
1488
+
1489
+ Dropzone.instances = [];
1490
+
1491
+ Dropzone.forElement = function(element) {
1492
+ if (typeof element === "string") {
1493
+ element = document.querySelector(element);
1494
+ }
1495
+ if ((element != null ? element.dropzone : void 0) == null) {
1496
+ 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.");
1497
+ }
1498
+ return element.dropzone;
1499
+ };
1500
+
1501
+ Dropzone.autoDiscover = true;
1502
+
1503
+ Dropzone.discover = function() {
1504
+ var checkElements, dropzone, dropzones, _i, _len, _results;
1505
+ if (document.querySelectorAll) {
1506
+ dropzones = document.querySelectorAll(".dropzone");
1507
+ } else {
1508
+ dropzones = [];
1509
+ checkElements = function(elements) {
1510
+ var el, _i, _len, _results;
1511
+ _results = [];
1512
+ for (_i = 0, _len = elements.length; _i < _len; _i++) {
1513
+ el = elements[_i];
1514
+ if (/(^| )dropzone($| )/.test(el.className)) {
1515
+ _results.push(dropzones.push(el));
1516
+ } else {
1517
+ _results.push(void 0);
1518
+ }
1519
+ }
1520
+ return _results;
1521
+ };
1522
+ checkElements(document.getElementsByTagName("div"));
1523
+ checkElements(document.getElementsByTagName("form"));
1524
+ }
1525
+ _results = [];
1526
+ for (_i = 0, _len = dropzones.length; _i < _len; _i++) {
1527
+ dropzone = dropzones[_i];
1528
+ if (Dropzone.optionsForElement(dropzone) !== false) {
1529
+ _results.push(new Dropzone(dropzone));
1530
+ } else {
1531
+ _results.push(void 0);
1532
+ }
1533
+ }
1534
+ return _results;
1535
+ };
1536
+
1537
+ Dropzone.blacklistedBrowsers = [/opera.*Macintosh.*version\/12/i];
1538
+
1539
+ Dropzone.isBrowserSupported = function() {
1540
+ var capableBrowser, regex, _i, _len, _ref;
1541
+ capableBrowser = true;
1542
+ if (window.File && window.FileReader && window.FileList && window.Blob && window.FormData && document.querySelector) {
1543
+ if (!("classList" in document.createElement("a"))) {
1544
+ capableBrowser = false;
1545
+ } else {
1546
+ _ref = Dropzone.blacklistedBrowsers;
1547
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1548
+ regex = _ref[_i];
1549
+ if (regex.test(navigator.userAgent)) {
1550
+ capableBrowser = false;
1551
+ continue;
1552
+ }
1553
+ }
1554
+ }
1555
+ } else {
1556
+ capableBrowser = false;
1557
+ }
1558
+ return capableBrowser;
1559
+ };
1560
+
1561
+ without = function(list, rejectedItem) {
1562
+ var item, _i, _len, _results;
1563
+ _results = [];
1564
+ for (_i = 0, _len = list.length; _i < _len; _i++) {
1565
+ item = list[_i];
1566
+ if (item !== rejectedItem) {
1567
+ _results.push(item);
1568
+ }
1569
+ }
1570
+ return _results;
1571
+ };
1572
+
1573
+ camelize = function(str) {
1574
+ return str.replace(/[\-_](\w)/g, function(match) {
1575
+ return match[1].toUpperCase();
1576
+ });
1577
+ };
1578
+
1579
+ Dropzone.createElement = function(string) {
1580
+ var div;
1581
+ div = document.createElement("div");
1582
+ div.innerHTML = string;
1583
+ return div.childNodes[0];
1584
+ };
1585
+
1586
+ Dropzone.elementInside = function(element, container) {
1587
+ if (element === container) {
1588
+ return true;
1589
+ }
1590
+ while (element = element.parentNode) {
1591
+ if (element === container) {
1592
+ return true;
1593
+ }
1594
+ }
1595
+ return false;
1596
+ };
1597
+
1598
+ Dropzone.getElement = function(el, name) {
1599
+ var element;
1600
+ if (typeof el === "string") {
1601
+ element = document.querySelector(el);
1602
+ } else if (el.nodeType != null) {
1603
+ element = el;
1604
+ }
1605
+ if (element == null) {
1606
+ throw new Error("Invalid `" + name + "` option provided. Please provide a CSS selector or a plain HTML element.");
1607
+ }
1608
+ return element;
1609
+ };
1610
+
1611
+ Dropzone.getElements = function(els, name) {
1612
+ var e, el, elements, _i, _j, _len, _len1, _ref;
1613
+ if (els instanceof Array) {
1614
+ elements = [];
1615
+ try {
1616
+ for (_i = 0, _len = els.length; _i < _len; _i++) {
1617
+ el = els[_i];
1618
+ elements.push(this.getElement(el, name));
1619
+ }
1620
+ } catch (_error) {
1621
+ e = _error;
1622
+ elements = null;
1623
+ }
1624
+ } else if (typeof els === "string") {
1625
+ elements = [];
1626
+ _ref = document.querySelectorAll(els);
1627
+ for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
1628
+ el = _ref[_j];
1629
+ elements.push(el);
1630
+ }
1631
+ } else if (els.nodeType != null) {
1632
+ elements = [els];
1633
+ }
1634
+ if (!((elements != null) && elements.length)) {
1635
+ throw new Error("Invalid `" + name + "` option provided. Please provide a CSS selector, a plain HTML element or a list of those.");
1636
+ }
1637
+ return elements;
1638
+ };
1639
+
1640
+ Dropzone.confirm = function(question, accepted, rejected) {
1641
+ if (window.confirm(question)) {
1642
+ return accepted();
1643
+ } else if (rejected != null) {
1644
+ return rejected();
1645
+ }
1646
+ };
1647
+
1648
+ Dropzone.isValidFile = function(file, acceptedFiles) {
1649
+ var baseMimeType, mimeType, validType, _i, _len;
1650
+ if (!acceptedFiles) {
1651
+ return true;
1652
+ }
1653
+ acceptedFiles = acceptedFiles.split(",");
1654
+ mimeType = file.type;
1655
+ baseMimeType = mimeType.replace(/\/.*$/, "");
1656
+ for (_i = 0, _len = acceptedFiles.length; _i < _len; _i++) {
1657
+ validType = acceptedFiles[_i];
1658
+ validType = validType.trim();
1659
+ if (validType.charAt(0) === ".") {
1660
+ if (file.name.indexOf(validType, file.name.length - validType.length) !== -1) {
1661
+ return true;
1662
+ }
1663
+ } else if (/\/\*$/.test(validType)) {
1664
+ if (baseMimeType === validType.replace(/\/.*$/, "")) {
1665
+ return true;
1666
+ }
1667
+ } else {
1668
+ if (mimeType === validType) {
1669
+ return true;
1670
+ }
1671
+ }
1672
+ }
1673
+ return false;
1674
+ };
1675
+
1676
+ if (typeof jQuery !== "undefined" && jQuery !== null) {
1677
+ jQuery.fn.dropzone = function(options) {
1678
+ return this.each(function() {
1679
+ return new Dropzone(this, options);
1680
+ });
1681
+ };
1682
+ }
1683
+
1684
+ if (typeof module !== "undefined" && module !== null) {
1685
+ module.exports = Dropzone;
1686
+ } else {
1687
+ window.Dropzone = Dropzone;
1688
+ }
1689
+
1690
+ Dropzone.ADDED = "added";
1691
+
1692
+ Dropzone.QUEUED = "queued";
1693
+
1694
+ Dropzone.ACCEPTED = Dropzone.QUEUED;
1695
+
1696
+ Dropzone.UPLOADING = "uploading";
1697
+
1698
+ Dropzone.PROCESSING = Dropzone.UPLOADING;
1699
+
1700
+ Dropzone.CANCELED = "canceled";
1701
+
1702
+ Dropzone.ERROR = "error";
1703
+
1704
+ Dropzone.SUCCESS = "success";
1705
+
1706
+ /*
1707
+ # contentloaded.js
1708
+ #
1709
+ # Author: Diego Perini (diego.perini at gmail.com)
1710
+ # Summary: cross-browser wrapper for DOMContentLoaded
1711
+ # Updated: 20101020
1712
+ # License: MIT
1713
+ # Version: 1.2
1714
+ #
1715
+ # URL:
1716
+ # http://javascript.nwbox.com/ContentLoaded/
1717
+ # http://javascript.nwbox.com/ContentLoaded/MIT-LICENSE
1718
+ */
1719
+
1720
+
1721
+ contentLoaded = function(win, fn) {
1722
+ var add, doc, done, init, poll, pre, rem, root, top;
1723
+ done = false;
1724
+ top = true;
1725
+ doc = win.document;
1726
+ root = doc.documentElement;
1727
+ add = (doc.addEventListener ? "addEventListener" : "attachEvent");
1728
+ rem = (doc.addEventListener ? "removeEventListener" : "detachEvent");
1729
+ pre = (doc.addEventListener ? "" : "on");
1730
+ init = function(e) {
1731
+ if (e.type === "readystatechange" && doc.readyState !== "complete") {
1732
+ return;
1733
+ }
1734
+ (e.type === "load" ? win : doc)[rem](pre + e.type, init, false);
1735
+ if (!done && (done = true)) {
1736
+ return fn.call(win, e.type || e);
1737
+ }
1738
+ };
1739
+ poll = function() {
1740
+ var e;
1741
+ try {
1742
+ root.doScroll("left");
1743
+ } catch (_error) {
1744
+ e = _error;
1745
+ setTimeout(poll, 50);
1746
+ return;
1747
+ }
1748
+ return init("poll");
1749
+ };
1750
+ if (doc.readyState !== "complete") {
1751
+ if (doc.createEventObject && root.doScroll) {
1752
+ try {
1753
+ top = !win.frameElement;
1754
+ } catch (_error) {}
1755
+ if (top) {
1756
+ poll();
1757
+ }
1758
+ }
1759
+ doc[add](pre + "DOMContentLoaded", init, false);
1760
+ doc[add](pre + "readystatechange", init, false);
1761
+ return win[add](pre + "load", init, false);
1762
+ }
1763
+ };
1764
+
1765
+ Dropzone._autoDiscoverFunction = function() {
1766
+ if (Dropzone.autoDiscover) {
1767
+ return Dropzone.discover();
1768
+ }
1769
+ };
1770
+
1771
+ contentLoaded(window, Dropzone._autoDiscoverFunction);
1772
+
1773
+ }).call(this);
1774
+
1775
+ });
1776
+ require.alias("component-emitter/index.js", "dropzone/deps/emitter/index.js");
1777
+ require.alias("component-emitter/index.js", "emitter/index.js");
1778
+ if (typeof exports == "object") {
1779
+ module.exports = require("dropzone");
1780
+ } else if (typeof define == "function" && define.amd) {
1781
+ define(function(){ return require("dropzone"); });
1782
+ } else {
1783
+ this["Dropzone"] = require("dropzone");
1784
+ }})();
1785
+
1786
+ Dropzone.autoDiscover = false;