Path: blob/master/web-gui/buildyourownbotnet/assets/js/dropzone/dropzone.js
1293 views
;(function(){12/**3* Require the given path.4*5* @param {String} path6* @return {Object} exports7* @api public8*/910function require(path, parent, orig) {11var resolved = require.resolve(path);1213// lookup failed14if (null == resolved) {15orig = orig || path;16parent = parent || 'root';17var err = new Error('Failed to require "' + orig + '" from "' + parent + '"');18err.path = orig;19err.parent = parent;20err.require = true;21throw err;22}2324var module = require.modules[resolved];2526// perform real require()27// by invoking the module's28// registered function29if (!module._resolving && !module.exports) {30var mod = {};31mod.exports = {};32mod.client = mod.component = true;33module._resolving = true;34module.call(this, mod.exports, require.relative(resolved), mod);35delete module._resolving;36module.exports = mod.exports;37}3839return module.exports;40}4142/**43* Registered modules.44*/4546require.modules = {};4748/**49* Registered aliases.50*/5152require.aliases = {};5354/**55* Resolve `path`.56*57* Lookup:58*59* - PATH/index.js60* - PATH.js61* - PATH62*63* @param {String} path64* @return {String} path or null65* @api private66*/6768require.resolve = function(path) {69if (path.charAt(0) === '/') path = path.slice(1);7071var paths = [72path,73path + '.js',74path + '.json',75path + '/index.js',76path + '/index.json'77];7879for (var i = 0; i < paths.length; i++) {80var path = paths[i];81if (require.modules.hasOwnProperty(path)) return path;82if (require.aliases.hasOwnProperty(path)) return require.aliases[path];83}84};8586/**87* Normalize `path` relative to the current path.88*89* @param {String} curr90* @param {String} path91* @return {String}92* @api private93*/9495require.normalize = function(curr, path) {96var segs = [];9798if ('.' != path.charAt(0)) return path;99100curr = curr.split('/');101path = path.split('/');102103for (var i = 0; i < path.length; ++i) {104if ('..' == path[i]) {105curr.pop();106} else if ('.' != path[i] && '' != path[i]) {107segs.push(path[i]);108}109}110111return curr.concat(segs).join('/');112};113114/**115* Register module at `path` with callback `definition`.116*117* @param {String} path118* @param {Function} definition119* @api private120*/121122require.register = function(path, definition) {123require.modules[path] = definition;124};125126/**127* Alias a module definition.128*129* @param {String} from130* @param {String} to131* @api private132*/133134require.alias = function(from, to) {135if (!require.modules.hasOwnProperty(from)) {136throw new Error('Failed to alias "' + from + '", it does not exist');137}138require.aliases[to] = from;139};140141/**142* Return a require function relative to the `parent` path.143*144* @param {String} parent145* @return {Function}146* @api private147*/148149require.relative = function(parent) {150var p = require.normalize(parent, '..');151152/**153* lastIndexOf helper.154*/155156function lastIndexOf(arr, obj) {157var i = arr.length;158while (i--) {159if (arr[i] === obj) return i;160}161return -1;162}163164/**165* The relative require() itself.166*/167168function localRequire(path) {169var resolved = localRequire.resolve(path);170return require(resolved, parent, path);171}172173/**174* Resolve relative to the parent.175*/176177localRequire.resolve = function(path) {178var c = path.charAt(0);179if ('/' == c) return path.slice(1);180if ('.' == c) return require.normalize(p, path);181182// resolve deps by returning183// the dep in the nearest "deps"184// directory185var segs = parent.split('/');186var i = lastIndexOf(segs, 'deps') + 1;187if (!i) i = 0;188path = segs.slice(0, i + 1).join('/') + '/deps/' + path;189return path;190};191192/**193* Check if module is defined at `path`.194*/195196localRequire.exists = function(path) {197return require.modules.hasOwnProperty(localRequire.resolve(path));198};199200return localRequire;201};202require.register("component-emitter/index.js", function(exports, require, module){203204/**205* Expose `Emitter`.206*/207208module.exports = Emitter;209210/**211* Initialize a new `Emitter`.212*213* @api public214*/215216function Emitter(obj) {217if (obj) return mixin(obj);218};219220/**221* Mixin the emitter properties.222*223* @param {Object} obj224* @return {Object}225* @api private226*/227228function mixin(obj) {229for (var key in Emitter.prototype) {230obj[key] = Emitter.prototype[key];231}232return obj;233}234235/**236* Listen on the given `event` with `fn`.237*238* @param {String} event239* @param {Function} fn240* @return {Emitter}241* @api public242*/243244Emitter.prototype.on = function(event, fn){245this._callbacks = this._callbacks || {};246(this._callbacks[event] = this._callbacks[event] || [])247.push(fn);248return this;249};250251/**252* Adds an `event` listener that will be invoked a single253* time then automatically removed.254*255* @param {String} event256* @param {Function} fn257* @return {Emitter}258* @api public259*/260261Emitter.prototype.once = function(event, fn){262var self = this;263this._callbacks = this._callbacks || {};264265function on() {266self.off(event, on);267fn.apply(this, arguments);268}269270fn._off = on;271this.on(event, on);272return this;273};274275/**276* Remove the given callback for `event` or all277* registered callbacks.278*279* @param {String} event280* @param {Function} fn281* @return {Emitter}282* @api public283*/284285Emitter.prototype.off =286Emitter.prototype.removeListener =287Emitter.prototype.removeAllListeners = function(event, fn){288this._callbacks = this._callbacks || {};289var callbacks = this._callbacks[event];290if (!callbacks) return this;291292// remove all handlers293if (1 == arguments.length) {294delete this._callbacks[event];295return this;296}297298// remove specific handler299var i = callbacks.indexOf(fn._off || fn);300if (~i) callbacks.splice(i, 1);301return this;302};303304/**305* Emit `event` with the given args.306*307* @param {String} event308* @param {Mixed} ...309* @return {Emitter}310*/311312Emitter.prototype.emit = function(event){313this._callbacks = this._callbacks || {};314var args = [].slice.call(arguments, 1)315, callbacks = this._callbacks[event];316317if (callbacks) {318callbacks = callbacks.slice(0);319for (var i = 0, len = callbacks.length; i < len; ++i) {320callbacks[i].apply(this, args);321}322}323324return this;325};326327/**328* Return array of callbacks for `event`.329*330* @param {String} event331* @return {Array}332* @api public333*/334335Emitter.prototype.listeners = function(event){336this._callbacks = this._callbacks || {};337return this._callbacks[event] || [];338};339340/**341* Check if this emitter has `event` handlers.342*343* @param {String} event344* @return {Boolean}345* @api public346*/347348Emitter.prototype.hasListeners = function(event){349return !! this.listeners(event).length;350};351352});353require.register("dropzone/index.js", function(exports, require, module){354355356/**357* Exposing dropzone358*/359module.exports = require("./lib/dropzone.js");360361});362require.register("dropzone/lib/dropzone.js", function(exports, require, module){363/*364#365# More info at [www.dropzonejs.com](http://www.dropzonejs.com)366#367# Copyright (c) 2012, Matias Meno368#369# Permission is hereby granted, free of charge, to any person obtaining a copy370# of this software and associated documentation files (the "Software"), to deal371# in the Software without restriction, including without limitation the rights372# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell373# copies of the Software, and to permit persons to whom the Software is374# furnished to do so, subject to the following conditions:375#376# The above copyright notice and this permission notice shall be included in377# all copies or substantial portions of the Software.378#379# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR380# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,381# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE382# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER383# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,384# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN385# THE SOFTWARE.386#387*/388389390(function() {391var Dropzone, Em, camelize, contentLoaded, noop, without,392__hasProp = {}.hasOwnProperty,393__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; },394__slice = [].slice;395396Em = typeof Emitter !== "undefined" && Emitter !== null ? Emitter : require("emitter");397398noop = function() {};399400Dropzone = (function(_super) {401var extend;402403__extends(Dropzone, _super);404405/*406This is a list of all available events you can register on a dropzone object.407408You can register an event handler like this:409410dropzone.on("dragEnter", function() { });411*/412413414Dropzone.prototype.events = ["drop", "dragstart", "dragend", "dragenter", "dragover", "dragleave", "selectedfiles", "addedfile", "removedfile", "thumbnail", "error", "errormultiple", "processing", "processingmultiple", "uploadprogress", "totaluploadprogress", "sending", "sendingmultiple", "success", "successmultiple", "canceled", "canceledmultiple", "complete", "completemultiple", "reset", "maxfilesexceeded", "maxfilesreached"];415416Dropzone.prototype.defaultOptions = {417url: null,418method: "post",419withCredentials: false,420parallelUploads: 2,421uploadMultiple: false,422maxFilesize: 256,423paramName: "file",424createImageThumbnails: true,425maxThumbnailFilesize: 10,426thumbnailWidth: 100,427thumbnailHeight: 100,428maxFiles: null,429params: {},430clickable: true,431ignoreHiddenFiles: true,432acceptedFiles: null,433acceptedMimeTypes: null,434autoProcessQueue: true,435addRemoveLinks: false,436previewsContainer: null,437dictDefaultMessage: "Drop files here to upload",438dictFallbackMessage: "Your browser does not support drag'n'drop file uploads.",439dictFallbackText: "Please use the fallback form below to upload your files like in the olden days.",440dictFileTooBig: "File is too big ({{filesize}}MB). Max filesize: {{maxFilesize}}MB.",441dictInvalidFileType: "You can't upload files of this type.",442dictResponseError: "Server responded with {{statusCode}} code.",443dictCancelUpload: "Cancel upload",444dictCancelUploadConfirmation: "Are you sure you want to cancel this upload?",445dictRemoveFile: "Remove file",446dictRemoveFileConfirmation: null,447dictMaxFilesExceeded: "You can not upload any more files.",448accept: function(file, done) {449return done();450},451init: function() {452return noop;453},454forceFallback: false,455fallback: function() {456var child, messageElement, span, _i, _len, _ref;457this.element.className = "" + this.element.className + " dz-browser-not-supported";458_ref = this.element.getElementsByTagName("div");459for (_i = 0, _len = _ref.length; _i < _len; _i++) {460child = _ref[_i];461if (/(^| )dz-message($| )/.test(child.className)) {462messageElement = child;463child.className = "dz-message";464continue;465}466}467if (!messageElement) {468messageElement = Dropzone.createElement("<div class=\"dz-message\"><span></span></div>");469this.element.appendChild(messageElement);470}471span = messageElement.getElementsByTagName("span")[0];472if (span) {473span.textContent = this.options.dictFallbackMessage;474}475return this.element.appendChild(this.getFallbackForm());476},477resize: function(file) {478var info, srcRatio, trgRatio;479info = {480srcX: 0,481srcY: 0,482srcWidth: file.width,483srcHeight: file.height484};485srcRatio = file.width / file.height;486trgRatio = this.options.thumbnailWidth / this.options.thumbnailHeight;487if (file.height < this.options.thumbnailHeight || file.width < this.options.thumbnailWidth) {488info.trgHeight = info.srcHeight;489info.trgWidth = info.srcWidth;490} else {491if (srcRatio > trgRatio) {492info.srcHeight = file.height;493info.srcWidth = info.srcHeight * trgRatio;494} else {495info.srcWidth = file.width;496info.srcHeight = info.srcWidth / trgRatio;497}498}499info.srcX = (file.width - info.srcWidth) / 2;500info.srcY = (file.height - info.srcHeight) / 2;501return info;502},503/*504Those functions register themselves to the events on init and handle all505the user interface specific stuff. Overwriting them won't break the upload506but can break the way it's displayed.507You can overwrite them if you don't like the default behavior. If you just508want to add an additional event handler, register it on the dropzone object509and don't overwrite those options.510*/511512drop: function(e) {513return this.element.classList.remove("dz-drag-hover");514},515dragstart: noop,516dragend: function(e) {517return this.element.classList.remove("dz-drag-hover");518},519dragenter: function(e) {520return this.element.classList.add("dz-drag-hover");521},522dragover: function(e) {523return this.element.classList.add("dz-drag-hover");524},525dragleave: function(e) {526return this.element.classList.remove("dz-drag-hover");527},528selectedfiles: function(files) {529if (this.element === this.previewsContainer) {530return this.element.classList.add("dz-started");531}532},533reset: function() {534return this.element.classList.remove("dz-started");535},536addedfile: function(file) {537var node, _i, _j, _len, _len1, _ref, _ref1,538_this = this;539file.previewElement = Dropzone.createElement(this.options.previewTemplate.trim());540file.previewTemplate = file.previewElement;541this.previewsContainer.appendChild(file.previewElement);542_ref = file.previewElement.querySelectorAll("[data-dz-name]");543for (_i = 0, _len = _ref.length; _i < _len; _i++) {544node = _ref[_i];545node.textContent = file.name;546}547_ref1 = file.previewElement.querySelectorAll("[data-dz-size]");548for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {549node = _ref1[_j];550node.innerHTML = this.filesize(file.size);551}552if (this.options.addRemoveLinks) {553file._removeLink = Dropzone.createElement("<a class=\"dz-remove\" href=\"javascript:undefined;\">" + this.options.dictRemoveFile + "</a>");554file._removeLink.addEventListener("click", function(e) {555e.preventDefault();556e.stopPropagation();557if (file.status === Dropzone.UPLOADING) {558return Dropzone.confirm(_this.options.dictCancelUploadConfirmation, function() {559return _this.removeFile(file);560});561} else {562if (_this.options.dictRemoveFileConfirmation) {563return Dropzone.confirm(_this.options.dictRemoveFileConfirmation, function() {564return _this.removeFile(file);565});566} else {567return _this.removeFile(file);568}569}570});571return file.previewElement.appendChild(file._removeLink);572}573},574removedfile: function(file) {575var _ref;576if ((_ref = file.previewElement) != null) {577_ref.parentNode.removeChild(file.previewElement);578}579return this._updateMaxFilesReachedClass();580},581thumbnail: function(file, dataUrl) {582var thumbnailElement, _i, _len, _ref, _results;583file.previewElement.classList.remove("dz-file-preview");584file.previewElement.classList.add("dz-image-preview");585_ref = file.previewElement.querySelectorAll("[data-dz-thumbnail]");586_results = [];587for (_i = 0, _len = _ref.length; _i < _len; _i++) {588thumbnailElement = _ref[_i];589thumbnailElement.alt = file.name;590_results.push(thumbnailElement.src = dataUrl);591}592return _results;593},594error: function(file, message) {595var node, _i, _len, _ref, _results;596file.previewElement.classList.add("dz-error");597if (typeof message !== "String" && message.error) {598message = message.error;599}600_ref = file.previewElement.querySelectorAll("[data-dz-errormessage]");601_results = [];602for (_i = 0, _len = _ref.length; _i < _len; _i++) {603node = _ref[_i];604_results.push(node.textContent = message);605}606return _results;607},608errormultiple: noop,609processing: function(file) {610file.previewElement.classList.add("dz-processing");611if (file._removeLink) {612return file._removeLink.textContent = this.options.dictCancelUpload;613}614},615processingmultiple: noop,616uploadprogress: function(file, progress, bytesSent) {617var node, _i, _len, _ref, _results;618_ref = file.previewElement.querySelectorAll("[data-dz-uploadprogress]");619_results = [];620for (_i = 0, _len = _ref.length; _i < _len; _i++) {621node = _ref[_i];622_results.push(node.style.width = "" + progress + "%");623}624return _results;625},626totaluploadprogress: noop,627sending: noop,628sendingmultiple: noop,629success: function(file) {630return file.previewElement.classList.add("dz-success");631},632successmultiple: noop,633canceled: function(file) {634return this.emit("error", file, "Upload canceled.");635},636canceledmultiple: noop,637complete: function(file) {638if (file._removeLink) {639return file._removeLink.textContent = this.options.dictRemoveFile;640}641},642completemultiple: noop,643maxfilesexceeded: noop,644maxfilesreached: noop,645previewTemplate: "<div class=\"dz-preview dz-file-preview\">\n <div class=\"dz-details\">\n <div class=\"dz-filename\"><span data-dz-name></span></div>\n <div class=\"dz-size\" data-dz-size></div>\n <img data-dz-thumbnail />\n </div>\n <div class=\"dz-progress\"><span class=\"dz-upload\" data-dz-uploadprogress></span></div>\n <div class=\"dz-success-mark\"><span>✔</span></div>\n <div class=\"dz-error-mark\"><span>✘</span></div>\n <div class=\"dz-error-message\"><span data-dz-errormessage></span></div>\n</div>"646};647648extend = function() {649var key, object, objects, target, val, _i, _len;650target = arguments[0], objects = 2 <= arguments.length ? __slice.call(arguments, 1) : [];651for (_i = 0, _len = objects.length; _i < _len; _i++) {652object = objects[_i];653for (key in object) {654val = object[key];655target[key] = val;656}657}658return target;659};660661function Dropzone(element, options) {662var elementOptions, fallback, _ref;663this.element = element;664this.version = Dropzone.version;665this.defaultOptions.previewTemplate = this.defaultOptions.previewTemplate.replace(/\n*/g, "");666this.clickableElements = [];667this.listeners = [];668this.files = [];669if (typeof this.element === "string") {670this.element = document.querySelector(this.element);671}672if (!(this.element && (this.element.nodeType != null))) {673throw new Error("Invalid dropzone element.");674}675if (this.element.dropzone) {676throw new Error("Dropzone already attached.");677}678Dropzone.instances.push(this);679this.element.dropzone = this;680elementOptions = (_ref = Dropzone.optionsForElement(this.element)) != null ? _ref : {};681this.options = extend({}, this.defaultOptions, elementOptions, options != null ? options : {});682if (this.options.forceFallback || !Dropzone.isBrowserSupported()) {683return this.options.fallback.call(this);684}685if (this.options.url == null) {686this.options.url = this.element.getAttribute("action");687}688if (!this.options.url) {689throw new Error("No URL provided.");690}691if (this.options.acceptedFiles && this.options.acceptedMimeTypes) {692throw new Error("You can't provide both 'acceptedFiles' and 'acceptedMimeTypes'. 'acceptedMimeTypes' is deprecated.");693}694if (this.options.acceptedMimeTypes) {695this.options.acceptedFiles = this.options.acceptedMimeTypes;696delete this.options.acceptedMimeTypes;697}698this.options.method = this.options.method.toUpperCase();699if ((fallback = this.getExistingFallback()) && fallback.parentNode) {700fallback.parentNode.removeChild(fallback);701}702if (this.options.previewsContainer) {703this.previewsContainer = Dropzone.getElement(this.options.previewsContainer, "previewsContainer");704} else {705this.previewsContainer = this.element;706}707if (this.options.clickable) {708if (this.options.clickable === true) {709this.clickableElements = [this.element];710} else {711this.clickableElements = Dropzone.getElements(this.options.clickable, "clickable");712}713}714this.init();715}716717Dropzone.prototype.getAcceptedFiles = function() {718var file, _i, _len, _ref, _results;719_ref = this.files;720_results = [];721for (_i = 0, _len = _ref.length; _i < _len; _i++) {722file = _ref[_i];723if (file.accepted) {724_results.push(file);725}726}727return _results;728};729730Dropzone.prototype.getRejectedFiles = function() {731var file, _i, _len, _ref, _results;732_ref = this.files;733_results = [];734for (_i = 0, _len = _ref.length; _i < _len; _i++) {735file = _ref[_i];736if (!file.accepted) {737_results.push(file);738}739}740return _results;741};742743Dropzone.prototype.getQueuedFiles = function() {744var file, _i, _len, _ref, _results;745_ref = this.files;746_results = [];747for (_i = 0, _len = _ref.length; _i < _len; _i++) {748file = _ref[_i];749if (file.status === Dropzone.QUEUED) {750_results.push(file);751}752}753return _results;754};755756Dropzone.prototype.getUploadingFiles = function() {757var file, _i, _len, _ref, _results;758_ref = this.files;759_results = [];760for (_i = 0, _len = _ref.length; _i < _len; _i++) {761file = _ref[_i];762if (file.status === Dropzone.UPLOADING) {763_results.push(file);764}765}766return _results;767};768769Dropzone.prototype.init = function() {770var eventName, noPropagation, setupHiddenFileInput, _i, _len, _ref, _ref1,771_this = this;772if (this.element.tagName === "form") {773this.element.setAttribute("enctype", "multipart/form-data");774}775if (this.element.classList.contains("dropzone") && !this.element.querySelector(".dz-message")) {776this.element.appendChild(Dropzone.createElement("<div class=\"dz-default dz-message\"><span>" + this.options.dictDefaultMessage + "</span></div>"));777}778if (this.clickableElements.length) {779setupHiddenFileInput = function() {780if (_this.hiddenFileInput) {781document.body.removeChild(_this.hiddenFileInput);782}783_this.hiddenFileInput = document.createElement("input");784_this.hiddenFileInput.setAttribute("type", "file");785if ((_this.options.maxFiles == null) || _this.options.maxFiles > 1) {786_this.hiddenFileInput.setAttribute("multiple", "multiple");787}788if (_this.options.acceptedFiles != null) {789_this.hiddenFileInput.setAttribute("accept", _this.options.acceptedFiles);790}791_this.hiddenFileInput.style.visibility = "hidden";792_this.hiddenFileInput.style.position = "absolute";793_this.hiddenFileInput.style.top = "0";794_this.hiddenFileInput.style.left = "0";795_this.hiddenFileInput.style.height = "0";796_this.hiddenFileInput.style.width = "0";797document.body.appendChild(_this.hiddenFileInput);798return _this.hiddenFileInput.addEventListener("change", function() {799var files;800files = _this.hiddenFileInput.files;801if (files.length) {802_this.emit("selectedfiles", files);803_this.handleFiles(files);804}805return setupHiddenFileInput();806});807};808setupHiddenFileInput();809}810this.URL = (_ref = window.URL) != null ? _ref : window.webkitURL;811_ref1 = this.events;812for (_i = 0, _len = _ref1.length; _i < _len; _i++) {813eventName = _ref1[_i];814this.on(eventName, this.options[eventName]);815}816this.on("uploadprogress", function() {817return _this.updateTotalUploadProgress();818});819this.on("removedfile", function() {820return _this.updateTotalUploadProgress();821});822this.on("canceled", function(file) {823return _this.emit("complete", file);824});825noPropagation = function(e) {826e.stopPropagation();827if (e.preventDefault) {828return e.preventDefault();829} else {830return e.returnValue = false;831}832};833this.listeners = [834{835element: this.element,836events: {837"dragstart": function(e) {838return _this.emit("dragstart", e);839},840"dragenter": function(e) {841noPropagation(e);842return _this.emit("dragenter", e);843},844"dragover": function(e) {845var efct;846efct = e.dataTransfer.effectAllowed;847e.dataTransfer.dropEffect = 'move' === efct || 'linkMove' === efct ? 'move' : 'copy';848noPropagation(e);849return _this.emit("dragover", e);850},851"dragleave": function(e) {852return _this.emit("dragleave", e);853},854"drop": function(e) {855noPropagation(e);856return _this.drop(e);857},858"dragend": function(e) {859return _this.emit("dragend", e);860}861}862}863];864this.clickableElements.forEach(function(clickableElement) {865return _this.listeners.push({866element: clickableElement,867events: {868"click": function(evt) {869if ((clickableElement !== _this.element) || (evt.target === _this.element || Dropzone.elementInside(evt.target, _this.element.querySelector(".dz-message")))) {870return _this.hiddenFileInput.click();871}872}873}874});875});876this.enable();877return this.options.init.call(this);878};879880Dropzone.prototype.destroy = function() {881var _ref;882this.disable();883this.removeAllFiles(true);884if ((_ref = this.hiddenFileInput) != null ? _ref.parentNode : void 0) {885this.hiddenFileInput.parentNode.removeChild(this.hiddenFileInput);886this.hiddenFileInput = null;887}888delete this.element.dropzone;889return Dropzone.instances.splice(Dropzone.instances.indexOf(this), 1);890};891892Dropzone.prototype.updateTotalUploadProgress = function() {893var acceptedFiles, file, totalBytes, totalBytesSent, totalUploadProgress, _i, _len, _ref;894totalBytesSent = 0;895totalBytes = 0;896acceptedFiles = this.getAcceptedFiles();897if (acceptedFiles.length) {898_ref = this.getAcceptedFiles();899for (_i = 0, _len = _ref.length; _i < _len; _i++) {900file = _ref[_i];901totalBytesSent += file.upload.bytesSent;902totalBytes += file.upload.total;903}904totalUploadProgress = 100 * totalBytesSent / totalBytes;905} else {906totalUploadProgress = 100;907}908return this.emit("totaluploadprogress", totalUploadProgress, totalBytes, totalBytesSent);909};910911Dropzone.prototype.getFallbackForm = function() {912var existingFallback, fields, fieldsString, form;913if (existingFallback = this.getExistingFallback()) {914return existingFallback;915}916fieldsString = "<div class=\"dz-fallback\">";917if (this.options.dictFallbackText) {918fieldsString += "<p>" + this.options.dictFallbackText + "</p>";919}920fieldsString += "<input type=\"file\" name=\"" + this.options.paramName + (this.options.uploadMultiple ? "[]" : "") + "\" " + (this.options.uploadMultiple ? 'multiple="multiple"' : void 0) + " /><input type=\"submit\" value=\"Upload!\"></div>";921fields = Dropzone.createElement(fieldsString);922if (this.element.tagName !== "FORM") {923form = Dropzone.createElement("<form action=\"" + this.options.url + "\" enctype=\"multipart/form-data\" method=\"" + this.options.method + "\"></form>");924form.appendChild(fields);925} else {926this.element.setAttribute("enctype", "multipart/form-data");927this.element.setAttribute("method", this.options.method);928}929return form != null ? form : fields;930};931932Dropzone.prototype.getExistingFallback = function() {933var fallback, getFallback, tagName, _i, _len, _ref;934getFallback = function(elements) {935var el, _i, _len;936for (_i = 0, _len = elements.length; _i < _len; _i++) {937el = elements[_i];938if (/(^| )fallback($| )/.test(el.className)) {939return el;940}941}942};943_ref = ["div", "form"];944for (_i = 0, _len = _ref.length; _i < _len; _i++) {945tagName = _ref[_i];946if (fallback = getFallback(this.element.getElementsByTagName(tagName))) {947return fallback;948}949}950};951952Dropzone.prototype.setupEventListeners = function() {953var elementListeners, event, listener, _i, _len, _ref, _results;954_ref = this.listeners;955_results = [];956for (_i = 0, _len = _ref.length; _i < _len; _i++) {957elementListeners = _ref[_i];958_results.push((function() {959var _ref1, _results1;960_ref1 = elementListeners.events;961_results1 = [];962for (event in _ref1) {963listener = _ref1[event];964_results1.push(elementListeners.element.addEventListener(event, listener, false));965}966return _results1;967})());968}969return _results;970};971972Dropzone.prototype.removeEventListeners = function() {973var elementListeners, event, listener, _i, _len, _ref, _results;974_ref = this.listeners;975_results = [];976for (_i = 0, _len = _ref.length; _i < _len; _i++) {977elementListeners = _ref[_i];978_results.push((function() {979var _ref1, _results1;980_ref1 = elementListeners.events;981_results1 = [];982for (event in _ref1) {983listener = _ref1[event];984_results1.push(elementListeners.element.removeEventListener(event, listener, false));985}986return _results1;987})());988}989return _results;990};991992Dropzone.prototype.disable = function() {993var file, _i, _len, _ref, _results;994this.clickableElements.forEach(function(element) {995return element.classList.remove("dz-clickable");996});997this.removeEventListeners();998_ref = this.files;999_results = [];1000for (_i = 0, _len = _ref.length; _i < _len; _i++) {1001file = _ref[_i];1002_results.push(this.cancelUpload(file));1003}1004return _results;1005};10061007Dropzone.prototype.enable = function() {1008this.clickableElements.forEach(function(element) {1009return element.classList.add("dz-clickable");1010});1011return this.setupEventListeners();1012};10131014Dropzone.prototype.filesize = function(size) {1015var string;1016if (size >= 1024 * 1024 * 1024 * 1024 / 10) {1017size = size / (1024 * 1024 * 1024 * 1024 / 10);1018string = "TiB";1019} else if (size >= 1024 * 1024 * 1024 / 10) {1020size = size / (1024 * 1024 * 1024 / 10);1021string = "GiB";1022} else if (size >= 1024 * 1024 / 10) {1023size = size / (1024 * 1024 / 10);1024string = "MiB";1025} else if (size >= 1024 / 10) {1026size = size / (1024 / 10);1027string = "KiB";1028} else {1029size = size * 10;1030string = "b";1031}1032return "<strong>" + (Math.round(size) / 10) + "</strong> " + string;1033};10341035Dropzone.prototype._updateMaxFilesReachedClass = function() {1036if ((this.options.maxFiles != null) && this.getAcceptedFiles().length >= this.options.maxFiles) {1037if (this.getAcceptedFiles().length === this.options.maxFiles) {1038this.emit('maxfilesreached', this.files);1039}1040return this.element.classList.add("dz-max-files-reached");1041} else {1042return this.element.classList.remove("dz-max-files-reached");1043}1044};10451046Dropzone.prototype.drop = function(e) {1047var files, items;1048if (!e.dataTransfer) {1049return;1050}1051this.emit("drop", e);1052files = e.dataTransfer.files;1053this.emit("selectedfiles", files);1054if (files.length) {1055items = e.dataTransfer.items;1056if (items && items.length && ((items[0].webkitGetAsEntry != null) || (items[0].getAsEntry != null))) {1057this.handleItems(items);1058} else {1059this.handleFiles(files);1060}1061}1062};10631064Dropzone.prototype.handleFiles = function(files) {1065var file, _i, _len, _results;1066_results = [];1067for (_i = 0, _len = files.length; _i < _len; _i++) {1068file = files[_i];1069_results.push(this.addFile(file));1070}1071return _results;1072};10731074Dropzone.prototype.handleItems = function(items) {1075var entry, item, _i, _len;1076for (_i = 0, _len = items.length; _i < _len; _i++) {1077item = items[_i];1078if (item.webkitGetAsEntry != null) {1079entry = item.webkitGetAsEntry();1080if (entry.isFile) {1081this.addFile(item.getAsFile());1082} else if (entry.isDirectory) {1083this.addDirectory(entry, entry.name);1084}1085} else {1086this.addFile(item.getAsFile());1087}1088}1089};10901091Dropzone.prototype.accept = function(file, done) {1092if (file.size > this.options.maxFilesize * 1024 * 1024) {1093return done(this.options.dictFileTooBig.replace("{{filesize}}", Math.round(file.size / 1024 / 10.24) / 100).replace("{{maxFilesize}}", this.options.maxFilesize));1094} else if (!Dropzone.isValidFile(file, this.options.acceptedFiles)) {1095return done(this.options.dictInvalidFileType);1096} else if ((this.options.maxFiles != null) && this.getAcceptedFiles().length >= this.options.maxFiles) {1097done(this.options.dictMaxFilesExceeded.replace("{{maxFiles}}", this.options.maxFiles));1098return this.emit("maxfilesexceeded", file);1099} else {1100return this.options.accept.call(this, file, done);1101}1102};11031104Dropzone.prototype.addFile = function(file) {1105var _this = this;1106file.upload = {1107progress: 0,1108total: file.size,1109bytesSent: 01110};1111this.files.push(file);1112file.status = Dropzone.ADDED;1113this.emit("addedfile", file);1114if (this.options.createImageThumbnails && file.type.match(/image.*/) && file.size <= this.options.maxThumbnailFilesize * 1024 * 1024) {1115this.createThumbnail(file);1116}1117return this.accept(file, function(error) {1118if (error) {1119file.accepted = false;1120_this._errorProcessing([file], error);1121} else {1122_this.enqueueFile(file);1123}1124return _this._updateMaxFilesReachedClass();1125});1126};11271128Dropzone.prototype.enqueueFiles = function(files) {1129var file, _i, _len;1130for (_i = 0, _len = files.length; _i < _len; _i++) {1131file = files[_i];1132this.enqueueFile(file);1133}1134return null;1135};11361137Dropzone.prototype.enqueueFile = function(file) {1138var _this = this;1139file.accepted = true;1140if (file.status === Dropzone.ADDED) {1141file.status = Dropzone.QUEUED;1142if (this.options.autoProcessQueue) {1143return setTimeout((function() {1144return _this.processQueue();1145}), 1);1146}1147} else {1148throw new Error("This file can't be queued because it has already been processed or was rejected.");1149}1150};11511152Dropzone.prototype.addDirectory = function(entry, path) {1153var dirReader, entriesReader,1154_this = this;1155dirReader = entry.createReader();1156entriesReader = function(entries) {1157var _i, _len;1158for (_i = 0, _len = entries.length; _i < _len; _i++) {1159entry = entries[_i];1160if (entry.isFile) {1161entry.file(function(file) {1162if (_this.options.ignoreHiddenFiles && file.name.substring(0, 1) === '.') {1163return;1164}1165file.fullPath = "" + path + "/" + file.name;1166return _this.addFile(file);1167});1168} else if (entry.isDirectory) {1169_this.addDirectory(entry, "" + path + "/" + entry.name);1170}1171}1172};1173return dirReader.readEntries(entriesReader, function(error) {1174return typeof console !== "undefined" && console !== null ? typeof console.log === "function" ? console.log(error) : void 0 : void 0;1175});1176};11771178Dropzone.prototype.removeFile = function(file) {1179if (file.status === Dropzone.UPLOADING) {1180this.cancelUpload(file);1181}1182this.files = without(this.files, file);1183this.emit("removedfile", file);1184if (this.files.length === 0) {1185return this.emit("reset");1186}1187};11881189Dropzone.prototype.removeAllFiles = function(cancelIfNecessary) {1190var file, _i, _len, _ref;1191if (cancelIfNecessary == null) {1192cancelIfNecessary = false;1193}1194_ref = this.files.slice();1195for (_i = 0, _len = _ref.length; _i < _len; _i++) {1196file = _ref[_i];1197if (file.status !== Dropzone.UPLOADING || cancelIfNecessary) {1198this.removeFile(file);1199}1200}1201return null;1202};12031204Dropzone.prototype.createThumbnail = function(file) {1205var fileReader,1206_this = this;1207fileReader = new FileReader;1208fileReader.onload = function() {1209var img;1210img = document.createElement("img");1211img.onload = function() {1212var canvas, ctx, resizeInfo, thumbnail, _ref, _ref1, _ref2, _ref3;1213file.width = img.width;1214file.height = img.height;1215resizeInfo = _this.options.resize.call(_this, file);1216if (resizeInfo.trgWidth == null) {1217resizeInfo.trgWidth = _this.options.thumbnailWidth;1218}1219if (resizeInfo.trgHeight == null) {1220resizeInfo.trgHeight = _this.options.thumbnailHeight;1221}1222canvas = document.createElement("canvas");1223ctx = canvas.getContext("2d");1224canvas.width = resizeInfo.trgWidth;1225canvas.height = resizeInfo.trgHeight;1226ctx.drawImage(img, (_ref = resizeInfo.srcX) != null ? _ref : 0, (_ref1 = resizeInfo.srcY) != null ? _ref1 : 0, resizeInfo.srcWidth, resizeInfo.srcHeight, (_ref2 = resizeInfo.trgX) != null ? _ref2 : 0, (_ref3 = resizeInfo.trgY) != null ? _ref3 : 0, resizeInfo.trgWidth, resizeInfo.trgHeight);1227thumbnail = canvas.toDataURL("image/png");1228return _this.emit("thumbnail", file, thumbnail);1229};1230return img.src = fileReader.result;1231};1232return fileReader.readAsDataURL(file);1233};12341235Dropzone.prototype.processQueue = function() {1236var i, parallelUploads, processingLength, queuedFiles;1237parallelUploads = this.options.parallelUploads;1238processingLength = this.getUploadingFiles().length;1239i = processingLength;1240if (processingLength >= parallelUploads) {1241return;1242}1243queuedFiles = this.getQueuedFiles();1244if (!(queuedFiles.length > 0)) {1245return;1246}1247if (this.options.uploadMultiple) {1248return this.processFiles(queuedFiles.slice(0, parallelUploads - processingLength));1249} else {1250while (i < parallelUploads) {1251if (!queuedFiles.length) {1252return;1253}1254this.processFile(queuedFiles.shift());1255i++;1256}1257}1258};12591260Dropzone.prototype.processFile = function(file) {1261return this.processFiles([file]);1262};12631264Dropzone.prototype.processFiles = function(files) {1265var file, _i, _len;1266for (_i = 0, _len = files.length; _i < _len; _i++) {1267file = files[_i];1268file.processing = true;1269file.status = Dropzone.UPLOADING;1270this.emit("processing", file);1271}1272if (this.options.uploadMultiple) {1273this.emit("processingmultiple", files);1274}1275return this.uploadFiles(files);1276};12771278Dropzone.prototype._getFilesWithXhr = function(xhr) {1279var file, files;1280return files = (function() {1281var _i, _len, _ref, _results;1282_ref = this.files;1283_results = [];1284for (_i = 0, _len = _ref.length; _i < _len; _i++) {1285file = _ref[_i];1286if (file.xhr === xhr) {1287_results.push(file);1288}1289}1290return _results;1291}).call(this);1292};12931294Dropzone.prototype.cancelUpload = function(file) {1295var groupedFile, groupedFiles, _i, _j, _len, _len1, _ref;1296if (file.status === Dropzone.UPLOADING) {1297groupedFiles = this._getFilesWithXhr(file.xhr);1298for (_i = 0, _len = groupedFiles.length; _i < _len; _i++) {1299groupedFile = groupedFiles[_i];1300groupedFile.status = Dropzone.CANCELED;1301}1302file.xhr.abort();1303for (_j = 0, _len1 = groupedFiles.length; _j < _len1; _j++) {1304groupedFile = groupedFiles[_j];1305this.emit("canceled", groupedFile);1306}1307if (this.options.uploadMultiple) {1308this.emit("canceledmultiple", groupedFiles);1309}1310} else if ((_ref = file.status) === Dropzone.ADDED || _ref === Dropzone.QUEUED) {1311file.status = Dropzone.CANCELED;1312this.emit("canceled", file);1313if (this.options.uploadMultiple) {1314this.emit("canceledmultiple", [file]);1315}1316}1317if (this.options.autoProcessQueue) {1318return this.processQueue();1319}1320};13211322Dropzone.prototype.uploadFile = function(file) {1323return this.uploadFiles([file]);1324};13251326Dropzone.prototype.uploadFiles = function(files) {1327var file, formData, handleError, headerName, headerValue, headers, input, inputName, inputType, key, option, progressObj, response, updateProgress, value, xhr, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _ref, _ref1, _ref2, _ref3, _ref4,1328_this = this;1329xhr = new XMLHttpRequest();1330for (_i = 0, _len = files.length; _i < _len; _i++) {1331file = files[_i];1332file.xhr = xhr;1333}1334xhr.open(this.options.method, this.options.url, true);1335xhr.withCredentials = !!this.options.withCredentials;1336response = null;1337handleError = function() {1338var _j, _len1, _results;1339_results = [];1340for (_j = 0, _len1 = files.length; _j < _len1; _j++) {1341file = files[_j];1342_results.push(_this._errorProcessing(files, response || _this.options.dictResponseError.replace("{{statusCode}}", xhr.status), xhr));1343}1344return _results;1345};1346updateProgress = function(e) {1347var allFilesFinished, progress, _j, _k, _l, _len1, _len2, _len3, _results;1348if (e != null) {1349progress = 100 * e.loaded / e.total;1350for (_j = 0, _len1 = files.length; _j < _len1; _j++) {1351file = files[_j];1352file.upload = {1353progress: progress,1354total: e.total,1355bytesSent: e.loaded1356};1357}1358} else {1359allFilesFinished = true;1360progress = 100;1361for (_k = 0, _len2 = files.length; _k < _len2; _k++) {1362file = files[_k];1363if (!(file.upload.progress === 100 && file.upload.bytesSent === file.upload.total)) {1364allFilesFinished = false;1365}1366file.upload.progress = progress;1367file.upload.bytesSent = file.upload.total;1368}1369if (allFilesFinished) {1370return;1371}1372}1373_results = [];1374for (_l = 0, _len3 = files.length; _l < _len3; _l++) {1375file = files[_l];1376_results.push(_this.emit("uploadprogress", file, progress, file.upload.bytesSent));1377}1378return _results;1379};1380xhr.onload = function(e) {1381var _ref;1382if (files[0].status === Dropzone.CANCELED) {1383return;1384}1385if (xhr.readyState !== 4) {1386return;1387}1388response = xhr.responseText;1389if (xhr.getResponseHeader("content-type") && ~xhr.getResponseHeader("content-type").indexOf("application/json")) {1390try {1391response = JSON.parse(response);1392} catch (_error) {1393e = _error;1394response = "Invalid JSON response from server.";1395}1396}1397updateProgress();1398console.log(xhr.status);1399if (!((200 <= (_ref = xhr.status) && _ref < 300))) {1400return handleError();1401} else {1402return _this._finished(files, response, e);1403}1404};1405xhr.onerror = function() {1406if (files[0].status === Dropzone.CANCELED) {1407return;1408}1409return handleError();1410};1411progressObj = (_ref = xhr.upload) != null ? _ref : xhr;1412progressObj.onprogress = updateProgress;1413headers = {1414"Accept": "application/json",1415"Cache-Control": "no-cache",1416"X-Requested-With": "XMLHttpRequest"1417};1418if (this.options.headers) {1419extend(headers, this.options.headers);1420}1421for (headerName in headers) {1422headerValue = headers[headerName];1423xhr.setRequestHeader(headerName, headerValue);1424}1425formData = new FormData();1426if (this.options.params) {1427_ref1 = this.options.params;1428for (key in _ref1) {1429value = _ref1[key];1430formData.append(key, value);1431}1432}1433for (_j = 0, _len1 = files.length; _j < _len1; _j++) {1434file = files[_j];1435this.emit("sending", file, xhr, formData);1436}1437if (this.options.uploadMultiple) {1438this.emit("sendingmultiple", files, xhr, formData);1439}1440if (this.element.tagName === "FORM") {1441_ref2 = this.element.querySelectorAll("input, textarea, select, button");1442for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {1443input = _ref2[_k];1444inputName = input.getAttribute("name");1445inputType = input.getAttribute("type");1446if (input.tagName === "SELECT" && input.hasAttribute("multiple")) {1447_ref3 = input.options;1448for (_l = 0, _len3 = _ref3.length; _l < _len3; _l++) {1449option = _ref3[_l];1450if (option.selected) {1451formData.append(inputName, option.value);1452}1453}1454} else if (!inputType || ((_ref4 = inputType.toLowerCase()) !== "checkbox" && _ref4 !== "radio") || input.checked) {1455formData.append(inputName, input.value);1456}1457}1458}1459for (_m = 0, _len4 = files.length; _m < _len4; _m++) {1460file = files[_m];1461formData.append("" + this.options.paramName + (this.options.uploadMultiple ? "[]" : ""), file, file.name);1462}1463return xhr.send(formData);1464};14651466Dropzone.prototype._finished = function(files, responseText, e) {1467var file, _i, _len;1468for (_i = 0, _len = files.length; _i < _len; _i++) {1469file = files[_i];1470file.status = Dropzone.SUCCESS;1471this.emit("success", file, responseText, e);1472this.emit("complete", file);1473}1474if (this.options.uploadMultiple) {1475this.emit("successmultiple", files, responseText, e);1476this.emit("completemultiple", files);1477}1478if (this.options.autoProcessQueue) {1479return this.processQueue();1480}1481};14821483Dropzone.prototype._errorProcessing = function(files, message, xhr) {1484var file, _i, _len;1485for (_i = 0, _len = files.length; _i < _len; _i++) {1486file = files[_i];1487file.status = Dropzone.ERROR;1488this.emit("error", file, message, xhr);1489this.emit("complete", file);1490}1491if (this.options.uploadMultiple) {1492this.emit("errormultiple", files, message, xhr);1493this.emit("completemultiple", files);1494}1495if (this.options.autoProcessQueue) {1496return this.processQueue();1497}1498};14991500return Dropzone;15011502})(Em);15031504Dropzone.version = "3.7.5-dev";15051506Dropzone.options = {};15071508Dropzone.optionsForElement = function(element) {1509if (element.getAttribute("id")) {1510return Dropzone.options[camelize(element.getAttribute("id"))];1511} else {1512return void 0;1513}1514};15151516Dropzone.instances = [];15171518Dropzone.forElement = function(element) {1519if (typeof element === "string") {1520element = document.querySelector(element);1521}1522if ((element != null ? element.dropzone : void 0) == null) {1523throw 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.");1524}1525return element.dropzone;1526};15271528Dropzone.autoDiscover = true;15291530Dropzone.discover = function() {1531var checkElements, dropzone, dropzones, _i, _len, _results;1532if (document.querySelectorAll) {1533dropzones = document.querySelectorAll(".dropzone");1534} else {1535dropzones = [];1536checkElements = function(elements) {1537var el, _i, _len, _results;1538_results = [];1539for (_i = 0, _len = elements.length; _i < _len; _i++) {1540el = elements[_i];1541if (/(^| )dropzone($| )/.test(el.className)) {1542_results.push(dropzones.push(el));1543} else {1544_results.push(void 0);1545}1546}1547return _results;1548};1549checkElements(document.getElementsByTagName("div"));1550checkElements(document.getElementsByTagName("form"));1551}1552_results = [];1553for (_i = 0, _len = dropzones.length; _i < _len; _i++) {1554dropzone = dropzones[_i];1555if (Dropzone.optionsForElement(dropzone) !== false) {1556_results.push(new Dropzone(dropzone));1557} else {1558_results.push(void 0);1559}1560}1561return _results;1562};15631564Dropzone.blacklistedBrowsers = [/opera.*Macintosh.*version\/12/i];15651566Dropzone.isBrowserSupported = function() {1567var capableBrowser, regex, _i, _len, _ref;1568capableBrowser = true;1569if (window.File && window.FileReader && window.FileList && window.Blob && window.FormData && document.querySelector) {1570if (!("classList" in document.createElement("a"))) {1571capableBrowser = false;1572} else {1573_ref = Dropzone.blacklistedBrowsers;1574for (_i = 0, _len = _ref.length; _i < _len; _i++) {1575regex = _ref[_i];1576if (regex.test(navigator.userAgent)) {1577capableBrowser = false;1578continue;1579}1580}1581}1582} else {1583capableBrowser = false;1584}1585return capableBrowser;1586};15871588without = function(list, rejectedItem) {1589var item, _i, _len, _results;1590_results = [];1591for (_i = 0, _len = list.length; _i < _len; _i++) {1592item = list[_i];1593if (item !== rejectedItem) {1594_results.push(item);1595}1596}1597return _results;1598};15991600camelize = function(str) {1601return str.replace(/[\-_](\w)/g, function(match) {1602return match[1].toUpperCase();1603});1604};16051606Dropzone.createElement = function(string) {1607var div;1608div = document.createElement("div");1609div.innerHTML = string;1610return div.childNodes[0];1611};16121613Dropzone.elementInside = function(element, container) {1614if (element === container) {1615return true;1616}1617while (element = element.parentNode) {1618if (element === container) {1619return true;1620}1621}1622return false;1623};16241625Dropzone.getElement = function(el, name) {1626var element;1627if (typeof el === "string") {1628element = document.querySelector(el);1629} else if (el.nodeType != null) {1630element = el;1631}1632if (element == null) {1633throw new Error("Invalid `" + name + "` option provided. Please provide a CSS selector or a plain HTML element.");1634}1635return element;1636};16371638Dropzone.getElements = function(els, name) {1639var e, el, elements, _i, _j, _len, _len1, _ref;1640if (els instanceof Array) {1641elements = [];1642try {1643for (_i = 0, _len = els.length; _i < _len; _i++) {1644el = els[_i];1645elements.push(this.getElement(el, name));1646}1647} catch (_error) {1648e = _error;1649elements = null;1650}1651} else if (typeof els === "string") {1652elements = [];1653_ref = document.querySelectorAll(els);1654for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {1655el = _ref[_j];1656elements.push(el);1657}1658} else if (els.nodeType != null) {1659elements = [els];1660}1661if (!((elements != null) && elements.length)) {1662throw new Error("Invalid `" + name + "` option provided. Please provide a CSS selector, a plain HTML element or a list of those.");1663}1664return elements;1665};16661667Dropzone.confirm = function(question, accepted, rejected) {1668if (window.confirm(question)) {1669return accepted();1670} else if (rejected != null) {1671return rejected();1672}1673};16741675Dropzone.isValidFile = function(file, acceptedFiles) {1676var baseMimeType, mimeType, validType, _i, _len;1677if (!acceptedFiles) {1678return true;1679}1680acceptedFiles = acceptedFiles.split(",");1681mimeType = file.type;1682baseMimeType = mimeType.replace(/\/.*$/, "");1683for (_i = 0, _len = acceptedFiles.length; _i < _len; _i++) {1684validType = acceptedFiles[_i];1685validType = validType.trim();1686if (validType.charAt(0) === ".") {1687if (file.name.toLowerCase().indexOf(validType.toLowerCase(), file.name.length - validType.length) !== -1) {1688return true;1689}1690} else if (/\/\*$/.test(validType)) {1691if (baseMimeType === validType.replace(/\/.*$/, "")) {1692return true;1693}1694} else {1695if (mimeType === validType) {1696return true;1697}1698}1699}1700return false;1701};17021703if (typeof jQuery !== "undefined" && jQuery !== null) {1704jQuery.fn.dropzone = function(options) {1705return this.each(function() {1706return new Dropzone(this, options);1707});1708};1709}17101711if (typeof module !== "undefined" && module !== null) {1712module.exports = Dropzone;1713} else {1714window.Dropzone = Dropzone;1715}17161717Dropzone.ADDED = "added";17181719Dropzone.QUEUED = "queued";17201721Dropzone.ACCEPTED = Dropzone.QUEUED;17221723Dropzone.UPLOADING = "uploading";17241725Dropzone.PROCESSING = Dropzone.UPLOADING;17261727Dropzone.CANCELED = "canceled";17281729Dropzone.ERROR = "error";17301731Dropzone.SUCCESS = "success";17321733/*1734# contentloaded.js1735#1736# Author: Diego Perini (diego.perini at gmail.com)1737# Summary: cross-browser wrapper for DOMContentLoaded1738# Updated: 201010201739# License: MIT1740# Version: 1.21741#1742# URL:1743# http://javascript.nwbox.com/ContentLoaded/1744# http://javascript.nwbox.com/ContentLoaded/MIT-LICENSE1745*/174617471748contentLoaded = function(win, fn) {1749var add, doc, done, init, poll, pre, rem, root, top;1750done = false;1751top = true;1752doc = win.document;1753root = doc.documentElement;1754add = (doc.addEventListener ? "addEventListener" : "attachEvent");1755rem = (doc.addEventListener ? "removeEventListener" : "detachEvent");1756pre = (doc.addEventListener ? "" : "on");1757init = function(e) {1758if (e.type === "readystatechange" && doc.readyState !== "complete") {1759return;1760}1761(e.type === "load" ? win : doc)[rem](pre + e.type, init, false);1762if (!done && (done = true)) {1763return fn.call(win, e.type || e);1764}1765};1766poll = function() {1767var e;1768try {1769root.doScroll("left");1770} catch (_error) {1771e = _error;1772setTimeout(poll, 50);1773return;1774}1775return init("poll");1776};1777if (doc.readyState !== "complete") {1778if (doc.createEventObject && root.doScroll) {1779try {1780top = !win.frameElement;1781} catch (_error) {}1782if (top) {1783poll();1784}1785}1786doc[add](pre + "DOMContentLoaded", init, false);1787doc[add](pre + "readystatechange", init, false);1788return win[add](pre + "load", init, false);1789}1790};17911792Dropzone._autoDiscoverFunction = function() {1793if (Dropzone.autoDiscover) {1794return Dropzone.discover();1795}1796};17971798contentLoaded(window, Dropzone._autoDiscoverFunction);17991800}).call(this);18011802});1803require.alias("component-emitter/index.js", "dropzone/deps/emitter/index.js");1804require.alias("component-emitter/index.js", "emitter/index.js");1805if (typeof exports == "object") {1806module.exports = require("dropzone");1807} else if (typeof define == "function" && define.amd) {1808define(function(){ return require("dropzone"); });1809} else {1810this["Dropzone"] = require("dropzone");1811}})();18121813