update dropzone
This commit is contained in:
parent
5364810e93
commit
d649e1649d
@ -10,9 +10,9 @@ compass_config do |config|
|
||||
config.output_style = :compact
|
||||
end
|
||||
|
||||
configure :build do
|
||||
ignore "source/images/companies/*.png"
|
||||
end
|
||||
#configure :build do
|
||||
# ignore "source/images/companies/*.png"
|
||||
#end
|
||||
|
||||
##
|
||||
# Slim
|
||||
|
@ -1,5 +1,6 @@
|
||||
== javascript_include_tag "dropzone.js"
|
||||
|
||||
h1 Inbox
|
||||
p All uploaded files are sent to us
|
||||
p
|
||||
form#my-awesome-dropzone.dropzone.clickable action="/upload"
|
||||
|
@ -368,8 +368,6 @@ module.exports = require("./lib/dropzone.js");
|
||||
|
||||
});
|
||||
require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
||||
// Generated by CoffeeScript 1.4.0
|
||||
|
||||
/*
|
||||
#
|
||||
# More info at [www.dropzonejs.com](http://www.dropzonejs.com)
|
||||
@ -401,22 +399,22 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
||||
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;
|
||||
__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.
|
||||
This is a list of all available events you can register on a dropzone object.
|
||||
|
||||
You can register an event handler like this:
|
||||
You can register an event handler like this:
|
||||
|
||||
dropzone.on("dragEnter", function() { });
|
||||
dropzone.on("dragEnter", function() { });
|
||||
*/
|
||||
|
||||
|
||||
@ -424,6 +422,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
||||
|
||||
Dropzone.prototype.defaultOptions = {
|
||||
url: null,
|
||||
method: "post",
|
||||
parallelUploads: 2,
|
||||
maxFilesize: 256,
|
||||
paramName: "file",
|
||||
@ -446,6 +445,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
||||
},
|
||||
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++) {
|
||||
@ -467,12 +467,12 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
||||
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.
|
||||
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) {
|
||||
@ -533,6 +533,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
||||
|
||||
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, "");
|
||||
@ -550,6 +551,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
||||
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];
|
||||
@ -567,19 +569,32 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
||||
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);
|
||||
}
|
||||
this.previewsContainer = this.options.previewsContainer ? createElement(this.options.previewsContainer) : this.element;
|
||||
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");
|
||||
}
|
||||
@ -594,6 +609,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
||||
document.body.appendChild(this.hiddenFileInput);
|
||||
this.hiddenFileInput.addEventListener("change", function() {
|
||||
var files;
|
||||
|
||||
files = _this.hiddenFileInput.files;
|
||||
if (files.length) {
|
||||
_this.emit("selectedfiles", files);
|
||||
@ -656,6 +672,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
||||
|
||||
Dropzone.prototype.getFallbackForm = function() {
|
||||
var existingFallback, fields, fieldsString, form;
|
||||
|
||||
if (existingFallback = this.getExistingFallback()) {
|
||||
return existingFallback;
|
||||
}
|
||||
@ -666,19 +683,21 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
||||
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=\"post\"></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", "post");
|
||||
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)) {
|
||||
@ -697,6 +716,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
||||
|
||||
Dropzone.prototype.setupEventListeners = function() {
|
||||
var event, listener, _ref, _results;
|
||||
|
||||
_ref = this.listeners;
|
||||
_results = [];
|
||||
for (event in _ref) {
|
||||
@ -708,6 +728,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
||||
|
||||
Dropzone.prototype.removeEventListeners = function() {
|
||||
var event, listener, _ref, _results;
|
||||
|
||||
_ref = this.listeners;
|
||||
_results = [];
|
||||
for (event in _ref) {
|
||||
@ -735,6 +756,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
||||
|
||||
Dropzone.prototype.filesize = function(size) {
|
||||
var string;
|
||||
|
||||
if (size >= 100000000000) {
|
||||
size = size / 100000000000;
|
||||
string = "TB";
|
||||
@ -756,6 +778,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
||||
|
||||
Dropzone.prototype.drop = function(e) {
|
||||
var files;
|
||||
|
||||
if (!e.dataTransfer) {
|
||||
return;
|
||||
}
|
||||
@ -768,6 +791,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
||||
|
||||
Dropzone.prototype.handleFiles = function(files) {
|
||||
var file, _i, _len, _results;
|
||||
|
||||
_results = [];
|
||||
for (_i = 0, _len = files.length; _i < _len; _i++) {
|
||||
file = files[_i];
|
||||
@ -786,6 +810,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
||||
|
||||
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) {
|
||||
@ -815,15 +840,31 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
||||
}
|
||||
};
|
||||
|
||||
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;
|
||||
@ -865,6 +906,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
||||
|
||||
Dropzone.prototype.processQueue = function() {
|
||||
var i, parallelUploads, processingLength;
|
||||
|
||||
parallelUploads = this.options.parallelUploads;
|
||||
processingLength = this.filesProcessing.length;
|
||||
i = processingLength;
|
||||
@ -887,13 +929,15 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
||||
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("POST", this.options.url, true);
|
||||
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 {
|
||||
@ -924,7 +968,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
||||
formData.append(key, value);
|
||||
}
|
||||
}
|
||||
if (this.element.tagName = "FORM") {
|
||||
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];
|
||||
@ -961,7 +1005,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
||||
|
||||
})(Em);
|
||||
|
||||
Dropzone.version = "2.0.3";
|
||||
Dropzone.version = "2.0.10";
|
||||
|
||||
Dropzone.options = {};
|
||||
|
||||
@ -969,6 +1013,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
||||
|
||||
Dropzone.forElement = function(element) {
|
||||
var instance, _i, _len, _ref;
|
||||
|
||||
if (typeof element === "string") {
|
||||
element = document.querySelector(element);
|
||||
}
|
||||
@ -986,8 +1031,9 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
||||
|
||||
Dropzone.isBrowserSupported = function() {
|
||||
var capableBrowser, regex, _i, _len, _ref;
|
||||
|
||||
capableBrowser = true;
|
||||
if (window.File && window.FileReader && window.FileList && window.Blob && window.FormData) {
|
||||
if (window.File && window.FileReader && window.FileList && window.Blob && window.FormData && document.querySelector) {
|
||||
if (!("classList" in document.createElement("a"))) {
|
||||
capableBrowser = false;
|
||||
} else {
|
||||
@ -1008,6 +1054,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
||||
|
||||
without = function(list, rejectedItem) {
|
||||
var item, _i, _len, _results;
|
||||
|
||||
_results = [];
|
||||
for (_i = 0, _len = list.length; _i < _len; _i++) {
|
||||
item = list[_i];
|
||||
@ -1026,6 +1073,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
||||
|
||||
createElement = function(string) {
|
||||
var div;
|
||||
|
||||
div = document.createElement("div");
|
||||
div.innerHTML = string;
|
||||
return div.childNodes[0];
|
||||
@ -1047,6 +1095,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
||||
|
||||
contentLoaded = function(win, fn) {
|
||||
var add, doc, done, init, poll, pre, rem, root, top;
|
||||
|
||||
done = false;
|
||||
top = true;
|
||||
doc = win.document;
|
||||
@ -1064,9 +1113,12 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
||||
}
|
||||
};
|
||||
poll = function() {
|
||||
var e;
|
||||
|
||||
try {
|
||||
root.doScroll("left");
|
||||
} catch (e) {
|
||||
} catch (_error) {
|
||||
e = _error;
|
||||
setTimeout(poll, 50);
|
||||
return;
|
||||
}
|
||||
@ -1089,12 +1141,14 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
|
||||
|
||||
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];
|
||||
|
Loading…
Reference in New Issue
Block a user