Permalink
Browse files

Merge pull request #1140 from enyo/master

Dropzone 2.0.8
  • Loading branch information...
2 parents a386df8 + 9d7e792 commit 51029c29831be4ea69cc246cbb787ea078b1e9d5 @Lockyc Lockyc committed Apr 9, 2013
View
155 ajax/libs/dropzone/2.0.8/css/basic.css
@@ -0,0 +1,155 @@
+/* The MIT License */
+.dropzone,
+.dropzone *,
+.dropzone-previews,
+.dropzone-previews * {
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+.dropzone {
+ position: relative;
+ border: 1px solid rgba(0,0,0,0.08);
+ background: rgba(0,0,0,0.02);
+ padding: 1em;
+}
+.dropzone.clickable {
+ cursor: pointer;
+}
+.dropzone.clickable .message {
+ cursor: pointer;
+}
+.dropzone.clickable * {
+ cursor: default;
+}
+.dropzone .message {
+ opacity: 1;
+ -ms-filter: none;
+ filter: none;
+}
+.dropzone.drag-hover {
+ border-color: rgba(0,0,0,0.15);
+ background: rgba(0,0,0,0.04);
+}
+.dropzone.started .message {
+ display: none;
+}
+.dropzone .preview,
+.dropzone-previews .preview {
+ background: rgba(255,255,255,0.8);
+ position: relative;
+ display: inline-block;
+ margin: 17px;
+ vertical-align: top;
+ border: 1px solid #acacac;
+ padding: 6px 6px 6px 6px;
+}
+.dropzone .preview .details,
+.dropzone-previews .preview .details {
+ width: 100px;
+ height: 100px;
+ position: relative;
+ background: #ebebeb;
+ padding: 5px;
+ margin-bottom: 22px;
+}
+.dropzone .preview .details .filename,
+.dropzone-previews .preview .details .filename {
+ overflow: hidden;
+ height: 100%;
+}
+.dropzone .preview .details img,
+.dropzone-previews .preview .details img {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 100px;
+ height: 100px;
+}
+.dropzone .preview .details .size,
+.dropzone-previews .preview .details .size {
+ position: absolute;
+ bottom: -28px;
+ left: 3px;
+ height: 28px;
+ line-height: 28px;
+}
+.dropzone .preview.error .error-mark,
+.dropzone-previews .preview.error .error-mark {
+ display: block;
+}
+.dropzone .preview.success .success-mark,
+.dropzone-previews .preview.success .success-mark {
+ display: block;
+}
+.dropzone .preview:hover .details img,
+.dropzone-previews .preview:hover .details img {
+ display: none;
+}
+.dropzone .preview:hover .success-mark,
+.dropzone-previews .preview:hover .success-mark,
+.dropzone .preview:hover .error-mark,
+.dropzone-previews .preview:hover .error-mark {
+ display: none;
+}
+.dropzone .preview .success-mark,
+.dropzone-previews .preview .success-mark,
+.dropzone .preview .error-mark,
+.dropzone-previews .preview .error-mark {
+ display: none;
+ position: absolute;
+ width: 40px;
+ height: 40px;
+ font-size: 30px;
+ text-align: center;
+ right: -10px;
+ top: -10px;
+}
+.dropzone .preview .success-mark,
+.dropzone-previews .preview .success-mark {
+ color: #8cc657;
+}
+.dropzone .preview .error-mark,
+.dropzone-previews .preview .error-mark {
+ color: #ee162d;
+}
+.dropzone .preview .progress,
+.dropzone-previews .preview .progress {
+ position: absolute;
+ top: 100px;
+ left: 6px;
+ right: 6px;
+ height: 6px;
+ background: #d7d7d7;
+ display: none;
+}
+.dropzone .preview .progress .upload,
+.dropzone-previews .preview .progress .upload {
+ position: absolute;
+ top: 0;
+ bottom: 0;
+ left: 0;
+ width: 0%;
+ background-color: #8cc657;
+}
+.dropzone .preview.processing .progress,
+.dropzone-previews .preview.processing .progress {
+ display: block;
+}
+.dropzone .preview .error-message,
+.dropzone-previews .preview .error-message {
+ display: none;
+ position: absolute;
+ top: -5px;
+ left: -20px;
+ background: rgba(245,245,245,0.8);
+ padding: 8px 10px;
+ color: #800;
+ min-width: 140px;
+ max-width: 500px;
+ z-index: 500;
+}
+.dropzone .preview:hover.error .error-message,
+.dropzone-previews .preview:hover.error .error-message {
+ display: block;
+}
View
394 ajax/libs/dropzone/2.0.8/css/dropzone.css
@@ -0,0 +1,394 @@
+/* The MIT License */
+.dropzone,
+.dropzone *,
+.dropzone-previews,
+.dropzone-previews * {
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+.dropzone {
+ position: relative;
+ border: 1px solid rgba(0,0,0,0.08);
+ background: rgba(0,0,0,0.02);
+ padding: 1em;
+}
+.dropzone.clickable {
+ cursor: pointer;
+}
+.dropzone.clickable .message {
+ cursor: pointer;
+}
+.dropzone.clickable * {
+ cursor: default;
+}
+.dropzone .message {
+ opacity: 1;
+ -ms-filter: none;
+ filter: none;
+}
+.dropzone.drag-hover {
+ border-color: rgba(0,0,0,0.15);
+ background: rgba(0,0,0,0.04);
+}
+.dropzone.started .message {
+ display: none;
+}
+.dropzone .preview,
+.dropzone-previews .preview {
+ background: rgba(255,255,255,0.8);
+ position: relative;
+ display: inline-block;
+ margin: 17px;
+ vertical-align: top;
+ border: 1px solid #acacac;
+ padding: 6px 6px 6px 6px;
+}
+.dropzone .preview .details,
+.dropzone-previews .preview .details {
+ width: 100px;
+ height: 100px;
+ position: relative;
+ background: #ebebeb;
+ padding: 5px;
+ margin-bottom: 22px;
+}
+.dropzone .preview .details .filename,
+.dropzone-previews .preview .details .filename {
+ overflow: hidden;
+ height: 100%;
+}
+.dropzone .preview .details img,
+.dropzone-previews .preview .details img {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 100px;
+ height: 100px;
+}
+.dropzone .preview .details .size,
+.dropzone-previews .preview .details .size {
+ position: absolute;
+ bottom: -28px;
+ left: 3px;
+ height: 28px;
+ line-height: 28px;
+}
+.dropzone .preview.error .error-mark,
+.dropzone-previews .preview.error .error-mark {
+ display: block;
+}
+.dropzone .preview.success .success-mark,
+.dropzone-previews .preview.success .success-mark {
+ display: block;
+}
+.dropzone .preview:hover .details img,
+.dropzone-previews .preview:hover .details img {
+ display: none;
+}
+.dropzone .preview:hover .success-mark,
+.dropzone-previews .preview:hover .success-mark,
+.dropzone .preview:hover .error-mark,
+.dropzone-previews .preview:hover .error-mark {
+ display: none;
+}
+.dropzone .preview .success-mark,
+.dropzone-previews .preview .success-mark,
+.dropzone .preview .error-mark,
+.dropzone-previews .preview .error-mark {
+ display: none;
+ position: absolute;
+ width: 40px;
+ height: 40px;
+ font-size: 30px;
+ text-align: center;
+ right: -10px;
+ top: -10px;
+}
+.dropzone .preview .success-mark,
+.dropzone-previews .preview .success-mark {
+ color: #8cc657;
+}
+.dropzone .preview .error-mark,
+.dropzone-previews .preview .error-mark {
+ color: #ee162d;
+}
+.dropzone .preview .progress,
+.dropzone-previews .preview .progress {
+ position: absolute;
+ top: 100px;
+ left: 6px;
+ right: 6px;
+ height: 6px;
+ background: #d7d7d7;
+ display: none;
+}
+.dropzone .preview .progress .upload,
+.dropzone-previews .preview .progress .upload {
+ position: absolute;
+ top: 0;
+ bottom: 0;
+ left: 0;
+ width: 0%;
+ background-color: #8cc657;
+}
+.dropzone .preview.processing .progress,
+.dropzone-previews .preview.processing .progress {
+ display: block;
+}
+.dropzone .preview .error-message,
+.dropzone-previews .preview .error-message {
+ display: none;
+ position: absolute;
+ top: -5px;
+ left: -20px;
+ background: rgba(245,245,245,0.8);
+ padding: 8px 10px;
+ color: #800;
+ min-width: 140px;
+ max-width: 500px;
+ z-index: 500;
+}
+.dropzone .preview:hover.error .error-message,
+.dropzone-previews .preview:hover.error .error-message {
+ display: block;
+}
+.dropzone {
+ border: 1px solid rgba(0,0,0,0.03);
+ min-height: 360px;
+ -webkit-border-radius: 3px;
+ border-radius: 3px;
+ background: rgba(0,0,0,0.03);
+ padding: 23px;
+}
+.dropzone .default.message {
+ opacity: 1;
+ -ms-filter: none;
+ filter: none;
+ -webkit-transition: opacity 0.3s ease-in-out;
+ -moz-transition: opacity 0.3s ease-in-out;
+ -o-transition: opacity 0.3s ease-in-out;
+ -ms-transition: opacity 0.3s ease-in-out;
+ transition: opacity 0.3s ease-in-out;
+ background-image: url("../images/spritemap.png");
+ background-repeat: no-repeat;
+ background-position: 0 0;
+ position: absolute;
+ width: 428px;
+ height: 123px;
+ margin-left: -214px;
+ margin-top: -61.5px;
+ top: 50%;
+ left: 50%;
+}
+@media all and (-webkit-min-device-pixel-ratio: 1.5) {
+ .dropzone .default.message {
+ background-image: url("../images/spritemap@2x.png");
+ -webkit-background-size: 428px 406px;
+ -moz-background-size: 428px 406px;
+ background-size: 428px 406px;
+ }
+}
+.dropzone .default.message span {
+ display: none;
+}
+.dropzone.square .default.message {
+ background-position: 0 -123px;
+ width: 268px;
+ margin-left: -134px;
+ height: 174px;
+ margin-top: -87px;
+}
+.dropzone.drag-hover .message {
+ opacity: 0.15;
+ filter: alpha(opacity=15);
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=15)";
+}
+.dropzone.started .message {
+ display: block;
+ opacity: 0;
+ filter: alpha(opacity=0);
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
+}
+.dropzone .preview,
+.dropzone-previews .preview {
+ -webkit-box-shadow: 1px 1px 4px rgba(0,0,0,0.16);
+ box-shadow: 1px 1px 4px rgba(0,0,0,0.16);
+ font-size: 14px;
+}
+.dropzone .preview .details img,
+.dropzone-previews .preview .details img {
+ width: 100px;
+ height: 100px;
+}
+.dropzone .preview.image-preview:hover .details img,
+.dropzone-previews .preview.image-preview:hover .details img {
+ display: block;
+ opacity: 0.1;
+ filter: alpha(opacity=10);
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=10)";
+}
+.dropzone .preview.success .success-mark,
+.dropzone-previews .preview.success .success-mark {
+ opacity: 1;
+ -ms-filter: none;
+ filter: none;
+}
+.dropzone .preview.error .error-mark,
+.dropzone-previews .preview.error .error-mark {
+ opacity: 1;
+ -ms-filter: none;
+ filter: none;
+}
+.dropzone .preview.error .progress .upload,
+.dropzone-previews .preview.error .progress .upload {
+ background: #ee1e2d;
+}
+.dropzone .preview .error-mark,
+.dropzone-previews .preview .error-mark,
+.dropzone .preview .success-mark,
+.dropzone-previews .preview .success-mark {
+ display: block;
+ opacity: 0;
+ filter: alpha(opacity=0);
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
+ -webkit-transition: opacity 0.4s ease-in-out;
+ -moz-transition: opacity 0.4s ease-in-out;
+ -o-transition: opacity 0.4s ease-in-out;
+ -ms-transition: opacity 0.4s ease-in-out;
+ transition: opacity 0.4s ease-in-out;
+ background-image: url("../images/spritemap.png");
+ background-repeat: no-repeat;
+}
+@media all and (-webkit-min-device-pixel-ratio: 1.5) {
+ .dropzone .preview .error-mark,
+ .dropzone-previews .preview .error-mark,
+ .dropzone .preview .success-mark,
+ .dropzone-previews .preview .success-mark {
+ background-image: url("../images/spritemap@2x.png");
+ -webkit-background-size: 428px 406px;
+ -moz-background-size: 428px 406px;
+ background-size: 428px 406px;
+ }
+}
+.dropzone .preview .error-mark span,
+.dropzone-previews .preview .error-mark span,
+.dropzone .preview .success-mark span,
+.dropzone-previews .preview .success-mark span {
+ display: none;
+}
+.dropzone .preview .error-mark,
+.dropzone-previews .preview .error-mark {
+ background-position: -268px -123px;
+}
+.dropzone .preview .success-mark,
+.dropzone-previews .preview .success-mark {
+ background-position: -268px -163px;
+}
+.dropzone .preview .progress .upload,
+.dropzone-previews .preview .progress .upload {
+ -webkit-animation: loading 0.4s linear infinite;
+ -moz-animation: loading 0.4s linear infinite;
+ -o-animation: loading 0.4s linear infinite;
+ -ms-animation: loading 0.4s linear infinite;
+ animation: loading 0.4s linear infinite;
+ -webkit-transition: width 0.3s ease-in-out;
+ -moz-transition: width 0.3s ease-in-out;
+ -o-transition: width 0.3s ease-in-out;
+ -ms-transition: width 0.3s ease-in-out;
+ transition: width 0.3s ease-in-out;
+ -webkit-border-radius: 2px;
+ border-radius: 2px;
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 0%;
+ height: 100%;
+ background-image: url("../images/spritemap.png");
+ background-repeat: repeat-x;
+ background-position: 0px -400px;
+}
+@media all and (-webkit-min-device-pixel-ratio: 1.5) {
+ .dropzone .preview .progress .upload,
+ .dropzone-previews .preview .progress .upload {
+ background-image: url("../images/spritemap@2x.png");
+ -webkit-background-size: 428px 406px;
+ -moz-background-size: 428px 406px;
+ background-size: 428px 406px;
+ }
+}
+.dropzone .preview.success .progress,
+.dropzone-previews .preview.success .progress {
+ display: block;
+ opacity: 0;
+ filter: alpha(opacity=0);
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
+ -webkit-transition: opacity 0.4s ease-in-out;
+ -moz-transition: opacity 0.4s ease-in-out;
+ -o-transition: opacity 0.4s ease-in-out;
+ -ms-transition: opacity 0.4s ease-in-out;
+ transition: opacity 0.4s ease-in-out;
+}
+.dropzone .preview .error-message,
+.dropzone-previews .preview .error-message {
+ display: block;
+ opacity: 0;
+ filter: alpha(opacity=0);
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
+ -webkit-transition: opacity 0.3s ease-in-out;
+ -moz-transition: opacity 0.3s ease-in-out;
+ -o-transition: opacity 0.3s ease-in-out;
+ -ms-transition: opacity 0.3s ease-in-out;
+ transition: opacity 0.3s ease-in-out;
+}
+.dropzone .preview:hover.error .error-message,
+.dropzone-previews .preview:hover.error .error-message {
+ opacity: 1;
+ -ms-filter: none;
+ filter: none;
+}
+@-moz-keyframes loading {
+ 0% {
+ background-position: 0 -400px;
+ }
+
+ 100% {
+ background-position: -7px -400px;
+ }
+}
+@-webkit-keyframes loading {
+ 0% {
+ background-position: 0 -400px;
+ }
+
+ 100% {
+ background-position: -7px -400px;
+ }
+}
+@-o-keyframes loading {
+ 0% {
+ background-position: 0 -400px;
+ }
+
+ 100% {
+ background-position: -7px -400px;
+ }
+}
+@-ms-keyframes loading {
+ 0% {
+ background-position: 0 -400px;
+ }
+
+ 100% {
+ background-position: -7px -400px;
+ }
+}
+@keyframes loading {
+ 0% {
+ background-position: 0 -400px;
+ }
+
+ 100% {
+ background-position: -7px -400px;
+ }
+}
View
968 ajax/libs/dropzone/2.0.8/dropzone-amd-module.js
@@ -0,0 +1,968 @@
+// Uses AMD or browser globals to create a jQuery plugin.
+(function (factory) {
+ if (typeof define === 'function' && define.amd) {
+ // AMD. Register as an anonymous module.
+ define(['jquery'], factory);
+ } else {
+ // Browser globals
+ factory(jQuery);
+ }
+} (function (jQuery) {
+ var module = { exports: { } }; // Fake component
+
+
+/**
+ * Expose `Emitter`.
+ */
+
+module.exports = Emitter;
+
+/**
+ * Initialize a new `Emitter`.
+ *
+ * @api public
+ */
+
+function Emitter(obj) {
+ if (obj) return mixin(obj);
+};
+
+/**
+ * Mixin the emitter properties.
+ *
+ * @param {Object} obj
+ * @return {Object}
+ * @api private
+ */
+
+function mixin(obj) {
+ for (var key in Emitter.prototype) {
+ obj[key] = Emitter.prototype[key];
+ }
+ return obj;
+}
+
+/**
+ * Listen on the given `event` with `fn`.
+ *
+ * @param {String} event
+ * @param {Function} fn
+ * @return {Emitter}
+ * @api public
+ */
+
+Emitter.prototype.on = function(event, fn){
+ this._callbacks = this._callbacks || {};
+ (this._callbacks[event] = this._callbacks[event] || [])
+ .push(fn);
+ return this;
+};
+
+/**
+ * Adds an `event` listener that will be invoked a single
+ * time then automatically removed.
+ *
+ * @param {String} event
+ * @param {Function} fn
+ * @return {Emitter}
+ * @api public
+ */
+
+Emitter.prototype.once = function(event, fn){
+ var self = this;
+ this._callbacks = this._callbacks || {};
+
+ function on() {
+ self.off(event, on);
+ fn.apply(this, arguments);
+ }
+
+ fn._off = on;
+ this.on(event, on);
+ return this;
+};
+
+/**
+ * Remove the given callback for `event` or all
+ * registered callbacks.
+ *
+ * @param {String} event
+ * @param {Function} fn
+ * @return {Emitter}
+ * @api public
+ */
+
+Emitter.prototype.off =
+Emitter.prototype.removeListener =
+Emitter.prototype.removeAllListeners = function(event, fn){
+ this._callbacks = this._callbacks || {};
+ var callbacks = this._callbacks[event];
+ if (!callbacks) return this;
+
+ // remove all handlers
+ if (1 == arguments.length) {
+ delete this._callbacks[event];
+ return this;
+ }
+
+ // remove specific handler
+ var i = callbacks.indexOf(fn._off || fn);
+ if (~i) callbacks.splice(i, 1);
+ return this;
+};
+
+/**
+ * Emit `event` with the given args.
+ *
+ * @param {String} event
+ * @param {Mixed} ...
+ * @return {Emitter}
+ */
+
+Emitter.prototype.emit = function(event){
+ this._callbacks = this._callbacks || {};
+ var args = [].slice.call(arguments, 1)
+ , callbacks = this._callbacks[event];
+
+ if (callbacks) {
+ callbacks = callbacks.slice(0);
+ for (var i = 0, len = callbacks.length; i < len; ++i) {
+ callbacks[i].apply(this, args);
+ }
+ }
+
+ return this;
+};
+
+/**
+ * Return array of callbacks for `event`.
+ *
+ * @param {String} event
+ * @return {Array}
+ * @api public
+ */
+
+Emitter.prototype.listeners = function(event){
+ this._callbacks = this._callbacks || {};
+ return this._callbacks[event] || [];
+};
+
+/**
+ * Check if this emitter has `event` handlers.
+ *
+ * @param {String} event
+ * @return {Boolean}
+ * @api public
+ */
+
+Emitter.prototype.hasListeners = function(event){
+ return !! this.listeners(event).length;
+};
+
+/*
+#
+# More info at [www.dropzonejs.com](http://www.dropzonejs.com)
+#
+# Copyright (c) 2012, Matias Meno
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+*/
+
+
+(function() {
+ var Dropzone, Em, camelize, contentLoaded, createElement, noop, without,
+ __hasProp = {}.hasOwnProperty,
+ __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; },
+ __slice = [].slice,
+ __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
+
+ Em = typeof Emitter !== "undefined" && Emitter !== null ? Emitter : require("emitter");
+
+ noop = function() {};
+
+ Dropzone = (function(_super) {
+ __extends(Dropzone, _super);
+
+ /*
+ This is a list of all available events you can register on a dropzone object.
+
+ You can register an event handler like this:
+
+ dropzone.on("dragEnter", function() { });
+ */
+
+
+ Dropzone.prototype.events = ["drop", "dragstart", "dragend", "dragenter", "dragover", "dragleave", "selectedfiles", "addedfile", "removedfile", "thumbnail", "error", "processingfile", "uploadprogress", "sending", "success", "complete", "reset"];
+
+ Dropzone.prototype.defaultOptions = {
+ url: null,
+ method: "post",
+ parallelUploads: 2,
+ maxFilesize: 256,
+ paramName: "file",
+ createImageThumbnails: true,
+ maxThumbnailFilesize: 2,
+ thumbnailWidth: 100,
+ thumbnailHeight: 100,
+ params: {},
+ clickable: true,
+ enqueueForUpload: true,
+ previewsContainer: null,
+ dictDefaultMessage: "Drop files here to upload",
+ dictFallbackMessage: "Your browser does not support drag'n'drop file uploads.",
+ dictFallbackText: "Please use the fallback form below to upload your files like in the olden days.",
+ accept: function(file, done) {
+ return done();
+ },
+ init: function() {
+ return noop;
+ },
+ fallback: function() {
+ var child, messageElement, span, _i, _len, _ref;
+
+ this.element.className = "" + this.element.className + " browser-not-supported";
+ _ref = this.element.getElementsByTagName("div");
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ child = _ref[_i];
+ if (/(^| )message($| )/.test(child.className)) {
+ messageElement = child;
+ child.className = "message";
+ continue;
+ }
+ }
+ if (!messageElement) {
+ messageElement = createElement("<div class=\"message\"><span></span></div>");
+ this.element.appendChild(messageElement);
+ }
+ span = messageElement.getElementsByTagName("span")[0];
+ if (span) {
+ span.textContent = this.options.dictFallbackMessage;
+ }
+ return this.element.appendChild(this.getFallbackForm());
+ },
+ /*
+ Those functions register themselves to the events on init and handle all
+ the user interface specific stuff. Overwriting them won't break the upload
+ but can break the way it's displayed.
+ You can overwrite them if you don't like the default behavior. If you just
+ want to add an additional event handler, register it on the dropzone object
+ and don't overwrite those options.
+ */
+
+ drop: function(e) {
+ return this.element.classList.remove("drag-hover");
+ },
+ dragstart: noop,
+ dragend: function(e) {
+ return this.element.classList.remove("drag-hover");
+ },
+ dragenter: function(e) {
+ return this.element.classList.add("drag-hover");
+ },
+ dragover: function(e) {
+ return this.element.classList.add("drag-hover");
+ },
+ dragleave: function(e) {
+ return this.element.classList.remove("drag-hover");
+ },
+ selectedfiles: function(files) {
+ if (this.element === this.previewsContainer) {
+ return this.element.classList.add("started");
+ }
+ },
+ reset: function() {
+ return this.element.classList.remove("started");
+ },
+ addedfile: function(file) {
+ file.previewTemplate = createElement(this.options.previewTemplate);
+ this.previewsContainer.appendChild(file.previewTemplate);
+ file.previewTemplate.querySelector(".filename span").textContent = file.name;
+ return file.previewTemplate.querySelector(".details").appendChild(createElement("<div class=\"size\">" + (this.filesize(file.size)) + "</div>"));
+ },
+ removedfile: function(file) {
+ return file.previewTemplate.parentNode.removeChild(file.previewTemplate);
+ },
+ thumbnail: function(file, dataUrl) {
+ file.previewTemplate.classList.remove("file-preview");
+ file.previewTemplate.classList.add("image-preview");
+ return file.previewTemplate.querySelector(".details").appendChild(createElement("<img alt=\"" + file.name + "\" src=\"" + dataUrl + "\"/>"));
+ },
+ error: function(file, message) {
+ file.previewTemplate.classList.add("error");
+ return file.previewTemplate.querySelector(".error-message span").textContent = message;
+ },
+ processingfile: function(file) {
+ return file.previewTemplate.classList.add("processing");
+ },
+ uploadprogress: function(file, progress) {
+ return file.previewTemplate.querySelector(".progress .upload").style.width = "" + progress + "%";
+ },
+ sending: noop,
+ success: function(file) {
+ return file.previewTemplate.classList.add("success");
+ },
+ complete: noop,
+ previewTemplate: "<div class=\"preview file-preview\">\n <div class=\"details\">\n <div class=\"filename\"><span></span></div>\n </div>\n <div class=\"progress\"><span class=\"upload\"></span></div>\n <div class=\"success-mark\"><span>✔</span></div>\n <div class=\"error-mark\"><span>✘</span></div>\n <div class=\"error-message\"><span></span></div>\n</div>"
+ };
+
+ function Dropzone(element, options) {
+ var elementId, elementOptions, extend, fallback, _ref;
+
+ this.element = element;
+ this.version = Dropzone.version;
+ this.defaultOptions.previewTemplate = this.defaultOptions.previewTemplate.replace(/\n*/g, "");
+ if (typeof this.element === "string") {
+ this.element = document.querySelector(this.element);
+ }
+ if (!(this.element && (this.element.nodeType != null))) {
+ throw new Error("Invalid dropzone element.");
+ }
+ if (Dropzone.forElement(this.element)) {
+ throw new Error("Dropzone already attached.");
+ }
+ Dropzone.instances.push(this);
+ elementId = this.element.id;
+ elementOptions = (_ref = (elementId ? Dropzone.options[camelize(elementId)] : void 0)) != null ? _ref : {};
+ extend = function() {
+ var key, object, objects, target, val, _i, _len;
+
+ target = arguments[0], objects = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
+ for (_i = 0, _len = objects.length; _i < _len; _i++) {
+ object = objects[_i];
+ for (key in object) {
+ val = object[key];
+ target[key] = val;
+ }
+ }
+ return target;
+ };
+ this.options = extend({}, this.defaultOptions, elementOptions, options != null ? options : {});
+ if (this.options.url == null) {
+ this.options.url = this.element.action;
+ }
+ if (!this.options.url) {
+ throw new Error("No URL provided.");
+ }
+ this.options.method = this.options.method.toUpperCase();
+ if (!Dropzone.isBrowserSupported()) {
+ return this.options.fallback.call(this);
+ }
+ if ((fallback = this.getExistingFallback()) && fallback.parentNode) {
+ fallback.parentNode.removeChild(fallback);
+ }
+ if (this.options.previewsContainer) {
+ if (typeof this.options.previewsContainer === "string") {
+ this.previewsContainer = document.querySelector(this.options.previewsContainer);
+ } else if (this.options.previewsContainer.nodeType != null) {
+ this.previewsContainer = this.options.previewsContainer;
+ }
+ if (this.previewsContainer == null) {
+ throw new Error("Invalid `previewsContainer` option provided. Please provide a CSS selector or a plain HTML element.");
+ }
+ } else {
+ this.previewsContainer = this.element;
+ }
+ this.init();
+ }
+
+ Dropzone.prototype.init = function() {
+ var eventName, noPropagation, _i, _len, _ref, _ref1,
+ _this = this;
+
+ if (this.element.tagName === "form") {
+ this.element.setAttribute("enctype", "multipart/form-data");
+ }
+ if (this.element.classList.contains("dropzone") && !this.element.querySelector(".message")) {
+ this.element.appendChild(createElement("<div class=\"default message\"><span>" + this.options.dictDefaultMessage + "</span></div>"));
+ }
+ if (this.options.clickable) {
+ this.hiddenFileInput = document.createElement("input");
+ this.hiddenFileInput.setAttribute("type", "file");
+ this.hiddenFileInput.setAttribute("multiple", "multiple");
+ this.hiddenFileInput.style.display = "none";
+ document.body.appendChild(this.hiddenFileInput);
+ this.hiddenFileInput.addEventListener("change", function() {
+ var files;
+
+ files = _this.hiddenFileInput.files;
+ if (files.length) {
+ _this.emit("selectedfiles", files);
+ return _this.handleFiles(files);
+ }
+ });
+ }
+ this.files = [];
+ this.filesQueue = [];
+ this.filesProcessing = [];
+ this.URL = (_ref = window.URL) != null ? _ref : window.webkitURL;
+ _ref1 = this.events;
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
+ eventName = _ref1[_i];
+ this.on(eventName, this.options[eventName]);
+ }
+ noPropagation = function(e) {
+ e.stopPropagation();
+ if (e.preventDefault) {
+ return e.preventDefault();
+ } else {
+ return e.returnValue = false;
+ }
+ };
+ this.listeners = {
+ "dragstart": function(e) {
+ return _this.emit("dragstart", e);
+ },
+ "dragenter": function(e) {
+ noPropagation(e);
+ return _this.emit("dragenter", e);
+ },
+ "dragover": function(e) {
+ noPropagation(e);
+ return _this.emit("dragover", e);
+ },
+ "dragleave": function(e) {
+ return _this.emit("dragleave", e);
+ },
+ "drop": function(e) {
+ noPropagation(e);
+ _this.drop(e);
+ return _this.emit("drop", e);
+ },
+ "dragend": function(e) {
+ return _this.emit("dragend", e);
+ },
+ "click": function(evt) {
+ if (!_this.options.clickable) {
+ return;
+ }
+ if (evt.target === _this.element || evt.target === _this.element.querySelector(".message")) {
+ return _this.hiddenFileInput.click();
+ }
+ }
+ };
+ this.enable();
+ return this.options.init.call(this);
+ };
+
+ Dropzone.prototype.getFallbackForm = function() {
+ var existingFallback, fields, fieldsString, form;
+
+ if (existingFallback = this.getExistingFallback()) {
+ return existingFallback;
+ }
+ fieldsString = "<div class=\"fallback\">";
+ if (this.options.dictFallbackText) {
+ fieldsString += "<p>" + this.options.dictFallbackText + "</p>";
+ }
+ fieldsString += "<input type=\"file\" name=\"" + this.options.paramName + "\" multiple=\"multiple\" /><button type=\"submit\">Upload!</button></div>";
+ fields = createElement(fieldsString);
+ if (this.element.tagName !== "FORM") {
+ form = createElement("<form action=\"" + this.options.url + "\" enctype=\"multipart/form-data\" method=\"" + this.options.method + "\"></form>");
+ form.appendChild(fields);
+ } else {
+ this.element.setAttribute("enctype", "multipart/form-data");
+ this.element.setAttribute("method", this.options.method);
+ }
+ return form != null ? form : fields;
+ };
+
+ Dropzone.prototype.getExistingFallback = function() {
+ var fallback, getFallback, tagName, _i, _len, _ref;
+
+ getFallback = function(elements) {
+ var el, _i, _len;
+
+ for (_i = 0, _len = elements.length; _i < _len; _i++) {
+ el = elements[_i];
+ if (/(^| )fallback($| )/.test(el.className)) {
+ return el;
+ }
+ }
+ };
+ _ref = ["div", "form"];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ tagName = _ref[_i];
+ if (fallback = getFallback(this.element.getElementsByTagName("div"))) {
+ return fallback;
+ }
+ }
+ };
+
+ Dropzone.prototype.setupEventListeners = function() {
+ var event, listener, _ref, _results;
+
+ _ref = this.listeners;
+ _results = [];
+ for (event in _ref) {
+ listener = _ref[event];
+ _results.push(this.element.addEventListener(event, listener, false));
+ }
+ return _results;
+ };
+
+ Dropzone.prototype.removeEventListeners = function() {
+ var event, listener, _ref, _results;
+
+ _ref = this.listeners;
+ _results = [];
+ for (event in _ref) {
+ listener = _ref[event];
+ _results.push(this.element.removeEventListener(event, listener, false));
+ }
+ return _results;
+ };
+
+ Dropzone.prototype.disable = function() {
+ if (this.options.clickable) {
+ this.element.classList.remove("clickable");
+ }
+ this.removeEventListeners();
+ this.filesProcessing = [];
+ return this.filesQueue = [];
+ };
+
+ Dropzone.prototype.enable = function() {
+ if (this.options.clickable) {
+ this.element.classList.add("clickable");
+ }
+ return this.setupEventListeners();
+ };
+
+ Dropzone.prototype.filesize = function(size) {
+ var string;
+
+ if (size >= 100000000000) {
+ size = size / 100000000000;
+ string = "TB";
+ } else if (size >= 100000000) {
+ size = size / 100000000;
+ string = "GB";
+ } else if (size >= 100000) {
+ size = size / 100000;
+ string = "MB";
+ } else if (size >= 100) {
+ size = size / 100;
+ string = "KB";
+ } else {
+ size = size * 10;
+ string = "b";
+ }
+ return "<strong>" + (Math.round(size) / 10) + "</strong> " + string;
+ };
+
+ Dropzone.prototype.drop = function(e) {
+ var files;
+
+ if (!e.dataTransfer) {
+ return;
+ }
+ files = e.dataTransfer.files;
+ this.emit("selectedfiles", files);
+ if (files.length) {
+ return this.handleFiles(files);
+ }
+ };
+
+ Dropzone.prototype.handleFiles = function(files) {
+ var file, _i, _len, _results;
+
+ _results = [];
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
+ file = files[_i];
+ _results.push(this.addFile(file));
+ }
+ return _results;
+ };
+
+ Dropzone.prototype.accept = function(file, done) {
+ if (file.size > this.options.maxFilesize * 1024 * 1024) {
+ return done("File is too big (" + (Math.round(file.size / 1024 / 10.24) / 100) + "MB). Max filesize: " + this.options.maxFilesize + "MB");
+ } else {
+ return this.options.accept.call(this, file, done);
+ }
+ };
+
+ Dropzone.prototype.addFile = function(file) {
+ var _this = this;
+
+ this.files.push(file);
+ this.emit("addedfile", file);
+ if (this.options.createImageThumbnails && file.type.match(/image.*/) && file.size <= this.options.maxThumbnailFilesize * 1024 * 1024) {
+ this.createThumbnail(file);
+ }
+ return this.accept(file, function(error) {
+ if (error) {
+ return _this.errorProcessing(file, error);
+ } else {
+ if (_this.options.enqueueForUpload) {
+ _this.filesQueue.push(file);
+ return _this.processQueue();
+ }
+ }
+ });
+ };
+
+ Dropzone.prototype.removeFile = function(file) {
+ if (file.processing) {
+ throw new Error("Can't remove file currently processing");
+ }
+ this.files = without(this.files, file);
+ this.filesQueue = without(this.filesQueue, file);
+ this.emit("removedfile", file);
+ if (this.files.length === 0) {
+ return this.emit("reset");
+ }
+ };
+
+ Dropzone.prototype.removeAllFiles = function() {
+ var file, _i, _len, _ref;
+
+ _ref = this.files.slice();
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ file = _ref[_i];
+ if (__indexOf.call(this.filesProcessing, file) < 0) {
+ this.removeFile(file);
+ }
+ }
+ return null;
+ };
+
+ Dropzone.prototype.createThumbnail = function(file) {
+ var fileReader,
+ _this = this;
+
+ fileReader = new FileReader;
+ fileReader.onload = function() {
+ var img;
+
+ img = new Image;
+ img.onload = function() {
+ var canvas, ctx, srcHeight, srcRatio, srcWidth, srcX, srcY, thumbnail, trgHeight, trgRatio, trgWidth, trgX, trgY;
+
+ canvas = document.createElement("canvas");
+ ctx = canvas.getContext("2d");
+ srcX = 0;
+ srcY = 0;
+ srcWidth = img.width;
+ srcHeight = img.height;
+ canvas.width = _this.options.thumbnailWidth;
+ canvas.height = _this.options.thumbnailHeight;
+ trgX = 0;
+ trgY = 0;
+ trgWidth = canvas.width;
+ trgHeight = canvas.height;
+ srcRatio = img.width / img.height;
+ trgRatio = canvas.width / canvas.height;
+ if (img.height < canvas.height || img.width < canvas.width) {
+ trgHeight = srcHeight;
+ trgWidth = srcWidth;
+ } else {
+ if (srcRatio > trgRatio) {
+ srcHeight = img.height;
+ srcWidth = srcHeight * trgRatio;
+ } else {
+ srcWidth = img.width;
+ srcHeight = srcWidth / trgRatio;
+ }
+ }
+ srcX = (img.width - srcWidth) / 2;
+ srcY = (img.height - srcHeight) / 2;
+ trgY = (canvas.height - trgHeight) / 2;
+ trgX = (canvas.width - trgWidth) / 2;
+ ctx.drawImage(img, srcX, srcY, srcWidth, srcHeight, trgX, trgY, trgWidth, trgHeight);
+ thumbnail = canvas.toDataURL("image/png");
+ return _this.emit("thumbnail", file, thumbnail);
+ };
+ return img.src = fileReader.result;
+ };
+ return fileReader.readAsDataURL(file);
+ };
+
+ Dropzone.prototype.processQueue = function() {
+ var i, parallelUploads, processingLength;
+
+ parallelUploads = this.options.parallelUploads;
+ processingLength = this.filesProcessing.length;
+ i = processingLength;
+ while (i < parallelUploads) {
+ if (!this.filesQueue.length) {
+ return;
+ }
+ this.processFile(this.filesQueue.shift());
+ i++;
+ }
+ };
+
+ Dropzone.prototype.processFile = function(file) {
+ this.filesProcessing.push(file);
+ file.processing = true;
+ this.emit("processingfile", file);
+ return this.uploadFile(file);
+ };
+
+ Dropzone.prototype.uploadFile = function(file) {
+ var formData, handleError, input, inputName, inputType, key, progressObj, value, xhr, _i, _len, _ref, _ref1, _ref2,
+ _this = this;
+
+ xhr = new XMLHttpRequest();
+ xhr.open(this.options.method, this.options.url, true);
+ handleError = function() {
+ return _this.errorProcessing(file, xhr.responseText || ("Server responded with " + xhr.status + " code."));
+ };
+ xhr.onload = function(e) {
+ var response, _ref;
+
+ if (!((200 <= (_ref = xhr.status) && _ref < 300))) {
+ return handleError();
+ } else {
+ _this.emit("uploadprogress", file, 100);
+ response = xhr.responseText;
+ if (xhr.getResponseHeader("content-type") && ~xhr.getResponseHeader("content-type").indexOf("application/json")) {
+ response = JSON.parse(response);
+ }
+ return _this.finished(file, response, e);
+ }
+ };
+ xhr.onerror = function() {
+ return handleError();
+ };
+ progressObj = (_ref = xhr.upload) != null ? _ref : xhr;
+ progressObj.onprogress = function(e) {
+ return _this.emit("uploadprogress", file, Math.max(0, Math.min(100, (e.loaded / e.total) * 100)));
+ };
+ xhr.setRequestHeader("Accept", "application/json");
+ xhr.setRequestHeader("Cache-Control", "no-cache");
+ xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
+ xhr.setRequestHeader("X-File-Name", file.name);
+ formData = new FormData();
+ if (this.options.params) {
+ _ref1 = this.options.params;
+ for (key in _ref1) {
+ value = _ref1[key];
+ formData.append(key, value);
+ }
+ }
+ if (this.element.tagName === "FORM") {
+ _ref2 = this.element.querySelectorAll("input, textarea, select, button");
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
+ input = _ref2[_i];
+ inputName = input.getAttribute("name");
+ inputType = input.getAttribute("type");
+ if (!inputType || inputType.toLowerCase() !== "checkbox" || input.checked) {
+ formData.append(inputName, input.value);
+ }
+ }
+ }
+ this.emit("sending", file, xhr, formData);
+ formData.append(this.options.paramName, file);
+ return xhr.send(formData);
+ };
+
+ Dropzone.prototype.finished = function(file, responseText, e) {
+ this.filesProcessing = without(this.filesProcessing, file);
+ file.processing = false;
+ this.processQueue();
+ this.emit("success", file, responseText, e);
+ this.emit("finished", file, responseText, e);
+ return this.emit("complete", file);
+ };
+
+ Dropzone.prototype.errorProcessing = function(file, message) {
+ this.filesProcessing = without(this.filesProcessing, file);
+ file.processing = false;
+ this.processQueue();
+ this.emit("error", file, message);
+ return this.emit("complete", file);
+ };
+
+ return Dropzone;
+
+ })(Em);
+
+ Dropzone.version = "2.0.8";
+
+ Dropzone.options = {};
+
+ Dropzone.instances = [];
+
+ Dropzone.forElement = function(element) {
+ var instance, _i, _len, _ref;
+
+ if (typeof element === "string") {
+ element = document.querySelector(element);
+ }
+ _ref = Dropzone.instances;
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ instance = _ref[_i];
+ if (instance.element === element) {
+ return instance;
+ }
+ }
+ return null;
+ };
+
+ Dropzone.blacklistedBrowsers = [/opera.*Macintosh.*version\/12/i];
+
+ Dropzone.isBrowserSupported = function() {
+ var capableBrowser, regex, _i, _len, _ref;
+
+ capableBrowser = true;
+ if (window.File && window.FileReader && window.FileList && window.Blob && window.FormData && document.querySelector) {
+ if (!("classList" in document.createElement("a"))) {
+ capableBrowser = false;
+ } else {
+ _ref = Dropzone.blacklistedBrowsers;
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ regex = _ref[_i];
+ if (regex.test(navigator.userAgent)) {
+ capableBrowser = false;
+ continue;
+ }
+ }
+ }
+ } else {
+ capableBrowser = false;
+ }
+ return capableBrowser;
+ };
+
+ without = function(list, rejectedItem) {
+ var item, _i, _len, _results;
+
+ _results = [];
+ for (_i = 0, _len = list.length; _i < _len; _i++) {
+ item = list[_i];
+ if (item !== rejectedItem) {
+ _results.push(item);
+ }
+ }
+ return _results;
+ };
+
+ camelize = function(str) {
+ return str.replace(/[\-_](\w)/g, function(match) {
+ return match[1].toUpperCase();
+ });
+ };
+
+ createElement = function(string) {
+ var div;
+
+ div = document.createElement("div");
+ div.innerHTML = string;
+ return div.childNodes[0];
+ };
+
+ if (typeof jQuery !== "undefined" && jQuery !== null) {
+ jQuery.fn.dropzone = function(options) {
+ return this.each(function() {
+ return new Dropzone(this, options);
+ });
+ };
+ }
+
+ if (typeof module !== "undefined" && module !== null) {
+ module.exports = Dropzone;
+ } else {
+ window.Dropzone = Dropzone;
+ }
+
+ contentLoaded = function(win, fn) {
+ var add, doc, done, init, poll, pre, rem, root, top;
+
+ done = false;
+ top = true;
+ doc = win.document;
+ root = doc.documentElement;
+ add = (doc.addEventListener ? "addEventListener" : "attachEvent");
+ rem = (doc.addEventListener ? "removeEventListener" : "detachEvent");
+ pre = (doc.addEventListener ? "" : "on");
+ init = function(e) {
+ if (e.type === "readystatechange" && doc.readyState !== "complete") {
+ return;
+ }
+ (e.type === "load" ? win : doc)[rem](pre + e.type, init, false);
+ if (!done && (done = true)) {
+ return fn.call(win, e.type || e);
+ }
+ };
+ poll = function() {
+ var e;
+
+ try {
+ root.doScroll("left");
+ } catch (_error) {
+ e = _error;
+ setTimeout(poll, 50);
+ return;
+ }
+ return init("poll");
+ };
+ if (doc.readyState !== "complete") {
+ if (doc.createEventObject && root.doScroll) {
+ try {
+ top = !win.frameElement;
+ } catch (_error) {}
+ if (top) {
+ poll();
+ }
+ }
+ doc[add](pre + "DOMContentLoaded", init, false);
+ doc[add](pre + "readystatechange", init, false);
+ return win[add](pre + "load", init, false);
+ }
+ };
+
+ contentLoaded(window, function() {
+ var checkElements, dropzone, dropzones, _i, _len, _results;
+
+ if (false) {
+ dropzones = document.querySelectorAll(".dropzone");
+ } else {
+ dropzones = [];
+ checkElements = function(elements) {
+ var el, _i, _len, _results;
+
+ _results = [];
+ for (_i = 0, _len = elements.length; _i < _len; _i++) {
+ el = elements[_i];
+ if (/(^| )dropzone($| )/.test(el.className)) {
+ _results.push(dropzones.push(el));
+ } else {
+ _results.push(void 0);
+ }
+ }
+ return _results;
+ };
+ checkElements(document.getElementsByTagName("div"));
+ checkElements(document.getElementsByTagName("form"));
+ }
+ _results = [];
+ for (_i = 0, _len = dropzones.length; _i < _len; _i++) {
+ dropzone = dropzones[_i];
+ _results.push(new Dropzone(dropzone));
+ }
+ return _results;
+ });
+
+}).call(this);
+
+ return module.exports;
+}));
View
1 ajax/libs/dropzone/2.0.8/dropzone-amd-module.min.js
@@ -0,0 +1 @@
+(function(e){"function"==typeof define&&define.amd?define(["jquery"],e):e(jQuery)})(function(e){function t(e){return e?i(e):void 0}function i(e){for(var i in t.prototype)e[i]=t.prototype[i];return e}var n={exports:{}};return n.exports=t,t.prototype.on=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks[e]=this._callbacks[e]||[]).push(t),this},t.prototype.once=function(e,t){function i(){n.off(e,i),t.apply(this,arguments)}var n=this;return this._callbacks=this._callbacks||{},t._off=i,this.on(e,i),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=function(e,t){this._callbacks=this._callbacks||{};var i=this._callbacks[e];if(!i)return this;if(1==arguments.length)return delete this._callbacks[e],this;var n=i.indexOf(t._off||t);return~n&&i.splice(n,1),this},t.prototype.emit=function(e){this._callbacks=this._callbacks||{};var t=[].slice.call(arguments,1),i=this._callbacks[e];if(i){i=i.slice(0);for(var n=0,s=i.length;s>n;++n)i[n].apply(this,t)}return this},t.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks[e]||[]},t.prototype.hasListeners=function(e){return!!this.listeners(e).length},function(){var i,s,r,o,a,l,p,u={}.hasOwnProperty,c=function(e,t){function i(){this.constructor=e}for(var n in t)u.call(t,n)&&(e[n]=t[n]);return i.prototype=t.prototype,e.prototype=new i,e.__super__=t.prototype,e},h=[].slice,d=[].indexOf||function(e){for(var t=0,i=this.length;i>t;t++)if(t in this&&this[t]===e)return t;return-1};s=t!==void 0&&null!==t?t:require("emitter"),l=function(){},i=function(e){function t(e,i){var n,s,o,a,l;if(this.element=e,this.version=t.version,this.defaultOptions.previewTemplate=this.defaultOptions.previewTemplate.replace(/\n*/g,""),"string"==typeof this.element&&(this.element=document.querySelector(this.element)),!this.element||null==this.element.nodeType)throw Error("Invalid dropzone element.");if(t.forElement(this.element))throw Error("Dropzone already attached.");if(t.instances.push(this),n=this.element.id,s=null!=(l=n?t.options[r(n)]:void 0)?l:{},o=function(){var e,t,i,n,s,r,o;for(n=arguments[0],i=arguments.length>=2?h.call(arguments,1):[],r=0,o=i.length;o>r;r++){t=i[r];for(e in t)s=t[e],n[e]=s}return n},this.options=o({},this.defaultOptions,s,null!=i?i:{}),null==this.options.url&&(this.options.url=this.element.action),!this.options.url)throw Error("No URL provided.");if(this.options.method=this.options.method.toUpperCase(),!t.isBrowserSupported())return this.options.fallback.call(this);if((a=this.getExistingFallback())&&a.parentNode&&a.parentNode.removeChild(a),this.options.previewsContainer){if("string"==typeof this.options.previewsContainer?this.previewsContainer=document.querySelector(this.options.previewsContainer):null!=this.options.previewsContainer.nodeType&&(this.previewsContainer=this.options.previewsContainer),null==this.previewsContainer)throw Error("Invalid `previewsContainer` option provided. Please provide a CSS selector or a plain HTML element.")}else this.previewsContainer=this.element;this.init()}return c(t,e),t.prototype.events=["drop","dragstart","dragend","dragenter","dragover","dragleave","selectedfiles","addedfile","removedfile","thumbnail","error","processingfile","uploadprogress","sending","success","complete","reset"],t.prototype.defaultOptions={url:null,method:"post",parallelUploads:2,maxFilesize:256,paramName:"file",createImageThumbnails:!0,maxThumbnailFilesize:2,thumbnailWidth:100,thumbnailHeight:100,params:{},clickable:!0,enqueueForUpload:!0,previewsContainer:null,dictDefaultMessage:"Drop files here to upload",dictFallbackMessage:"Your browser does not support drag'n'drop file uploads.",dictFallbackText:"Please use the fallback form below to upload your files like in the olden days.",accept:function(e,t){return t()},init:function(){return l},fallback:function(){var e,t,i,n,s,r;for(this.element.className=""+this.element.className+" browser-not-supported",r=this.element.getElementsByTagName("div"),n=0,s=r.length;s>n;n++)e=r[n],/(^| )message($| )/.test(e.className)&&(t=e,e.className="message");return t||(t=a('<div class="message"><span></span></div>'),this.element.appendChild(t)),i=t.getElementsByTagName("span")[0],i&&(i.textContent=this.options.dictFallbackMessage),this.element.appendChild(this.getFallbackForm())},drop:function(){return this.element.classList.remove("drag-hover")},dragstart:l,dragend:function(){return this.element.classList.remove("drag-hover")},dragenter:function(){return this.element.classList.add("drag-hover")},dragover:function(){return this.element.classList.add("drag-hover")},dragleave:function(){return this.element.classList.remove("drag-hover")},selectedfiles:function(){return this.element===this.previewsContainer?this.element.classList.add("started"):void 0},reset:function(){return this.element.classList.remove("started")},addedfile:function(e){return e.previewTemplate=a(this.options.previewTemplate),this.previewsContainer.appendChild(e.previewTemplate),e.previewTemplate.querySelector(".filename span").textContent=e.name,e.previewTemplate.querySelector(".details").appendChild(a('<div class="size">'+this.filesize(e.size)+"</div>"))},removedfile:function(e){return e.previewTemplate.parentNode.removeChild(e.previewTemplate)},thumbnail:function(e,t){return e.previewTemplate.classList.remove("file-preview"),e.previewTemplate.classList.add("image-preview"),e.previewTemplate.querySelector(".details").appendChild(a('<img alt="'+e.name+'" src="'+t+'"/>'))},error:function(e,t){return e.previewTemplate.classList.add("error"),e.previewTemplate.querySelector(".error-message span").textContent=t},processingfile:function(e){return e.previewTemplate.classList.add("processing")},uploadprogress:function(e,t){return e.previewTemplate.querySelector(".progress .upload").style.width=""+t+"%"},sending:l,success:function(e){return e.previewTemplate.classList.add("success")},complete:l,previewTemplate:'<div class="preview file-preview">\n <div class="details">\n <div class="filename"><span></span></div>\n </div>\n <div class="progress"><span class="upload"></span></div>\n <div class="success-mark"><span>✔</span></div>\n <div class="error-mark"><span>✘</span></div>\n <div class="error-message"><span></span></div>\n</div>'},t.prototype.init=function(){var e,t,i,n,s,r,o=this;for("form"===this.element.tagName&&this.element.setAttribute("enctype","multipart/form-data"),this.element.classList.contains("dropzone")&&!this.element.querySelector(".message")&&this.element.appendChild(a('<div class="default message"><span>'+this.options.dictDefaultMessage+"</span></div>")),this.options.clickable&&(this.hiddenFileInput=document.createElement("input"),this.hiddenFileInput.setAttribute("type","file"),this.hiddenFileInput.setAttribute("multiple","multiple"),this.hiddenFileInput.style.display="none",document.body.appendChild(this.hiddenFileInput),this.hiddenFileInput.addEventListener("change",function(){var e;return e=o.hiddenFileInput.files,e.length?(o.emit("selectedfiles",e),o.handleFiles(e)):void 0})),this.files=[],this.filesQueue=[],this.filesProcessing=[],this.URL=null!=(s=window.URL)?s:window.webkitURL,r=this.events,i=0,n=r.length;n>i;i++)e=r[i],this.on(e,this.options[e]);return t=function(e){return e.stopPropagation(),e.preventDefault?e.preventDefault():e.returnValue=!1},this.listeners={dragstart:function(e){return o.emit("dragstart",e)},dragenter:function(e){return t(e),o.emit("dragenter",e)},dragover:function(e){return t(e),o.emit("dragover",e)},dragleave:function(e){return o.emit("dragleave",e)},drop:function(e){return t(e),o.drop(e),o.emit("drop",e)},dragend:function(e){return o.emit("dragend",e)},click:function(e){return o.options.clickable?e.target===o.element||e.target===o.element.querySelector(".message")?o.hiddenFileInput.click():void 0:void 0}},this.enable(),this.options.init.call(this)},t.prototype.getFallbackForm=function(){var e,t,i,n;return(e=this.getExistingFallback())?e:(i='<div class="fallback">',this.options.dictFallbackText&&(i+="<p>"+this.options.dictFallbackText+"</p>"),i+='<input type="file" name="'+this.options.paramName+'" multiple="multiple" /><button type="submit">Upload!</button></div>',t=a(i),"FORM"!==this.element.tagName?(n=a('<form action="'+this.options.url+'" enctype="multipart/form-data" method="'+this.options.method+'"></form>'),n.appendChild(t)):(this.element.setAttribute("enctype","multipart/form-data"),this.element.setAttribute("method",this.options.method)),null!=n?n:t)},t.prototype.getExistingFallback=function(){var e,t,i,n,s,r;for(t=function(e){var t,i,n;for(i=0,n=e.length;n>i;i++)if(t=e[i],/(^| )fallback($| )/.test(t.className))return t},r=["div","form"],n=0,s=r.length;s>n;n++)if(i=r[n],e=t(this.element.getElementsByTagName("div")))return e},t.prototype.setupEventListeners=function(){var e,t,i,n;i=this.listeners,n=[];for(e in i)t=i[e],n.push(this.element.addEventListener(e,t,!1));return n},t.prototype.removeEventListeners=function(){var e,t,i,n;i=this.listeners,n=[];for(e in i)t=i[e],n.push(this.element.removeEventListener(e,t,!1));return n},t.prototype.disable=function(){return this.options.clickable&&this.element.classList.remove("clickable"),this.removeEventListeners(),this.filesProcessing=[],this.filesQueue=[]},t.prototype.enable=function(){return this.options.clickable&&this.element.classList.add("clickable"),this.setupEventListeners()},t.prototype.filesize=function(e){var t;return e>=1e11?(e/=1e11,t="TB"):e>=1e8?(e/=1e8,t="GB"):e>=1e5?(e/=1e5,t="MB"):e>=100?(e/=100,t="KB"):(e=10*e,t="b"),"<strong>"+Math.round(e)/10+"</strong> "+t},t.prototype.drop=function(e){var t;if(e.dataTransfer)return t=e.dataTransfer.files,this.emit("selectedfiles",t),t.length?this.handleFiles(t):void 0},t.prototype.handleFiles=function(e){var t,i,n,s;for(s=[],i=0,n=e.length;n>i;i++)t=e[i],s.push(this.addFile(t));return s},t.prototype.accept=function(e,t){return e.size>1024*1024*this.options.maxFilesize?t("File is too big ("+Math.round(e.size/1024/10.24)/100+"MB). Max filesize: "+this.options.maxFilesize+"MB"):this.options.accept.call(this,e,t)},t.prototype.addFile=function(e){var t=this;return this.files.push(e),this.emit("addedfile",e),this.options.createImageThumbnails&&e.type.match(/image.*/)&&e.size<=1024*1024*this.options.maxThumbnailFilesize&&this.createThumbnail(e),this.accept(e,function(i){return i?t.errorProcessing(e,i):t.options.enqueueForUpload?(t.filesQueue.push(e),t.processQueue()):void 0})},t.prototype.removeFile=function(e){if(e.processing)throw Error("Can't remove file currently processing");return this.files=p(this.files,e),this.filesQueue=p(this.filesQueue,e),this.emit("removedfile",e),0===this.files.length?this.emit("reset"):void 0},t.prototype.removeAllFiles=function(){var e,t,i,n;for(n=this.files.slice(),t=0,i=n.length;i>t;t++)e=n[t],0>d.call(this.filesProcessing,e)&&this.removeFile(e);return null},t.prototype.createThumbnail=function(e){var t,i=this;return t=new FileReader,t.onload=function(){var n;return n=new Image,n.onload=function(){var t,s,r,o,a,l,p,u,c,h,d,m,f;return t=document.createElement("canvas"),s=t.getContext("2d"),l=0,p=0,a=n.width,r=n.height,t.width=i.options.thumbnailWidth,t.height=i.options.thumbnailHeight,m=0,f=0,d=t.width,c=t.height,o=n.width/n.height,h=t.width/t.height,n.height<t.height||n.width<t.width?(c=r,d=a):o>h?(r=n.height,a=r*h):(a=n.width,r=a/h),l=(n.width-a)/2,p=(n.height-r)/2,f=(t.height-c)/2,m=(t.width-d)/2,s.drawImage(n,l,p,a,r,m,f,d,c),u=t.toDataURL("image/png"),i.emit("thumbnail",e,u)},n.src=t.result},t.readAsDataURL(e)},t.prototype.processQueue=function(){var e,t,i;for(t=this.options.parallelUploads,i=this.filesProcessing.length,e=i;t>e;){if(!this.filesQueue.length)return;this.processFile(this.filesQueue.shift()),e++}},t.prototype.processFile=function(e){return this.filesProcessing.push(e),e.processing=!0,this.emit("processingfile",e),this.uploadFile(e)},t.prototype.uploadFile=function(e){var t,i,n,s,r,o,a,l,p,u,c,h,d,m,f=this;if(p=new XMLHttpRequest,p.open(this.options.method,this.options.url,!0),i=function(){return f.errorProcessing(e,p.responseText||"Server responded with "+p.status+" code.")},p.onload=function(t){var n,s;return(s=p.status)>=200&&300>s?(f.emit("uploadprogress",e,100),n=p.responseText,p.getResponseHeader("content-type")&&~p.getResponseHeader("content-type").indexOf("application/json")&&(n=JSON.parse(n)),f.finished(e,n,t)):i()},p.onerror=function(){return i()},a=null!=(h=p.upload)?h:p,a.onprogress=function(t){return f.emit("uploadprogress",e,Math.max(0,Math.min(100,100*(t.loaded/t.total))))},p.setRequestHeader("Accept","application/json"),p.setRequestHeader("Cache-Control","no-cache"),p.setRequestHeader("X-Requested-With","XMLHttpRequest"),p.setRequestHeader("X-File-Name",e.name),t=new FormData,this.options.params){d=this.options.params;for(o in d)l=d[o],t.append(o,l)}if("FORM"===this.element.tagName)for(m=this.element.querySelectorAll("input, textarea, select, button"),u=0,c=m.length;c>u;u++)n=m[u],s=n.getAttribute("name"),r=n.getAttribute("type"),(!r||"checkbox"!==r.toLowerCase()||n.checked)&&t.append(s,n.value);return this.emit("sending",e,p,t),t.append(this.options.paramName,e),p.send(t)},t.prototype.finished=function(e,t,i){return this.filesProcessing=p(this.filesProcessing,e),e.processing=!1,this.processQueue(),this.emit("success",e,t,i),this.emit("finished",e,t,i),this.emit("complete",e)},t.prototype.errorProcessing=function(e,t){return this.filesProcessing=p(this.filesProcessing,e),e.processing=!1,this.processQueue(),this.emit("error",e,t),this.emit("complete",e)},t}(s),i.version="2.0.8",i.options={},i.instances=[],i.forElement=function(e){var t,n,s,r;for("string"==typeof e&&(e=document.querySelector(e)),r=i.instances,n=0,s=r.length;s>n;n++)if(t=r[n],t.element===e)return t;return null},i.blacklistedBrowsers=[/opera.*Macintosh.*version\/12/i],i.isBrowserSupported=function(){var e,t,n,s,r;if(e=!0,window.File&&window.FileReader&&window.FileList&&window.Blob&&window.FormData&&document.querySelector)if("classList"in document.createElement("a"))for(r=i.blacklistedBrowsers,n=0,s=r.length;s>n;n++)t=r[n],t.test(navigator.userAgent)&&(e=!1);else e=!1;else e=!1;return e},p=function(e,t){var i,n,s,r;for(r=[],n=0,s=e.length;s>n;n++)i=e[n],i!==t&&r.push(i);return r},r=function(e){return e.replace(/[\-_](\w)/g,function(e){return e[1].toUpperCase()})},a=function(e){var t;return t=document.createElement("div"),t.innerHTML=e,t.childNodes[0]},e!==void 0&&null!==e&&(e.fn.dropzone=function(e){return this.each(function(){return new i(this,e)})}),n!==void 0&&null!==n?n.exports=i:window.Dropzone=i,o=function(e,t){var i,n,s,r,o,a,l,p,u;if(s=!1,u=!0,n=e.document,p=n.documentElement,i=n.addEventListener?"addEventListener":"attachEvent",l=n.addEventListener?"removeEventListener":"detachEvent",a=n.addEventListener?"":"on",r=function(i){return"readystatechange"!==i.type||"complete"===n.readyState?(("load"===i.type?e:n)[l](a+i.type,r,!1),!s&&(s=!0)?t.call(e,i.type||i):void 0):void 0},o=function(){var e;try{p.doScroll("left")}catch(t){return e=t,setTimeout(o,50),void 0}return r("poll")},"complete"!==n.readyState){if(n.createEventObject&&p.doScroll){try{u=!e.frameElement}catch(c){}u&&o()}return n[i](a+"DOMContentLoaded",r,!1),n[i](a+"readystatechange",r,!1),e[i](a+"load",r,!1)}},o(window,function(){var e,t,n,s,r,o;for(n=[],e=function(e){var t,i,s,r;for(r=[],i=0,s=e.length;s>i;i++)t=e[i],/(^| )dropzone($| )/.test(t.className)?r.push(n.push(t)):r.push(void 0);return r},e(document.getElementsByTagName("div")),e(document.getElementsByTagName("form")),o=[],s=0,r=n.length;r>s;s++)t=n[s],o.push(new i(t));return o})}.call(this),n.exports});
View
1,185 ajax/libs/dropzone/2.0.8/dropzone.js
@@ -0,0 +1,1185 @@
+;(function(){
+
+
+/**
+ * hasOwnProperty.
+ */
+
+var has = Object.prototype.hasOwnProperty;
+
+/**
+ * Require the given path.
+ *
+ * @param {String} path
+ * @return {Object} exports
+ * @api public
+ */
+
+function require(path, parent, orig) {
+ var resolved = require.resolve(path);
+
+ // lookup failed
+ if (null == resolved) {
+ orig = orig || path;
+ parent = parent || 'root';
+ var err = new Error('Failed to require "' + orig + '" from "' + parent + '"');
+ err.path = orig;
+ err.parent = parent;
+ err.require = true;
+ throw err;
+ }
+
+ var module = require.modules[resolved];
+
+ // perform real require()
+ // by invoking the module's
+ // registered function
+ if (!module.exports) {
+ module.exports = {};
+ module.client = module.component = true;
+ module.call(this, module.exports, require.relative(resolved), module);
+ }
+
+ return module.exports;
+}
+
+/**
+ * Registered modules.
+ */
+
+require.modules = {};
+
+/**
+ * Registered aliases.
+ */
+
+require.aliases = {};
+
+/**
+ * Resolve `path`.
+ *
+ * Lookup:
+ *
+ * - PATH/index.js
+ * - PATH.js
+ * - PATH
+ *
+ * @param {String} path
+ * @return {String} path or null
+ * @api private
+ */
+
+require.resolve = function(path) {
+ if (path.charAt(0) === '/') path = path.slice(1);
+ var index = path + '/index.js';
+
+ var paths = [
+ path,
+ path + '.js',
+ path + '.json',
+ path + '/index.js',
+ path + '/index.json'
+ ];
+
+ for (var i = 0; i < paths.length; i++) {
+ var path = paths[i];
+ if (has.call(require.modules, path)) return path;
+ }
+
+ if (has.call(require.aliases, index)) {
+ return require.aliases[index];
+ }
+};
+
+/**
+ * Normalize `path` relative to the current path.
+ *
+ * @param {String} curr
+ * @param {String} path
+ * @return {String}
+ * @api private
+ */
+
+require.normalize = function(curr, path) {
+ var segs = [];
+
+ if ('.' != path.charAt(0)) return path;
+
+ curr = curr.split('/');
+ path = path.split('/');
+
+ for (var i = 0; i < path.length; ++i) {
+ if ('..' == path[i]) {
+ curr.pop();
+ } else if ('.' != path[i] && '' != path[i]) {
+ segs.push(path[i]);
+ }
+ }
+
+ return curr.concat(segs).join('/');
+};
+
+/**
+ * Register module at `path` with callback `definition`.
+ *
+ * @param {String} path
+ * @param {Function} definition
+ * @api private
+ */
+
+require.register = function(path, definition) {
+ require.modules[path] = definition;
+};
+
+/**
+ * Alias a module definition.
+ *
+ * @param {String} from
+ * @param {String} to
+ * @api private
+ */
+
+require.alias = function(from, to) {
+ if (!has.call(require.modules, from)) {
+ throw new Error('Failed to alias "' + from + '", it does not exist');
+ }
+ require.aliases[to] = from;
+};
+
+/**
+ * Return a require function relative to the `parent` path.
+ *
+ * @param {String} parent
+ * @return {Function}
+ * @api private
+ */
+
+require.relative = function(parent) {
+ var p = require.normalize(parent, '..');
+
+ /**
+ * lastIndexOf helper.
+ */
+
+ function lastIndexOf(arr, obj) {
+ var i = arr.length;
+ while (i--) {
+ if (arr[i] === obj) return i;
+ }
+ return -1;
+ }
+
+ /**
+ * The relative require() itself.
+ */
+
+ function localRequire(path) {
+ var resolved = localRequire.resolve(path);
+ return require(resolved, parent, path);
+ }
+
+ /**
+ * Resolve relative to the parent.
+ */
+
+ localRequire.resolve = function(path) {
+ var c = path.charAt(0);
+ if ('/' == c) return path.slice(1);
+ if ('.' == c) return require.normalize(p, path);
+
+ // resolve deps by returning
+ // the dep in the nearest "deps"
+ // directory
+ var segs = parent.split('/');
+ var i = lastIndexOf(segs, 'deps') + 1;
+ if (!i) i = 0;
+ path = segs.slice(0, i + 1).join('/') + '/deps/' + path;
+ return path;
+ };
+
+ /**
+ * Check if module is defined at `path`.
+ */
+
+ localRequire.exists = function(path) {
+ return has.call(require.modules, localRequire.resolve(path));
+ };
+
+ return localRequire;
+};
+require.register("component-emitter/index.js", function(exports, require, module){
+
+/**
+ * Expose `Emitter`.
+ */
+
+module.exports = Emitter;
+
+/**
+ * Initialize a new `Emitter`.
+ *
+ * @api public
+ */
+
+function Emitter(obj) {
+ if (obj) return mixin(obj);
+};
+
+/**
+ * Mixin the emitter properties.
+ *
+ * @param {Object} obj
+ * @return {Object}
+ * @api private
+ */
+
+function mixin(obj) {
+ for (var key in Emitter.prototype) {
+ obj[key] = Emitter.prototype[key];
+ }
+ return obj;
+}
+
+/**
+ * Listen on the given `event` with `fn`.
+ *
+ * @param {String} event
+ * @param {Function} fn
+ * @return {Emitter}
+ * @api public
+ */
+
+Emitter.prototype.on = function(event, fn){
+ this._callbacks = this._callbacks || {};
+ (this._callbacks[event] = this._callbacks[event] || [])
+ .push(fn);
+ return this;
+};
+
+/**
+ * Adds an `event` listener that will be invoked a single
+ * time then automatically removed.
+ *
+ * @param {String} event
+ * @param {Function} fn
+ * @return {Emitter}
+ * @api public
+ */
+
+Emitter.prototype.once = function(event, fn){
+ var self = this;
+ this._callbacks = this._callbacks || {};
+
+ function on() {
+ self.off(event, on);
+ fn.apply(this, arguments);
+ }
+
+ fn._off = on;
+ this.on(event, on);
+ return this;
+};
+
+/**
+ * Remove the given callback for `event` or all
+ * registered callbacks.
+ *
+ * @param {String} event
+ * @param {Function} fn
+ * @return {Emitter}
+ * @api public
+ */
+
+Emitter.prototype.off =
+Emitter.prototype.removeListener =
+Emitter.prototype.removeAllListeners = function(event, fn){
+ this._callbacks = this._callbacks || {};
+ var callbacks = this._callbacks[event];
+ if (!callbacks) return this;
+
+ // remove all handlers
+ if (1 == arguments.length) {
+ delete this._callbacks[event];
+ return this;
+ }
+
+ // remove specific handler
+ var i = callbacks.indexOf(fn._off || fn);
+ if (~i) callbacks.splice(i, 1);
+ return this;
+};
+
+/**
+ * Emit `event` with the given args.
+ *
+ * @param {String} event
+ * @param {Mixed} ...
+ * @return {Emitter}
+ */
+
+Emitter.prototype.emit = function(event){
+ this._callbacks = this._callbacks || {};
+ var args = [].slice.call(arguments, 1)
+ , callbacks = this._callbacks[event];
+
+ if (callbacks) {
+ callbacks = callbacks.slice(0);
+ for (var i = 0, len = callbacks.length; i < len; ++i) {
+ callbacks[i].apply(this, args);
+ }
+ }
+
+ return this;
+};
+
+/**
+ * Return array of callbacks for `event`.
+ *
+ * @param {String} event
+ * @return {Array}
+ * @api public
+ */
+
+Emitter.prototype.listeners = function(event){
+ this._callbacks = this._callbacks || {};
+ return this._callbacks[event] || [];
+};
+
+/**
+ * Check if this emitter has `event` handlers.
+ *
+ * @param {String} event
+ * @return {Boolean}
+ * @api public
+ */
+
+Emitter.prototype.hasListeners = function(event){
+ return !! this.listeners(event).length;
+};
+
+});
+require.register("dropzone/index.js", function(exports, require, module){
+
+
+/**
+ * Exposing dropzone
+ */
+module.exports = require("./lib/dropzone.js");
+
+});
+require.register("dropzone/lib/dropzone.js", function(exports, require, module){
+/*
+#
+# More info at [www.dropzonejs.com](http://www.dropzonejs.com)
+#
+# Copyright (c) 2012, Matias Meno
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+*/
+
+
+(function() {
+ var Dropzone, Em, camelize, contentLoaded, createElement, noop, without,
+ __hasProp = {}.hasOwnProperty,
+ __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; },
+ __slice = [].slice,
+ __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
+
+ Em = typeof Emitter !== "undefined" && Emitter !== null ? Emitter : require("emitter");
+
+ noop = function() {};
+
+ Dropzone = (function(_super) {
+ __extends(Dropzone, _super);
+
+ /*
+ This is a list of all available events you can register on a dropzone object.
+
+ You can register an event handler like this:
+
+ dropzone.on("dragEnter", function() { });
+ */
+
+
+ Dropzone.prototype.events = ["drop", "dragstart", "dragend", "dragenter", "dragover", "dragleave", "selectedfiles", "addedfile", "removedfile", "thumbnail", "error", "processingfile", "uploadprogress", "sending", "success", "complete", "reset"];
+
+ Dropzone.prototype.defaultOptions = {
+ url: null,
+ method: "post",
+ parallelUploads: 2,
+ maxFilesize: 256,
+ paramName: "file",
+ createImageThumbnails: true,
+ maxThumbnailFilesize: 2,
+ thumbnailWidth: 100,
+ thumbnailHeight: 100,
+ params: {},
+ clickable: true,
+ enqueueForUpload: true,
+ previewsContainer: null,
+ dictDefaultMessage: "Drop files here to upload",
+ dictFallbackMessage: "Your browser does not support drag'n'drop file uploads.",
+ dictFallbackText: "Please use the fallback form below to upload your files like in the olden days.",
+ accept: function(file, done) {
+ return done();
+ },
+ init: function() {
+ return noop;
+ },
+ fallback: function() {
+ var child, messageElement, span, _i, _len, _ref;
+
+ this.element.className = "" + this.element.className + " browser-not-supported";
+ _ref = this.element.getElementsByTagName("div");
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ child = _ref[_i];
+ if (/(^| )message($| )/.test(child.className)) {
+ messageElement = child;
+ child.className = "message";
+ continue;
+ }
+ }
+ if (!messageElement) {
+ messageElement = createElement("<div class=\"message\"><span></span></div>");
+ this.element.appendChild(messageElement);
+ }
+ span = messageElement.getElementsByTagName("span")[0];
+ if (span) {
+ span.textContent = this.options.dictFallbackMessage;
+ }
+ return this.element.appendChild(this.getFallbackForm());
+ },
+ /*
+ Those functions register themselves to the events on init and handle all
+ the user interface specific stuff. Overwriting them won't break the upload
+ but can break the way it's displayed.
+ You can overwrite them if you don't like the default behavior. If you just
+ want to add an additional event handler, register it on the dropzone object
+ and don't overwrite those options.
+ */
+
+ drop: function(e) {
+ return this.element.classList.remove("drag-hover");
+ },
+ dragstart: noop,
+ dragend: function(e) {
+ return this.element.classList.remove("drag-hover");
+ },
+ dragenter: function(e) {
+ return this.element.classList.add("drag-hover");
+ },
+ dragover: function(e) {
+ return this.element.classList.add("drag-hover");
+ },
+ dragleave: function(e) {
+ return this.element.classList.remove("drag-hover");
+ },
+ selectedfiles: function(files) {
+ if (this.element === this.previewsContainer) {
+ return this.element.classList.add("started");
+ }
+ },
+ reset: function() {
+ return this.element.classList.remove("started");
+ },
+ addedfile: function(file) {
+ file.previewTemplate = createElement(this.options.previewTemplate);
+ this.previewsContainer.appendChild(file.previewTemplate);
+ file.previewTemplate.querySelector(".filename span").textContent = file.name;
+ return file.previewTemplate.querySelector(".details").appendChild(createElement("<div class=\"size\">" + (this.filesize(file.size)) + "</div>"));
+ },
+ removedfile: function(file) {
+ return file.previewTemplate.parentNode.removeChild(file.previewTemplate);
+ },
+ thumbnail: function(file, dataUrl) {
+ file.previewTemplate.classList.remove("file-preview");
+ file.previewTemplate.classList.add("image-preview");
+ return file.previewTemplate.querySelector(".details").appendChild(createElement("<img alt=\"" + file.name + "\" src=\"" + dataUrl + "\"/>"));
+ },
+ error: function(file, message) {
+ file.previewTemplate.classList.add("error");
+ return file.previewTemplate.querySelector(".error-message span").textContent = message;
+ },
+ processingfile: function(file) {
+ return file.previewTemplate.classList.add("processing");
+ },
+ uploadprogress: function(file, progress) {
+ return file.previewTemplate.querySelector(".progress .upload").style.width = "" + progress + "%";
+ },
+ sending: noop,
+ success: function(file) {
+ return file.previewTemplate.classList.add("success");
+ },
+ complete: noop,
+ previewTemplate: "<div class=\"preview file-preview\">\n <div class=\"details\">\n <div class=\"filename\"><span></span></div>\n </div>\n <div class=\"progress\"><span class=\"upload\"></span></div>\n <div class=\"success-mark\"><span>✔</span></div>\n <div class=\"error-mark\"><span>✘</span></div>\n <div class=\"error-message\"><span></span></div>\n</div>"
+ };
+
+ function Dropzone(element, options) {
+ var elementId, elementOptions, extend, fallback, _ref;
+
+ this.element = element;
+ this.version = Dropzone.version;
+ this.defaultOptions.previewTemplate = this.defaultOptions.previewTemplate.replace(/\n*/g, "");
+ if (typeof this.element === "string") {
+ this.element = document.querySelector(this.element);
+ }
+ if (!(this.element && (this.element.nodeType != null))) {
+ throw new Error("Invalid dropzone element.");
+ }
+ if (Dropzone.forElement(this.element)) {
+ throw new Error("Dropzone already attached.");
+ }
+ Dropzone.instances.push(this);
+ elementId = this.element.id;
+ elementOptions = (_ref = (elementId ? Dropzone.options[camelize(elementId)] : void 0)) != null ? _ref : {};
+ extend = function() {
+ var key, object, objects, target, val, _i, _len;
+
+ target = arguments[0], objects = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
+ for (_i = 0, _len = objects.length; _i < _len; _i++) {
+ object = objects[_i];
+ for (key in object) {
+ val = object[key];
+ target[key] = val;
+ }
+ }
+ return target;
+ };
+ this.options = extend({}, this.defaultOptions, elementOptions, options != null ? options : {});
+ if (this.options.url == null) {
+ this.options.url = this.element.action;
+ }
+ if (!this.options.url) {
+ throw new Error("No URL provided.");
+ }
+ this.options.method = this.options.method.toUpperCase();
+ if (!Dropzone.isBrowserSupported()) {
+ return this.options.fallback.call(this);
+ }
+ if ((fallback = this.getExistingFallback()) && fallback.parentNode) {
+ fallback.parentNode.removeChild(fallback);
+ }
+ if (this.options.previewsContainer) {
+ if (typeof this.options.previewsContainer === "string") {
+ this.previewsContainer = document.querySelector(this.options.previewsContainer);
+ } else if (this.options.previewsContainer.nodeType != null) {
+ this.previewsContainer = this.options.previewsContainer;
+ }
+ if (this.previewsContainer == null) {
+ throw new Error("Invalid `previewsContainer` option provided. Please provide a CSS selector or a plain HTML element.");
+ }
+ } else {
+ this.previewsContainer = this.element;
+ }
+ this.init();
+ }
+
+ Dropzone.prototype.init = function() {
+ var eventName, noPropagation, _i, _len, _ref, _ref1,
+ _this = this;
+
+ if (this.element.tagName === "form") {
+ this.element.setAttribute("enctype", "multipart/form-data");
+ }
+ if (this.element.classList.contains("dropzone") && !this.element.querySelector(".message")) {
+ this.element.appendChild(createElement("<div class=\"default message\"><span>" + this.options.dictDefaultMessage + "</span></div>"));
+ }
+ if (this.options.clickable) {
+ this.hiddenFileInput = document.createElement("input");
+ this.hiddenFileInput.setAttribute("type", "file");
+ this.hiddenFileInput.setAttribute("multiple", "multiple");
+ this.hiddenFileInput.style.display = "none";
+ document.body.appendChild(this.hiddenFileInput);
+ this.hiddenFileInput.addEventListener("change", function() {
+ var files;
+
+ files = _this.hiddenFileInput.files;
+ if (files.length) {
+ _this.emit("selectedfiles", files);
+ return _this.handleFiles(files);
+ }
+ });
+ }
+ this.files = [];
+ this.filesQueue = [];
+ this.filesProcessing = [];
+ this.URL = (_ref = window.URL) != null ? _ref : window.webkitURL;
+ _ref1 = this.events;
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
+ eventName = _ref1[_i];
+ this.on(eventName, this.options[eventName]);
+ }
+ noPropagation = function(e) {
+ e.stopPropagation();
+ if (e.preventDefault) {
+ return e.preventDefault();
+ } else {
+ return e.returnValue = false;
+ }
+ };
+ this.listeners = {
+ "dragstart": function(e) {
+ return _this.emit("dragstart", e);
+ },
+ "dragenter": function(e) {
+ noPropagation(e);
+ return _this.emit("dragenter", e);
+ },
+ "dragover": function(e) {
+ noPropagation(e);
+ return _this.emit("dragover", e);
+ },
+ "dragleave": function(e) {
+ return _this.emit("dragleave", e);
+ },
+ "drop": function(e) {
+ noPropagation(e);
+ _this.drop(e);
+ return _this.emit("drop", e);
+ },
+ "dragend": function(e) {
+ return _this.emit("dragend", e);
+ },
+ "click": function(evt) {
+ if (!_this.options.clickable) {
+ return;
+ }
+ if (evt.target === _this.element || evt.target === _this.element.querySelector(".message")) {
+ return _this.hiddenFileInput.click();
+ }
+ }
+ };
+ this.enable();
+ return this.options.init.call(this);
+ };
+
+ Dropzone.prototype.getFallbackForm = function() {
+ var existingFallback, fields, fieldsString, form;
+
+ if (existingFallback = this.getExistingFallback()) {
+ return existingFallback;
+ }
+ fieldsString = "<div class=\"fallback\">";
+ if (this.options.dictFallbackText) {
+ fieldsString += "<p>" + this.options.dictFallbackText + "</p>";
+ }
+ fieldsString += "<input type=\"file\" name=\"" + this.options.paramName + "\" multiple=\"multiple\" /><button type=\"submit\">Upload!</button></div>";
+ fields = createElement(fieldsString);
+ if (this.element.tagName !== "FORM") {
+ form = createElement("<form action=\"" + this.options.url + "\" enctype=\"multipart/form-data\" method=\"" + this.options.method + "\"></form>");
+ form.appendChild(fields);
+ } else {
+ this.element.setAttribute("enctype", "multipart/form-data");
+ this.element.setAttribute("method", this.options.method);
+ }
+ return form != null ? form : fields;
+ };
+
+ Dropzone.prototype.getExistingFallback = function() {
+ var fallback, getFallback, tagName, _i, _len, _ref;
+
+ getFallback = function(elements) {
+ var el, _i, _len;
+
+ for (_i = 0, _len = elements.length; _i < _len; _i++) {
+ el = elements[_i];
+ if (/(^| )fallback($| )/.test(el.className)) {
+ return el;
+ }
+ }
+ };
+ _ref = ["div", "form"];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ tagName = _ref[_i];
+ if (fallback = getFallback(this.element.getElementsByTagName("div"))) {
+ return fallback;
+ }
+ }
+ };
+
+ Dropzone.prototype.setupEventListeners = function() {
+ var event, listener, _ref, _results;
+
+ _ref = this.listeners;
+ _results = [];
+ for (event in _ref) {
+ listener = _ref[event];
+ _results.push(this.element.addEventListener(event, listener, false));
+ }
+ return _results;
+ };
+
+ Dropzone.prototype.removeEventListeners = function() {
+ var event, listener, _ref, _results;
+
+ _ref = this.listeners;
+ _results = [];
+ for (event in _ref) {
+ listener = _ref[event];