Advertisement
Guest User

dropzone.js

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