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