New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dropzone

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dropzone - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

npm_publish.sh

10

example/ender.min.js

@@ -27,2 +27,6 @@ /*!

/*!
* domready (c) Dustin Diaz 2012 - License MIT
*/
;!function(name,definition){typeof module!="undefined"?module.exports=definition():typeof define=="function"&&typeof define.amd=="object"?define(definition):this[name]=definition()}("domready",function(ready){function flush(f){loaded=1;while(f=fns.shift())f()}var fns=[],fn,f=!1,doc=document,testEl=doc.documentElement,hack=testEl.doScroll,domContentLoaded="DOMContentLoaded",addEventListener="addEventListener",onreadystatechange="onreadystatechange",readyState="readyState",loaded=/^loade|c/.test(doc[readyState]);doc[addEventListener]&&doc[addEventListener](domContentLoaded,fn=function(){doc.removeEventListener(domContentLoaded,fn,f);flush()},f);hack&&doc.attachEvent(onreadystatechange,fn=function(){if(/^c/.test(doc[readyState])){doc.detachEvent(onreadystatechange,fn);flush()}});return ready=hack?function(fn){self!=top?loaded?fn():fns.push(fn):function(){try{testEl.doScroll("left")}catch(e){return setTimeout(function(){ready(fn)},50)}fn()}()}:function(fn){loaded?fn():fns.push(fn)}});provide("domready",module.exports);!function($){var ready=require("domready");$.ender({domReady:ready});$.ender({ready:function(f){ready(f);return this}},!0)}(ender)})();(function(){var module={exports:{}},exports=module.exports;
/*!
* Bonzo: DOM Utility (c) Dustin Diaz 2012

@@ -34,6 +38,2 @@ * https://github.com/ded/bonzo

/*!
* domready (c) Dustin Diaz 2012 - License MIT
*/
;!function(name,definition){typeof module!="undefined"?module.exports=definition():typeof define=="function"&&typeof define.amd=="object"?define(definition):this[name]=definition()}("domready",function(ready){function flush(f){loaded=1;while(f=fns.shift())f()}var fns=[],fn,f=!1,doc=document,testEl=doc.documentElement,hack=testEl.doScroll,domContentLoaded="DOMContentLoaded",addEventListener="addEventListener",onreadystatechange="onreadystatechange",readyState="readyState",loaded=/^loade|c/.test(doc[readyState]);doc[addEventListener]&&doc[addEventListener](domContentLoaded,fn=function(){doc.removeEventListener(domContentLoaded,fn,f);flush()},f);hack&&doc.attachEvent(onreadystatechange,fn=function(){if(/^c/.test(doc[readyState])){doc.detachEvent(onreadystatechange,fn);flush()}});return ready=hack?function(fn){self!=top?loaded?fn():fns.push(fn):function(){try{testEl.doScroll("left")}catch(e){return setTimeout(function(){ready(fn)},50)}fn()}()}:function(fn){loaded?fn():fns.push(fn)}});provide("domready",module.exports);!function($){var ready=require("domready");$.ender({domReady:ready});$.ender({ready:function(f){ready(f);return this}},!0)}(ender)})();(function(){var module={exports:{}},exports=module.exports;
/*!
* @preserve Qwery - A Blazing Fast query selector engine

@@ -44,2 +44,2 @@ * https://github.com/ded/qwery

*/
(function(name,definition,context){typeof module!="undefined"&&module.exports?module.exports=definition():typeof context["define"]=="function"&&context.define.amd?define(name,definition):context[name]=definition()})("qwery",function(){function cache(){this.c={}}function classRegex(c){return classCache.g(c)||classCache.s(c,"(^|\\s+)"+c+"(\\s+|$)",1)}function each(a,fn){var i=0,l=a.length;for(;i<l;i++)fn(a[i])}function flatten(ar){for(var r=[],i=0,l=ar.length;i<l;++i)arrayLike(ar[i])?r=r.concat(ar[i]):r[r.length]=ar[i];return r}function arrayify(ar){var i=0,l=ar.length,r=[];for(;i<l;i++)r[i]=ar[i];return r}function previous(n){while(n=n.previousSibling)if(n[nodeType]==1)break;return n}function q(query){return query.match(chunker)}function interpret(whole,tag,idsAndClasses,wholeAttribute,attribute,qualifier,value,wholePseudo,pseudo,wholePseudoVal,pseudoVal){var i,m,k,o,classes;if(this[nodeType]!==1)return!1;if(tag&&tag!=="*"&&this[tagName]&&this[tagName].toLowerCase()!==tag)return!1;if(idsAndClasses&&(m=idsAndClasses.match(id))&&m[1]!==this.id)return!1;if(idsAndClasses&&(classes=idsAndClasses.match(clas)))for(i=classes.length;i--;)if(!classRegex(classes[i].slice(1)).test(this.className))return!1;if(pseudo&&qwery.pseudos[pseudo]&&!qwery.pseudos[pseudo](this,pseudoVal))return!1;if(wholeAttribute&&!value){o=this.attributes;for(k in o)if(Object.prototype.hasOwnProperty.call(o,k)&&(o[k].name||k)==attribute)return this}return wholeAttribute&&!checkAttr(qualifier,getAttr(this,attribute)||"",value)?!1:this}function clean(s){return cleanCache.g(s)||cleanCache.s(s,s.replace(specialChars,"\\$1"))}function checkAttr(qualify,actual,val){switch(qualify){case"=":return actual==val;case"^=":return actual.match(attrCache.g("^="+val)||attrCache.s("^="+val,"^"+clean(val),1));case"$=":return actual.match(attrCache.g("$="+val)||attrCache.s("$="+val,clean(val)+"$",1));case"*=":return actual.match(attrCache.g(val)||attrCache.s(val,clean(val),1));case"~=":return actual.match(attrCache.g("~="+val)||attrCache.s("~="+val,"(?:^|\\s+)"+clean(val)+"(?:\\s+|$)",1));case"|=":return actual.match(attrCache.g("|="+val)||attrCache.s("|="+val,"^"+clean(val)+"(-|$)",1))}return 0}function _qwery(selector,_root){var r=[],ret=[],i,l,m,token,tag,els,intr,item,root=_root,tokens=tokenCache.g(selector)||tokenCache.s(selector,selector.split(tokenizr)),dividedTokens=selector.match(dividers);if(!tokens.length)return r;token=(tokens=tokens.slice(0)).pop();tokens.length&&(m=tokens[tokens.length-1].match(idOnly))&&(root=byId(_root,m[1]));if(!root)return r;intr=q(token);els=root!==_root&&root[nodeType]!==9&&dividedTokens&&/^[+~]$/.test(dividedTokens[dividedTokens.length-1])?function(r){while(root=root.nextSibling)root[nodeType]==1&&(intr[1]?intr[1]==root[tagName].toLowerCase():1)&&(r[r.length]=root);return r}([]):root[byTag](intr[1]||"*");for(i=0,l=els.length;i<l;i++)if(item=interpret.apply(els[i],intr))r[r.length]=item;if(!tokens.length)return r;each(r,function(e){ancestorMatch(e,tokens,dividedTokens)&&(ret[ret.length]=e)});return ret}function is(el,selector,root){if(isNode(selector))return el==selector;if(arrayLike(selector))return!!~flatten(selector).indexOf(el);var selectors=selector.split(","),tokens,dividedTokens;while(selector=selectors.pop()){tokens=tokenCache.g(selector)||tokenCache.s(selector,selector.split(tokenizr));dividedTokens=selector.match(dividers);tokens=tokens.slice(0);if(interpret.apply(el,q(tokens.pop()))&&(!tokens.length||ancestorMatch(el,tokens,dividedTokens,root)))return!0}return!1}function ancestorMatch(el,tokens,dividedTokens,root){function crawl(e,i,p){while(p=walker[dividedTokens[i]](p,e))if(isNode(p)&&interpret.apply(p,q(tokens[i]))){if(!i)return p;if(cand=crawl(p,i-1,p))return cand}}var cand;return(cand=crawl(el,tokens.length-1,el))&&(!root||isAncestor(cand,root))}function isNode(el,t){return el&&typeof el=="object"&&(t=el[nodeType])&&(t==1||t==9)}function uniq(ar){var a=[],i,j;e:for(i=0;i<ar.length;++i){for(j=0;j<a.length;++j)if(a[j]==ar[i])continue e;a[a.length]=ar[i]}return a}function arrayLike(o){return typeof o=="object"&&isFinite(o.length)}function normalizeRoot(root){return root?typeof root=="string"?qwery(root)[0]:!root[nodeType]&&arrayLike(root)?root[0]:root:doc}function byId(root,id,el){return root[nodeType]===9?root.getElementById(id):root.ownerDocument&&((el=root.ownerDocument.getElementById(id))&&isAncestor(el,root)&&el||!isAncestor(root,root.ownerDocument)&&select('[id="'+id+'"]',root)[0])}function qwery(selector,_root){var m,el,root=normalizeRoot(_root);if(!root||!selector)return[];if(selector===window||isNode(selector))return!_root||selector!==window&&isNode(root)&&isAncestor(selector,root)?[selector]:[];if(selector&&arrayLike(selector))return flatten(selector);if(m=selector.match(easy)){if(m[1])return(el=byId(root,m[1]))?[el]:[];if(m[2])return arrayify(root[byTag](m[2]));if(hasByClass&&m[3])return arrayify(root[byClass](m[3]))}return select(selector,root)}function collectSelector(root,collector){return function(s){var oid,nid;if(splittable.test(s)){if(root[nodeType]!==9){(nid=oid=root.getAttribute("id"))||root.setAttribute("id",nid="__qwerymeupscotty");s='[id="'+nid+'"]'+s;collector(root.parentNode||root,s,!0);oid||root.removeAttribute("id")}return}s.length&&collector(root,s,!1)}}var doc=document,html=doc.documentElement,byClass="getElementsByClassName",byTag="getElementsByTagName",qSA="querySelectorAll",useNativeQSA="useNativeQSA",tagName="tagName",nodeType="nodeType",select,id=/#([\w\-]+)/,clas=/\.[\w\-]+/g,idOnly=/^#([\w\-]+)$/,classOnly=/^\.([\w\-]+)$/,tagOnly=/^([\w\-]+)$/,tagAndOrClass=/^([\w]+)?\.([\w\-]+)$/,splittable=/(^|,)\s*[>~+]/,normalizr=/^\s+|\s*([,\s\+\~>]|$)\s*/g,splitters=/[\s\>\+\~]/,splittersMore=/(?![\s\w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^'"]*\]|[\s\w\+\-]*\))/,specialChars=/([.*+?\^=!:${}()|\[\]\/\\])/g,simple=/^(\*|[a-z0-9]+)?(?:([\.\#]+[\w\-\.#]+)?)/,attr=/\[([\w\-]+)(?:([\|\^\$\*\~]?\=)['"]?([ \w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^]+)["']?)?\]/,pseudo=/:([\w\-]+)(\(['"]?([^()]+)['"]?\))?/,easy=new RegExp(idOnly.source+"|"+tagOnly.source+"|"+classOnly.source),dividers=new RegExp("("+splitters.source+")"+splittersMore.source,"g"),tokenizr=new RegExp(splitters.source+splittersMore.source),chunker=new RegExp(simple.source+"("+attr.source+")?"+"("+pseudo.source+")?"),walker={" ":function(node){return node&&node!==html&&node.parentNode},">":function(node,contestant){return node&&node.parentNode==contestant.parentNode&&node.parentNode},"~":function(node){return node&&node.previousSibling},"+":function(node,contestant,p1,p2){return node?(p1=previous(node))&&(p2=previous(contestant))&&p1==p2&&p1:!1}};cache.prototype={g:function(k){return this.c[k]||undefined},s:function(k,v,r){v=r?new RegExp(v):v;return this.c[k]=v}};var classCache=new cache,cleanCache=new cache,attrCache=new cache,tokenCache=new cache,isAncestor="compareDocumentPosition"in html?function(element,container){return(container.compareDocumentPosition(element)&16)==16}:"contains"in html?function(element,container){container=container[nodeType]===9||container==window?html:container;return container!==element&&container.contains(element)}:function(element,container){while(element=element.parentNode)if(element===container)return 1;return 0},getAttr=function(){var e=doc.createElement("p");return(e.innerHTML='<a href="#x">x</a>')&&e.firstChild.getAttribute("href")!="#x"?function(e,a){return a==="class"?e.className:a==="href"||a==="src"?e.getAttribute(a,2):e.getAttribute(a)}:function(e,a){return e.getAttribute(a)}}(),hasByClass=!!doc[byClass],hasQSA=doc.querySelector&&doc[qSA],selectQSA=function(selector,root){var result=[],ss,e;try{if(root[nodeType]===9||!splittable.test(selector))return arrayify(root[qSA](selector));each(ss=selector.split(","),collectSelector(root,function(ctx,s){e=ctx[qSA](s);e.length==1?result[result.length]=e.item(0):e.length&&(result=result.concat(arrayify(e)))}));return ss.length>1&&result.length>1?uniq(result):result}catch(ex){}return selectNonNative(selector,root)},selectNonNative=function(selector,root){var result=[],items,m,i,l,r,ss;selector=selector.replace(normalizr,"$1");if(m=selector.match(tagAndOrClass)){r=classRegex(m[2]);items=root[byTag](m[1]||"*");for(i=0,l=items.length;i<l;i++)r.test(items[i].className)&&(result[result.length]=items[i]);return result}each(ss=selector.split(","),collectSelector(root,function(ctx,s,rewrite){r=_qwery(s,ctx);for(i=0,l=r.length;i<l;i++)if(ctx[nodeType]===9||rewrite||isAncestor(r[i],root))result[result.length]=r[i]}));return ss.length>1&&result.length>1?uniq(result):result},configure=function(options){typeof options[useNativeQSA]!="undefined"&&(select=options[useNativeQSA]?hasQSA?selectQSA:selectNonNative:selectNonNative)};configure({useNativeQSA:!0});qwery.configure=configure;qwery.uniq=uniq;qwery.is=is;qwery.pseudos={};return qwery},this);provide("qwery",module.exports);(function($){var q=function(){var r;try{r=require("qwery")}catch(ex){r=require("qwery-mobile")}finally{return r}}();$.pseudos=q.pseudos;$._select=function(s,r){return($._select=function(){var b;if(typeof $.create=="function")return function(s,r){return/^\s*</.test(s)?$.create(s,r):q(s,r)};try{b=require("bonzo");return function(s,r){return/^\s*</.test(s)?b.create(s,r):q(s,r)}}catch(e){}return q}())(s,r)};$.ender({find:function(s){var r=[],i,l,j,k,els;for(i=0,l=this.length;i<l;i++){els=q(s,this[i]);for(j=0,k=els.length;j<k;j++)r.push(els[j])}return $(q.uniq(r))},and:function(s){var plus=$(s);for(var i=this.length,j=0,l=this.length+plus.length;i<l;i++,j++)this[i]=plus[j];this.length+=plus.length;return this},is:function(s,r){var i,l;for(i=0,l=this.length;i<l;i++)if(q.is(this[i],s,r))return!0;return!1}},!0)})(ender)})();(function(){var module={exports:{}},exports=module.exports;(function(){var $,Dropzone,bean,noOp,without,__slice=[].slice;$=ender;$.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}},!0);$.domReady(function(){return $(".dropzone").dropzone()});bean=require("bean");noOp=function(){};Dropzone=function(){function Dropzone(element,options){var extend;this.element=$(element);if(this.element.data("dropzone"))throw new Error("Dropzone already attached.");this.element.data("dropzone",this);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:{});this.options.url==null&&(this.options.url=this.element.attr("action"));this.init()}var defaultOptions;Dropzone.prototype.version="0.1.6-dev";Dropzone.prototype.events=["fallback","drop","dragstart","dragend","dragenter","dragover","dragleave","addedfile","thumbnail","error","processingfile","uploadprogress","finished"];defaultOptions={url:null,parallelUploads:2,maxFilesize:256,paramName:"file",createImageThumbnails:!0,maxThumbnailFilesize:2,thumbnailWidth:120,thumbnailHeight:120,accept:function(file){return!0},fallback:function(){return this.element.find(".message").html("Your browser does not support drag'n'drop file uploads.")},drop:function(e){return this.element.find(".message").hide()},dragstart:function(e){},dragend:function(e){},dragenter:function(e){return this.element.addClass("drag-hover")},dragover:function(e){return this.element.addClass("drag-hover")},dragleave:function(e){return this.element.addClass("drag-hover")},addedfile:function(file){file.previewTemplate=$(this.options.previewTemplate);this.element.append(file.previewTemplate);return file.previewTemplate.find(".details").html($("<span>"+file.name+"</span>"))},thumbnail:function(file,dataUrl){file.previewTemplate.removeClass("file-preview").addClass("image-preview");return file.previewTemplate.find(".details").html($('<img alt="" src="'+dataUrl+'"/>'))},error:function(file,message){file.previewTemplate.addClass("process-error");return file.previewTemplate.find(".error-message span").html(message)},processingfile:function(file){return file.previewTemplate.addClass("processing")},uploadprogress:function(file,progress){return file.previewTemplate.find(".progress .upload").css({width:""+progress+"%"})},finished:function(file){return file.previewTemplate.addClass("finished")},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="finished-success"><span>✔</span></div>\n <div class="finished-error"><span>✘</span></div>\n <div class="error-message"><span></span></div>\n</div>'};defaultOptions.previewTemplate=defaultOptions.previewTemplate.replace(/\n*/g,"");Dropzone.prototype.init=function(){var _ref;if(!(window.File&&window.FileReader&&window.FileList&&window.Blob&&window.FormData)){this.options.fallback.call(this);return}this.files=[];this.files.queue=[];this.files.processing=[];this.URL=(_ref=window.URL)!=null?_ref:window.webkitURL;this.setupEventListeners();if(this.element.find(".message").length===0)return this.element.append($('<div class="message">Drop files here to upload</div>'))};Dropzone.prototype.getFallbackForm=function(){return $('<form action="'+this.options.url+'" enctype="multipart/form-data" method="post"><input type="file" name="newFiles" multiple="multiple" /><button type="submit">Upload!</button></form>')};Dropzone.prototype.setupEventListeners=function(){var eventName,noPropagation,_i,_len,_ref,_this=this;_ref=this.events;for(_i=0,_len=_ref.length;_i<_len;_i++){eventName=_ref[_i];bean.add(this,eventName,this.options[eventName])}noPropagation=function(e){e.stopPropagation();return e.preventDefault()};this.element.on("dragstart",function(e){return bean.fire(_this,"dragstart",e)});this.element.on("dragenter",function(e){noPropagation(e);return bean.fire(_this,"dragenter",e)});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){bean.fire(_this,"dragleave",e);return bean.fire(_this,"dragend",e)})};Dropzone.prototype.drop=function(e){var files;if(!e.dataTransfer)return;files=e.dataTransfer.files;if(files.length)return this.handleFiles(files)};Dropzone.prototype.handleFiles=function(files){var file,_i,_len;for(_i=0,_len=files.length;_i<_len;_i++){file=files[_i];this.accept(file)&&this.addFile(file)}return this.processQueue()};Dropzone.prototype.accept=function(file){return this.options.accept.call(this,file)};Dropzone.prototype.addFile=function(file){this.files.push(file);this.files.queue.push(file);bean.fire(this,"addedfile",file);if(this.options.createImageThumbnails&&file.type.match(/image.*/)&&file.size<=this.options.maxThumbnailFilesize*1024*1024)return this.createThumbnail(file)};Dropzone.prototype.createThumbnail=function(file){var blobUrl,img,_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,srcRatio,thumbnail,trgHeight,trgRatio,trgWidth,trgX,trgY;canvas=document.createElement("canvas");ctx=canvas.getContext("2d");trgX=0;trgY=0;trgWidth=0;trgHeight=0;srcRatio=void 0;trgRatio=void 0;canvas.width=_this.options.thumbnailWidth;canvas.height=_this.options.thumbnailHeight;srcRatio=img.width/img.height;trgRatio=canvas.width/canvas.height;if(srcRatio>trgRatio){trgWidth=canvas.width;trgHeight=trgWidth/srcRatio}else{trgHeight=canvas.height;trgWidth=trgHeight*srcRatio}trgX=(canvas.width-trgWidth)/2;trgY=(canvas.height-trgHeight)/2;ctx.drawImage(img,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};Dropzone.prototype.processQueue=function(){var i,parallelUploads,processingLength;parallelUploads=this.options.parallelUploads;processingLength=this.files.processing.length;i=processingLength;while(i<parallelUploads){if(!this.files.queue.length)return;this.processFile(this.files.queue.shift());i++}};Dropzone.prototype.processFile=function(file){var fileReader;fileReader=new FileReader;this.files.processing.push(file);bean.fire(this,"processingfile",file);return file.size>this.options.maxFilesize*1024*1024?this.errorProcessing(file,"File is too big ("+Math.round(file.size/1024/10.24)/100+"MB). Max filesize: "+this.options.maxFilesize+"MB"):this.uploadFile(file)};Dropzone.prototype.uploadFile=function(file){var formData,progressObj,xhr,_ref,_this=this;xhr=new XMLHttpRequest;formData=new FormData;formData.append(this.options.paramName,file);formData.append("test","HI");xhr.open("POST",this.options.url,!0);xhr.onload=function(e){if(xhr.status!==200)return _this.errorProcessing(file,"Server responded with "+xhr.status+" code.");bean.fire(_this,"uploadprogress",[file,100]);return _this.finished(file,e)};xhr.onerror=function(){return _this.errorProcessing(file,xhr.responseText)};progressObj=(_ref=xhr.upload)!=null?_ref:xhr;progressObj.onprogress=function(e){return bean.fire(_this,"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);return xhr.send(formData)};Dropzone.prototype.finished=function(file){this.files.processing=without(this.files.processing,file);bean.fire(this,"finished",file);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()};return Dropzone}();without=function(list,rejectedItem){var item,_i,_len,_results;_results=[];for(_i=0,_len=list.length;_i<_len;_i++){item=list[_i];item!==rejectedItem&&_results.push(item)}return _results}}).call(this);provide("dropzone",module.exports)})()
(function(name,definition,context){typeof module!="undefined"&&module.exports?module.exports=definition():typeof context["define"]=="function"&&context.define.amd?define(name,definition):context[name]=definition()})("qwery",function(){function cache(){this.c={}}function classRegex(c){return classCache.g(c)||classCache.s(c,"(^|\\s+)"+c+"(\\s+|$)",1)}function each(a,fn){var i=0,l=a.length;for(;i<l;i++)fn(a[i])}function flatten(ar){for(var r=[],i=0,l=ar.length;i<l;++i)arrayLike(ar[i])?r=r.concat(ar[i]):r[r.length]=ar[i];return r}function arrayify(ar){var i=0,l=ar.length,r=[];for(;i<l;i++)r[i]=ar[i];return r}function previous(n){while(n=n.previousSibling)if(n[nodeType]==1)break;return n}function q(query){return query.match(chunker)}function interpret(whole,tag,idsAndClasses,wholeAttribute,attribute,qualifier,value,wholePseudo,pseudo,wholePseudoVal,pseudoVal){var i,m,k,o,classes;if(this[nodeType]!==1)return!1;if(tag&&tag!=="*"&&this[tagName]&&this[tagName].toLowerCase()!==tag)return!1;if(idsAndClasses&&(m=idsAndClasses.match(id))&&m[1]!==this.id)return!1;if(idsAndClasses&&(classes=idsAndClasses.match(clas)))for(i=classes.length;i--;)if(!classRegex(classes[i].slice(1)).test(this.className))return!1;if(pseudo&&qwery.pseudos[pseudo]&&!qwery.pseudos[pseudo](this,pseudoVal))return!1;if(wholeAttribute&&!value){o=this.attributes;for(k in o)if(Object.prototype.hasOwnProperty.call(o,k)&&(o[k].name||k)==attribute)return this}return wholeAttribute&&!checkAttr(qualifier,getAttr(this,attribute)||"",value)?!1:this}function clean(s){return cleanCache.g(s)||cleanCache.s(s,s.replace(specialChars,"\\$1"))}function checkAttr(qualify,actual,val){switch(qualify){case"=":return actual==val;case"^=":return actual.match(attrCache.g("^="+val)||attrCache.s("^="+val,"^"+clean(val),1));case"$=":return actual.match(attrCache.g("$="+val)||attrCache.s("$="+val,clean(val)+"$",1));case"*=":return actual.match(attrCache.g(val)||attrCache.s(val,clean(val),1));case"~=":return actual.match(attrCache.g("~="+val)||attrCache.s("~="+val,"(?:^|\\s+)"+clean(val)+"(?:\\s+|$)",1));case"|=":return actual.match(attrCache.g("|="+val)||attrCache.s("|="+val,"^"+clean(val)+"(-|$)",1))}return 0}function _qwery(selector,_root){var r=[],ret=[],i,l,m,token,tag,els,intr,item,root=_root,tokens=tokenCache.g(selector)||tokenCache.s(selector,selector.split(tokenizr)),dividedTokens=selector.match(dividers);if(!tokens.length)return r;token=(tokens=tokens.slice(0)).pop();tokens.length&&(m=tokens[tokens.length-1].match(idOnly))&&(root=byId(_root,m[1]));if(!root)return r;intr=q(token);els=root!==_root&&root[nodeType]!==9&&dividedTokens&&/^[+~]$/.test(dividedTokens[dividedTokens.length-1])?function(r){while(root=root.nextSibling)root[nodeType]==1&&(intr[1]?intr[1]==root[tagName].toLowerCase():1)&&(r[r.length]=root);return r}([]):root[byTag](intr[1]||"*");for(i=0,l=els.length;i<l;i++)if(item=interpret.apply(els[i],intr))r[r.length]=item;if(!tokens.length)return r;each(r,function(e){ancestorMatch(e,tokens,dividedTokens)&&(ret[ret.length]=e)});return ret}function is(el,selector,root){if(isNode(selector))return el==selector;if(arrayLike(selector))return!!~flatten(selector).indexOf(el);var selectors=selector.split(","),tokens,dividedTokens;while(selector=selectors.pop()){tokens=tokenCache.g(selector)||tokenCache.s(selector,selector.split(tokenizr));dividedTokens=selector.match(dividers);tokens=tokens.slice(0);if(interpret.apply(el,q(tokens.pop()))&&(!tokens.length||ancestorMatch(el,tokens,dividedTokens,root)))return!0}return!1}function ancestorMatch(el,tokens,dividedTokens,root){function crawl(e,i,p){while(p=walker[dividedTokens[i]](p,e))if(isNode(p)&&interpret.apply(p,q(tokens[i]))){if(!i)return p;if(cand=crawl(p,i-1,p))return cand}}var cand;return(cand=crawl(el,tokens.length-1,el))&&(!root||isAncestor(cand,root))}function isNode(el,t){return el&&typeof el=="object"&&(t=el[nodeType])&&(t==1||t==9)}function uniq(ar){var a=[],i,j;e:for(i=0;i<ar.length;++i){for(j=0;j<a.length;++j)if(a[j]==ar[i])continue e;a[a.length]=ar[i]}return a}function arrayLike(o){return typeof o=="object"&&isFinite(o.length)}function normalizeRoot(root){return root?typeof root=="string"?qwery(root)[0]:!root[nodeType]&&arrayLike(root)?root[0]:root:doc}function byId(root,id,el){return root[nodeType]===9?root.getElementById(id):root.ownerDocument&&((el=root.ownerDocument.getElementById(id))&&isAncestor(el,root)&&el||!isAncestor(root,root.ownerDocument)&&select('[id="'+id+'"]',root)[0])}function qwery(selector,_root){var m,el,root=normalizeRoot(_root);if(!root||!selector)return[];if(selector===window||isNode(selector))return!_root||selector!==window&&isNode(root)&&isAncestor(selector,root)?[selector]:[];if(selector&&arrayLike(selector))return flatten(selector);if(m=selector.match(easy)){if(m[1])return(el=byId(root,m[1]))?[el]:[];if(m[2])return arrayify(root[byTag](m[2]));if(hasByClass&&m[3])return arrayify(root[byClass](m[3]))}return select(selector,root)}function collectSelector(root,collector){return function(s){var oid,nid;if(splittable.test(s)){if(root[nodeType]!==9){(nid=oid=root.getAttribute("id"))||root.setAttribute("id",nid="__qwerymeupscotty");s='[id="'+nid+'"]'+s;collector(root.parentNode||root,s,!0);oid||root.removeAttribute("id")}return}s.length&&collector(root,s,!1)}}var doc=document,html=doc.documentElement,byClass="getElementsByClassName",byTag="getElementsByTagName",qSA="querySelectorAll",useNativeQSA="useNativeQSA",tagName="tagName",nodeType="nodeType",select,id=/#([\w\-]+)/,clas=/\.[\w\-]+/g,idOnly=/^#([\w\-]+)$/,classOnly=/^\.([\w\-]+)$/,tagOnly=/^([\w\-]+)$/,tagAndOrClass=/^([\w]+)?\.([\w\-]+)$/,splittable=/(^|,)\s*[>~+]/,normalizr=/^\s+|\s*([,\s\+\~>]|$)\s*/g,splitters=/[\s\>\+\~]/,splittersMore=/(?![\s\w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^'"]*\]|[\s\w\+\-]*\))/,specialChars=/([.*+?\^=!:${}()|\[\]\/\\])/g,simple=/^(\*|[a-z0-9]+)?(?:([\.\#]+[\w\-\.#]+)?)/,attr=/\[([\w\-]+)(?:([\|\^\$\*\~]?\=)['"]?([ \w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^]+)["']?)?\]/,pseudo=/:([\w\-]+)(\(['"]?([^()]+)['"]?\))?/,easy=new RegExp(idOnly.source+"|"+tagOnly.source+"|"+classOnly.source),dividers=new RegExp("("+splitters.source+")"+splittersMore.source,"g"),tokenizr=new RegExp(splitters.source+splittersMore.source),chunker=new RegExp(simple.source+"("+attr.source+")?"+"("+pseudo.source+")?"),walker={" ":function(node){return node&&node!==html&&node.parentNode},">":function(node,contestant){return node&&node.parentNode==contestant.parentNode&&node.parentNode},"~":function(node){return node&&node.previousSibling},"+":function(node,contestant,p1,p2){return node?(p1=previous(node))&&(p2=previous(contestant))&&p1==p2&&p1:!1}};cache.prototype={g:function(k){return this.c[k]||undefined},s:function(k,v,r){v=r?new RegExp(v):v;return this.c[k]=v}};var classCache=new cache,cleanCache=new cache,attrCache=new cache,tokenCache=new cache,isAncestor="compareDocumentPosition"in html?function(element,container){return(container.compareDocumentPosition(element)&16)==16}:"contains"in html?function(element,container){container=container[nodeType]===9||container==window?html:container;return container!==element&&container.contains(element)}:function(element,container){while(element=element.parentNode)if(element===container)return 1;return 0},getAttr=function(){var e=doc.createElement("p");return(e.innerHTML='<a href="#x">x</a>')&&e.firstChild.getAttribute("href")!="#x"?function(e,a){return a==="class"?e.className:a==="href"||a==="src"?e.getAttribute(a,2):e.getAttribute(a)}:function(e,a){return e.getAttribute(a)}}(),hasByClass=!!doc[byClass],hasQSA=doc.querySelector&&doc[qSA],selectQSA=function(selector,root){var result=[],ss,e;try{if(root[nodeType]===9||!splittable.test(selector))return arrayify(root[qSA](selector));each(ss=selector.split(","),collectSelector(root,function(ctx,s){e=ctx[qSA](s);e.length==1?result[result.length]=e.item(0):e.length&&(result=result.concat(arrayify(e)))}));return ss.length>1&&result.length>1?uniq(result):result}catch(ex){}return selectNonNative(selector,root)},selectNonNative=function(selector,root){var result=[],items,m,i,l,r,ss;selector=selector.replace(normalizr,"$1");if(m=selector.match(tagAndOrClass)){r=classRegex(m[2]);items=root[byTag](m[1]||"*");for(i=0,l=items.length;i<l;i++)r.test(items[i].className)&&(result[result.length]=items[i]);return result}each(ss=selector.split(","),collectSelector(root,function(ctx,s,rewrite){r=_qwery(s,ctx);for(i=0,l=r.length;i<l;i++)if(ctx[nodeType]===9||rewrite||isAncestor(r[i],root))result[result.length]=r[i]}));return ss.length>1&&result.length>1?uniq(result):result},configure=function(options){typeof options[useNativeQSA]!="undefined"&&(select=options[useNativeQSA]?hasQSA?selectQSA:selectNonNative:selectNonNative)};configure({useNativeQSA:!0});qwery.configure=configure;qwery.uniq=uniq;qwery.is=is;qwery.pseudos={};return qwery},this);provide("qwery",module.exports);(function($){var q=function(){var r;try{r=require("qwery")}catch(ex){r=require("qwery-mobile")}finally{return r}}();$.pseudos=q.pseudos;$._select=function(s,r){return($._select=function(){var b;if(typeof $.create=="function")return function(s,r){return/^\s*</.test(s)?$.create(s,r):q(s,r)};try{b=require("bonzo");return function(s,r){return/^\s*</.test(s)?b.create(s,r):q(s,r)}}catch(e){}return q}())(s,r)};$.ender({find:function(s){var r=[],i,l,j,k,els;for(i=0,l=this.length;i<l;i++){els=q(s,this[i]);for(j=0,k=els.length;j<k;j++)r.push(els[j])}return $(q.uniq(r))},and:function(s){var plus=$(s);for(var i=this.length,j=0,l=this.length+plus.length;i<l;i++,j++)this[i]=plus[j];this.length+=plus.length;return this},is:function(s,r){var i,l;for(i=0,l=this.length;i<l;i++)if(q.is(this[i],s,r))return!0;return!1}},!0)})(ender)})();(function(){var module={exports:{}},exports=module.exports;(function(){var $,Dropzone,bean,noOp,without,__slice=[].slice;$=ender;$.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}},!0);$.domReady(function(){return $(".dropzone").dropzone()});bean=require("bean");noOp=function(){};Dropzone=function(){function Dropzone(element,options){var extend;this.element=$(element);if(this.element.data("dropzone"))throw new Error("Dropzone already attached.");this.element.data("dropzone",this);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:{});this.options.url==null&&(this.options.url=this.element.attr("action"));this.init()}var defaultOptions;Dropzone.prototype.version="0.2.1-dev";Dropzone.prototype.events=["fallback","drop","dragstart","dragend","dragenter","dragover","dragleave","addedfile","thumbnail","error","processingfile","uploadprogress","finished"];defaultOptions={url:null,parallelUploads:2,maxFilesize:256,paramName:"file",createImageThumbnails:!0,maxThumbnailFilesize:2,thumbnailWidth:120,thumbnailHeight:120,accept:function(file){return!0},fallback:function(){return this.element.find(".message").html("Your browser does not support drag'n'drop file uploads.")},drop:function(e){return this.element.find(".message").hide()},dragstart:function(e){},dragend:function(e){},dragenter:function(e){return this.element.addClass("drag-hover")},dragover:function(e){return this.element.addClass("drag-hover")},dragleave:function(e){return this.element.removeClass("drag-hover")},addedfile:function(file){file.previewTemplate=$(this.options.previewTemplate);this.element.append(file.previewTemplate);return file.previewTemplate.find(".details").html($("<span>"+file.name+"</span>"))},thumbnail:function(file,dataUrl){file.previewTemplate.removeClass("file-preview").addClass("image-preview");return file.previewTemplate.find(".details").html($('<img alt="" src="'+dataUrl+'"/>'))},error:function(file,message){file.previewTemplate.addClass("process-error");return file.previewTemplate.find(".error-message span").html(message)},processingfile:function(file){return file.previewTemplate.addClass("processing")},uploadprogress:function(file,progress){return file.previewTemplate.find(".progress .upload").css({width:""+progress+"%"})},finished:function(file){return file.previewTemplate.addClass("finished")},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="finished-success"><span>✔</span></div>\n <div class="finished-error"><span>✘</span></div>\n <div class="error-message"><span></span></div>\n</div>'};defaultOptions.previewTemplate=defaultOptions.previewTemplate.replace(/\n*/g,"");Dropzone.prototype.init=function(){var _ref;if(!(window.File&&window.FileReader&&window.FileList&&window.Blob&&window.FormData)){this.options.fallback.call(this);return}this.files=[];this.files.queue=[];this.files.processing=[];this.URL=(_ref=window.URL)!=null?_ref:window.webkitURL;this.setupEventListeners();if(this.element.find(".message").length===0)return this.element.append($('<div class="message">Drop files here to upload</div>'))};Dropzone.prototype.getFallbackForm=function(){return $('<form action="'+this.options.url+'" enctype="multipart/form-data" method="post"><input type="file" name="newFiles" multiple="multiple" /><button type="submit">Upload!</button></form>')};Dropzone.prototype.setupEventListeners=function(){var eventName,noPropagation,_i,_len,_ref,_this=this;_ref=this.events;for(_i=0,_len=_ref.length;_i<_len;_i++){eventName=_ref[_i];bean.add(this,eventName,this.options[eventName])}noPropagation=function(e){e.stopPropagation();return e.preventDefault()};this.element.on("dragstart",function(e){return bean.fire(_this,"dragstart",e)});this.element.on("dragenter",function(e){noPropagation(e);return bean.fire(_this,"dragenter",e)});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){bean.fire(_this,"dragleave",e);return bean.fire(_this,"dragend",e)})};Dropzone.prototype.drop=function(e){var files;if(!e.dataTransfer)return;files=e.dataTransfer.files;if(files.length)return this.handleFiles(files)};Dropzone.prototype.handleFiles=function(files){var file,_i,_len;for(_i=0,_len=files.length;_i<_len;_i++){file=files[_i];this.accept(file)&&this.addFile(file)}return this.processQueue()};Dropzone.prototype.accept=function(file){return this.options.accept.call(this,file)};Dropzone.prototype.addFile=function(file){this.files.push(file);this.files.queue.push(file);bean.fire(this,"addedfile",file);if(this.options.createImageThumbnails&&file.type.match(/image.*/)&&file.size<=this.options.maxThumbnailFilesize*1024*1024)return this.createThumbnail(file)};Dropzone.prototype.createThumbnail=function(file){var blobUrl,img,_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,srcRatio,thumbnail,trgHeight,trgRatio,trgWidth,trgX,trgY;canvas=document.createElement("canvas");ctx=canvas.getContext("2d");trgX=0;trgY=0;trgWidth=0;trgHeight=0;srcRatio=void 0;trgRatio=void 0;canvas.width=_this.options.thumbnailWidth;canvas.height=_this.options.thumbnailHeight;srcRatio=img.width/img.height;trgRatio=canvas.width/canvas.height;if(srcRatio>trgRatio){trgWidth=canvas.width;trgHeight=trgWidth/srcRatio}else{trgHeight=canvas.height;trgWidth=trgHeight*srcRatio}trgX=(canvas.width-trgWidth)/2;trgY=(canvas.height-trgHeight)/2;ctx.drawImage(img,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};Dropzone.prototype.processQueue=function(){var i,parallelUploads,processingLength;parallelUploads=this.options.parallelUploads;processingLength=this.files.processing.length;i=processingLength;while(i<parallelUploads){if(!this.files.queue.length)return;this.processFile(this.files.queue.shift());i++}};Dropzone.prototype.processFile=function(file){var fileReader;fileReader=new FileReader;this.files.processing.push(file);bean.fire(this,"processingfile",file);return file.size>this.options.maxFilesize*1024*1024?this.errorProcessing(file,"File is too big ("+Math.round(file.size/1024/10.24)/100+"MB). Max filesize: "+this.options.maxFilesize+"MB"):this.uploadFile(file)};Dropzone.prototype.uploadFile=function(file){var formData,progressObj,xhr,_ref,_this=this;xhr=new XMLHttpRequest;formData=new FormData;formData.append(this.options.paramName,file);formData.append("test","HI");xhr.open("POST",this.options.url,!0);xhr.onload=function(e){if(xhr.status!==200)return _this.errorProcessing(file,"Server responded with "+xhr.status+" code.");bean.fire(_this,"uploadprogress",[file,100]);return _this.finished(file,e)};xhr.onerror=function(){return _this.errorProcessing(file,xhr.responseText)};progressObj=(_ref=xhr.upload)!=null?_ref:xhr;progressObj.onprogress=function(e){return bean.fire(_this,"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);return xhr.send(formData)};Dropzone.prototype.finished=function(file){this.files.processing=without(this.files.processing,file);bean.fire(this,"finished",file);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()};return Dropzone}();without=function(list,rejectedItem){var item,_i,_len,_results;_results=[];for(_i=0,_len=list.length;_i<_len;_i++){item=list[_i];item!==rejectedItem&&_results.push(item)}return _results}}).call(this);provide("dropzone",module.exports)})()

@@ -31,3 +31,3 @@ // Generated by CoffeeScript 1.3.3

Dropzone.prototype.version = "0.2.0";
Dropzone.prototype.version = "0.2.1";

@@ -79,3 +79,3 @@ /*

dragleave: function(e) {
return this.element.addClass("drag-hover");
return this.element.removeClass("drag-hover");
},

@@ -82,0 +82,0 @@ addedfile: function(file) {

{
"name": "dropzone",
"version": "0.2.0",
"version": "0.2.1",
"description": "Handles drag and drop of files for you.",

@@ -5,0 +5,0 @@ "keywords": [ "dragndrop", "ender" ],

@@ -1,2 +0,2 @@

# Dropzone.js Version 0.2.0
# Dropzone.js Version 0.2.1

@@ -3,0 +3,0 @@ Dropzone.js is a light weight JavaScript library for [ender](http://ender.no.de) that turns an HTML element into a dropzone.

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc