dropzonejs-rails4 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/app/assets/images/dropzonejs/spritemap.png +0 -0
- data/app/assets/images/dropzonejs/spritemap@2x.png +0 -0
- data/app/assets/javascripts/dropzonejs/dropzone-amd-module.js +1514 -0
- data/app/assets/javascripts/dropzonejs/dropzone.js +1721 -0
- data/app/assets/stylesheets/dropzonejs/basic.css.scss +154 -0
- data/app/assets/stylesheets/dropzonejs/dropzone.css.scss +410 -0
- data/dropzonejs-rails4.gemspec +24 -0
- data/lib/dropzonejs/rails4.rb +8 -0
- data/lib/dropzonejs/rails4/engine.rb +6 -0
- data/lib/dropzonejs/rails4/version.rb +6 -0
- metadata +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 54b0b29bc3337e811538ae6e43b555ba37a85828
|
4
|
+
data.tar.gz: 11f68a0c5d1e9173be0ab126742a62a338413ff8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d92c83d1c70fc7108e7d5e3f3555d67112b1252893bf958994599ac5e8412e4cabc32526401554445aee9f1e381a4224d18f98430ddff70bccf5b583600a0115
|
7
|
+
data.tar.gz: 6b4cc73b910c148ce3559b99762024733e8c7b6a59e4c10ee9b2f2b011c954e9f854f7b2a67bb0e35b96e50773f528d23695b3885e3f13a58c471a77b29653a2
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Jordan
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Dropzonejs::Rails4
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'dropzonejs-rails4'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install dropzonejs-rails4
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
Binary file
|
Binary file
|
@@ -0,0 +1,1514 @@
|
|
1
|
+
// Uses AMD or browser globals to create a jQuery plugin.
|
2
|
+
(function (factory) {
|
3
|
+
if (typeof define === 'function' && define.amd) {
|
4
|
+
// AMD. Register as an anonymous module.
|
5
|
+
define(['jquery'], factory);
|
6
|
+
} else {
|
7
|
+
// Browser globals
|
8
|
+
factory(jQuery);
|
9
|
+
}
|
10
|
+
} (function (jQuery) {
|
11
|
+
var module = { exports: { } }; // Fake component
|
12
|
+
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Expose `Emitter`.
|
16
|
+
*/
|
17
|
+
|
18
|
+
module.exports = Emitter;
|
19
|
+
|
20
|
+
/**
|
21
|
+
* Initialize a new `Emitter`.
|
22
|
+
*
|
23
|
+
* @api public
|
24
|
+
*/
|
25
|
+
|
26
|
+
function Emitter(obj) {
|
27
|
+
if (obj) return mixin(obj);
|
28
|
+
};
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Mixin the emitter properties.
|
32
|
+
*
|
33
|
+
* @param {Object} obj
|
34
|
+
* @return {Object}
|
35
|
+
* @api private
|
36
|
+
*/
|
37
|
+
|
38
|
+
function mixin(obj) {
|
39
|
+
for (var key in Emitter.prototype) {
|
40
|
+
obj[key] = Emitter.prototype[key];
|
41
|
+
}
|
42
|
+
return obj;
|
43
|
+
}
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Listen on the given `event` with `fn`.
|
47
|
+
*
|
48
|
+
* @param {String} event
|
49
|
+
* @param {Function} fn
|
50
|
+
* @return {Emitter}
|
51
|
+
* @api public
|
52
|
+
*/
|
53
|
+
|
54
|
+
Emitter.prototype.on = function(event, fn){
|
55
|
+
this._callbacks = this._callbacks || {};
|
56
|
+
(this._callbacks[event] = this._callbacks[event] || [])
|
57
|
+
.push(fn);
|
58
|
+
return this;
|
59
|
+
};
|
60
|
+
|
61
|
+
/**
|
62
|
+
* Adds an `event` listener that will be invoked a single
|
63
|
+
* time then automatically removed.
|
64
|
+
*
|
65
|
+
* @param {String} event
|
66
|
+
* @param {Function} fn
|
67
|
+
* @return {Emitter}
|
68
|
+
* @api public
|
69
|
+
*/
|
70
|
+
|
71
|
+
Emitter.prototype.once = function(event, fn){
|
72
|
+
var self = this;
|
73
|
+
this._callbacks = this._callbacks || {};
|
74
|
+
|
75
|
+
function on() {
|
76
|
+
self.off(event, on);
|
77
|
+
fn.apply(this, arguments);
|
78
|
+
}
|
79
|
+
|
80
|
+
fn._off = on;
|
81
|
+
this.on(event, on);
|
82
|
+
return this;
|
83
|
+
};
|
84
|
+
|
85
|
+
/**
|
86
|
+
* Remove the given callback for `event` or all
|
87
|
+
* registered callbacks.
|
88
|
+
*
|
89
|
+
* @param {String} event
|
90
|
+
* @param {Function} fn
|
91
|
+
* @return {Emitter}
|
92
|
+
* @api public
|
93
|
+
*/
|
94
|
+
|
95
|
+
Emitter.prototype.off =
|
96
|
+
Emitter.prototype.removeListener =
|
97
|
+
Emitter.prototype.removeAllListeners = function(event, fn){
|
98
|
+
this._callbacks = this._callbacks || {};
|
99
|
+
var callbacks = this._callbacks[event];
|
100
|
+
if (!callbacks) return this;
|
101
|
+
|
102
|
+
// remove all handlers
|
103
|
+
if (1 == arguments.length) {
|
104
|
+
delete this._callbacks[event];
|
105
|
+
return this;
|
106
|
+
}
|
107
|
+
|
108
|
+
// remove specific handler
|
109
|
+
var i = callbacks.indexOf(fn._off || fn);
|
110
|
+
if (~i) callbacks.splice(i, 1);
|
111
|
+
return this;
|
112
|
+
};
|
113
|
+
|
114
|
+
/**
|
115
|
+
* Emit `event` with the given args.
|
116
|
+
*
|
117
|
+
* @param {String} event
|
118
|
+
* @param {Mixed} ...
|
119
|
+
* @return {Emitter}
|
120
|
+
*/
|
121
|
+
|
122
|
+
Emitter.prototype.emit = function(event){
|
123
|
+
this._callbacks = this._callbacks || {};
|
124
|
+
var args = [].slice.call(arguments, 1)
|
125
|
+
, callbacks = this._callbacks[event];
|
126
|
+
|
127
|
+
if (callbacks) {
|
128
|
+
callbacks = callbacks.slice(0);
|
129
|
+
for (var i = 0, len = callbacks.length; i < len; ++i) {
|
130
|
+
callbacks[i].apply(this, args);
|
131
|
+
}
|
132
|
+
}
|
133
|
+
|
134
|
+
return this;
|
135
|
+
};
|
136
|
+
|
137
|
+
/**
|
138
|
+
* Return array of callbacks for `event`.
|
139
|
+
*
|
140
|
+
* @param {String} event
|
141
|
+
* @return {Array}
|
142
|
+
* @api public
|
143
|
+
*/
|
144
|
+
|
145
|
+
Emitter.prototype.listeners = function(event){
|
146
|
+
this._callbacks = this._callbacks || {};
|
147
|
+
return this._callbacks[event] || [];
|
148
|
+
};
|
149
|
+
|
150
|
+
/**
|
151
|
+
* Check if this emitter has `event` handlers.
|
152
|
+
*
|
153
|
+
* @param {String} event
|
154
|
+
* @return {Boolean}
|
155
|
+
* @api public
|
156
|
+
*/
|
157
|
+
|
158
|
+
Emitter.prototype.hasListeners = function(event){
|
159
|
+
return !! this.listeners(event).length;
|
160
|
+
};
|
161
|
+
|
162
|
+
/*
|
163
|
+
#
|
164
|
+
# More info at [www.dropzonejs.com](http://www.dropzonejs.com)
|
165
|
+
#
|
166
|
+
# Copyright (c) 2012, Matias Meno
|
167
|
+
#
|
168
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
169
|
+
# of this software and associated documentation files (the "Software"), to deal
|
170
|
+
# in the Software without restriction, including without limitation the rights
|
171
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
172
|
+
# copies of the Software, and to permit persons to whom the Software is
|
173
|
+
# furnished to do so, subject to the following conditions:
|
174
|
+
#
|
175
|
+
# The above copyright notice and this permission notice shall be included in
|
176
|
+
# all copies or substantial portions of the Software.
|
177
|
+
#
|
178
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
179
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
180
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
181
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
182
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
183
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
184
|
+
# THE SOFTWARE.
|
185
|
+
#
|
186
|
+
*/
|
187
|
+
|
188
|
+
|
189
|
+
(function() {
|
190
|
+
var Dropzone, Em, camelize, contentLoaded, noop, without,
|
191
|
+
__hasProp = {}.hasOwnProperty,
|
192
|
+
__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; },
|
193
|
+
__slice = [].slice;
|
194
|
+
|
195
|
+
Em = typeof Emitter !== "undefined" && Emitter !== null ? Emitter : require("emitter");
|
196
|
+
|
197
|
+
noop = function() {};
|
198
|
+
|
199
|
+
Dropzone = (function(_super) {
|
200
|
+
var extend;
|
201
|
+
|
202
|
+
__extends(Dropzone, _super);
|
203
|
+
|
204
|
+
/*
|
205
|
+
This is a list of all available events you can register on a dropzone object.
|
206
|
+
|
207
|
+
You can register an event handler like this:
|
208
|
+
|
209
|
+
dropzone.on("dragEnter", function() { });
|
210
|
+
*/
|
211
|
+
|
212
|
+
|
213
|
+
Dropzone.prototype.events = ["drop", "dragstart", "dragend", "dragenter", "dragover", "dragleave", "selectedfiles", "addedfile", "removedfile", "thumbnail", "error", "processing", "processingmultiple", "uploadprogress", "totaluploadprogress", "sending", "sendingmultiple", "success", "successmultiple", "canceled", "canceledmultiple", "complete", "completemultiple", "reset"];
|
214
|
+
|
215
|
+
Dropzone.prototype.defaultOptions = {
|
216
|
+
url: null,
|
217
|
+
method: "post",
|
218
|
+
withCredentials: false,
|
219
|
+
parallelUploads: 2,
|
220
|
+
uploadMultiple: false,
|
221
|
+
maxFilesize: 256,
|
222
|
+
paramName: "file",
|
223
|
+
createImageThumbnails: true,
|
224
|
+
maxThumbnailFilesize: 10,
|
225
|
+
thumbnailWidth: 100,
|
226
|
+
thumbnailHeight: 100,
|
227
|
+
params: {},
|
228
|
+
clickable: true,
|
229
|
+
ignoreHiddenFiles: true,
|
230
|
+
acceptedFiles: null,
|
231
|
+
acceptedMimeTypes: null,
|
232
|
+
autoProcessQueue: true,
|
233
|
+
addRemoveLinks: false,
|
234
|
+
previewsContainer: null,
|
235
|
+
dictDefaultMessage: "Drop files here to upload",
|
236
|
+
dictFallbackMessage: "Your browser does not support drag'n'drop file uploads.",
|
237
|
+
dictFallbackText: "Please use the fallback form below to upload your files like in the olden days.",
|
238
|
+
dictFileTooBig: "File is too big ({{filesize}}MB). Max filesize: {{maxFilesize}}MB.",
|
239
|
+
dictInvalidFileType: "You can't upload files of this type.",
|
240
|
+
dictResponseError: "Server responded with {{statusCode}} code.",
|
241
|
+
dictCancelUpload: "Cancel upload",
|
242
|
+
dictCancelUploadConfirmation: "Are you sure you want to cancel this upload?",
|
243
|
+
dictRemoveFile: "Remove file",
|
244
|
+
accept: function(file, done) {
|
245
|
+
return done();
|
246
|
+
},
|
247
|
+
init: function() {
|
248
|
+
return noop;
|
249
|
+
},
|
250
|
+
forceFallback: false,
|
251
|
+
fallback: function() {
|
252
|
+
var child, messageElement, span, _i, _len, _ref;
|
253
|
+
this.element.className = "" + this.element.className + " dz-browser-not-supported";
|
254
|
+
_ref = this.element.getElementsByTagName("div");
|
255
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
256
|
+
child = _ref[_i];
|
257
|
+
if (/(^| )dz-message($| )/.test(child.className)) {
|
258
|
+
messageElement = child;
|
259
|
+
child.className = "dz-message";
|
260
|
+
continue;
|
261
|
+
}
|
262
|
+
}
|
263
|
+
if (!messageElement) {
|
264
|
+
messageElement = Dropzone.createElement("<div class=\"dz-message\"><span></span></div>");
|
265
|
+
this.element.appendChild(messageElement);
|
266
|
+
}
|
267
|
+
span = messageElement.getElementsByTagName("span")[0];
|
268
|
+
if (span) {
|
269
|
+
span.textContent = this.options.dictFallbackMessage;
|
270
|
+
}
|
271
|
+
return this.element.appendChild(this.getFallbackForm());
|
272
|
+
},
|
273
|
+
resize: function(file) {
|
274
|
+
var info, srcRatio, trgRatio;
|
275
|
+
info = {
|
276
|
+
srcX: 0,
|
277
|
+
srcY: 0,
|
278
|
+
srcWidth: file.width,
|
279
|
+
srcHeight: file.height
|
280
|
+
};
|
281
|
+
srcRatio = file.width / file.height;
|
282
|
+
trgRatio = this.options.thumbnailWidth / this.options.thumbnailHeight;
|
283
|
+
if (file.height < this.options.thumbnailHeight || file.width < this.options.thumbnailWidth) {
|
284
|
+
info.trgHeight = info.srcHeight;
|
285
|
+
info.trgWidth = info.srcWidth;
|
286
|
+
} else {
|
287
|
+
if (srcRatio > trgRatio) {
|
288
|
+
info.srcHeight = file.height;
|
289
|
+
info.srcWidth = info.srcHeight * trgRatio;
|
290
|
+
} else {
|
291
|
+
info.srcWidth = file.width;
|
292
|
+
info.srcHeight = info.srcWidth / trgRatio;
|
293
|
+
}
|
294
|
+
}
|
295
|
+
info.srcX = (file.width - info.srcWidth) / 2;
|
296
|
+
info.srcY = (file.height - info.srcHeight) / 2;
|
297
|
+
return info;
|
298
|
+
},
|
299
|
+
/*
|
300
|
+
Those functions register themselves to the events on init and handle all
|
301
|
+
the user interface specific stuff. Overwriting them won't break the upload
|
302
|
+
but can break the way it's displayed.
|
303
|
+
You can overwrite them if you don't like the default behavior. If you just
|
304
|
+
want to add an additional event handler, register it on the dropzone object
|
305
|
+
and don't overwrite those options.
|
306
|
+
*/
|
307
|
+
|
308
|
+
drop: function(e) {
|
309
|
+
return this.element.classList.remove("dz-drag-hover");
|
310
|
+
},
|
311
|
+
dragstart: noop,
|
312
|
+
dragend: function(e) {
|
313
|
+
return this.element.classList.remove("dz-drag-hover");
|
314
|
+
},
|
315
|
+
dragenter: function(e) {
|
316
|
+
return this.element.classList.add("dz-drag-hover");
|
317
|
+
},
|
318
|
+
dragover: function(e) {
|
319
|
+
return this.element.classList.add("dz-drag-hover");
|
320
|
+
},
|
321
|
+
dragleave: function(e) {
|
322
|
+
return this.element.classList.remove("dz-drag-hover");
|
323
|
+
},
|
324
|
+
selectedfiles: function(files) {
|
325
|
+
if (this.element === this.previewsContainer) {
|
326
|
+
return this.element.classList.add("dz-started");
|
327
|
+
}
|
328
|
+
},
|
329
|
+
reset: function() {
|
330
|
+
return this.element.classList.remove("dz-started");
|
331
|
+
},
|
332
|
+
addedfile: function(file) {
|
333
|
+
var _this = this;
|
334
|
+
file.previewElement = Dropzone.createElement(this.options.previewTemplate);
|
335
|
+
file.previewTemplate = file.previewElement;
|
336
|
+
this.previewsContainer.appendChild(file.previewElement);
|
337
|
+
file.previewElement.querySelector("[data-dz-name]").textContent = file.name;
|
338
|
+
file.previewElement.querySelector("[data-dz-size]").innerHTML = this.filesize(file.size);
|
339
|
+
if (this.options.addRemoveLinks) {
|
340
|
+
file._removeLink = Dropzone.createElement("<a class=\"dz-remove\" href=\"javascript:undefined;\">" + this.options.dictRemoveFile + "</a>");
|
341
|
+
file._removeLink.addEventListener("click", function(e) {
|
342
|
+
e.preventDefault();
|
343
|
+
e.stopPropagation();
|
344
|
+
if (file.status === Dropzone.UPLOADING) {
|
345
|
+
if (window.confirm(_this.options.dictCancelUploadConfirmation)) {
|
346
|
+
return _this.removeFile(file);
|
347
|
+
}
|
348
|
+
} else {
|
349
|
+
return _this.removeFile(file);
|
350
|
+
}
|
351
|
+
});
|
352
|
+
return file.previewElement.appendChild(file._removeLink);
|
353
|
+
}
|
354
|
+
},
|
355
|
+
removedfile: function(file) {
|
356
|
+
var _ref;
|
357
|
+
return (_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) : void 0;
|
358
|
+
},
|
359
|
+
thumbnail: function(file, dataUrl) {
|
360
|
+
var thumbnailElement;
|
361
|
+
file.previewElement.classList.remove("dz-file-preview");
|
362
|
+
file.previewElement.classList.add("dz-image-preview");
|
363
|
+
thumbnailElement = file.previewElement.querySelector("[data-dz-thumbnail]");
|
364
|
+
thumbnailElement.alt = file.name;
|
365
|
+
return thumbnailElement.src = dataUrl;
|
366
|
+
},
|
367
|
+
error: function(file, message) {
|
368
|
+
file.previewElement.classList.add("dz-error");
|
369
|
+
return file.previewElement.querySelector("[data-dz-errormessage]").textContent = message;
|
370
|
+
},
|
371
|
+
processing: function(file) {
|
372
|
+
file.previewElement.classList.add("dz-processing");
|
373
|
+
if (file._removeLink) {
|
374
|
+
return file._removeLink.textContent = this.options.dictCancelUpload;
|
375
|
+
}
|
376
|
+
},
|
377
|
+
processingmultiple: noop,
|
378
|
+
uploadprogress: function(file, progress, bytesSent) {
|
379
|
+
return file.previewElement.querySelector("[data-dz-uploadprogress]").style.width = "" + progress + "%";
|
380
|
+
},
|
381
|
+
totaluploadprogress: noop,
|
382
|
+
sending: noop,
|
383
|
+
sendingmultiple: noop,
|
384
|
+
success: function(file) {
|
385
|
+
return file.previewElement.classList.add("dz-success");
|
386
|
+
},
|
387
|
+
successmultiple: noop,
|
388
|
+
canceled: function(file) {
|
389
|
+
return this.emit("error", file, "Upload canceled.");
|
390
|
+
},
|
391
|
+
canceledmultiple: noop,
|
392
|
+
complete: function(file) {
|
393
|
+
if (file._removeLink) {
|
394
|
+
return file._removeLink.textContent = this.options.dictRemoveFile;
|
395
|
+
}
|
396
|
+
},
|
397
|
+
completemultiple: noop,
|
398
|
+
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>"
|
399
|
+
};
|
400
|
+
|
401
|
+
extend = function() {
|
402
|
+
var key, object, objects, target, val, _i, _len;
|
403
|
+
target = arguments[0], objects = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
|
404
|
+
for (_i = 0, _len = objects.length; _i < _len; _i++) {
|
405
|
+
object = objects[_i];
|
406
|
+
for (key in object) {
|
407
|
+
val = object[key];
|
408
|
+
target[key] = val;
|
409
|
+
}
|
410
|
+
}
|
411
|
+
return target;
|
412
|
+
};
|
413
|
+
|
414
|
+
function Dropzone(element, options) {
|
415
|
+
var elementOptions, fallback, _ref;
|
416
|
+
this.element = element;
|
417
|
+
this.version = Dropzone.version;
|
418
|
+
this.defaultOptions.previewTemplate = this.defaultOptions.previewTemplate.replace(/\n*/g, "");
|
419
|
+
this.clickableElements = [];
|
420
|
+
this.listeners = [];
|
421
|
+
this.files = [];
|
422
|
+
if (typeof this.element === "string") {
|
423
|
+
this.element = document.querySelector(this.element);
|
424
|
+
}
|
425
|
+
if (!(this.element && (this.element.nodeType != null))) {
|
426
|
+
throw new Error("Invalid dropzone element.");
|
427
|
+
}
|
428
|
+
if (this.element.dropzone) {
|
429
|
+
throw new Error("Dropzone already attached.");
|
430
|
+
}
|
431
|
+
Dropzone.instances.push(this);
|
432
|
+
element.dropzone = this;
|
433
|
+
elementOptions = (_ref = Dropzone.optionsForElement(this.element)) != null ? _ref : {};
|
434
|
+
this.options = extend({}, this.defaultOptions, elementOptions, options != null ? options : {});
|
435
|
+
if (this.options.url == null) {
|
436
|
+
this.options.url = this.element.action;
|
437
|
+
}
|
438
|
+
if (!this.options.url) {
|
439
|
+
throw new Error("No URL provided.");
|
440
|
+
}
|
441
|
+
if (this.options.acceptedFiles && this.options.acceptedMimeTypes) {
|
442
|
+
throw new Error("You can't provide both 'acceptedFiles' and 'acceptedMimeTypes'. 'acceptedMimeTypes' is deprecated.");
|
443
|
+
}
|
444
|
+
if (this.options.acceptedMimeTypes) {
|
445
|
+
this.options.acceptedFiles = this.options.acceptedMimeTypes;
|
446
|
+
delete this.options.acceptedMimeTypes;
|
447
|
+
}
|
448
|
+
this.options.method = this.options.method.toUpperCase();
|
449
|
+
if (this.options.forceFallback || !Dropzone.isBrowserSupported()) {
|
450
|
+
return this.options.fallback.call(this);
|
451
|
+
}
|
452
|
+
if ((fallback = this.getExistingFallback()) && fallback.parentNode) {
|
453
|
+
fallback.parentNode.removeChild(fallback);
|
454
|
+
}
|
455
|
+
if (this.options.previewsContainer) {
|
456
|
+
this.previewsContainer = Dropzone.getElement(this.options.previewsContainer, "previewsContainer");
|
457
|
+
} else {
|
458
|
+
this.previewsContainer = this.element;
|
459
|
+
}
|
460
|
+
if (this.options.clickable) {
|
461
|
+
if (this.options.clickable === true) {
|
462
|
+
this.clickableElements = [this.element];
|
463
|
+
} else {
|
464
|
+
this.clickableElements = Dropzone.getElements(this.options.clickable, "clickable");
|
465
|
+
}
|
466
|
+
}
|
467
|
+
this.init();
|
468
|
+
}
|
469
|
+
|
470
|
+
Dropzone.prototype.getAcceptedFiles = function() {
|
471
|
+
var file, _i, _len, _ref, _results;
|
472
|
+
_ref = this.files;
|
473
|
+
_results = [];
|
474
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
475
|
+
file = _ref[_i];
|
476
|
+
if (file.accepted) {
|
477
|
+
_results.push(file);
|
478
|
+
}
|
479
|
+
}
|
480
|
+
return _results;
|
481
|
+
};
|
482
|
+
|
483
|
+
Dropzone.prototype.getRejectedFiles = function() {
|
484
|
+
var file, _i, _len, _ref, _results;
|
485
|
+
_ref = this.files;
|
486
|
+
_results = [];
|
487
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
488
|
+
file = _ref[_i];
|
489
|
+
if (!file.accepted) {
|
490
|
+
_results.push(file);
|
491
|
+
}
|
492
|
+
}
|
493
|
+
return _results;
|
494
|
+
};
|
495
|
+
|
496
|
+
Dropzone.prototype.getQueuedFiles = function() {
|
497
|
+
var file, _i, _len, _ref, _results;
|
498
|
+
_ref = this.files;
|
499
|
+
_results = [];
|
500
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
501
|
+
file = _ref[_i];
|
502
|
+
if (file.status === Dropzone.QUEUED) {
|
503
|
+
_results.push(file);
|
504
|
+
}
|
505
|
+
}
|
506
|
+
return _results;
|
507
|
+
};
|
508
|
+
|
509
|
+
Dropzone.prototype.getUploadingFiles = function() {
|
510
|
+
var file, _i, _len, _ref, _results;
|
511
|
+
_ref = this.files;
|
512
|
+
_results = [];
|
513
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
514
|
+
file = _ref[_i];
|
515
|
+
if (file.status === Dropzone.UPLOADING) {
|
516
|
+
_results.push(file);
|
517
|
+
}
|
518
|
+
}
|
519
|
+
return _results;
|
520
|
+
};
|
521
|
+
|
522
|
+
Dropzone.prototype.init = function() {
|
523
|
+
var eventName, noPropagation, setupHiddenFileInput, _i, _len, _ref, _ref1,
|
524
|
+
_this = this;
|
525
|
+
if (this.element.tagName === "form") {
|
526
|
+
this.element.setAttribute("enctype", "multipart/form-data");
|
527
|
+
}
|
528
|
+
if (this.element.classList.contains("dropzone") && !this.element.querySelector(".dz-message")) {
|
529
|
+
this.element.appendChild(Dropzone.createElement("<div class=\"dz-default dz-message\"><span>" + this.options.dictDefaultMessage + "</span></div>"));
|
530
|
+
}
|
531
|
+
if (this.clickableElements.length) {
|
532
|
+
setupHiddenFileInput = function() {
|
533
|
+
if (_this.hiddenFileInput) {
|
534
|
+
document.body.removeChild(_this.hiddenFileInput);
|
535
|
+
}
|
536
|
+
_this.hiddenFileInput = document.createElement("input");
|
537
|
+
_this.hiddenFileInput.setAttribute("type", "file");
|
538
|
+
if (_this.options.uploadMultiple) {
|
539
|
+
_this.hiddenFileInput.setAttribute("multiple", "multiple");
|
540
|
+
}
|
541
|
+
if (_this.options.acceptedFiles != null) {
|
542
|
+
_this.hiddenFileInput.setAttribute("accept", _this.options.acceptedFiles);
|
543
|
+
}
|
544
|
+
_this.hiddenFileInput.style.visibility = "hidden";
|
545
|
+
_this.hiddenFileInput.style.position = "absolute";
|
546
|
+
_this.hiddenFileInput.style.top = "0";
|
547
|
+
_this.hiddenFileInput.style.left = "0";
|
548
|
+
_this.hiddenFileInput.style.height = "0";
|
549
|
+
_this.hiddenFileInput.style.width = "0";
|
550
|
+
document.body.appendChild(_this.hiddenFileInput);
|
551
|
+
return _this.hiddenFileInput.addEventListener("change", function() {
|
552
|
+
var files;
|
553
|
+
files = _this.hiddenFileInput.files;
|
554
|
+
if (files.length) {
|
555
|
+
_this.emit("selectedfiles", files);
|
556
|
+
_this.handleFiles(files);
|
557
|
+
}
|
558
|
+
return setupHiddenFileInput();
|
559
|
+
});
|
560
|
+
};
|
561
|
+
setupHiddenFileInput();
|
562
|
+
}
|
563
|
+
this.URL = (_ref = window.URL) != null ? _ref : window.webkitURL;
|
564
|
+
_ref1 = this.events;
|
565
|
+
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
566
|
+
eventName = _ref1[_i];
|
567
|
+
this.on(eventName, this.options[eventName]);
|
568
|
+
}
|
569
|
+
this.on("uploadprogress", function() {
|
570
|
+
return _this.updateTotalUploadProgress();
|
571
|
+
});
|
572
|
+
this.on("removedfile", function() {
|
573
|
+
return _this.updateTotalUploadProgress();
|
574
|
+
});
|
575
|
+
this.on("canceled", function(file) {
|
576
|
+
return _this.emit("complete", file);
|
577
|
+
});
|
578
|
+
noPropagation = function(e) {
|
579
|
+
e.stopPropagation();
|
580
|
+
if (e.preventDefault) {
|
581
|
+
return e.preventDefault();
|
582
|
+
} else {
|
583
|
+
return e.returnValue = false;
|
584
|
+
}
|
585
|
+
};
|
586
|
+
this.listeners = [
|
587
|
+
{
|
588
|
+
element: this.element,
|
589
|
+
events: {
|
590
|
+
"dragstart": function(e) {
|
591
|
+
return _this.emit("dragstart", e);
|
592
|
+
},
|
593
|
+
"dragenter": function(e) {
|
594
|
+
noPropagation(e);
|
595
|
+
return _this.emit("dragenter", e);
|
596
|
+
},
|
597
|
+
"dragover": function(e) {
|
598
|
+
noPropagation(e);
|
599
|
+
return _this.emit("dragover", e);
|
600
|
+
},
|
601
|
+
"dragleave": function(e) {
|
602
|
+
return _this.emit("dragleave", e);
|
603
|
+
},
|
604
|
+
"drop": function(e) {
|
605
|
+
noPropagation(e);
|
606
|
+
_this.drop(e);
|
607
|
+
return _this.emit("drop", e);
|
608
|
+
},
|
609
|
+
"dragend": function(e) {
|
610
|
+
return _this.emit("dragend", e);
|
611
|
+
}
|
612
|
+
}
|
613
|
+
}
|
614
|
+
];
|
615
|
+
this.clickableElements.forEach(function(clickableElement) {
|
616
|
+
return _this.listeners.push({
|
617
|
+
element: clickableElement,
|
618
|
+
events: {
|
619
|
+
"click": function(evt) {
|
620
|
+
if ((clickableElement !== _this.element) || (evt.target === _this.element || Dropzone.elementInside(evt.target, _this.element.querySelector(".dz-message")))) {
|
621
|
+
return _this.hiddenFileInput.click();
|
622
|
+
}
|
623
|
+
}
|
624
|
+
}
|
625
|
+
});
|
626
|
+
});
|
627
|
+
this.enable();
|
628
|
+
return this.options.init.call(this);
|
629
|
+
};
|
630
|
+
|
631
|
+
Dropzone.prototype.destroy = function() {
|
632
|
+
var _ref;
|
633
|
+
this.disable();
|
634
|
+
this.removeAllFiles(true);
|
635
|
+
if ((_ref = this.hiddenFileInput) != null ? _ref.parentNode : void 0) {
|
636
|
+
this.hiddenFileInput.parentNode.removeChild(this.hiddenFileInput);
|
637
|
+
this.hiddenFileInput = null;
|
638
|
+
}
|
639
|
+
return delete this.element.dropzone;
|
640
|
+
};
|
641
|
+
|
642
|
+
Dropzone.prototype.updateTotalUploadProgress = function() {
|
643
|
+
var acceptedFiles, file, totalBytes, totalBytesSent, totalUploadProgress, _i, _len, _ref;
|
644
|
+
totalBytesSent = 0;
|
645
|
+
totalBytes = 0;
|
646
|
+
acceptedFiles = this.getAcceptedFiles();
|
647
|
+
if (acceptedFiles.length) {
|
648
|
+
_ref = this.getAcceptedFiles();
|
649
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
650
|
+
file = _ref[_i];
|
651
|
+
totalBytesSent += file.upload.bytesSent;
|
652
|
+
totalBytes += file.upload.total;
|
653
|
+
}
|
654
|
+
totalUploadProgress = 100 * totalBytesSent / totalBytes;
|
655
|
+
} else {
|
656
|
+
totalUploadProgress = 100;
|
657
|
+
}
|
658
|
+
return this.emit("totaluploadprogress", totalUploadProgress, totalBytes, totalBytesSent);
|
659
|
+
};
|
660
|
+
|
661
|
+
Dropzone.prototype.getFallbackForm = function() {
|
662
|
+
var existingFallback, fields, fieldsString, form;
|
663
|
+
if (existingFallback = this.getExistingFallback()) {
|
664
|
+
return existingFallback;
|
665
|
+
}
|
666
|
+
fieldsString = "<div class=\"dz-fallback\">";
|
667
|
+
if (this.options.dictFallbackText) {
|
668
|
+
fieldsString += "<p>" + this.options.dictFallbackText + "</p>";
|
669
|
+
}
|
670
|
+
fieldsString += "<input type=\"file\" name=\"" + this.options.paramName + (this.options.uploadMultiple ? "[]" : "") + "\" " + (this.options.uploadMultiple ? 'multiple="multiple"' : void 0) + " /><button type=\"submit\">Upload!</button></div>";
|
671
|
+
fields = Dropzone.createElement(fieldsString);
|
672
|
+
if (this.element.tagName !== "FORM") {
|
673
|
+
form = Dropzone.createElement("<form action=\"" + this.options.url + "\" enctype=\"multipart/form-data\" method=\"" + this.options.method + "\"></form>");
|
674
|
+
form.appendChild(fields);
|
675
|
+
} else {
|
676
|
+
this.element.setAttribute("enctype", "multipart/form-data");
|
677
|
+
this.element.setAttribute("method", this.options.method);
|
678
|
+
}
|
679
|
+
return form != null ? form : fields;
|
680
|
+
};
|
681
|
+
|
682
|
+
Dropzone.prototype.getExistingFallback = function() {
|
683
|
+
var fallback, getFallback, tagName, _i, _len, _ref;
|
684
|
+
getFallback = function(elements) {
|
685
|
+
var el, _i, _len;
|
686
|
+
for (_i = 0, _len = elements.length; _i < _len; _i++) {
|
687
|
+
el = elements[_i];
|
688
|
+
if (/(^| )fallback($| )/.test(el.className)) {
|
689
|
+
return el;
|
690
|
+
}
|
691
|
+
}
|
692
|
+
};
|
693
|
+
_ref = ["div", "form"];
|
694
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
695
|
+
tagName = _ref[_i];
|
696
|
+
if (fallback = getFallback(this.element.getElementsByTagName(tagName))) {
|
697
|
+
return fallback;
|
698
|
+
}
|
699
|
+
}
|
700
|
+
};
|
701
|
+
|
702
|
+
Dropzone.prototype.setupEventListeners = function() {
|
703
|
+
var elementListeners, event, listener, _i, _len, _ref, _results;
|
704
|
+
_ref = this.listeners;
|
705
|
+
_results = [];
|
706
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
707
|
+
elementListeners = _ref[_i];
|
708
|
+
_results.push((function() {
|
709
|
+
var _ref1, _results1;
|
710
|
+
_ref1 = elementListeners.events;
|
711
|
+
_results1 = [];
|
712
|
+
for (event in _ref1) {
|
713
|
+
listener = _ref1[event];
|
714
|
+
_results1.push(elementListeners.element.addEventListener(event, listener, false));
|
715
|
+
}
|
716
|
+
return _results1;
|
717
|
+
})());
|
718
|
+
}
|
719
|
+
return _results;
|
720
|
+
};
|
721
|
+
|
722
|
+
Dropzone.prototype.removeEventListeners = function() {
|
723
|
+
var elementListeners, event, listener, _i, _len, _ref, _results;
|
724
|
+
_ref = this.listeners;
|
725
|
+
_results = [];
|
726
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
727
|
+
elementListeners = _ref[_i];
|
728
|
+
_results.push((function() {
|
729
|
+
var _ref1, _results1;
|
730
|
+
_ref1 = elementListeners.events;
|
731
|
+
_results1 = [];
|
732
|
+
for (event in _ref1) {
|
733
|
+
listener = _ref1[event];
|
734
|
+
_results1.push(elementListeners.element.removeEventListener(event, listener, false));
|
735
|
+
}
|
736
|
+
return _results1;
|
737
|
+
})());
|
738
|
+
}
|
739
|
+
return _results;
|
740
|
+
};
|
741
|
+
|
742
|
+
Dropzone.prototype.disable = function() {
|
743
|
+
var file, _i, _len, _ref, _results;
|
744
|
+
this.clickableElements.forEach(function(element) {
|
745
|
+
return element.classList.remove("dz-clickable");
|
746
|
+
});
|
747
|
+
this.removeEventListeners();
|
748
|
+
_ref = this.files;
|
749
|
+
_results = [];
|
750
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
751
|
+
file = _ref[_i];
|
752
|
+
_results.push(this.cancelUpload(file));
|
753
|
+
}
|
754
|
+
return _results;
|
755
|
+
};
|
756
|
+
|
757
|
+
Dropzone.prototype.enable = function() {
|
758
|
+
this.clickableElements.forEach(function(element) {
|
759
|
+
return element.classList.add("dz-clickable");
|
760
|
+
});
|
761
|
+
return this.setupEventListeners();
|
762
|
+
};
|
763
|
+
|
764
|
+
Dropzone.prototype.filesize = function(size) {
|
765
|
+
var string;
|
766
|
+
if (size >= 100000000000) {
|
767
|
+
size = size / 100000000000;
|
768
|
+
string = "TB";
|
769
|
+
} else if (size >= 100000000) {
|
770
|
+
size = size / 100000000;
|
771
|
+
string = "GB";
|
772
|
+
} else if (size >= 100000) {
|
773
|
+
size = size / 100000;
|
774
|
+
string = "MB";
|
775
|
+
} else if (size >= 100) {
|
776
|
+
size = size / 100;
|
777
|
+
string = "KB";
|
778
|
+
} else {
|
779
|
+
size = size * 10;
|
780
|
+
string = "b";
|
781
|
+
}
|
782
|
+
return "<strong>" + (Math.round(size) / 10) + "</strong> " + string;
|
783
|
+
};
|
784
|
+
|
785
|
+
Dropzone.prototype.drop = function(e) {
|
786
|
+
var files, items;
|
787
|
+
if (!e.dataTransfer) {
|
788
|
+
return;
|
789
|
+
}
|
790
|
+
files = e.dataTransfer.files;
|
791
|
+
this.emit("selectedfiles", files);
|
792
|
+
if (files.length) {
|
793
|
+
items = e.dataTransfer.items;
|
794
|
+
if (items && items.length && ((items[0].webkitGetAsEntry != null) || (items[0].getAsEntry != null))) {
|
795
|
+
this.handleItems(items);
|
796
|
+
} else {
|
797
|
+
this.handleFiles(files);
|
798
|
+
}
|
799
|
+
}
|
800
|
+
};
|
801
|
+
|
802
|
+
Dropzone.prototype.handleFiles = function(files) {
|
803
|
+
var file, _i, _len, _results;
|
804
|
+
_results = [];
|
805
|
+
for (_i = 0, _len = files.length; _i < _len; _i++) {
|
806
|
+
file = files[_i];
|
807
|
+
_results.push(this.addFile(file));
|
808
|
+
}
|
809
|
+
return _results;
|
810
|
+
};
|
811
|
+
|
812
|
+
Dropzone.prototype.handleItems = function(items) {
|
813
|
+
var entry, item, _i, _len;
|
814
|
+
for (_i = 0, _len = items.length; _i < _len; _i++) {
|
815
|
+
item = items[_i];
|
816
|
+
if (item.webkitGetAsEntry != null) {
|
817
|
+
entry = item.webkitGetAsEntry();
|
818
|
+
if (entry.isFile) {
|
819
|
+
this.addFile(item.getAsFile());
|
820
|
+
} else if (entry.isDirectory) {
|
821
|
+
this.addDirectory(entry, entry.name);
|
822
|
+
}
|
823
|
+
} else {
|
824
|
+
this.addFile(item.getAsFile());
|
825
|
+
}
|
826
|
+
}
|
827
|
+
};
|
828
|
+
|
829
|
+
Dropzone.prototype.accept = function(file, done) {
|
830
|
+
if (file.size > this.options.maxFilesize * 1024 * 1024) {
|
831
|
+
return done(this.options.dictFileTooBig.replace("{{filesize}}", Math.round(file.size / 1024 / 10.24) / 100).replace("{{maxFilesize}}", this.options.maxFilesize));
|
832
|
+
} else if (!Dropzone.isValidFile(file, this.options.acceptedFiles)) {
|
833
|
+
return done(this.options.dictInvalidFileType);
|
834
|
+
} else {
|
835
|
+
return this.options.accept.call(this, file, done);
|
836
|
+
}
|
837
|
+
};
|
838
|
+
|
839
|
+
Dropzone.prototype.addFile = function(file) {
|
840
|
+
var _this = this;
|
841
|
+
file.upload = {
|
842
|
+
progress: 0,
|
843
|
+
total: file.size,
|
844
|
+
bytesSent: 0
|
845
|
+
};
|
846
|
+
this.files.push(file);
|
847
|
+
file.status = Dropzone.ADDED;
|
848
|
+
this.emit("addedfile", file);
|
849
|
+
if (this.options.createImageThumbnails && file.type.match(/image.*/) && file.size <= this.options.maxThumbnailFilesize * 1024 * 1024) {
|
850
|
+
this.createThumbnail(file);
|
851
|
+
}
|
852
|
+
return this.accept(file, function(error) {
|
853
|
+
if (error) {
|
854
|
+
file.accepted = false;
|
855
|
+
return _this._errorProcessing([file], error);
|
856
|
+
} else {
|
857
|
+
file.accepted = true;
|
858
|
+
return _this.enqueueFile(file);
|
859
|
+
}
|
860
|
+
});
|
861
|
+
};
|
862
|
+
|
863
|
+
Dropzone.prototype.enqueueFiles = function(files) {
|
864
|
+
var file, _i, _len;
|
865
|
+
for (_i = 0, _len = files.length; _i < _len; _i++) {
|
866
|
+
file = files[_i];
|
867
|
+
this.enqueueFile(file);
|
868
|
+
}
|
869
|
+
return null;
|
870
|
+
};
|
871
|
+
|
872
|
+
Dropzone.prototype.enqueueFile = function(file) {
|
873
|
+
var _this = this;
|
874
|
+
if (file.status === Dropzone.ADDED) {
|
875
|
+
file.status = Dropzone.QUEUED;
|
876
|
+
if (this.options.autoProcessQueue) {
|
877
|
+
return setTimeout((function() {
|
878
|
+
return _this.processQueue();
|
879
|
+
}), 1);
|
880
|
+
}
|
881
|
+
} else {
|
882
|
+
throw new Error("This file can't be queued because it has already been processed or was rejected.");
|
883
|
+
}
|
884
|
+
};
|
885
|
+
|
886
|
+
Dropzone.prototype.addDirectory = function(entry, path) {
|
887
|
+
var dirReader, entriesReader,
|
888
|
+
_this = this;
|
889
|
+
dirReader = entry.createReader();
|
890
|
+
entriesReader = function(entries) {
|
891
|
+
var _i, _len;
|
892
|
+
for (_i = 0, _len = entries.length; _i < _len; _i++) {
|
893
|
+
entry = entries[_i];
|
894
|
+
if (entry.isFile) {
|
895
|
+
entry.file(function(file) {
|
896
|
+
if (_this.options.ignoreHiddenFiles && file.name.substring(0, 1) === '.') {
|
897
|
+
return;
|
898
|
+
}
|
899
|
+
file.fullPath = "" + path + "/" + file.name;
|
900
|
+
return _this.addFile(file);
|
901
|
+
});
|
902
|
+
} else if (entry.isDirectory) {
|
903
|
+
_this.addDirectory(entry, "" + path + "/" + entry.name);
|
904
|
+
}
|
905
|
+
}
|
906
|
+
};
|
907
|
+
return dirReader.readEntries(entriesReader, function(error) {
|
908
|
+
return typeof console !== "undefined" && console !== null ? typeof console.log === "function" ? console.log(error) : void 0 : void 0;
|
909
|
+
});
|
910
|
+
};
|
911
|
+
|
912
|
+
Dropzone.prototype.removeFile = function(file) {
|
913
|
+
if (file.status === Dropzone.UPLOADING) {
|
914
|
+
this.cancelUpload(file);
|
915
|
+
}
|
916
|
+
this.files = without(this.files, file);
|
917
|
+
this.emit("removedfile", file);
|
918
|
+
if (this.files.length === 0) {
|
919
|
+
return this.emit("reset");
|
920
|
+
}
|
921
|
+
};
|
922
|
+
|
923
|
+
Dropzone.prototype.removeAllFiles = function(cancelIfNecessary) {
|
924
|
+
var file, _i, _len, _ref;
|
925
|
+
if (cancelIfNecessary == null) {
|
926
|
+
cancelIfNecessary = false;
|
927
|
+
}
|
928
|
+
_ref = this.files.slice();
|
929
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
930
|
+
file = _ref[_i];
|
931
|
+
if (file.status !== Dropzone.UPLOADING || cancelIfNecessary) {
|
932
|
+
this.removeFile(file);
|
933
|
+
}
|
934
|
+
}
|
935
|
+
return null;
|
936
|
+
};
|
937
|
+
|
938
|
+
Dropzone.prototype.createThumbnail = function(file) {
|
939
|
+
var fileReader,
|
940
|
+
_this = this;
|
941
|
+
fileReader = new FileReader;
|
942
|
+
fileReader.onload = function() {
|
943
|
+
var img;
|
944
|
+
img = new Image;
|
945
|
+
img.onload = function() {
|
946
|
+
var canvas, ctx, resizeInfo, thumbnail, _ref, _ref1, _ref2, _ref3;
|
947
|
+
file.width = img.width;
|
948
|
+
file.height = img.height;
|
949
|
+
resizeInfo = _this.options.resize.call(_this, file);
|
950
|
+
if (resizeInfo.trgWidth == null) {
|
951
|
+
resizeInfo.trgWidth = _this.options.thumbnailWidth;
|
952
|
+
}
|
953
|
+
if (resizeInfo.trgHeight == null) {
|
954
|
+
resizeInfo.trgHeight = _this.options.thumbnailHeight;
|
955
|
+
}
|
956
|
+
canvas = document.createElement("canvas");
|
957
|
+
ctx = canvas.getContext("2d");
|
958
|
+
canvas.width = resizeInfo.trgWidth;
|
959
|
+
canvas.height = resizeInfo.trgHeight;
|
960
|
+
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);
|
961
|
+
thumbnail = canvas.toDataURL("image/png");
|
962
|
+
return _this.emit("thumbnail", file, thumbnail);
|
963
|
+
};
|
964
|
+
return img.src = fileReader.result;
|
965
|
+
};
|
966
|
+
return fileReader.readAsDataURL(file);
|
967
|
+
};
|
968
|
+
|
969
|
+
Dropzone.prototype.processQueue = function() {
|
970
|
+
var i, parallelUploads, processingLength, queuedFiles;
|
971
|
+
parallelUploads = this.options.parallelUploads;
|
972
|
+
processingLength = this.getUploadingFiles().length;
|
973
|
+
i = processingLength;
|
974
|
+
queuedFiles = this.getQueuedFiles();
|
975
|
+
if (!(queuedFiles.length > 0)) {
|
976
|
+
return;
|
977
|
+
}
|
978
|
+
if (this.options.uploadMultiple) {
|
979
|
+
return this.processFiles(queuedFiles.slice(0, parallelUploads));
|
980
|
+
} else {
|
981
|
+
while (i < parallelUploads) {
|
982
|
+
if (!queuedFiles.length) {
|
983
|
+
return;
|
984
|
+
}
|
985
|
+
this.processFile(queuedFiles.shift());
|
986
|
+
i++;
|
987
|
+
}
|
988
|
+
}
|
989
|
+
};
|
990
|
+
|
991
|
+
Dropzone.prototype.processFile = function(file) {
|
992
|
+
return this.processFiles([file]);
|
993
|
+
};
|
994
|
+
|
995
|
+
Dropzone.prototype.processFiles = function(files) {
|
996
|
+
var file, _i, _len;
|
997
|
+
for (_i = 0, _len = files.length; _i < _len; _i++) {
|
998
|
+
file = files[_i];
|
999
|
+
file.processing = true;
|
1000
|
+
file.status = Dropzone.UPLOADING;
|
1001
|
+
this.emit("processing", file);
|
1002
|
+
}
|
1003
|
+
if (this.options.uploadMultiple) {
|
1004
|
+
this.emit("processingmultiple", files);
|
1005
|
+
}
|
1006
|
+
return this.uploadFiles(files);
|
1007
|
+
};
|
1008
|
+
|
1009
|
+
Dropzone.prototype._getFilesWithXhr = function(xhr) {
|
1010
|
+
var file, files;
|
1011
|
+
return files = (function() {
|
1012
|
+
var _i, _len, _ref, _results;
|
1013
|
+
_ref = this.files;
|
1014
|
+
_results = [];
|
1015
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
1016
|
+
file = _ref[_i];
|
1017
|
+
if (file.xhr === xhr) {
|
1018
|
+
_results.push(file);
|
1019
|
+
}
|
1020
|
+
}
|
1021
|
+
return _results;
|
1022
|
+
}).call(this);
|
1023
|
+
};
|
1024
|
+
|
1025
|
+
Dropzone.prototype.cancelUpload = function(file) {
|
1026
|
+
var groupedFile, groupedFiles, _i, _j, _len, _len1, _ref;
|
1027
|
+
if (file.status === Dropzone.UPLOADING) {
|
1028
|
+
groupedFiles = this._getFilesWithXhr(file.xhr);
|
1029
|
+
for (_i = 0, _len = groupedFiles.length; _i < _len; _i++) {
|
1030
|
+
groupedFile = groupedFiles[_i];
|
1031
|
+
groupedFile.status = Dropzone.CANCELED;
|
1032
|
+
}
|
1033
|
+
file.xhr.abort();
|
1034
|
+
for (_j = 0, _len1 = groupedFiles.length; _j < _len1; _j++) {
|
1035
|
+
groupedFile = groupedFiles[_j];
|
1036
|
+
this.emit("canceled", groupedFile);
|
1037
|
+
}
|
1038
|
+
if (this.options.uploadMultiple) {
|
1039
|
+
this.emit("canceledmultiple", groupedFiles);
|
1040
|
+
}
|
1041
|
+
} else if ((_ref = file.status) === Dropzone.ADDED || _ref === Dropzone.QUEUED) {
|
1042
|
+
file.status = Dropzone.CANCELED;
|
1043
|
+
this.emit("canceled", file);
|
1044
|
+
if (this.options.uploadMultiple) {
|
1045
|
+
this.emit("canceledmultiple", [file]);
|
1046
|
+
}
|
1047
|
+
}
|
1048
|
+
if (this.options.autoProcessQueue) {
|
1049
|
+
return this.processQueue();
|
1050
|
+
}
|
1051
|
+
};
|
1052
|
+
|
1053
|
+
Dropzone.prototype.uploadFile = function(file) {
|
1054
|
+
return this.uploadFiles([file]);
|
1055
|
+
};
|
1056
|
+
|
1057
|
+
Dropzone.prototype.uploadFiles = function(files) {
|
1058
|
+
var file, formData, handleError, header, headers, input, inputName, inputType, key, name, progressObj, response, updateProgress, value, xhr, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2, _ref3,
|
1059
|
+
_this = this;
|
1060
|
+
xhr = new XMLHttpRequest();
|
1061
|
+
for (_i = 0, _len = files.length; _i < _len; _i++) {
|
1062
|
+
file = files[_i];
|
1063
|
+
file.xhr = xhr;
|
1064
|
+
}
|
1065
|
+
xhr.open(this.options.method, this.options.url, true);
|
1066
|
+
xhr.withCredentials = !!this.options.withCredentials;
|
1067
|
+
response = null;
|
1068
|
+
handleError = function() {
|
1069
|
+
var _j, _len1, _results;
|
1070
|
+
_results = [];
|
1071
|
+
for (_j = 0, _len1 = files.length; _j < _len1; _j++) {
|
1072
|
+
file = files[_j];
|
1073
|
+
_results.push(_this._errorProcessing(files, response || _this.options.dictResponseError.replace("{{statusCode}}", xhr.status), xhr));
|
1074
|
+
}
|
1075
|
+
return _results;
|
1076
|
+
};
|
1077
|
+
updateProgress = function(e) {
|
1078
|
+
var allFilesFinished, progress, _j, _k, _l, _len1, _len2, _len3, _results;
|
1079
|
+
if (e != null) {
|
1080
|
+
progress = 100 * e.loaded / e.total;
|
1081
|
+
for (_j = 0, _len1 = files.length; _j < _len1; _j++) {
|
1082
|
+
file = files[_j];
|
1083
|
+
file.upload = {
|
1084
|
+
progress: progress,
|
1085
|
+
total: e.total,
|
1086
|
+
bytesSent: e.loaded
|
1087
|
+
};
|
1088
|
+
}
|
1089
|
+
} else {
|
1090
|
+
allFilesFinished = true;
|
1091
|
+
progress = 100;
|
1092
|
+
for (_k = 0, _len2 = files.length; _k < _len2; _k++) {
|
1093
|
+
file = files[_k];
|
1094
|
+
if (!(file.upload.progress === 100 && file.upload.bytesSent === file.upload.total)) {
|
1095
|
+
allFilesFinished = false;
|
1096
|
+
}
|
1097
|
+
file.upload.progress = progress;
|
1098
|
+
file.upload.bytesSent = file.upload.total;
|
1099
|
+
}
|
1100
|
+
if (allFilesFinished) {
|
1101
|
+
return;
|
1102
|
+
}
|
1103
|
+
}
|
1104
|
+
_results = [];
|
1105
|
+
for (_l = 0, _len3 = files.length; _l < _len3; _l++) {
|
1106
|
+
file = files[_l];
|
1107
|
+
_results.push(_this.emit("uploadprogress", file, progress, file.upload.bytesSent));
|
1108
|
+
}
|
1109
|
+
return _results;
|
1110
|
+
};
|
1111
|
+
xhr.onload = function(e) {
|
1112
|
+
var _ref;
|
1113
|
+
if (files[0].status === Dropzone.CANCELED) {
|
1114
|
+
return;
|
1115
|
+
}
|
1116
|
+
if (xhr.readyState !== 4) {
|
1117
|
+
return;
|
1118
|
+
}
|
1119
|
+
response = xhr.responseText;
|
1120
|
+
if (xhr.getResponseHeader("content-type") && ~xhr.getResponseHeader("content-type").indexOf("application/json")) {
|
1121
|
+
try {
|
1122
|
+
response = JSON.parse(response);
|
1123
|
+
} catch (_error) {
|
1124
|
+
e = _error;
|
1125
|
+
response = "Invalid JSON response from server.";
|
1126
|
+
}
|
1127
|
+
}
|
1128
|
+
updateProgress();
|
1129
|
+
if (!((200 <= (_ref = xhr.status) && _ref < 300))) {
|
1130
|
+
return handleError();
|
1131
|
+
} else {
|
1132
|
+
return _this._finished(files, response, e);
|
1133
|
+
}
|
1134
|
+
};
|
1135
|
+
xhr.onerror = function() {
|
1136
|
+
if (files[0].status === Dropzone.CANCELED) {
|
1137
|
+
return;
|
1138
|
+
}
|
1139
|
+
return handleError();
|
1140
|
+
};
|
1141
|
+
progressObj = (_ref = xhr.upload) != null ? _ref : xhr;
|
1142
|
+
progressObj.onprogress = updateProgress;
|
1143
|
+
headers = {
|
1144
|
+
"Accept": "application/json",
|
1145
|
+
"Cache-Control": "no-cache",
|
1146
|
+
"X-Requested-With": "XMLHttpRequest"
|
1147
|
+
};
|
1148
|
+
if (this.options.headers) {
|
1149
|
+
extend(headers, this.options.headers);
|
1150
|
+
}
|
1151
|
+
for (header in headers) {
|
1152
|
+
name = headers[header];
|
1153
|
+
xhr.setRequestHeader(header, name);
|
1154
|
+
}
|
1155
|
+
formData = new FormData();
|
1156
|
+
if (this.options.params) {
|
1157
|
+
_ref1 = this.options.params;
|
1158
|
+
for (key in _ref1) {
|
1159
|
+
value = _ref1[key];
|
1160
|
+
formData.append(key, value);
|
1161
|
+
}
|
1162
|
+
}
|
1163
|
+
for (_j = 0, _len1 = files.length; _j < _len1; _j++) {
|
1164
|
+
file = files[_j];
|
1165
|
+
this.emit("sending", file, xhr, formData);
|
1166
|
+
}
|
1167
|
+
if (this.options.uploadMultiple) {
|
1168
|
+
this.emit("sendingmultiple", files, xhr, formData);
|
1169
|
+
}
|
1170
|
+
if (this.element.tagName === "FORM") {
|
1171
|
+
_ref2 = this.element.querySelectorAll("input, textarea, select, button");
|
1172
|
+
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
|
1173
|
+
input = _ref2[_k];
|
1174
|
+
inputName = input.getAttribute("name");
|
1175
|
+
inputType = input.getAttribute("type");
|
1176
|
+
if (!inputType || ((_ref3 = inputType.toLowerCase()) !== "checkbox" && _ref3 !== "radio") || input.checked) {
|
1177
|
+
formData.append(inputName, input.value);
|
1178
|
+
}
|
1179
|
+
}
|
1180
|
+
}
|
1181
|
+
for (_l = 0, _len3 = files.length; _l < _len3; _l++) {
|
1182
|
+
file = files[_l];
|
1183
|
+
formData.append("" + this.options.paramName + (this.options.uploadMultiple ? "[]" : ""), file, file.name);
|
1184
|
+
}
|
1185
|
+
return xhr.send(formData);
|
1186
|
+
};
|
1187
|
+
|
1188
|
+
Dropzone.prototype._finished = function(files, responseText, e) {
|
1189
|
+
var file, _i, _len;
|
1190
|
+
for (_i = 0, _len = files.length; _i < _len; _i++) {
|
1191
|
+
file = files[_i];
|
1192
|
+
file.status = Dropzone.SUCCESS;
|
1193
|
+
this.emit("success", file, responseText, e);
|
1194
|
+
this.emit("complete", file);
|
1195
|
+
}
|
1196
|
+
if (this.options.uploadMultiple) {
|
1197
|
+
this.emit("successmultiple", files, responseText, e);
|
1198
|
+
this.emit("completemultiple", files);
|
1199
|
+
}
|
1200
|
+
if (this.options.autoProcessQueue) {
|
1201
|
+
return this.processQueue();
|
1202
|
+
}
|
1203
|
+
};
|
1204
|
+
|
1205
|
+
Dropzone.prototype._errorProcessing = function(files, message, xhr) {
|
1206
|
+
var file, _i, _len;
|
1207
|
+
for (_i = 0, _len = files.length; _i < _len; _i++) {
|
1208
|
+
file = files[_i];
|
1209
|
+
file.status = Dropzone.ERROR;
|
1210
|
+
this.emit("error", file, message, xhr);
|
1211
|
+
this.emit("complete", file);
|
1212
|
+
}
|
1213
|
+
if (this.options.uploadMultiple) {
|
1214
|
+
this.emit("errormultiple", files, message, xhr);
|
1215
|
+
this.emit("completemultiple", files);
|
1216
|
+
}
|
1217
|
+
if (this.options.autoProcessQueue) {
|
1218
|
+
return this.processQueue();
|
1219
|
+
}
|
1220
|
+
};
|
1221
|
+
|
1222
|
+
return Dropzone;
|
1223
|
+
|
1224
|
+
})(Em);
|
1225
|
+
|
1226
|
+
Dropzone.version = "3.6.1";
|
1227
|
+
|
1228
|
+
Dropzone.options = {};
|
1229
|
+
|
1230
|
+
Dropzone.optionsForElement = function(element) {
|
1231
|
+
if (element.id) {
|
1232
|
+
return Dropzone.options[camelize(element.id)];
|
1233
|
+
} else {
|
1234
|
+
return void 0;
|
1235
|
+
}
|
1236
|
+
};
|
1237
|
+
|
1238
|
+
Dropzone.instances = [];
|
1239
|
+
|
1240
|
+
Dropzone.forElement = function(element) {
|
1241
|
+
if (typeof element === "string") {
|
1242
|
+
element = document.querySelector(element);
|
1243
|
+
}
|
1244
|
+
if ((element != null ? element.dropzone : void 0) == null) {
|
1245
|
+
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.");
|
1246
|
+
}
|
1247
|
+
return element.dropzone;
|
1248
|
+
};
|
1249
|
+
|
1250
|
+
Dropzone.autoDiscover = true;
|
1251
|
+
|
1252
|
+
Dropzone.discover = function() {
|
1253
|
+
var checkElements, dropzone, dropzones, _i, _len, _results;
|
1254
|
+
if (!Dropzone.autoDiscover) {
|
1255
|
+
return;
|
1256
|
+
}
|
1257
|
+
if (document.querySelectorAll) {
|
1258
|
+
dropzones = document.querySelectorAll(".dropzone");
|
1259
|
+
} else {
|
1260
|
+
dropzones = [];
|
1261
|
+
checkElements = function(elements) {
|
1262
|
+
var el, _i, _len, _results;
|
1263
|
+
_results = [];
|
1264
|
+
for (_i = 0, _len = elements.length; _i < _len; _i++) {
|
1265
|
+
el = elements[_i];
|
1266
|
+
if (/(^| )dropzone($| )/.test(el.className)) {
|
1267
|
+
_results.push(dropzones.push(el));
|
1268
|
+
} else {
|
1269
|
+
_results.push(void 0);
|
1270
|
+
}
|
1271
|
+
}
|
1272
|
+
return _results;
|
1273
|
+
};
|
1274
|
+
checkElements(document.getElementsByTagName("div"));
|
1275
|
+
checkElements(document.getElementsByTagName("form"));
|
1276
|
+
}
|
1277
|
+
_results = [];
|
1278
|
+
for (_i = 0, _len = dropzones.length; _i < _len; _i++) {
|
1279
|
+
dropzone = dropzones[_i];
|
1280
|
+
if (Dropzone.optionsForElement(dropzone) !== false) {
|
1281
|
+
_results.push(new Dropzone(dropzone));
|
1282
|
+
} else {
|
1283
|
+
_results.push(void 0);
|
1284
|
+
}
|
1285
|
+
}
|
1286
|
+
return _results;
|
1287
|
+
};
|
1288
|
+
|
1289
|
+
Dropzone.blacklistedBrowsers = [/opera.*Macintosh.*version\/12/i];
|
1290
|
+
|
1291
|
+
Dropzone.isBrowserSupported = function() {
|
1292
|
+
var capableBrowser, regex, _i, _len, _ref;
|
1293
|
+
capableBrowser = true;
|
1294
|
+
if (window.File && window.FileReader && window.FileList && window.Blob && window.FormData && document.querySelector) {
|
1295
|
+
if (!("classList" in document.createElement("a"))) {
|
1296
|
+
capableBrowser = false;
|
1297
|
+
} else {
|
1298
|
+
_ref = Dropzone.blacklistedBrowsers;
|
1299
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
1300
|
+
regex = _ref[_i];
|
1301
|
+
if (regex.test(navigator.userAgent)) {
|
1302
|
+
capableBrowser = false;
|
1303
|
+
continue;
|
1304
|
+
}
|
1305
|
+
}
|
1306
|
+
}
|
1307
|
+
} else {
|
1308
|
+
capableBrowser = false;
|
1309
|
+
}
|
1310
|
+
return capableBrowser;
|
1311
|
+
};
|
1312
|
+
|
1313
|
+
without = function(list, rejectedItem) {
|
1314
|
+
var item, _i, _len, _results;
|
1315
|
+
_results = [];
|
1316
|
+
for (_i = 0, _len = list.length; _i < _len; _i++) {
|
1317
|
+
item = list[_i];
|
1318
|
+
if (item !== rejectedItem) {
|
1319
|
+
_results.push(item);
|
1320
|
+
}
|
1321
|
+
}
|
1322
|
+
return _results;
|
1323
|
+
};
|
1324
|
+
|
1325
|
+
camelize = function(str) {
|
1326
|
+
return str.replace(/[\-_](\w)/g, function(match) {
|
1327
|
+
return match[1].toUpperCase();
|
1328
|
+
});
|
1329
|
+
};
|
1330
|
+
|
1331
|
+
Dropzone.createElement = function(string) {
|
1332
|
+
var div;
|
1333
|
+
div = document.createElement("div");
|
1334
|
+
div.innerHTML = string;
|
1335
|
+
return div.childNodes[0];
|
1336
|
+
};
|
1337
|
+
|
1338
|
+
Dropzone.elementInside = function(element, container) {
|
1339
|
+
if (element === container) {
|
1340
|
+
return true;
|
1341
|
+
}
|
1342
|
+
while (element = element.parentNode) {
|
1343
|
+
if (element === container) {
|
1344
|
+
return true;
|
1345
|
+
}
|
1346
|
+
}
|
1347
|
+
return false;
|
1348
|
+
};
|
1349
|
+
|
1350
|
+
Dropzone.getElement = function(el, name) {
|
1351
|
+
var element;
|
1352
|
+
if (typeof el === "string") {
|
1353
|
+
element = document.querySelector(el);
|
1354
|
+
} else if (el.nodeType != null) {
|
1355
|
+
element = el;
|
1356
|
+
}
|
1357
|
+
if (element == null) {
|
1358
|
+
throw new Error("Invalid `" + name + "` option provided. Please provide a CSS selector or a plain HTML element.");
|
1359
|
+
}
|
1360
|
+
return element;
|
1361
|
+
};
|
1362
|
+
|
1363
|
+
Dropzone.getElements = function(els, name) {
|
1364
|
+
var e, el, elements, _i, _j, _len, _len1, _ref;
|
1365
|
+
if (els instanceof Array) {
|
1366
|
+
elements = [];
|
1367
|
+
try {
|
1368
|
+
for (_i = 0, _len = els.length; _i < _len; _i++) {
|
1369
|
+
el = els[_i];
|
1370
|
+
elements.push(this.getElement(el, name));
|
1371
|
+
}
|
1372
|
+
} catch (_error) {
|
1373
|
+
e = _error;
|
1374
|
+
elements = null;
|
1375
|
+
}
|
1376
|
+
} else if (typeof els === "string") {
|
1377
|
+
elements = [];
|
1378
|
+
_ref = document.querySelectorAll(els);
|
1379
|
+
for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
|
1380
|
+
el = _ref[_j];
|
1381
|
+
elements.push(el);
|
1382
|
+
}
|
1383
|
+
} else if (els.nodeType != null) {
|
1384
|
+
elements = [els];
|
1385
|
+
}
|
1386
|
+
if (!((elements != null) && elements.length)) {
|
1387
|
+
throw new Error("Invalid `" + name + "` option provided. Please provide a CSS selector, a plain HTML element or a list of those.");
|
1388
|
+
}
|
1389
|
+
return elements;
|
1390
|
+
};
|
1391
|
+
|
1392
|
+
Dropzone.isValidFile = function(file, acceptedFiles) {
|
1393
|
+
var baseMimeType, mimeType, validType, _i, _len;
|
1394
|
+
if (!acceptedFiles) {
|
1395
|
+
return true;
|
1396
|
+
}
|
1397
|
+
acceptedFiles = acceptedFiles.split(",");
|
1398
|
+
mimeType = file.type;
|
1399
|
+
baseMimeType = mimeType.replace(/\/.*$/, "");
|
1400
|
+
for (_i = 0, _len = acceptedFiles.length; _i < _len; _i++) {
|
1401
|
+
validType = acceptedFiles[_i];
|
1402
|
+
validType = validType.trim();
|
1403
|
+
if (validType.charAt(0) === ".") {
|
1404
|
+
if (file.name.indexOf(validType, file.name.length - validType.length) !== -1) {
|
1405
|
+
return true;
|
1406
|
+
}
|
1407
|
+
} else if (/\/\*$/.test(validType)) {
|
1408
|
+
if (baseMimeType === validType.replace(/\/.*$/, "")) {
|
1409
|
+
return true;
|
1410
|
+
}
|
1411
|
+
} else {
|
1412
|
+
if (mimeType === validType) {
|
1413
|
+
return true;
|
1414
|
+
}
|
1415
|
+
}
|
1416
|
+
}
|
1417
|
+
return false;
|
1418
|
+
};
|
1419
|
+
|
1420
|
+
if (typeof jQuery !== "undefined" && jQuery !== null) {
|
1421
|
+
jQuery.fn.dropzone = function(options) {
|
1422
|
+
return this.each(function() {
|
1423
|
+
return new Dropzone(this, options);
|
1424
|
+
});
|
1425
|
+
};
|
1426
|
+
}
|
1427
|
+
|
1428
|
+
if (typeof module !== "undefined" && module !== null) {
|
1429
|
+
module.exports = Dropzone;
|
1430
|
+
} else {
|
1431
|
+
window.Dropzone = Dropzone;
|
1432
|
+
}
|
1433
|
+
|
1434
|
+
Dropzone.ADDED = "added";
|
1435
|
+
|
1436
|
+
Dropzone.QUEUED = "queued";
|
1437
|
+
|
1438
|
+
Dropzone.ACCEPTED = Dropzone.QUEUED;
|
1439
|
+
|
1440
|
+
Dropzone.UPLOADING = "uploading";
|
1441
|
+
|
1442
|
+
Dropzone.PROCESSING = Dropzone.UPLOADING;
|
1443
|
+
|
1444
|
+
Dropzone.CANCELED = "canceled";
|
1445
|
+
|
1446
|
+
Dropzone.ERROR = "error";
|
1447
|
+
|
1448
|
+
Dropzone.SUCCESS = "success";
|
1449
|
+
|
1450
|
+
/*
|
1451
|
+
# contentloaded.js
|
1452
|
+
#
|
1453
|
+
# Author: Diego Perini (diego.perini at gmail.com)
|
1454
|
+
# Summary: cross-browser wrapper for DOMContentLoaded
|
1455
|
+
# Updated: 20101020
|
1456
|
+
# License: MIT
|
1457
|
+
# Version: 1.2
|
1458
|
+
#
|
1459
|
+
# URL:
|
1460
|
+
# http://javascript.nwbox.com/ContentLoaded/
|
1461
|
+
# http://javascript.nwbox.com/ContentLoaded/MIT-LICENSE
|
1462
|
+
*/
|
1463
|
+
|
1464
|
+
|
1465
|
+
contentLoaded = function(win, fn) {
|
1466
|
+
var add, doc, done, init, poll, pre, rem, root, top;
|
1467
|
+
done = false;
|
1468
|
+
top = true;
|
1469
|
+
doc = win.document;
|
1470
|
+
root = doc.documentElement;
|
1471
|
+
add = (doc.addEventListener ? "addEventListener" : "attachEvent");
|
1472
|
+
rem = (doc.addEventListener ? "removeEventListener" : "detachEvent");
|
1473
|
+
pre = (doc.addEventListener ? "" : "on");
|
1474
|
+
init = function(e) {
|
1475
|
+
if (e.type === "readystatechange" && doc.readyState !== "complete") {
|
1476
|
+
return;
|
1477
|
+
}
|
1478
|
+
(e.type === "load" ? win : doc)[rem](pre + e.type, init, false);
|
1479
|
+
if (!done && (done = true)) {
|
1480
|
+
return fn.call(win, e.type || e);
|
1481
|
+
}
|
1482
|
+
};
|
1483
|
+
poll = function() {
|
1484
|
+
var e;
|
1485
|
+
try {
|
1486
|
+
root.doScroll("left");
|
1487
|
+
} catch (_error) {
|
1488
|
+
e = _error;
|
1489
|
+
setTimeout(poll, 50);
|
1490
|
+
return;
|
1491
|
+
}
|
1492
|
+
return init("poll");
|
1493
|
+
};
|
1494
|
+
if (doc.readyState !== "complete") {
|
1495
|
+
if (doc.createEventObject && root.doScroll) {
|
1496
|
+
try {
|
1497
|
+
top = !win.frameElement;
|
1498
|
+
} catch (_error) {}
|
1499
|
+
if (top) {
|
1500
|
+
poll();
|
1501
|
+
}
|
1502
|
+
}
|
1503
|
+
doc[add](pre + "DOMContentLoaded", init, false);
|
1504
|
+
doc[add](pre + "readystatechange", init, false);
|
1505
|
+
return win[add](pre + "load", init, false);
|
1506
|
+
}
|
1507
|
+
};
|
1508
|
+
|
1509
|
+
contentLoaded(window, Dropzone.discover);
|
1510
|
+
|
1511
|
+
}).call(this);
|
1512
|
+
|
1513
|
+
return module.exports;
|
1514
|
+
}));
|