PageSourceSearch

https://dhamul.co.kr/vendors/Dropzone/js/dropzone.min.js

js dhamul.co.kr collected 2026-10-02 22:50:05 UTC 63,687 bytes, 1,748 lines download raw bytes

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

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.