Comparing version 1.0.0 to 3.7.4
1535
lib/dropzone.js
@@ -1,208 +0,650 @@ | ||
// Generated by CoffeeScript 1.3.3 | ||
/* | ||
# | ||
# 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, bean, noOp, without, | ||
var Dropzone, Em, camelize, contentLoaded, 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; | ||
$ = ender; | ||
Em = typeof Emitter !== "undefined" && Emitter !== null ? Emitter : require("emitter"); | ||
$.ender({ | ||
dropzone: function(options) { | ||
var element, _i, _len, _results; | ||
_results = []; | ||
for (_i = 0, _len = this.length; _i < _len; _i++) { | ||
element = this[_i]; | ||
_results.push(new Dropzone(element, options)); | ||
} | ||
return _results; | ||
} | ||
}, true); | ||
noop = function() {}; | ||
$.domReady(function() { | ||
return $(".dropzone").dropzone(); | ||
}); | ||
Dropzone = (function(_super) { | ||
var extend; | ||
bean = require("bean"); | ||
__extends(Dropzone, _super); | ||
noOp = function() {}; | ||
Dropzone = (function() { | ||
var defaultOptions; | ||
Dropzone.prototype.version = "1.0.0"; | ||
/* | ||
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: | ||
var bean = require("bean"); | ||
bean.add(dropzone, "dragEnter", function() { }); | ||
dropzone.on("dragEnter", function() { }); | ||
*/ | ||
Dropzone.prototype.events = ["fallback", "drop", "dragstart", "dragend", "dragenter", "dragover", "dragleave", "addedfile", "thumbnail", "error", "processingfile", "uploadprogress", "finished"]; | ||
Dropzone.prototype.events = ["drop", "dragstart", "dragend", "dragenter", "dragover", "dragleave", "selectedfiles", "addedfile", "removedfile", "thumbnail", "error", "errormultiple", "processing", "processingmultiple", "uploadprogress", "totaluploadprogress", "sending", "sendingmultiple", "success", "successmultiple", "canceled", "canceledmultiple", "complete", "completemultiple", "reset", "maxfilesexceeded", "maxfilesreached"]; | ||
defaultOptions = { | ||
Dropzone.prototype.defaultOptions = { | ||
url: null, | ||
method: "post", | ||
withCredentials: false, | ||
parallelUploads: 2, | ||
uploadMultiple: false, | ||
maxFilesize: 256, | ||
paramName: "file", | ||
createImageThumbnails: true, | ||
maxThumbnailFilesize: 2, | ||
maxThumbnailFilesize: 10, | ||
thumbnailWidth: 100, | ||
thumbnailHeight: 100, | ||
accept: function(file) { | ||
return true; | ||
maxFiles: null, | ||
params: {}, | ||
clickable: true, | ||
ignoreHiddenFiles: true, | ||
acceptedFiles: null, | ||
acceptedMimeTypes: null, | ||
autoProcessQueue: true, | ||
addRemoveLinks: false, | ||
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.", | ||
dictFileTooBig: "File is too big ({{filesize}}MB). Max filesize: {{maxFilesize}}MB.", | ||
dictInvalidFileType: "You can't upload files of this type.", | ||
dictResponseError: "Server responded with {{statusCode}} code.", | ||
dictCancelUpload: "Cancel upload", | ||
dictCancelUploadConfirmation: "Are you sure you want to cancel this upload?", | ||
dictRemoveFile: "Remove file", | ||
dictRemoveFileConfirmation: null, | ||
dictMaxFilesExceeded: "You can not upload any more files.", | ||
accept: function(file, done) { | ||
return done(); | ||
}, | ||
init: function() { | ||
return noop; | ||
}, | ||
forceFallback: false, | ||
fallback: function() { | ||
var child, messageElement, span, _i, _len, _ref; | ||
this.element.className = "" + this.element.className + " dz-browser-not-supported"; | ||
_ref = this.element.getElementsByTagName("div"); | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
child = _ref[_i]; | ||
if (/(^| )dz-message($| )/.test(child.className)) { | ||
messageElement = child; | ||
child.className = "dz-message"; | ||
continue; | ||
} | ||
} | ||
if (!messageElement) { | ||
messageElement = Dropzone.createElement("<div class=\"dz-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()); | ||
}, | ||
resize: function(file) { | ||
var info, srcRatio, trgRatio; | ||
info = { | ||
srcX: 0, | ||
srcY: 0, | ||
srcWidth: file.width, | ||
srcHeight: file.height | ||
}; | ||
srcRatio = file.width / file.height; | ||
trgRatio = this.options.thumbnailWidth / this.options.thumbnailHeight; | ||
if (file.height < this.options.thumbnailHeight || file.width < this.options.thumbnailWidth) { | ||
info.trgHeight = info.srcHeight; | ||
info.trgWidth = info.srcWidth; | ||
} else { | ||
if (srcRatio > trgRatio) { | ||
info.srcHeight = file.height; | ||
info.srcWidth = info.srcHeight * trgRatio; | ||
} else { | ||
info.srcWidth = file.width; | ||
info.srcHeight = info.srcWidth / trgRatio; | ||
} | ||
} | ||
info.srcX = (file.width - info.srcWidth) / 2; | ||
info.srcY = (file.height - info.srcHeight) / 2; | ||
return info; | ||
}, | ||
/* | ||
Those functions register themselves to the events on init. | ||
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. | ||
*/ | ||
fallback: function() { | ||
this.element.addClass("browser-not-supported"); | ||
this.element.find(".message span").html("Your browser does not support drag'n'drop file uploads."); | ||
this.element.append("<p>Sadly your dusty browser does not support nice drag'n'drop file uploads.<br />Please use the fallback form below to upload your files like in the olden days.</p>"); | ||
return this.element.append(this.getFallbackForm()); | ||
}, | ||
drop: function(e) { | ||
this.element.removeClass("drag-hover"); | ||
return this.element.addClass("started"); | ||
return this.element.classList.remove("dz-drag-hover"); | ||
}, | ||
dragstart: function(e) {}, | ||
dragstart: noop, | ||
dragend: function(e) { | ||
return this.element.removeClass("drag-hover"); | ||
return this.element.classList.remove("dz-drag-hover"); | ||
}, | ||
dragenter: function(e) { | ||
return this.element.addClass("drag-hover"); | ||
return this.element.classList.add("dz-drag-hover"); | ||
}, | ||
dragover: function(e) { | ||
return this.element.addClass("drag-hover"); | ||
return this.element.classList.add("dz-drag-hover"); | ||
}, | ||
dragleave: function(e) { | ||
return this.element.removeClass("drag-hover"); | ||
return this.element.classList.remove("dz-drag-hover"); | ||
}, | ||
selectedfiles: function(files) { | ||
if (this.element === this.previewsContainer) { | ||
return this.element.classList.add("dz-started"); | ||
} | ||
}, | ||
reset: function() { | ||
return this.element.classList.remove("dz-started"); | ||
}, | ||
addedfile: function(file) { | ||
file.previewTemplate = $(this.options.previewTemplate); | ||
this.element.append(file.previewTemplate); | ||
file.previewTemplate.find(".filename span").text(file.name); | ||
return file.previewTemplate.find(".details").append($("<div class=\"size\">" + (this.filesize(file.size)) + "</div>")); | ||
var node, _i, _j, _len, _len1, _ref, _ref1, | ||
_this = this; | ||
file.previewElement = Dropzone.createElement(this.options.previewTemplate.trim()); | ||
file.previewTemplate = file.previewElement; | ||
this.previewsContainer.appendChild(file.previewElement); | ||
_ref = file.previewElement.querySelectorAll("[data-dz-name]"); | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
node = _ref[_i]; | ||
node.textContent = file.name; | ||
} | ||
_ref1 = file.previewElement.querySelectorAll("[data-dz-size]"); | ||
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { | ||
node = _ref1[_j]; | ||
node.innerHTML = this.filesize(file.size); | ||
} | ||
if (this.options.addRemoveLinks) { | ||
file._removeLink = Dropzone.createElement("<a class=\"dz-remove\" href=\"javascript:undefined;\">" + this.options.dictRemoveFile + "</a>"); | ||
file._removeLink.addEventListener("click", function(e) { | ||
e.preventDefault(); | ||
e.stopPropagation(); | ||
if (file.status === Dropzone.UPLOADING) { | ||
return Dropzone.confirm(_this.options.dictCancelUploadConfirmation, function() { | ||
return _this.removeFile(file); | ||
}); | ||
} else { | ||
if (_this.options.dictRemoveFileConfirmation) { | ||
return Dropzone.confirm(_this.options.dictRemoveFileConfirmation, function() { | ||
return _this.removeFile(file); | ||
}); | ||
} else { | ||
return _this.removeFile(file); | ||
} | ||
} | ||
}); | ||
return file.previewElement.appendChild(file._removeLink); | ||
} | ||
}, | ||
removedfile: function(file) { | ||
var _ref; | ||
if ((_ref = file.previewElement) != null) { | ||
_ref.parentNode.removeChild(file.previewElement); | ||
} | ||
return this._updateMaxFilesReachedClass(); | ||
}, | ||
thumbnail: function(file, dataUrl) { | ||
file.previewTemplate.removeClass("file-preview").addClass("image-preview"); | ||
return file.previewTemplate.find(".details").append($("<img alt=\"" + file.name + "\" src=\"" + dataUrl + "\"/>")); | ||
var thumbnailElement, _i, _len, _ref, _results; | ||
file.previewElement.classList.remove("dz-file-preview"); | ||
file.previewElement.classList.add("dz-image-preview"); | ||
_ref = file.previewElement.querySelectorAll("[data-dz-thumbnail]"); | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
thumbnailElement = _ref[_i]; | ||
thumbnailElement.alt = file.name; | ||
_results.push(thumbnailElement.src = dataUrl); | ||
} | ||
return _results; | ||
}, | ||
error: function(file, message) { | ||
file.previewTemplate.addClass("error"); | ||
return file.previewTemplate.find(".error-message span").text(message); | ||
var node, _i, _len, _ref, _results; | ||
file.previewElement.classList.add("dz-error"); | ||
if (typeof message !== "String" && message.error) { | ||
message = message.error; | ||
} | ||
_ref = file.previewElement.querySelectorAll("[data-dz-errormessage]"); | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
node = _ref[_i]; | ||
_results.push(node.textContent = message); | ||
} | ||
return _results; | ||
}, | ||
processingfile: function(file) { | ||
return file.previewTemplate.addClass("processing"); | ||
errormultiple: noop, | ||
processing: function(file) { | ||
file.previewElement.classList.add("dz-processing"); | ||
if (file._removeLink) { | ||
return file._removeLink.textContent = this.options.dictCancelUpload; | ||
} | ||
}, | ||
uploadprogress: function(file, progress) { | ||
return file.previewTemplate.find(".progress .upload").css({ | ||
width: "" + progress + "%" | ||
}); | ||
processingmultiple: noop, | ||
uploadprogress: function(file, progress, bytesSent) { | ||
var node, _i, _len, _ref, _results; | ||
_ref = file.previewElement.querySelectorAll("[data-dz-uploadprogress]"); | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
node = _ref[_i]; | ||
_results.push(node.style.width = "" + progress + "%"); | ||
} | ||
return _results; | ||
}, | ||
finished: function(file) { | ||
return file.previewTemplate.addClass("success"); | ||
totaluploadprogress: noop, | ||
sending: noop, | ||
sendingmultiple: noop, | ||
success: function(file) { | ||
return file.previewElement.classList.add("dz-success"); | ||
}, | ||
previewTemplate: "<div class=\"preview file-preview\">\n <div class=\"details\"></div>\n <div class=\"progress\"><span class=\"load\"></span><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 class=\"filename\"><span></span></div>\n</div>" | ||
successmultiple: noop, | ||
canceled: function(file) { | ||
return this.emit("error", file, "Upload canceled."); | ||
}, | ||
canceledmultiple: noop, | ||
complete: function(file) { | ||
if (file._removeLink) { | ||
return file._removeLink.textContent = this.options.dictRemoveFile; | ||
} | ||
}, | ||
completemultiple: noop, | ||
maxfilesexceeded: noop, | ||
maxfilesreached: noop, | ||
previewTemplate: "<div class=\"dz-preview dz-file-preview\">\n <div class=\"dz-details\">\n <div class=\"dz-filename\"><span data-dz-name></span></div>\n <div class=\"dz-size\" data-dz-size></div>\n <img data-dz-thumbnail />\n </div>\n <div class=\"dz-progress\"><span class=\"dz-upload\" data-dz-uploadprogress></span></div>\n <div class=\"dz-success-mark\"><span>✔</span></div>\n <div class=\"dz-error-mark\"><span>✘</span></div>\n <div class=\"dz-error-message\"><span data-dz-errormessage></span></div>\n</div>" | ||
}; | ||
defaultOptions.previewTemplate = defaultOptions.previewTemplate.replace(/\n*/g, ""); | ||
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; | ||
}; | ||
function Dropzone(element, options) { | ||
var extend; | ||
this.element = $(element); | ||
if (this.element.length !== 1) { | ||
throw new Error("You can only instantiate dropzone on a single element."); | ||
var elementOptions, fallback, _ref; | ||
this.element = element; | ||
this.version = Dropzone.version; | ||
this.defaultOptions.previewTemplate = this.defaultOptions.previewTemplate.replace(/\n*/g, ""); | ||
this.clickableElements = []; | ||
this.listeners = []; | ||
this.files = []; | ||
if (typeof this.element === "string") { | ||
this.element = document.querySelector(this.element); | ||
} | ||
if (this.element.data("dropzone")) { | ||
if (!(this.element && (this.element.nodeType != null))) { | ||
throw new Error("Invalid dropzone element."); | ||
} | ||
if (this.element.dropzone) { | ||
throw new Error("Dropzone already attached."); | ||
} | ||
this.element.data("dropzone", this); | ||
this.elementTagName = this.element.get(0).tagName; | ||
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({}, defaultOptions, options != null ? options : {}); | ||
Dropzone.instances.push(this); | ||
this.element.dropzone = this; | ||
elementOptions = (_ref = Dropzone.optionsForElement(this.element)) != null ? _ref : {}; | ||
this.options = extend({}, this.defaultOptions, elementOptions, options != null ? options : {}); | ||
if (this.options.forceFallback || !Dropzone.isBrowserSupported()) { | ||
return this.options.fallback.call(this); | ||
} | ||
if (this.options.url == null) { | ||
this.options.url = this.element.attr("action"); | ||
this.options.url = this.element.getAttribute("action"); | ||
} | ||
if (!this.options.url) { | ||
throw new Error("No URL provided."); | ||
} | ||
if (this.options.acceptedFiles && this.options.acceptedMimeTypes) { | ||
throw new Error("You can't provide both 'acceptedFiles' and 'acceptedMimeTypes'. 'acceptedMimeTypes' is deprecated."); | ||
} | ||
if (this.options.acceptedMimeTypes) { | ||
this.options.acceptedFiles = this.options.acceptedMimeTypes; | ||
delete this.options.acceptedMimeTypes; | ||
} | ||
this.options.method = this.options.method.toUpperCase(); | ||
if ((fallback = this.getExistingFallback()) && fallback.parentNode) { | ||
fallback.parentNode.removeChild(fallback); | ||
} | ||
if (this.options.previewsContainer) { | ||
this.previewsContainer = Dropzone.getElement(this.options.previewsContainer, "previewsContainer"); | ||
} else { | ||
this.previewsContainer = this.element; | ||
} | ||
if (this.options.clickable) { | ||
if (this.options.clickable === true) { | ||
this.clickableElements = [this.element]; | ||
} else { | ||
this.clickableElements = Dropzone.getElements(this.options.clickable, "clickable"); | ||
} | ||
} | ||
this.init(); | ||
} | ||
Dropzone.prototype.getAcceptedFiles = function() { | ||
var file, _i, _len, _ref, _results; | ||
_ref = this.files; | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
file = _ref[_i]; | ||
if (file.accepted) { | ||
_results.push(file); | ||
} | ||
} | ||
return _results; | ||
}; | ||
Dropzone.prototype.getRejectedFiles = function() { | ||
var file, _i, _len, _ref, _results; | ||
_ref = this.files; | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
file = _ref[_i]; | ||
if (!file.accepted) { | ||
_results.push(file); | ||
} | ||
} | ||
return _results; | ||
}; | ||
Dropzone.prototype.getQueuedFiles = function() { | ||
var file, _i, _len, _ref, _results; | ||
_ref = this.files; | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
file = _ref[_i]; | ||
if (file.status === Dropzone.QUEUED) { | ||
_results.push(file); | ||
} | ||
} | ||
return _results; | ||
}; | ||
Dropzone.prototype.getUploadingFiles = function() { | ||
var file, _i, _len, _ref, _results; | ||
_ref = this.files; | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
file = _ref[_i]; | ||
if (file.status === Dropzone.UPLOADING) { | ||
_results.push(file); | ||
} | ||
} | ||
return _results; | ||
}; | ||
Dropzone.prototype.init = function() { | ||
var _ref; | ||
if (this.elementTagName === "form" && this.element.attr("enctype") !== "multipart/form-data") { | ||
this.element.attr("enctype", "multipart/form-data"); | ||
var eventName, noPropagation, setupHiddenFileInput, _i, _len, _ref, _ref1, | ||
_this = this; | ||
if (this.element.tagName === "form") { | ||
this.element.setAttribute("enctype", "multipart/form-data"); | ||
} | ||
if (this.element.find(".message").length === 0) { | ||
this.element.append($("<div class=\"message\"><span>Drop files here to upload</span></div>")); | ||
if (this.element.classList.contains("dropzone") && !this.element.querySelector(".dz-message")) { | ||
this.element.appendChild(Dropzone.createElement("<div class=\"dz-default dz-message\"><span>" + this.options.dictDefaultMessage + "</span></div>")); | ||
} | ||
if (!(window.File && window.FileReader && window.FileList && window.Blob && window.FormData)) { | ||
this.options.fallback.call(this); | ||
return; | ||
if (this.clickableElements.length) { | ||
setupHiddenFileInput = function() { | ||
if (_this.hiddenFileInput) { | ||
document.body.removeChild(_this.hiddenFileInput); | ||
} | ||
_this.hiddenFileInput = document.createElement("input"); | ||
_this.hiddenFileInput.setAttribute("type", "file"); | ||
if ((_this.options.maxFiles == null) || _this.options.maxFiles > 1) { | ||
_this.hiddenFileInput.setAttribute("multiple", "multiple"); | ||
} | ||
if (_this.options.acceptedFiles != null) { | ||
_this.hiddenFileInput.setAttribute("accept", _this.options.acceptedFiles); | ||
} | ||
_this.hiddenFileInput.style.visibility = "hidden"; | ||
_this.hiddenFileInput.style.position = "absolute"; | ||
_this.hiddenFileInput.style.top = "0"; | ||
_this.hiddenFileInput.style.left = "0"; | ||
_this.hiddenFileInput.style.height = "0"; | ||
_this.hiddenFileInput.style.width = "0"; | ||
document.body.appendChild(_this.hiddenFileInput); | ||
return _this.hiddenFileInput.addEventListener("change", function() { | ||
var files; | ||
files = _this.hiddenFileInput.files; | ||
if (files.length) { | ||
_this.emit("selectedfiles", files); | ||
_this.handleFiles(files); | ||
} | ||
return setupHiddenFileInput(); | ||
}); | ||
}; | ||
setupHiddenFileInput(); | ||
} | ||
this.files = []; | ||
this.files.queue = []; | ||
this.files.processing = []; | ||
this.URL = (_ref = window.URL) != null ? _ref : window.webkitURL; | ||
return this.setupEventListeners(); | ||
_ref1 = this.events; | ||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { | ||
eventName = _ref1[_i]; | ||
this.on(eventName, this.options[eventName]); | ||
} | ||
this.on("uploadprogress", function() { | ||
return _this.updateTotalUploadProgress(); | ||
}); | ||
this.on("removedfile", function() { | ||
return _this.updateTotalUploadProgress(); | ||
}); | ||
this.on("canceled", function(file) { | ||
return _this.emit("complete", file); | ||
}); | ||
noPropagation = function(e) { | ||
e.stopPropagation(); | ||
if (e.preventDefault) { | ||
return e.preventDefault(); | ||
} else { | ||
return e.returnValue = false; | ||
} | ||
}; | ||
this.listeners = [ | ||
{ | ||
element: this.element, | ||
events: { | ||
"dragstart": function(e) { | ||
return _this.emit("dragstart", e); | ||
}, | ||
"dragenter": function(e) { | ||
noPropagation(e); | ||
return _this.emit("dragenter", e); | ||
}, | ||
"dragover": function(e) { | ||
var efct; | ||
efct = e.dataTransfer.effectAllowed; | ||
e.dataTransfer.dropEffect = 'move' === efct || 'linkMove' === efct ? 'move' : 'copy'; | ||
noPropagation(e); | ||
return _this.emit("dragover", e); | ||
}, | ||
"dragleave": function(e) { | ||
return _this.emit("dragleave", e); | ||
}, | ||
"drop": function(e) { | ||
noPropagation(e); | ||
return _this.drop(e); | ||
}, | ||
"dragend": function(e) { | ||
return _this.emit("dragend", e); | ||
} | ||
} | ||
} | ||
]; | ||
this.clickableElements.forEach(function(clickableElement) { | ||
return _this.listeners.push({ | ||
element: clickableElement, | ||
events: { | ||
"click": function(evt) { | ||
if ((clickableElement !== _this.element) || (evt.target === _this.element || Dropzone.elementInside(evt.target, _this.element.querySelector(".dz-message")))) { | ||
return _this.hiddenFileInput.click(); | ||
} | ||
} | ||
} | ||
}); | ||
}); | ||
this.enable(); | ||
return this.options.init.call(this); | ||
}; | ||
Dropzone.prototype.destroy = function() { | ||
var _ref; | ||
this.disable(); | ||
this.removeAllFiles(true); | ||
if ((_ref = this.hiddenFileInput) != null ? _ref.parentNode : void 0) { | ||
this.hiddenFileInput.parentNode.removeChild(this.hiddenFileInput); | ||
this.hiddenFileInput = null; | ||
} | ||
delete this.element.dropzone; | ||
return Dropzone.instances.splice(Dropzone.instances.indexOf(this), 1); | ||
}; | ||
Dropzone.prototype.updateTotalUploadProgress = function() { | ||
var acceptedFiles, file, totalBytes, totalBytesSent, totalUploadProgress, _i, _len, _ref; | ||
totalBytesSent = 0; | ||
totalBytes = 0; | ||
acceptedFiles = this.getAcceptedFiles(); | ||
if (acceptedFiles.length) { | ||
_ref = this.getAcceptedFiles(); | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
file = _ref[_i]; | ||
totalBytesSent += file.upload.bytesSent; | ||
totalBytes += file.upload.total; | ||
} | ||
totalUploadProgress = 100 * totalBytesSent / totalBytes; | ||
} else { | ||
totalUploadProgress = 100; | ||
} | ||
return this.emit("totaluploadprogress", totalUploadProgress, totalBytes, totalBytesSent); | ||
}; | ||
Dropzone.prototype.getFallbackForm = function() { | ||
var fields; | ||
fields = $("<div class=\"fallback-elements\"><input type=\"file\" name=\"newFiles\" multiple=\"multiple\" /><button type=\"submit\">Upload!</button></div>"); | ||
if (this.elementTagName !== "FORM") { | ||
fields = $("<form action=\"" + this.options.url + "\" enctype=\"multipart/form-data\" method=\"post\"></form>").append(fields); | ||
var existingFallback, fields, fieldsString, form; | ||
if (existingFallback = this.getExistingFallback()) { | ||
return existingFallback; | ||
} | ||
return fields; | ||
fieldsString = "<div class=\"dz-fallback\">"; | ||
if (this.options.dictFallbackText) { | ||
fieldsString += "<p>" + this.options.dictFallbackText + "</p>"; | ||
} | ||
fieldsString += "<input type=\"file\" name=\"" + this.options.paramName + (this.options.uploadMultiple ? "[]" : "") + "\" " + (this.options.uploadMultiple ? 'multiple="multiple"' : void 0) + " /><input type=\"submit\" value=\"Upload!\"></div>"; | ||
fields = Dropzone.createElement(fieldsString); | ||
if (this.element.tagName !== "FORM") { | ||
form = Dropzone.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(tagName))) { | ||
return fallback; | ||
} | ||
} | ||
}; | ||
Dropzone.prototype.setupEventListeners = function() { | ||
var eventName, noPropagation, _i, _len, _ref, | ||
_this = this; | ||
_ref = this.events; | ||
var elementListeners, event, listener, _i, _len, _ref, _results; | ||
_ref = this.listeners; | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
eventName = _ref[_i]; | ||
bean.add(this, eventName, this.options[eventName]); | ||
elementListeners = _ref[_i]; | ||
_results.push((function() { | ||
var _ref1, _results1; | ||
_ref1 = elementListeners.events; | ||
_results1 = []; | ||
for (event in _ref1) { | ||
listener = _ref1[event]; | ||
_results1.push(elementListeners.element.addEventListener(event, listener, false)); | ||
} | ||
return _results1; | ||
})()); | ||
} | ||
noPropagation = function(e) { | ||
e.stopPropagation(); | ||
return e.preventDefault(); | ||
}; | ||
this.element.on("dragstart", function(e) { | ||
return bean.fire(_this, "dragstart", e); | ||
return _results; | ||
}; | ||
Dropzone.prototype.removeEventListeners = function() { | ||
var elementListeners, event, listener, _i, _len, _ref, _results; | ||
_ref = this.listeners; | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
elementListeners = _ref[_i]; | ||
_results.push((function() { | ||
var _ref1, _results1; | ||
_ref1 = elementListeners.events; | ||
_results1 = []; | ||
for (event in _ref1) { | ||
listener = _ref1[event]; | ||
_results1.push(elementListeners.element.removeEventListener(event, listener, false)); | ||
} | ||
return _results1; | ||
})()); | ||
} | ||
return _results; | ||
}; | ||
Dropzone.prototype.disable = function() { | ||
var file, _i, _len, _ref, _results; | ||
this.clickableElements.forEach(function(element) { | ||
return element.classList.remove("dz-clickable"); | ||
}); | ||
this.element.on("dragenter", function(e) { | ||
noPropagation(e); | ||
return bean.fire(_this, "dragenter", e); | ||
this.removeEventListeners(); | ||
_ref = this.files; | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
file = _ref[_i]; | ||
_results.push(this.cancelUpload(file)); | ||
} | ||
return _results; | ||
}; | ||
Dropzone.prototype.enable = function() { | ||
this.clickableElements.forEach(function(element) { | ||
return element.classList.add("dz-clickable"); | ||
}); | ||
this.element.on("dragover", function(e) { | ||
noPropagation(e); | ||
return bean.fire(_this, "dragover", e); | ||
}); | ||
this.element.on("dragleave", function(e) { | ||
return bean.fire(_this, "dragleave", e); | ||
}); | ||
this.element.on("drop", function(e) { | ||
noPropagation(e); | ||
_this.drop(e); | ||
return bean.fire(_this, "drop", e); | ||
}); | ||
return this.element.on("dragend", function(e) { | ||
return bean.fire(_this, "dragend", e); | ||
}); | ||
return this.setupEventListeners(); | ||
}; | ||
@@ -212,29 +654,47 @@ | ||
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"; | ||
if (size >= 1024 * 1024 * 1024 * 1024 / 10) { | ||
size = size / (1024 * 1024 * 1024 * 1024 / 10); | ||
string = "TiB"; | ||
} else if (size >= 1024 * 1024 * 1024 / 10) { | ||
size = size / (1024 * 1024 * 1024 / 10); | ||
string = "GiB"; | ||
} else if (size >= 1024 * 1024 / 10) { | ||
size = size / (1024 * 1024 / 10); | ||
string = "MiB"; | ||
} else if (size >= 1024 / 10) { | ||
size = size / (1024 / 10); | ||
string = "KiB"; | ||
} else { | ||
size = size * 10; | ||
string = "by"; | ||
string = "b"; | ||
} | ||
return "" + (Math.round(size) / 10) + " " + string; | ||
return "<strong>" + (Math.round(size) / 10) + "</strong> " + string; | ||
}; | ||
Dropzone.prototype._updateMaxFilesReachedClass = function() { | ||
if ((this.options.maxFiles != null) && this.getAcceptedFiles().length >= this.options.maxFiles) { | ||
if (this.getAcceptedFiles().length === this.options.maxFiles) { | ||
this.emit('maxfilesreached', this.files); | ||
} | ||
return this.element.classList.add("dz-max-files-reached"); | ||
} else { | ||
return this.element.classList.remove("dz-max-files-reached"); | ||
} | ||
}; | ||
Dropzone.prototype.drop = function(e) { | ||
var files; | ||
var files, items; | ||
if (!e.dataTransfer) { | ||
return; | ||
} | ||
this.emit("drop", e); | ||
files = e.dataTransfer.files; | ||
this.emit("selectedfiles", files); | ||
if (files.length) { | ||
return this.handleFiles(files); | ||
items = e.dataTransfer.items; | ||
if (items && items.length && ((items[0].webkitGetAsEntry != null) || (items[0].getAsEntry != null))) { | ||
this.handleItems(items); | ||
} else { | ||
this.handleFiles(files); | ||
} | ||
} | ||
@@ -244,86 +704,194 @@ }; | ||
Dropzone.prototype.handleFiles = function(files) { | ||
var file, _i, _len; | ||
var file, _i, _len, _results; | ||
_results = []; | ||
for (_i = 0, _len = files.length; _i < _len; _i++) { | ||
file = files[_i]; | ||
if (this.accept(file)) { | ||
this.addFile(file); | ||
_results.push(this.addFile(file)); | ||
} | ||
return _results; | ||
}; | ||
Dropzone.prototype.handleItems = function(items) { | ||
var entry, item, _i, _len; | ||
for (_i = 0, _len = items.length; _i < _len; _i++) { | ||
item = items[_i]; | ||
if (item.webkitGetAsEntry != null) { | ||
entry = item.webkitGetAsEntry(); | ||
if (entry.isFile) { | ||
this.addFile(item.getAsFile()); | ||
} else if (entry.isDirectory) { | ||
this.addDirectory(entry, entry.name); | ||
} | ||
} else { | ||
this.addFile(item.getAsFile()); | ||
} | ||
} | ||
return this.processQueue(); | ||
}; | ||
Dropzone.prototype.accept = function(file) { | ||
return this.options.accept.call(this, file); | ||
Dropzone.prototype.accept = function(file, done) { | ||
if (file.size > this.options.maxFilesize * 1024 * 1024) { | ||
return done(this.options.dictFileTooBig.replace("{{filesize}}", Math.round(file.size / 1024 / 10.24) / 100).replace("{{maxFilesize}}", this.options.maxFilesize)); | ||
} else if (!Dropzone.isValidFile(file, this.options.acceptedFiles)) { | ||
return done(this.options.dictInvalidFileType); | ||
} else if ((this.options.maxFiles != null) && this.getAcceptedFiles().length >= this.options.maxFiles) { | ||
done(this.options.dictMaxFilesExceeded.replace("{{maxFiles}}", this.options.maxFiles)); | ||
return this.emit("maxfilesexceeded", file); | ||
} else { | ||
return this.options.accept.call(this, file, done); | ||
} | ||
}; | ||
Dropzone.prototype.addFile = function(file) { | ||
var _this = this; | ||
file.upload = { | ||
progress: 0, | ||
total: file.size, | ||
bytesSent: 0 | ||
}; | ||
this.files.push(file); | ||
this.files.queue.push(file); | ||
bean.fire(this, "addedfile", file); | ||
file.status = Dropzone.ADDED; | ||
this.emit("addedfile", file); | ||
if (this.options.createImageThumbnails && file.type.match(/image.*/) && file.size <= this.options.maxThumbnailFilesize * 1024 * 1024) { | ||
return this.createThumbnail(file); | ||
this.createThumbnail(file); | ||
} | ||
return this.accept(file, function(error) { | ||
if (error) { | ||
file.accepted = false; | ||
_this._errorProcessing([file], error); | ||
} else { | ||
_this.enqueueFile(file); | ||
} | ||
return _this._updateMaxFilesReachedClass(); | ||
}); | ||
}; | ||
Dropzone.prototype.createThumbnail = function(file) { | ||
var blobUrl, img, | ||
Dropzone.prototype.enqueueFiles = function(files) { | ||
var file, _i, _len; | ||
for (_i = 0, _len = files.length; _i < _len; _i++) { | ||
file = files[_i]; | ||
this.enqueueFile(file); | ||
} | ||
return null; | ||
}; | ||
Dropzone.prototype.enqueueFile = function(file) { | ||
var _this = this; | ||
file.accepted = true; | ||
if (file.status === Dropzone.ADDED) { | ||
file.status = Dropzone.QUEUED; | ||
if (this.options.autoProcessQueue) { | ||
return setTimeout((function() { | ||
return _this.processQueue(); | ||
}), 1); | ||
} | ||
} else { | ||
throw new Error("This file can't be queued because it has already been processed or was rejected."); | ||
} | ||
}; | ||
Dropzone.prototype.addDirectory = function(entry, path) { | ||
var dirReader, entriesReader, | ||
_this = this; | ||
img = new Image(); | ||
blobUrl = this.URL.createObjectURL(file); | ||
img.onerror = img.onabort = function() { | ||
this.URL.revokeObjectURL(blobUrl); | ||
return img = null; | ||
}; | ||
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; | ||
dirReader = entry.createReader(); | ||
entriesReader = function(entries) { | ||
var _i, _len; | ||
for (_i = 0, _len = entries.length; _i < _len; _i++) { | ||
entry = entries[_i]; | ||
if (entry.isFile) { | ||
entry.file(function(file) { | ||
if (_this.options.ignoreHiddenFiles && file.name.substring(0, 1) === '.') { | ||
return; | ||
} | ||
file.fullPath = "" + path + "/" + file.name; | ||
return _this.addFile(file); | ||
}); | ||
} else if (entry.isDirectory) { | ||
_this.addDirectory(entry, "" + path + "/" + entry.name); | ||
} | ||
} | ||
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"); | ||
bean.fire(_this, "thumbnail", [file, thumbnail]); | ||
_this.URL.revokeObjectURL(blobUrl); | ||
return img = null; | ||
}; | ||
return img.src = blobUrl; | ||
return dirReader.readEntries(entriesReader, function(error) { | ||
return typeof console !== "undefined" && console !== null ? typeof console.log === "function" ? console.log(error) : void 0 : void 0; | ||
}); | ||
}; | ||
Dropzone.prototype.removeFile = function(file) { | ||
if (file.status === Dropzone.UPLOADING) { | ||
this.cancelUpload(file); | ||
} | ||
this.files = without(this.files, file); | ||
this.emit("removedfile", file); | ||
if (this.files.length === 0) { | ||
return this.emit("reset"); | ||
} | ||
}; | ||
Dropzone.prototype.removeAllFiles = function(cancelIfNecessary) { | ||
var file, _i, _len, _ref; | ||
if (cancelIfNecessary == null) { | ||
cancelIfNecessary = false; | ||
} | ||
_ref = this.files.slice(); | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
file = _ref[_i]; | ||
if (file.status !== Dropzone.UPLOADING || cancelIfNecessary) { | ||
this.removeFile(file); | ||
} | ||
} | ||
return null; | ||
}; | ||
Dropzone.prototype.createThumbnail = function(file) { | ||
var fileReader, | ||
_this = this; | ||
fileReader = new FileReader; | ||
fileReader.onload = function() { | ||
var img; | ||
img = document.createElement("img"); | ||
img.onload = function() { | ||
var canvas, ctx, resizeInfo, thumbnail, _ref, _ref1, _ref2, _ref3; | ||
file.width = img.width; | ||
file.height = img.height; | ||
resizeInfo = _this.options.resize.call(_this, file); | ||
if (resizeInfo.trgWidth == null) { | ||
resizeInfo.trgWidth = _this.options.thumbnailWidth; | ||
} | ||
if (resizeInfo.trgHeight == null) { | ||
resizeInfo.trgHeight = _this.options.thumbnailHeight; | ||
} | ||
canvas = document.createElement("canvas"); | ||
ctx = canvas.getContext("2d"); | ||
canvas.width = resizeInfo.trgWidth; | ||
canvas.height = resizeInfo.trgHeight; | ||
ctx.drawImage(img, (_ref = resizeInfo.srcX) != null ? _ref : 0, (_ref1 = resizeInfo.srcY) != null ? _ref1 : 0, resizeInfo.srcWidth, resizeInfo.srcHeight, (_ref2 = resizeInfo.trgX) != null ? _ref2 : 0, (_ref3 = resizeInfo.trgY) != null ? _ref3 : 0, resizeInfo.trgWidth, resizeInfo.trgHeight); | ||
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; | ||
var i, parallelUploads, processingLength, queuedFiles; | ||
parallelUploads = this.options.parallelUploads; | ||
processingLength = this.files.processing.length; | ||
processingLength = this.getUploadingFiles().length; | ||
i = processingLength; | ||
while (i < parallelUploads) { | ||
if (!this.files.queue.length) { | ||
return; | ||
if (processingLength >= parallelUploads) { | ||
return; | ||
} | ||
queuedFiles = this.getQueuedFiles(); | ||
if (!(queuedFiles.length > 0)) { | ||
return; | ||
} | ||
if (this.options.uploadMultiple) { | ||
return this.processFiles(queuedFiles.slice(0, parallelUploads - processingLength)); | ||
} else { | ||
while (i < parallelUploads) { | ||
if (!queuedFiles.length) { | ||
return; | ||
} | ||
this.processFile(queuedFiles.shift()); | ||
i++; | ||
} | ||
this.processFile(this.files.queue.shift()); | ||
i++; | ||
} | ||
@@ -333,71 +901,238 @@ }; | ||
Dropzone.prototype.processFile = function(file) { | ||
var fileReader; | ||
fileReader = new FileReader(); | ||
this.files.processing.push(file); | ||
bean.fire(this, "processingfile", file); | ||
if (file.size > this.options.maxFilesize * 1024 * 1024) { | ||
return this.errorProcessing(file, "File is too big (" + (Math.round(file.size / 1024 / 10.24) / 100) + "MB). Max filesize: " + this.options.maxFilesize + "MB"); | ||
} else { | ||
return this.uploadFile(file); | ||
return this.processFiles([file]); | ||
}; | ||
Dropzone.prototype.processFiles = function(files) { | ||
var file, _i, _len; | ||
for (_i = 0, _len = files.length; _i < _len; _i++) { | ||
file = files[_i]; | ||
file.processing = true; | ||
file.status = Dropzone.UPLOADING; | ||
this.emit("processing", file); | ||
} | ||
if (this.options.uploadMultiple) { | ||
this.emit("processingmultiple", files); | ||
} | ||
return this.uploadFiles(files); | ||
}; | ||
Dropzone.prototype.uploadFile = function(file) { | ||
var formData, handleError, input, inputElement, inputName, progressObj, xhr, _i, _len, _ref, _ref1, | ||
_this = this; | ||
xhr = new XMLHttpRequest(); | ||
formData = new FormData(); | ||
formData.append(this.options.paramName, file); | ||
if (this.elementTagName = "FORM") { | ||
_ref = this.element.find("input, textarea, select, button"); | ||
Dropzone.prototype._getFilesWithXhr = function(xhr) { | ||
var file, files; | ||
return files = (function() { | ||
var _i, _len, _ref, _results; | ||
_ref = this.files; | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
inputElement = _ref[_i]; | ||
input = $(inputElement); | ||
inputName = input.attr("name"); | ||
if (!input.attr("type") || input.attr("type").toLowerCase() !== "checkbox" || inputElement.checked) { | ||
formData.append(input.attr("name"), input.val()); | ||
file = _ref[_i]; | ||
if (file.xhr === xhr) { | ||
_results.push(file); | ||
} | ||
} | ||
return _results; | ||
}).call(this); | ||
}; | ||
Dropzone.prototype.cancelUpload = function(file) { | ||
var groupedFile, groupedFiles, _i, _j, _len, _len1, _ref; | ||
if (file.status === Dropzone.UPLOADING) { | ||
groupedFiles = this._getFilesWithXhr(file.xhr); | ||
for (_i = 0, _len = groupedFiles.length; _i < _len; _i++) { | ||
groupedFile = groupedFiles[_i]; | ||
groupedFile.status = Dropzone.CANCELED; | ||
} | ||
file.xhr.abort(); | ||
for (_j = 0, _len1 = groupedFiles.length; _j < _len1; _j++) { | ||
groupedFile = groupedFiles[_j]; | ||
this.emit("canceled", groupedFile); | ||
} | ||
if (this.options.uploadMultiple) { | ||
this.emit("canceledmultiple", groupedFiles); | ||
} | ||
} else if ((_ref = file.status) === Dropzone.ADDED || _ref === Dropzone.QUEUED) { | ||
file.status = Dropzone.CANCELED; | ||
this.emit("canceled", file); | ||
if (this.options.uploadMultiple) { | ||
this.emit("canceledmultiple", [file]); | ||
} | ||
} | ||
xhr.open("POST", this.options.url, true); | ||
if (this.options.autoProcessQueue) { | ||
return this.processQueue(); | ||
} | ||
}; | ||
Dropzone.prototype.uploadFile = function(file) { | ||
return this.uploadFiles([file]); | ||
}; | ||
Dropzone.prototype.uploadFiles = function(files) { | ||
var file, formData, handleError, headerName, headerValue, headers, input, inputName, inputType, key, option, progressObj, response, updateProgress, value, xhr, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _ref, _ref1, _ref2, _ref3, _ref4, | ||
_this = this; | ||
xhr = new XMLHttpRequest(); | ||
for (_i = 0, _len = files.length; _i < _len; _i++) { | ||
file = files[_i]; | ||
file.xhr = xhr; | ||
} | ||
xhr.open(this.options.method, this.options.url, true); | ||
xhr.withCredentials = !!this.options.withCredentials; | ||
response = null; | ||
handleError = function() { | ||
return _this.errorProcessing(file, xhr.responseText || ("Server responded with " + xhr.status + " code.")); | ||
var _j, _len1, _results; | ||
_results = []; | ||
for (_j = 0, _len1 = files.length; _j < _len1; _j++) { | ||
file = files[_j]; | ||
_results.push(_this._errorProcessing(files, response || _this.options.dictResponseError.replace("{{statusCode}}", xhr.status), xhr)); | ||
} | ||
return _results; | ||
}; | ||
updateProgress = function(e) { | ||
var allFilesFinished, progress, _j, _k, _l, _len1, _len2, _len3, _results; | ||
if (e != null) { | ||
progress = 100 * e.loaded / e.total; | ||
for (_j = 0, _len1 = files.length; _j < _len1; _j++) { | ||
file = files[_j]; | ||
file.upload = { | ||
progress: progress, | ||
total: e.total, | ||
bytesSent: e.loaded | ||
}; | ||
} | ||
} else { | ||
allFilesFinished = true; | ||
progress = 100; | ||
for (_k = 0, _len2 = files.length; _k < _len2; _k++) { | ||
file = files[_k]; | ||
if (!(file.upload.progress === 100 && file.upload.bytesSent === file.upload.total)) { | ||
allFilesFinished = false; | ||
} | ||
file.upload.progress = progress; | ||
file.upload.bytesSent = file.upload.total; | ||
} | ||
if (allFilesFinished) { | ||
return; | ||
} | ||
} | ||
_results = []; | ||
for (_l = 0, _len3 = files.length; _l < _len3; _l++) { | ||
file = files[_l]; | ||
_results.push(_this.emit("uploadprogress", file, progress, file.upload.bytesSent)); | ||
} | ||
return _results; | ||
}; | ||
xhr.onload = function(e) { | ||
var response; | ||
if (xhr.status !== 200) { | ||
return handleError(); | ||
} else { | ||
bean.fire(_this, "uploadprogress", [file, 100]); | ||
response = xhr.responseText; | ||
if (~xhr.getResponseHeader("content-type").indexOf("application/json")) { | ||
var _ref; | ||
if (files[0].status === Dropzone.CANCELED) { | ||
return; | ||
} | ||
if (xhr.readyState !== 4) { | ||
return; | ||
} | ||
response = xhr.responseText; | ||
if (xhr.getResponseHeader("content-type") && ~xhr.getResponseHeader("content-type").indexOf("application/json")) { | ||
try { | ||
response = JSON.parse(response); | ||
} catch (_error) { | ||
e = _error; | ||
response = "Invalid JSON response from server."; | ||
} | ||
return _this.finished(file, response, e); | ||
} | ||
updateProgress(); | ||
if (!((200 <= (_ref = xhr.status) && _ref < 300))) { | ||
return handleError(); | ||
} else { | ||
return _this._finished(files, response, e); | ||
} | ||
}; | ||
xhr.onerror = function() { | ||
if (files[0].status === Dropzone.CANCELED) { | ||
return; | ||
} | ||
return handleError(); | ||
}; | ||
progressObj = (_ref1 = xhr.upload) != null ? _ref1 : xhr; | ||
progressObj.onprogress = function(e) { | ||
return bean.fire(_this, "uploadprogress", [file, Math.max(0, Math.min(100, (e.loaded / e.total) * 100))]); | ||
progressObj = (_ref = xhr.upload) != null ? _ref : xhr; | ||
progressObj.onprogress = updateProgress; | ||
headers = { | ||
"Accept": "application/json", | ||
"Cache-Control": "no-cache", | ||
"X-Requested-With": "XMLHttpRequest" | ||
}; | ||
xhr.setRequestHeader("Accept", "application/json"); | ||
xhr.setRequestHeader("Cache-Control", "no-cache"); | ||
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"); | ||
xhr.setRequestHeader("X-File-Name", file.name); | ||
if (this.options.headers) { | ||
extend(headers, this.options.headers); | ||
} | ||
for (headerName in headers) { | ||
headerValue = headers[headerName]; | ||
xhr.setRequestHeader(headerName, headerValue); | ||
} | ||
formData = new FormData(); | ||
if (this.options.params) { | ||
_ref1 = this.options.params; | ||
for (key in _ref1) { | ||
value = _ref1[key]; | ||
formData.append(key, value); | ||
} | ||
} | ||
for (_j = 0, _len1 = files.length; _j < _len1; _j++) { | ||
file = files[_j]; | ||
this.emit("sending", file, xhr, formData); | ||
} | ||
if (this.options.uploadMultiple) { | ||
this.emit("sendingmultiple", files, xhr, formData); | ||
} | ||
if (this.element.tagName === "FORM") { | ||
_ref2 = this.element.querySelectorAll("input, textarea, select, button"); | ||
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) { | ||
input = _ref2[_k]; | ||
inputName = input.getAttribute("name"); | ||
inputType = input.getAttribute("type"); | ||
if (input.tagName === "SELECT" && input.hasAttribute("multiple")) { | ||
_ref3 = input.options; | ||
for (_l = 0, _len3 = _ref3.length; _l < _len3; _l++) { | ||
option = _ref3[_l]; | ||
if (option.selected) { | ||
formData.append(inputName, option.value); | ||
} | ||
} | ||
} else if (!inputType || ((_ref4 = inputType.toLowerCase()) !== "checkbox" && _ref4 !== "radio") || input.checked) { | ||
formData.append(inputName, input.value); | ||
} | ||
} | ||
} | ||
for (_m = 0, _len4 = files.length; _m < _len4; _m++) { | ||
file = files[_m]; | ||
formData.append("" + this.options.paramName + (this.options.uploadMultiple ? "[]" : ""), file, file.name); | ||
} | ||
return xhr.send(formData); | ||
}; | ||
Dropzone.prototype.finished = function(file, responseText, e) { | ||
this.files.processing = without(this.files.processing, file); | ||
bean.fire(this, "finished", [file, responseText, e]); | ||
return this.processQueue(); | ||
Dropzone.prototype._finished = function(files, responseText, e) { | ||
var file, _i, _len; | ||
for (_i = 0, _len = files.length; _i < _len; _i++) { | ||
file = files[_i]; | ||
file.status = Dropzone.SUCCESS; | ||
this.emit("success", file, responseText, e); | ||
this.emit("complete", file); | ||
} | ||
if (this.options.uploadMultiple) { | ||
this.emit("successmultiple", files, responseText, e); | ||
this.emit("completemultiple", files); | ||
} | ||
if (this.options.autoProcessQueue) { | ||
return this.processQueue(); | ||
} | ||
}; | ||
Dropzone.prototype.errorProcessing = function(file, message) { | ||
this.files.processing = without(this.files.processing, file); | ||
bean.fire(this, "error", [file, message]); | ||
return this.processQueue(); | ||
Dropzone.prototype._errorProcessing = function(files, message, xhr) { | ||
var file, _i, _len; | ||
for (_i = 0, _len = files.length; _i < _len; _i++) { | ||
file = files[_i]; | ||
file.status = Dropzone.ERROR; | ||
this.emit("error", file, message, xhr); | ||
this.emit("complete", file); | ||
} | ||
if (this.options.uploadMultiple) { | ||
this.emit("errormultiple", files, message, xhr); | ||
this.emit("completemultiple", files); | ||
} | ||
if (this.options.autoProcessQueue) { | ||
return this.processQueue(); | ||
} | ||
}; | ||
@@ -407,4 +1142,88 @@ | ||
})(); | ||
})(Em); | ||
Dropzone.version = "3.7.4"; | ||
Dropzone.options = {}; | ||
Dropzone.optionsForElement = function(element) { | ||
if (element.getAttribute("id")) { | ||
return Dropzone.options[camelize(element.getAttribute("id"))]; | ||
} else { | ||
return void 0; | ||
} | ||
}; | ||
Dropzone.instances = []; | ||
Dropzone.forElement = function(element) { | ||
if (typeof element === "string") { | ||
element = document.querySelector(element); | ||
} | ||
if ((element != null ? element.dropzone : void 0) == null) { | ||
throw new Error("No Dropzone found for given element. This is probably because you're trying to access it before Dropzone had the time to initialize. Use the `init` option to setup any additional observers on your Dropzone."); | ||
} | ||
return element.dropzone; | ||
}; | ||
Dropzone.autoDiscover = true; | ||
Dropzone.discover = function() { | ||
var checkElements, dropzone, dropzones, _i, _len, _results; | ||
if (document.querySelectorAll) { | ||
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]; | ||
if (Dropzone.optionsForElement(dropzone) !== false) { | ||
_results.push(new Dropzone(dropzone)); | ||
} else { | ||
_results.push(void 0); | ||
} | ||
} | ||
return _results; | ||
}; | ||
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) { | ||
@@ -422,2 +1241,202 @@ var item, _i, _len, _results; | ||
camelize = function(str) { | ||
return str.replace(/[\-_](\w)/g, function(match) { | ||
return match[1].toUpperCase(); | ||
}); | ||
}; | ||
Dropzone.createElement = function(string) { | ||
var div; | ||
div = document.createElement("div"); | ||
div.innerHTML = string; | ||
return div.childNodes[0]; | ||
}; | ||
Dropzone.elementInside = function(element, container) { | ||
if (element === container) { | ||
return true; | ||
} | ||
while (element = element.parentNode) { | ||
if (element === container) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; | ||
Dropzone.getElement = function(el, name) { | ||
var element; | ||
if (typeof el === "string") { | ||
element = document.querySelector(el); | ||
} else if (el.nodeType != null) { | ||
element = el; | ||
} | ||
if (element == null) { | ||
throw new Error("Invalid `" + name + "` option provided. Please provide a CSS selector or a plain HTML element."); | ||
} | ||
return element; | ||
}; | ||
Dropzone.getElements = function(els, name) { | ||
var e, el, elements, _i, _j, _len, _len1, _ref; | ||
if (els instanceof Array) { | ||
elements = []; | ||
try { | ||
for (_i = 0, _len = els.length; _i < _len; _i++) { | ||
el = els[_i]; | ||
elements.push(this.getElement(el, name)); | ||
} | ||
} catch (_error) { | ||
e = _error; | ||
elements = null; | ||
} | ||
} else if (typeof els === "string") { | ||
elements = []; | ||
_ref = document.querySelectorAll(els); | ||
for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) { | ||
el = _ref[_j]; | ||
elements.push(el); | ||
} | ||
} else if (els.nodeType != null) { | ||
elements = [els]; | ||
} | ||
if (!((elements != null) && elements.length)) { | ||
throw new Error("Invalid `" + name + "` option provided. Please provide a CSS selector, a plain HTML element or a list of those."); | ||
} | ||
return elements; | ||
}; | ||
Dropzone.confirm = function(question, accepted, rejected) { | ||
if (window.confirm(question)) { | ||
return accepted(); | ||
} else if (rejected != null) { | ||
return rejected(); | ||
} | ||
}; | ||
Dropzone.isValidFile = function(file, acceptedFiles) { | ||
var baseMimeType, mimeType, validType, _i, _len; | ||
if (!acceptedFiles) { | ||
return true; | ||
} | ||
acceptedFiles = acceptedFiles.split(","); | ||
mimeType = file.type; | ||
baseMimeType = mimeType.replace(/\/.*$/, ""); | ||
for (_i = 0, _len = acceptedFiles.length; _i < _len; _i++) { | ||
validType = acceptedFiles[_i]; | ||
validType = validType.trim(); | ||
if (validType.charAt(0) === ".") { | ||
if (file.name.toLowerCase().indexOf(validType.toLowerCase(), file.name.length - validType.length) !== -1) { | ||
return true; | ||
} | ||
} else if (/\/\*$/.test(validType)) { | ||
if (baseMimeType === validType.replace(/\/.*$/, "")) { | ||
return true; | ||
} | ||
} else { | ||
if (mimeType === validType) { | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
}; | ||
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; | ||
} | ||
Dropzone.ADDED = "added"; | ||
Dropzone.QUEUED = "queued"; | ||
Dropzone.ACCEPTED = Dropzone.QUEUED; | ||
Dropzone.UPLOADING = "uploading"; | ||
Dropzone.PROCESSING = Dropzone.UPLOADING; | ||
Dropzone.CANCELED = "canceled"; | ||
Dropzone.ERROR = "error"; | ||
Dropzone.SUCCESS = "success"; | ||
/* | ||
# contentloaded.js | ||
# | ||
# Author: Diego Perini (diego.perini at gmail.com) | ||
# Summary: cross-browser wrapper for DOMContentLoaded | ||
# Updated: 20101020 | ||
# License: MIT | ||
# Version: 1.2 | ||
# | ||
# URL: | ||
# http://javascript.nwbox.com/ContentLoaded/ | ||
# http://javascript.nwbox.com/ContentLoaded/MIT-LICENSE | ||
*/ | ||
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); | ||
} | ||
}; | ||
Dropzone._autoDiscoverFunction = function() { | ||
if (Dropzone.autoDiscover) { | ||
return Dropzone.discover(); | ||
} | ||
}; | ||
contentLoaded(window, Dropzone._autoDiscoverFunction); | ||
}).call(this); |
{ | ||
"name": "dropzone", | ||
"version": "1.0.0", | ||
"version": "3.7.4", | ||
"description": "Handles drag and drop of files for you.", | ||
"keywords": [ "dragndrop", "ender" ], | ||
"keywords": [ "dragndrop", "drag and drop", "file upload", "upload" ], | ||
"homepage": "http://www.dropzonejs.com", | ||
"main": [ | ||
"./lib/dropzone.js" | ||
], | ||
"maintainers": [ | ||
{ | ||
"main": [ "./lib/dropzone.js" ], | ||
"maintainers": [{ | ||
"name": "Matias Meno", | ||
"email": "m@tias.me", | ||
"web": "http://www.matiasmeno.com" | ||
} | ||
], | ||
"contributors": [ | ||
{ | ||
}], | ||
"contributors": [{ | ||
"name": "Matias Meno", | ||
"email": "m@tias.me", | ||
"web": "http://www.matiasmeno.com" | ||
} | ||
], | ||
}], | ||
"scripts": { | ||
"test": "./test.sh" | ||
}, | ||
"bugs": { | ||
"mail": "m@tias.me" | ||
"email": "m@tias.me", | ||
"url": "https://github.com/enyo/dropzone/issues" | ||
}, | ||
"licenses": [ | ||
{ | ||
"licenses": [{ | ||
"type": "MIT", | ||
"url": "http://www.opensource.org/licenses/MIT" | ||
} | ||
], | ||
"repositories": [ | ||
{ | ||
}], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/enyo/dropzone.git" | ||
} | ||
], | ||
"dependencies": { | ||
"qwery": "3.x", | ||
"domready": "0.x", | ||
"bean": "0.x", | ||
"bonzo": "1.x" | ||
}, | ||
"ender": "noop" | ||
} | ||
"dependencies": { }, | ||
"devDependencies": { | ||
"grunt": "*", | ||
"grunt-contrib-coffee": "*", | ||
"grunt-contrib-concat": "*", | ||
"grunt-contrib-stylus": "*", | ||
"grunt-contrib-uglify": "*", | ||
"grunt-component-build": "*", | ||
"grunt-contrib-copy": "*", | ||
"grunt-contrib-watch": "*", | ||
"mocha-phantomjs": "3.1.x", | ||
"mocha": "1.12.x", | ||
"sinon": "1.7.x", | ||
"chai": "1.7.x" | ||
} | ||
} |
114
readme.md
@@ -1,8 +0,33 @@ | ||
# Dropzone.js Version 1.0.0 | ||
<h1 align="center"> | ||
<img alt="Dropzone.js" src="http://www.dropzonejs.com/images/logo.png" /> | ||
</h1> | ||
Dropzone.js is a light weight JavaScript library for [ender](http://ender.no.de) that turns an HTML element into a dropzone. | ||
*Version 3.7.4* | ||
Dropzone.js is a light weight JavaScript library that turns an HTML element into a dropzone. | ||
This means that a user can drag and drop a file onto it, and the file gets uploaded to the server via AJAX. | ||
> **Please read the [contributing guidelines](CONTRIBUTING.md) before you start working on Dropzone!** | ||
<div align="center"> | ||
<a href="https://github.com/enyo/dropzone/releases/latest"><img src="https://raw.github.com/enyo/dropzone/master/download.png" alt="Download" /></a> | ||
</div> | ||
Starting with version 2.0.0 this library does no longer depend on jQuery (but | ||
it still works as a jQuery module). | ||
It is written as a [component](https://github.com/component/component) but | ||
there's a standalone version, and an [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) | ||
module that's compatible with [RequireJS](http://requirejs.org) in the downloads | ||
folder. | ||
![Screenshot](http://i.imgur.com/zXyTjMp.png) | ||
Master | ||
![Build status](https://travis-ci.org/enyo/dropzone.png?branch=master) | ||
## Main features | ||
@@ -14,3 +39,14 @@ | ||
- Support for large files | ||
- Well tested | ||
## Documentation | ||
For the full documentation and installation please visit www.dropzonejs.com | ||
Please also refer to the [FAQ](https://github.com/enyo/dropzone/wiki/FAQ). | ||
## Examples | ||
For examples, please see the [GitHub wiki](https://github.com/enyo/dropzone/wiki). | ||
## Usage | ||
@@ -20,3 +56,5 @@ | ||
<form action="/target" class="dropzone"></form> | ||
```html | ||
<form id="my-awesome-dropzone" action="/target" class="dropzone"></form> | ||
``` | ||
@@ -27,9 +65,19 @@ That's it. Really! | ||
Want more control? You can instantiate dropzone manually like this: | ||
Want more control? You can configure dropzones like this: | ||
$("div#my-zone").dropzone({ ...configuration... }); | ||
```js | ||
// "myAwesomeDropzone" is the camelized version of the ID of your HTML element | ||
Dropzone.options.myAwesomeDropzone = { maxFilesize: 1 }; | ||
``` | ||
...or instantiate dropzone manually like this: | ||
```js | ||
new Dropzone("div#my-dropzone", { /* options */ }); | ||
``` | ||
> Note that dropzones don't have to be forms. But if you choose another element you have to pass the `url` parameter in the options. | ||
For configuration options please look at the [source line 52](https://github.com/enyo/dropzonejs/blob/master/src/dropzone.coffee#L52). | ||
For configuration options please look at the [documentation on the website](http://www.dropzonejs.com/#configuration) | ||
or at the [source](https://github.com/enyo/dropzone/blob/master/src/dropzone.coffee#L90). | ||
@@ -40,8 +88,18 @@ | ||
I use [bean](https://github.com/fat/bean) to manage events. If you want to register to some event you can do so on the `dropzone` object itself: | ||
I use [emitter](https://github.com/component/emitter) to manage events. If you want to register to some event you can do so on the `dropzone` object itself: | ||
var myDropzone = $("div#my-zone").dropzone({ ...configuration... }); | ||
bean.add(myDropzone, "error", function(file, message) { alert(message); }); | ||
```js | ||
Dropzone.options.myDropzone({ | ||
init: function() { | ||
this.on("error", function(file, message) { alert(message); }); | ||
} | ||
}); | ||
// or if you need to access a Dropzone somewhere else: | ||
var myDropzone = Dropzone.forElement("div#my-dropzone"); | ||
myDropzone.on("error", function(file, message) { alert(message); }); | ||
``` | ||
For a list of all events, please look at the [source line 25](https://github.com/enyo/dropzonejs/blob/master/src/dropzone.coffee#L25). | ||
For a list of all events, please look at the chapter | ||
[»listen to events«](http://www.dropzonejs.com/#listen_to_events) in the documentation | ||
or at the [source](src/dropzone.coffee#L43). | ||
@@ -54,5 +112,7 @@ | ||
- IE 10+ | ||
- Opera 12+ | ||
- Safari 5+ | ||
- Opera 12+ (Version 12 for MacOS is disabled because their API is buggy) | ||
- Safari 6+ | ||
For all the other browsers, dropzone provides an oldschool file input fallback. | ||
## Why another library? | ||
@@ -67,1 +127,31 @@ | ||
- I want to use the latest API of browsers. I don't care if it falls back to the normal upload form if the browser is too old. | ||
- I don't think that it's necessary anymore to depend on libraries such as jQuery (especially when providing functionality that isn't available in old browsers anyway). | ||
## Other projects | ||
You might also be interested in my [open source tooltip library Opentip](http://www.opentip.org/). | ||
![Opentip](http://i.imgur.com/Zubpo.png) | ||
License | ||
------- | ||
(The MIT License) | ||
Copyright (c) 2012 Matias Meno <m@tias.me><br> | ||
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. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
553263
0
35
6610
0
152
0
12
1
5
- Removedbean@0.x
- Removedbonzo@1.x
- Removeddomready@0.x
- Removedqwery@3.x
- Removedbean@0.4.11(transitive)
- Removedbonzo@1.4.0(transitive)
- Removeddomready@0.3.0(transitive)
- Removedqwery@3.4.2(transitive)