diff --git a/component.json b/component.json index 41548fe72..8cb83314f 100644 --- a/component.json +++ b/component.json @@ -1,7 +1,7 @@ { "name": "dropzone", "repo": "enyo/dropzone", - "version": "3.1.1-dev", + "version": "3.2.0", "description": "Handles drag and drop of files for you.", "scripts": [ "index.js", "lib/dropzone.js" ], "styles": [ "downloads/css/basic.css" ], diff --git a/downloads/dropzone-amd-module.js b/downloads/dropzone-amd-module.js index 5896fca2e..4d28b08c5 100644 --- a/downloads/dropzone-amd-module.js +++ b/downloads/dropzone-amd-module.js @@ -908,7 +908,7 @@ Emitter.prototype.hasListeners = function(event){ })(Em); - Dropzone.version = "3.1.1-dev"; + Dropzone.version = "3.2.0"; Dropzone.options = {}; diff --git a/downloads/dropzone-amd-module.min.js b/downloads/dropzone-amd-module.min.js index 4bf7d06f5..7ea744299 100644 --- a/downloads/dropzone-amd-module.min.js +++ b/downloads/dropzone-amd-module.min.js @@ -1 +1 @@ -!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a(jQuery)}(function(a){function b(a){return a?c(a):void 0}function c(a){for(var c in b.prototype)a[c]=b.prototype[c];return a}var d={exports:{}};return d.exports=b,b.prototype.on=function(a,b){return this._callbacks=this._callbacks||{},(this._callbacks[a]=this._callbacks[a]||[]).push(b),this},b.prototype.once=function(a,b){function c(){d.off(a,c),b.apply(this,arguments)}var d=this;return this._callbacks=this._callbacks||{},b._off=c,this.on(a,c),this},b.prototype.off=b.prototype.removeListener=b.prototype.removeAllListeners=function(a,b){this._callbacks=this._callbacks||{};var c=this._callbacks[a];if(!c)return this;if(1==arguments.length)return delete this._callbacks[a],this;var d=c.indexOf(b._off||b);return~d&&c.splice(d,1),this},b.prototype.emit=function(a){this._callbacks=this._callbacks||{};var b=[].slice.call(arguments,1),c=this._callbacks[a];if(c){c=c.slice(0);for(var d=0,e=c.length;e>d;++d)c[d].apply(this,b)}return this},b.prototype.listeners=function(a){return this._callbacks=this._callbacks||{},this._callbacks[a]||[]},b.prototype.hasListeners=function(a){return!!this.listeners(a).length},function(){var c,e,f,g,h,i,j={}.hasOwnProperty,k=function(a,b){function c(){this.constructor=a}for(var d in b)j.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},l=[].slice,m=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};e="undefined"!=typeof b&&null!==b?b:require("emitter"),h=function(){},c=function(a){function b(a,c){var d,e,f,g;if(this.element=a,this.version=b.version,this.defaultOptions.previewTemplate=this.defaultOptions.previewTemplate.replace(/\n*/g,""),"string"==typeof this.element&&(this.element=document.querySelector(this.element)),!this.element||null==this.element.nodeType)throw new Error("Invalid dropzone element.");if(this.element.dropzone)throw new Error("Dropzone already attached.");if(b.instances.push(this),a.dropzone=this,d=null!=(g=b.optionsForElement(this.element))?g:{},e=function(){var a,b,c,d,e,f,g;for(d=arguments[0],c=2<=arguments.length?l.call(arguments,1):[],f=0,g=c.length;g>f;f++){b=c[f];for(a in b)e=b[a],d[a]=e}return d},this.options=e({},this.defaultOptions,d,null!=c?c:{}),null==this.options.url&&(this.options.url=this.element.action),!this.options.url)throw new Error("No URL provided.");if(this.options.acceptParameter&&this.options.acceptedMimeTypes)throw new Error("You can't provide both 'acceptParameter' and 'acceptedMimeTypes'. 'acceptParameter' is deprecated.");return this.options.method=this.options.method.toUpperCase(),this.options.forceFallback||!b.isBrowserSupported()?this.options.fallback.call(this):((f=this.getExistingFallback())&&f.parentNode&&f.parentNode.removeChild(f),this.previewsContainer=this.options.previewsContainer?b.getElement(this.options.previewsContainer,"previewsContainer"):this.element,this.clickableElements=this.options.clickable?this.options.clickable===!0?[this.element]:b.getElements(this.options.clickable,"clickable"):[],this.init(),void 0)}return k(b,a),b.prototype.events=["drop","dragstart","dragend","dragenter","dragover","dragleave","selectedfiles","addedfile","removedfile","thumbnail","error","processingfile","uploadprogress","totaluploadprogress","sending","success","complete","reset"],b.prototype.defaultOptions={url:null,method:"post",parallelUploads:2,maxFilesize:256,paramName:"file",createImageThumbnails:!0,maxThumbnailFilesize:10,thumbnailWidth:100,thumbnailHeight:100,params:{},clickable:!0,acceptedMimeTypes:null,acceptParameter:null,enqueueForUpload:!0,previewsContainer:null,dictDefaultMessage:"Drop files here to upload",dictFallbackMessage:"Your browser does not support drag'n'drop file uploads.",dictFallbackText:"Please use the fallback form below to upload your files like in the olden days.",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.",accept:function(a,b){return b()},init:function(){return h},forceFallback:!1,fallback:function(){var a,c,d,e,f,g;for(this.element.className=""+this.element.className+" dz-browser-not-supported",g=this.element.getElementsByTagName("div"),e=0,f=g.length;f>e;e++)a=g[e],/(^| )message($| )/.test(a.className)&&(c=a,a.className="dz-message");return c||(c=b.createElement('
'),this.element.appendChild(c)),d=c.getElementsByTagName("span")[0],d&&(d.textContent=this.options.dictFallbackMessage),this.element.appendChild(this.getFallbackForm())},resize:function(a){var b,c,d;return b={srcX:0,srcY:0,srcWidth:a.width,srcHeight:a.height},c=a.width/a.height,d=this.options.thumbnailWidth/this.options.thumbnailHeight,a.heightd?(b.srcHeight=a.height,b.srcWidth=b.srcHeight*d):(b.srcWidth=a.width,b.srcHeight=b.srcWidth/d),b.srcX=(a.width-b.srcWidth)/2,b.srcY=(a.height-b.srcHeight)/2,b},drop:function(){return this.element.classList.remove("dz-drag-hover")},dragstart:h,dragend:function(){return this.element.classList.remove("dz-drag-hover")},dragenter:function(){return this.element.classList.add("dz-drag-hover")},dragover:function(){return this.element.classList.add("dz-drag-hover")},dragleave:function(){return this.element.classList.remove("dz-drag-hover")},selectedfiles:function(){return this.element===this.previewsContainer?this.element.classList.add("dz-started"):void 0},reset:function(){return this.element.classList.remove("dz-started")},addedfile:function(a){return a.previewElement=b.createElement(this.options.previewTemplate),a.previewTemplate=a.previewElement,this.previewsContainer.appendChild(a.previewElement),a.previewElement.querySelector("[data-dz-name]").textContent=a.name,a.previewElement.querySelector("[data-dz-size]").innerHTML=this.filesize(a.size)},removedfile:function(a){return a.previewElement.parentNode.removeChild(a.previewElement)},thumbnail:function(a,b){var c;return a.previewElement.classList.remove("dz-file-preview"),a.previewElement.classList.add("dz-image-preview"),c=a.previewElement.querySelector("[data-dz-thumbnail]"),c.alt=a.name,c.src=b},error:function(a,b){return a.previewElement.classList.add("dz-error"),a.previewElement.querySelector("[data-dz-errormessage]").textContent=b},processingfile:function(a){return a.previewElement.classList.add("dz-processing")},uploadprogress:function(a,b){return a.previewElement.querySelector("[data-dz-uploadprogress]").style.width=""+b+"%"},totaluploadprogress:h,sending:h,success:function(a){return a.previewElement.classList.add("dz-success")},complete:h,previewTemplate:'
\n
\n
\n
\n \n
\n
\n
\n
\n
\n
'},b.prototype.init=function(){var a,c,d,e,f,g,h,i=this;for("form"===this.element.tagName&&this.element.setAttribute("enctype","multipart/form-data"),this.element.classList.contains("dropzone")&&!this.element.querySelector("[data-dz-message]")&&this.element.appendChild(b.createElement('
'+this.options.dictDefaultMessage+"
")),this.clickableElements.length&&(d=function(){return i.hiddenFileInput&&document.body.removeChild(i.hiddenFileInput),i.hiddenFileInput=document.createElement("input"),i.hiddenFileInput.setAttribute("type","file"),i.hiddenFileInput.setAttribute("multiple","multiple"),null!=i.options.acceptedMimeTypes&&i.hiddenFileInput.setAttribute("accept",i.options.acceptedMimeTypes),null!=i.options.acceptParameter&&i.hiddenFileInput.setAttribute("accept",i.options.acceptParameter),i.hiddenFileInput.style.visibility="hidden",i.hiddenFileInput.style.position="absolute",i.hiddenFileInput.style.top="0",i.hiddenFileInput.style.left="0",i.hiddenFileInput.style.height="0",i.hiddenFileInput.style.width="0",document.body.appendChild(i.hiddenFileInput),i.hiddenFileInput.addEventListener("change",function(){var a;return a=i.hiddenFileInput.files,a.length&&(i.emit("selectedfiles",a),i.handleFiles(a)),d()})},d()),this.files=[],this.acceptedFiles=[],this.filesQueue=[],this.filesProcessing=[],this.URL=null!=(g=window.URL)?g:window.webkitURL,h=this.events,e=0,f=h.length;f>e;e++)a=h[e],this.on(a,this.options[a]);return this.on("uploadprogress",function(a){var b,c,d,e,f,g;for(c=0,b=0,g=i.acceptedFiles,e=0,f=g.length;f>e;e++)a=g[e],c+=a.upload.bytesSent,b+=a.upload.total;return d=100*c/b,i.emit("totaluploadprogress",d,b,c)}),c=function(a){return a.stopPropagation(),a.preventDefault?a.preventDefault():a.returnValue=!1},this.listeners=[{element:this.element,events:{dragstart:function(a){return i.emit("dragstart",a)},dragenter:function(a){return c(a),i.emit("dragenter",a)},dragover:function(a){return c(a),i.emit("dragover",a)},dragleave:function(a){return i.emit("dragleave",a)},drop:function(a){return c(a),i.drop(a),i.emit("drop",a)},dragend:function(a){return i.emit("dragend",a)}}}],this.clickableElements.forEach(function(a){return i.listeners.push({element:a,events:{click:function(c){return a!==i.element||c.target===i.element||b.elementInside(c.target,i.element.querySelector(".dz-message"))?i.hiddenFileInput.click():void 0}}})}),this.enable(),this.options.init.call(this)},b.prototype.getFallbackForm=function(){var a,c,d,e;return(a=this.getExistingFallback())?a:(d='
',this.options.dictFallbackText&&(d+="

"+this.options.dictFallbackText+"

"),d+='
',c=b.createElement(d),"FORM"!==this.element.tagName?(e=b.createElement('
'),e.appendChild(c)):(this.element.setAttribute("enctype","multipart/form-data"),this.element.setAttribute("method",this.options.method)),null!=e?e:c)},b.prototype.getExistingFallback=function(){var a,b,c,d,e,f;for(b=function(a){var b,c,d;for(c=0,d=a.length;d>c;c++)if(b=a[c],/(^| )fallback($| )/.test(b.className))return b},f=["div","form"],d=0,e=f.length;e>d;d++)if(c=f[d],a=b(this.element.getElementsByTagName(c)))return a},b.prototype.setupEventListeners=function(){var a,b,c,d,e,f,g;for(f=this.listeners,g=[],d=0,e=f.length;e>d;d++)a=f[d],g.push(function(){var d,e;d=a.events,e=[];for(b in d)c=d[b],e.push(a.element.addEventListener(b,c,!1));return e}());return g},b.prototype.removeEventListeners=function(){var a,b,c,d,e,f,g;for(f=this.listeners,g=[],d=0,e=f.length;e>d;d++)a=f[d],g.push(function(){var d,e;d=a.events,e=[];for(b in d)c=d[b],e.push(a.element.removeEventListener(b,c,!1));return e}());return g},b.prototype.disable=function(){return this.clickableElements.forEach(function(a){return a.classList.remove("dz-clickable")}),this.removeEventListeners(),this.filesProcessing=[],this.filesQueue=[]},b.prototype.enable=function(){return this.clickableElements.forEach(function(a){return a.classList.add("dz-clickable")}),this.setupEventListeners()},b.prototype.filesize=function(a){var b;return a>=1e11?(a/=1e11,b="TB"):a>=1e8?(a/=1e8,b="GB"):a>=1e5?(a/=1e5,b="MB"):a>=100?(a/=100,b="KB"):(a=10*a,b="b"),""+Math.round(a)/10+" "+b},b.prototype.drop=function(a){var b;if(a.dataTransfer)return b=a.dataTransfer.files,this.emit("selectedfiles",b),b.length?this.handleFiles(b):void 0},b.prototype.handleFiles=function(a){var b,c,d,e;for(e=[],c=0,d=a.length;d>c;c++)b=a[c],e.push(this.addFile(b));return e},b.prototype.accept=function(a,c){return a.size>1024*1024*this.options.maxFilesize?c(this.options.dictFileTooBig.replace("{{filesize}}",Math.round(a.size/1024/10.24)/100).replace("{{maxFilesize}}",this.options.maxFilesize)):b.isValidMimeType(a.type,this.options.acceptedMimeTypes)?this.options.accept.call(this,a,c):c(this.options.dictInvalidFileType)},b.prototype.addFile=function(a){var b=this;return a.upload={progress:0,total:a.size,bytesSent:0},this.files.push(a),this.emit("addedfile",a),this.options.createImageThumbnails&&a.type.match(/image.*/)&&a.size<=1024*1024*this.options.maxThumbnailFilesize&&this.createThumbnail(a),this.accept(a,function(c){return c?(a.accepted=!1,b.errorProcessing(a,c)):(a.accepted=!0,b.acceptedFiles.push(a),b.options.enqueueForUpload?(b.filesQueue.push(a),b.processQueue()):void 0)})},b.prototype.removeFile=function(a){if(a.processing)throw new Error("Can't remove file currently processing");return this.files=i(this.files,a),this.filesQueue=i(this.filesQueue,a),this.emit("removedfile",a),0===this.files.length?this.emit("reset"):void 0},b.prototype.removeAllFiles=function(){var a,b,c,d;for(d=this.files.slice(),b=0,c=d.length;c>b;b++)a=d[b],m.call(this.filesProcessing,a)<0&&this.removeFile(a);return null},b.prototype.createThumbnail=function(a){var b,c=this;return b=new FileReader,b.onload=function(){var d;return d=new Image,d.onload=function(){var b,e,f,g,h,i,j,k,l,m;return a.width=d.width,a.height=d.height,f=c.options.resize.call(c,a),null==(h=f.trgWidth)&&(f.trgWidth=c.options.thumbnailWidth),null==(i=f.trgHeight)&&(f.trgHeight=c.options.thumbnailHeight),b=document.createElement("canvas"),e=b.getContext("2d"),b.width=f.trgWidth,b.height=f.trgHeight,e.drawImage(d,null!=(j=f.srcX)?j:0,null!=(k=f.srcY)?k:0,f.srcWidth,f.srcHeight,null!=(l=f.trgX)?l:0,null!=(m=f.trgY)?m:0,f.trgWidth,f.trgHeight),g=b.toDataURL("image/png"),c.emit("thumbnail",a,g)},d.src=b.result},b.readAsDataURL(a)},b.prototype.processQueue=function(){var a,b,c;for(b=this.options.parallelUploads,c=this.filesProcessing.length,a=c;b>a;){if(!this.filesQueue.length)return;this.processFile(this.filesQueue.shift()),a++}},b.prototype.processFile=function(a){return this.filesProcessing.push(a),a.processing=!0,this.emit("processingfile",a),this.uploadFile(a)},b.prototype.uploadFile=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q=this;if(k=new XMLHttpRequest,k.open(this.options.method,this.options.url,!0),i=null,c=function(){return q.errorProcessing(a,i||q.options.dictResponseError.replace("{{statusCode}}",k.status),k)},k.onload=function(b){var d;if(i=k.responseText,k.getResponseHeader("content-type")&&~k.getResponseHeader("content-type").indexOf("application/json"))try{i=JSON.parse(i)}catch(e){b=e,i="Invalid JSON response from server."}return 200<=(d=k.status)&&300>d?q.finished(a,i,b):c()},k.onerror=function(){return c()},h=null!=(n=k.upload)?n:k,h.onprogress=function(b){var c;return a.upload={progress:c,total:b.total,bytesSent:b.loaded},c=100*b.loaded/b.total,q.emit("uploadprogress",a,c,b.loaded)},k.setRequestHeader("Accept","application/json"),k.setRequestHeader("Cache-Control","no-cache"),k.setRequestHeader("X-Requested-With","XMLHttpRequest"),k.setRequestHeader("X-File-Name",a.name),b=new FormData,this.options.params){o=this.options.params;for(g in o)j=o[g],b.append(g,j)}if("FORM"===this.element.tagName)for(p=this.element.querySelectorAll("input, textarea, select, button"),l=0,m=p.length;m>l;l++)d=p[l],e=d.getAttribute("name"),f=d.getAttribute("type"),(!f||"checkbox"!==f.toLowerCase()||d.checked)&&b.append(e,d.value);return this.emit("sending",a,k,b),b.append(this.options.paramName,a),k.send(b)},b.prototype.finished=function(a,b,c){return this.filesProcessing=i(this.filesProcessing,a),a.processing=!1,this.processQueue(),this.emit("success",a,b,c),this.emit("finished",a,b,c),this.emit("complete",a)},b.prototype.errorProcessing=function(a,b,c){return this.filesProcessing=i(this.filesProcessing,a),a.processing=!1,this.processQueue(),this.emit("error",a,b,c),this.emit("complete",a)},b}(e),c.version="3.1.1-dev",c.options={},c.optionsForElement=function(a){return a.id?c.options[f(a.id)]:void 0},c.instances=[],c.forElement=function(a){var b;return"string"==typeof a&&(a=document.querySelector(a)),null!=(b=a.dropzone)?b:null},c.autoDiscover=!0,c.discover=function(){var a,b,d,e,f,g;if(c.autoDiscover){for(document.querySelectorAll?d=document.querySelectorAll(".dropzone"):(d=[],a=function(a){var b,c,e,f;for(f=[],c=0,e=a.length;e>c;c++)b=a[c],/(^| )dropzone($| )/.test(b.className)?f.push(d.push(b)):f.push(void 0);return f},a(document.getElementsByTagName("div")),a(document.getElementsByTagName("form"))),g=[],e=0,f=d.length;f>e;e++)b=d[e],c.optionsForElement(b)!==!1?g.push(new c(b)):g.push(void 0);return g}},c.blacklistedBrowsers=[/opera.*Macintosh.*version\/12/i],c.isBrowserSupported=function(){var a,b,d,e,f;if(a=!0,window.File&&window.FileReader&&window.FileList&&window.Blob&&window.FormData&&document.querySelector)if("classList"in document.createElement("a"))for(f=c.blacklistedBrowsers,d=0,e=f.length;e>d;d++)b=f[d],b.test(navigator.userAgent)&&(a=!1);else a=!1;else a=!1;return a},i=function(a,b){var c,d,e,f;for(f=[],d=0,e=a.length;e>d;d++)c=a[d],c!==b&&f.push(c);return f},f=function(a){return a.replace(/[\-_](\w)/g,function(a){return a[1].toUpperCase()})},c.createElement=function(a){var b;return b=document.createElement("div"),b.innerHTML=a,b.childNodes[0]},c.elementInside=function(a,b){if(a===b)return!0;for(;a=a.parentNode;)if(a===b)return!0;return!1},c.getElement=function(a,b){var c;if("string"==typeof a?c=document.querySelector(a):null!=a.nodeType&&(c=a),null==c)throw new Error("Invalid `"+b+"` option provided. Please provide a CSS selector or a plain HTML element.");return c},c.getElements=function(a,b){var c,d,e,f,g,h,i,j;if(a instanceof Array){e=[];try{for(f=0,h=a.length;h>f;f++)d=a[f],e.push(this.getElement(d,b))}catch(k){c=k,e=null}}else if("string"==typeof a)for(e=[],j=document.querySelectorAll(a),g=0,i=j.length;i>g;g++)d=j[g],e.push(d);else null!=a.nodeType&&(e=[a]);if(null==e||!e.length)throw new Error("Invalid `"+b+"` option provided. Please provide a CSS selector, a plain HTML element or a list of those.");return e},c.isValidMimeType=function(a,b){var c,d,e,f;if(!b)return!0;for(b=b.split(","),c=a.replace(/\/.*$/,""),e=0,f=b.length;f>e;e++)if(d=b[e],d=d.trim(),/\/\*$/.test(d)){if(c===d.replace(/\/.*$/,""))return!0}else if(a===d)return!0;return!1},"undefined"!=typeof a&&null!==a&&(a.fn.dropzone=function(a){return this.each(function(){return new c(this,a)})}),"undefined"!=typeof d&&null!==d?d.exports=c:window.Dropzone=c,g=function(a,b){var c,d,e,f,g,h,i,j,k;if(e=!1,k=!0,d=a.document,j=d.documentElement,c=d.addEventListener?"addEventListener":"attachEvent",i=d.addEventListener?"removeEventListener":"detachEvent",h=d.addEventListener?"":"on",f=function(c){return"readystatechange"!==c.type||"complete"===d.readyState?(("load"===c.type?a:d)[i](h+c.type,f,!1),!e&&(e=!0)?b.call(a,c.type||c):void 0):void 0},g=function(){var a;try{j.doScroll("left")}catch(b){return a=b,setTimeout(g,50),void 0}return f("poll")},"complete"!==d.readyState){if(d.createEventObject&&j.doScroll){try{k=!a.frameElement}catch(l){}k&&g()}return d[c](h+"DOMContentLoaded",f,!1),d[c](h+"readystatechange",f,!1),a[c](h+"load",f,!1)}},g(window,c.discover)}.call(this),d.exports}); \ No newline at end of file +!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a(jQuery)}(function(a){function b(a){return a?c(a):void 0}function c(a){for(var c in b.prototype)a[c]=b.prototype[c];return a}var d={exports:{}};return d.exports=b,b.prototype.on=function(a,b){return this._callbacks=this._callbacks||{},(this._callbacks[a]=this._callbacks[a]||[]).push(b),this},b.prototype.once=function(a,b){function c(){d.off(a,c),b.apply(this,arguments)}var d=this;return this._callbacks=this._callbacks||{},b._off=c,this.on(a,c),this},b.prototype.off=b.prototype.removeListener=b.prototype.removeAllListeners=function(a,b){this._callbacks=this._callbacks||{};var c=this._callbacks[a];if(!c)return this;if(1==arguments.length)return delete this._callbacks[a],this;var d=c.indexOf(b._off||b);return~d&&c.splice(d,1),this},b.prototype.emit=function(a){this._callbacks=this._callbacks||{};var b=[].slice.call(arguments,1),c=this._callbacks[a];if(c){c=c.slice(0);for(var d=0,e=c.length;e>d;++d)c[d].apply(this,b)}return this},b.prototype.listeners=function(a){return this._callbacks=this._callbacks||{},this._callbacks[a]||[]},b.prototype.hasListeners=function(a){return!!this.listeners(a).length},function(){var c,e,f,g,h,i,j={}.hasOwnProperty,k=function(a,b){function c(){this.constructor=a}for(var d in b)j.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},l=[].slice,m=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};e="undefined"!=typeof b&&null!==b?b:require("emitter"),h=function(){},c=function(a){function b(a,c){var d,e,f,g;if(this.element=a,this.version=b.version,this.defaultOptions.previewTemplate=this.defaultOptions.previewTemplate.replace(/\n*/g,""),"string"==typeof this.element&&(this.element=document.querySelector(this.element)),!this.element||null==this.element.nodeType)throw new Error("Invalid dropzone element.");if(this.element.dropzone)throw new Error("Dropzone already attached.");if(b.instances.push(this),a.dropzone=this,d=null!=(g=b.optionsForElement(this.element))?g:{},e=function(){var a,b,c,d,e,f,g;for(d=arguments[0],c=2<=arguments.length?l.call(arguments,1):[],f=0,g=c.length;g>f;f++){b=c[f];for(a in b)e=b[a],d[a]=e}return d},this.options=e({},this.defaultOptions,d,null!=c?c:{}),null==this.options.url&&(this.options.url=this.element.action),!this.options.url)throw new Error("No URL provided.");if(this.options.acceptParameter&&this.options.acceptedMimeTypes)throw new Error("You can't provide both 'acceptParameter' and 'acceptedMimeTypes'. 'acceptParameter' is deprecated.");return this.options.method=this.options.method.toUpperCase(),this.options.forceFallback||!b.isBrowserSupported()?this.options.fallback.call(this):((f=this.getExistingFallback())&&f.parentNode&&f.parentNode.removeChild(f),this.previewsContainer=this.options.previewsContainer?b.getElement(this.options.previewsContainer,"previewsContainer"):this.element,this.clickableElements=this.options.clickable?this.options.clickable===!0?[this.element]:b.getElements(this.options.clickable,"clickable"):[],this.init(),void 0)}return k(b,a),b.prototype.events=["drop","dragstart","dragend","dragenter","dragover","dragleave","selectedfiles","addedfile","removedfile","thumbnail","error","processingfile","uploadprogress","totaluploadprogress","sending","success","complete","reset"],b.prototype.defaultOptions={url:null,method:"post",parallelUploads:2,maxFilesize:256,paramName:"file",createImageThumbnails:!0,maxThumbnailFilesize:10,thumbnailWidth:100,thumbnailHeight:100,params:{},clickable:!0,acceptedMimeTypes:null,acceptParameter:null,enqueueForUpload:!0,previewsContainer:null,dictDefaultMessage:"Drop files here to upload",dictFallbackMessage:"Your browser does not support drag'n'drop file uploads.",dictFallbackText:"Please use the fallback form below to upload your files like in the olden days.",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.",accept:function(a,b){return b()},init:function(){return h},forceFallback:!1,fallback:function(){var a,c,d,e,f,g;for(this.element.className=""+this.element.className+" dz-browser-not-supported",g=this.element.getElementsByTagName("div"),e=0,f=g.length;f>e;e++)a=g[e],/(^| )message($| )/.test(a.className)&&(c=a,a.className="dz-message");return c||(c=b.createElement('
'),this.element.appendChild(c)),d=c.getElementsByTagName("span")[0],d&&(d.textContent=this.options.dictFallbackMessage),this.element.appendChild(this.getFallbackForm())},resize:function(a){var b,c,d;return b={srcX:0,srcY:0,srcWidth:a.width,srcHeight:a.height},c=a.width/a.height,d=this.options.thumbnailWidth/this.options.thumbnailHeight,a.heightd?(b.srcHeight=a.height,b.srcWidth=b.srcHeight*d):(b.srcWidth=a.width,b.srcHeight=b.srcWidth/d),b.srcX=(a.width-b.srcWidth)/2,b.srcY=(a.height-b.srcHeight)/2,b},drop:function(){return this.element.classList.remove("dz-drag-hover")},dragstart:h,dragend:function(){return this.element.classList.remove("dz-drag-hover")},dragenter:function(){return this.element.classList.add("dz-drag-hover")},dragover:function(){return this.element.classList.add("dz-drag-hover")},dragleave:function(){return this.element.classList.remove("dz-drag-hover")},selectedfiles:function(){return this.element===this.previewsContainer?this.element.classList.add("dz-started"):void 0},reset:function(){return this.element.classList.remove("dz-started")},addedfile:function(a){return a.previewElement=b.createElement(this.options.previewTemplate),a.previewTemplate=a.previewElement,this.previewsContainer.appendChild(a.previewElement),a.previewElement.querySelector("[data-dz-name]").textContent=a.name,a.previewElement.querySelector("[data-dz-size]").innerHTML=this.filesize(a.size)},removedfile:function(a){return a.previewElement.parentNode.removeChild(a.previewElement)},thumbnail:function(a,b){var c;return a.previewElement.classList.remove("dz-file-preview"),a.previewElement.classList.add("dz-image-preview"),c=a.previewElement.querySelector("[data-dz-thumbnail]"),c.alt=a.name,c.src=b},error:function(a,b){return a.previewElement.classList.add("dz-error"),a.previewElement.querySelector("[data-dz-errormessage]").textContent=b},processingfile:function(a){return a.previewElement.classList.add("dz-processing")},uploadprogress:function(a,b){return a.previewElement.querySelector("[data-dz-uploadprogress]").style.width=""+b+"%"},totaluploadprogress:h,sending:h,success:function(a){return a.previewElement.classList.add("dz-success")},complete:h,previewTemplate:'
\n
\n
\n
\n \n
\n
\n
\n
\n
\n
'},b.prototype.init=function(){var a,c,d,e,f,g,h,i=this;for("form"===this.element.tagName&&this.element.setAttribute("enctype","multipart/form-data"),this.element.classList.contains("dropzone")&&!this.element.querySelector("[data-dz-message]")&&this.element.appendChild(b.createElement('
'+this.options.dictDefaultMessage+"
")),this.clickableElements.length&&(d=function(){return i.hiddenFileInput&&document.body.removeChild(i.hiddenFileInput),i.hiddenFileInput=document.createElement("input"),i.hiddenFileInput.setAttribute("type","file"),i.hiddenFileInput.setAttribute("multiple","multiple"),null!=i.options.acceptedMimeTypes&&i.hiddenFileInput.setAttribute("accept",i.options.acceptedMimeTypes),null!=i.options.acceptParameter&&i.hiddenFileInput.setAttribute("accept",i.options.acceptParameter),i.hiddenFileInput.style.visibility="hidden",i.hiddenFileInput.style.position="absolute",i.hiddenFileInput.style.top="0",i.hiddenFileInput.style.left="0",i.hiddenFileInput.style.height="0",i.hiddenFileInput.style.width="0",document.body.appendChild(i.hiddenFileInput),i.hiddenFileInput.addEventListener("change",function(){var a;return a=i.hiddenFileInput.files,a.length&&(i.emit("selectedfiles",a),i.handleFiles(a)),d()})},d()),this.files=[],this.acceptedFiles=[],this.filesQueue=[],this.filesProcessing=[],this.URL=null!=(g=window.URL)?g:window.webkitURL,h=this.events,e=0,f=h.length;f>e;e++)a=h[e],this.on(a,this.options[a]);return this.on("uploadprogress",function(a){var b,c,d,e,f,g;for(c=0,b=0,g=i.acceptedFiles,e=0,f=g.length;f>e;e++)a=g[e],c+=a.upload.bytesSent,b+=a.upload.total;return d=100*c/b,i.emit("totaluploadprogress",d,b,c)}),c=function(a){return a.stopPropagation(),a.preventDefault?a.preventDefault():a.returnValue=!1},this.listeners=[{element:this.element,events:{dragstart:function(a){return i.emit("dragstart",a)},dragenter:function(a){return c(a),i.emit("dragenter",a)},dragover:function(a){return c(a),i.emit("dragover",a)},dragleave:function(a){return i.emit("dragleave",a)},drop:function(a){return c(a),i.drop(a),i.emit("drop",a)},dragend:function(a){return i.emit("dragend",a)}}}],this.clickableElements.forEach(function(a){return i.listeners.push({element:a,events:{click:function(c){return a!==i.element||c.target===i.element||b.elementInside(c.target,i.element.querySelector(".dz-message"))?i.hiddenFileInput.click():void 0}}})}),this.enable(),this.options.init.call(this)},b.prototype.getFallbackForm=function(){var a,c,d,e;return(a=this.getExistingFallback())?a:(d='
',this.options.dictFallbackText&&(d+="

"+this.options.dictFallbackText+"

"),d+='
',c=b.createElement(d),"FORM"!==this.element.tagName?(e=b.createElement('
'),e.appendChild(c)):(this.element.setAttribute("enctype","multipart/form-data"),this.element.setAttribute("method",this.options.method)),null!=e?e:c)},b.prototype.getExistingFallback=function(){var a,b,c,d,e,f;for(b=function(a){var b,c,d;for(c=0,d=a.length;d>c;c++)if(b=a[c],/(^| )fallback($| )/.test(b.className))return b},f=["div","form"],d=0,e=f.length;e>d;d++)if(c=f[d],a=b(this.element.getElementsByTagName(c)))return a},b.prototype.setupEventListeners=function(){var a,b,c,d,e,f,g;for(f=this.listeners,g=[],d=0,e=f.length;e>d;d++)a=f[d],g.push(function(){var d,e;d=a.events,e=[];for(b in d)c=d[b],e.push(a.element.addEventListener(b,c,!1));return e}());return g},b.prototype.removeEventListeners=function(){var a,b,c,d,e,f,g;for(f=this.listeners,g=[],d=0,e=f.length;e>d;d++)a=f[d],g.push(function(){var d,e;d=a.events,e=[];for(b in d)c=d[b],e.push(a.element.removeEventListener(b,c,!1));return e}());return g},b.prototype.disable=function(){return this.clickableElements.forEach(function(a){return a.classList.remove("dz-clickable")}),this.removeEventListeners(),this.filesProcessing=[],this.filesQueue=[]},b.prototype.enable=function(){return this.clickableElements.forEach(function(a){return a.classList.add("dz-clickable")}),this.setupEventListeners()},b.prototype.filesize=function(a){var b;return a>=1e11?(a/=1e11,b="TB"):a>=1e8?(a/=1e8,b="GB"):a>=1e5?(a/=1e5,b="MB"):a>=100?(a/=100,b="KB"):(a=10*a,b="b"),""+Math.round(a)/10+" "+b},b.prototype.drop=function(a){var b;if(a.dataTransfer)return b=a.dataTransfer.files,this.emit("selectedfiles",b),b.length?this.handleFiles(b):void 0},b.prototype.handleFiles=function(a){var b,c,d,e;for(e=[],c=0,d=a.length;d>c;c++)b=a[c],e.push(this.addFile(b));return e},b.prototype.accept=function(a,c){return a.size>1024*1024*this.options.maxFilesize?c(this.options.dictFileTooBig.replace("{{filesize}}",Math.round(a.size/1024/10.24)/100).replace("{{maxFilesize}}",this.options.maxFilesize)):b.isValidMimeType(a.type,this.options.acceptedMimeTypes)?this.options.accept.call(this,a,c):c(this.options.dictInvalidFileType)},b.prototype.addFile=function(a){var b=this;return a.upload={progress:0,total:a.size,bytesSent:0},this.files.push(a),this.emit("addedfile",a),this.options.createImageThumbnails&&a.type.match(/image.*/)&&a.size<=1024*1024*this.options.maxThumbnailFilesize&&this.createThumbnail(a),this.accept(a,function(c){return c?(a.accepted=!1,b.errorProcessing(a,c)):(a.accepted=!0,b.acceptedFiles.push(a),b.options.enqueueForUpload?(b.filesQueue.push(a),b.processQueue()):void 0)})},b.prototype.removeFile=function(a){if(a.processing)throw new Error("Can't remove file currently processing");return this.files=i(this.files,a),this.filesQueue=i(this.filesQueue,a),this.emit("removedfile",a),0===this.files.length?this.emit("reset"):void 0},b.prototype.removeAllFiles=function(){var a,b,c,d;for(d=this.files.slice(),b=0,c=d.length;c>b;b++)a=d[b],m.call(this.filesProcessing,a)<0&&this.removeFile(a);return null},b.prototype.createThumbnail=function(a){var b,c=this;return b=new FileReader,b.onload=function(){var d;return d=new Image,d.onload=function(){var b,e,f,g,h,i,j,k,l,m;return a.width=d.width,a.height=d.height,f=c.options.resize.call(c,a),null==(h=f.trgWidth)&&(f.trgWidth=c.options.thumbnailWidth),null==(i=f.trgHeight)&&(f.trgHeight=c.options.thumbnailHeight),b=document.createElement("canvas"),e=b.getContext("2d"),b.width=f.trgWidth,b.height=f.trgHeight,e.drawImage(d,null!=(j=f.srcX)?j:0,null!=(k=f.srcY)?k:0,f.srcWidth,f.srcHeight,null!=(l=f.trgX)?l:0,null!=(m=f.trgY)?m:0,f.trgWidth,f.trgHeight),g=b.toDataURL("image/png"),c.emit("thumbnail",a,g)},d.src=b.result},b.readAsDataURL(a)},b.prototype.processQueue=function(){var a,b,c;for(b=this.options.parallelUploads,c=this.filesProcessing.length,a=c;b>a;){if(!this.filesQueue.length)return;this.processFile(this.filesQueue.shift()),a++}},b.prototype.processFile=function(a){return this.filesProcessing.push(a),a.processing=!0,this.emit("processingfile",a),this.uploadFile(a)},b.prototype.uploadFile=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q=this;if(k=new XMLHttpRequest,k.open(this.options.method,this.options.url,!0),i=null,c=function(){return q.errorProcessing(a,i||q.options.dictResponseError.replace("{{statusCode}}",k.status),k)},k.onload=function(b){var d;if(i=k.responseText,k.getResponseHeader("content-type")&&~k.getResponseHeader("content-type").indexOf("application/json"))try{i=JSON.parse(i)}catch(e){b=e,i="Invalid JSON response from server."}return 200<=(d=k.status)&&300>d?q.finished(a,i,b):c()},k.onerror=function(){return c()},h=null!=(n=k.upload)?n:k,h.onprogress=function(b){var c;return a.upload={progress:c,total:b.total,bytesSent:b.loaded},c=100*b.loaded/b.total,q.emit("uploadprogress",a,c,b.loaded)},k.setRequestHeader("Accept","application/json"),k.setRequestHeader("Cache-Control","no-cache"),k.setRequestHeader("X-Requested-With","XMLHttpRequest"),k.setRequestHeader("X-File-Name",a.name),b=new FormData,this.options.params){o=this.options.params;for(g in o)j=o[g],b.append(g,j)}if("FORM"===this.element.tagName)for(p=this.element.querySelectorAll("input, textarea, select, button"),l=0,m=p.length;m>l;l++)d=p[l],e=d.getAttribute("name"),f=d.getAttribute("type"),(!f||"checkbox"!==f.toLowerCase()||d.checked)&&b.append(e,d.value);return this.emit("sending",a,k,b),b.append(this.options.paramName,a),k.send(b)},b.prototype.finished=function(a,b,c){return this.filesProcessing=i(this.filesProcessing,a),a.processing=!1,this.processQueue(),this.emit("success",a,b,c),this.emit("finished",a,b,c),this.emit("complete",a)},b.prototype.errorProcessing=function(a,b,c){return this.filesProcessing=i(this.filesProcessing,a),a.processing=!1,this.processQueue(),this.emit("error",a,b,c),this.emit("complete",a)},b}(e),c.version="3.2.0",c.options={},c.optionsForElement=function(a){return a.id?c.options[f(a.id)]:void 0},c.instances=[],c.forElement=function(a){var b;return"string"==typeof a&&(a=document.querySelector(a)),null!=(b=a.dropzone)?b:null},c.autoDiscover=!0,c.discover=function(){var a,b,d,e,f,g;if(c.autoDiscover){for(document.querySelectorAll?d=document.querySelectorAll(".dropzone"):(d=[],a=function(a){var b,c,e,f;for(f=[],c=0,e=a.length;e>c;c++)b=a[c],/(^| )dropzone($| )/.test(b.className)?f.push(d.push(b)):f.push(void 0);return f},a(document.getElementsByTagName("div")),a(document.getElementsByTagName("form"))),g=[],e=0,f=d.length;f>e;e++)b=d[e],c.optionsForElement(b)!==!1?g.push(new c(b)):g.push(void 0);return g}},c.blacklistedBrowsers=[/opera.*Macintosh.*version\/12/i],c.isBrowserSupported=function(){var a,b,d,e,f;if(a=!0,window.File&&window.FileReader&&window.FileList&&window.Blob&&window.FormData&&document.querySelector)if("classList"in document.createElement("a"))for(f=c.blacklistedBrowsers,d=0,e=f.length;e>d;d++)b=f[d],b.test(navigator.userAgent)&&(a=!1);else a=!1;else a=!1;return a},i=function(a,b){var c,d,e,f;for(f=[],d=0,e=a.length;e>d;d++)c=a[d],c!==b&&f.push(c);return f},f=function(a){return a.replace(/[\-_](\w)/g,function(a){return a[1].toUpperCase()})},c.createElement=function(a){var b;return b=document.createElement("div"),b.innerHTML=a,b.childNodes[0]},c.elementInside=function(a,b){if(a===b)return!0;for(;a=a.parentNode;)if(a===b)return!0;return!1},c.getElement=function(a,b){var c;if("string"==typeof a?c=document.querySelector(a):null!=a.nodeType&&(c=a),null==c)throw new Error("Invalid `"+b+"` option provided. Please provide a CSS selector or a plain HTML element.");return c},c.getElements=function(a,b){var c,d,e,f,g,h,i,j;if(a instanceof Array){e=[];try{for(f=0,h=a.length;h>f;f++)d=a[f],e.push(this.getElement(d,b))}catch(k){c=k,e=null}}else if("string"==typeof a)for(e=[],j=document.querySelectorAll(a),g=0,i=j.length;i>g;g++)d=j[g],e.push(d);else null!=a.nodeType&&(e=[a]);if(null==e||!e.length)throw new Error("Invalid `"+b+"` option provided. Please provide a CSS selector, a plain HTML element or a list of those.");return e},c.isValidMimeType=function(a,b){var c,d,e,f;if(!b)return!0;for(b=b.split(","),c=a.replace(/\/.*$/,""),e=0,f=b.length;f>e;e++)if(d=b[e],d=d.trim(),/\/\*$/.test(d)){if(c===d.replace(/\/.*$/,""))return!0}else if(a===d)return!0;return!1},"undefined"!=typeof a&&null!==a&&(a.fn.dropzone=function(a){return this.each(function(){return new c(this,a)})}),"undefined"!=typeof d&&null!==d?d.exports=c:window.Dropzone=c,g=function(a,b){var c,d,e,f,g,h,i,j,k;if(e=!1,k=!0,d=a.document,j=d.documentElement,c=d.addEventListener?"addEventListener":"attachEvent",i=d.addEventListener?"removeEventListener":"detachEvent",h=d.addEventListener?"":"on",f=function(c){return"readystatechange"!==c.type||"complete"===d.readyState?(("load"===c.type?a:d)[i](h+c.type,f,!1),!e&&(e=!0)?b.call(a,c.type||c):void 0):void 0},g=function(){var a;try{j.doScroll("left")}catch(b){return a=b,setTimeout(g,50),void 0}return f("poll")},"complete"!==d.readyState){if(d.createEventObject&&j.doScroll){try{k=!a.frameElement}catch(l){}k&&g()}return d[c](h+"DOMContentLoaded",f,!1),d[c](h+"readystatechange",f,!1),a[c](h+"load",f,!1)}},g(window,c.discover)}.call(this),d.exports}); \ No newline at end of file diff --git a/downloads/dropzone.js b/downloads/dropzone.js index abc48da37..6d3ada054 100644 --- a/downloads/dropzone.js +++ b/downloads/dropzone.js @@ -1110,7 +1110,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){ })(Em); - Dropzone.version = "3.1.1-dev"; + Dropzone.version = "3.2.0"; Dropzone.options = {}; diff --git a/downloads/dropzone.min.js b/downloads/dropzone.min.js index 3aae3fd77..765a6c0e7 100644 --- a/downloads/dropzone.min.js +++ b/downloads/dropzone.min.js @@ -1 +1 @@ -!function(){function a(b,c,d){var e=a.resolve(b);if(null==e){d=d||b,c=c||"root";var f=new Error('Failed to require "'+d+'" from "'+c+'"');throw f.path=d,f.parent=c,f.require=!0,f}var g=a.modules[e];return g.exports||(g.exports={},g.client=g.component=!0,g.call(this,g.exports,a.relative(e),g)),g.exports}a.modules={},a.aliases={},a.resolve=function(b){"/"===b.charAt(0)&&(b=b.slice(1));for(var c=b+"/index.js",d=[b,b+".js",b+".json",b+"/index.js",b+"/index.json"],e=0;ed;++d)c[d].apply(this,b)}return this},d.prototype.listeners=function(a){return this._callbacks=this._callbacks||{},this._callbacks[a]||[]},d.prototype.hasListeners=function(a){return!!this.listeners(a).length}}),a.register("dropzone/index.js",function(a,b,c){c.exports=b("./lib/dropzone.js")}),a.register("dropzone/lib/dropzone.js",function(a,b,c){!function(){var a,d,e,f,g,h,i={}.hasOwnProperty,j=function(a,b){function c(){this.constructor=a}for(var d in b)i.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},k=[].slice,l=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};d="undefined"!=typeof Emitter&&null!==Emitter?Emitter:b("emitter"),g=function(){},a=function(a){function b(a,c){var d,e,f,g;if(this.element=a,this.version=b.version,this.defaultOptions.previewTemplate=this.defaultOptions.previewTemplate.replace(/\n*/g,""),"string"==typeof this.element&&(this.element=document.querySelector(this.element)),!this.element||null==this.element.nodeType)throw new Error("Invalid dropzone element.");if(this.element.dropzone)throw new Error("Dropzone already attached.");if(b.instances.push(this),a.dropzone=this,d=null!=(g=b.optionsForElement(this.element))?g:{},e=function(){var a,b,c,d,e,f,g;for(d=arguments[0],c=2<=arguments.length?k.call(arguments,1):[],f=0,g=c.length;g>f;f++){b=c[f];for(a in b)e=b[a],d[a]=e}return d},this.options=e({},this.defaultOptions,d,null!=c?c:{}),null==this.options.url&&(this.options.url=this.element.action),!this.options.url)throw new Error("No URL provided.");if(this.options.acceptParameter&&this.options.acceptedMimeTypes)throw new Error("You can't provide both 'acceptParameter' and 'acceptedMimeTypes'. 'acceptParameter' is deprecated.");return this.options.method=this.options.method.toUpperCase(),this.options.forceFallback||!b.isBrowserSupported()?this.options.fallback.call(this):((f=this.getExistingFallback())&&f.parentNode&&f.parentNode.removeChild(f),this.previewsContainer=this.options.previewsContainer?b.getElement(this.options.previewsContainer,"previewsContainer"):this.element,this.clickableElements=this.options.clickable?this.options.clickable===!0?[this.element]:b.getElements(this.options.clickable,"clickable"):[],this.init(),void 0)}return j(b,a),b.prototype.events=["drop","dragstart","dragend","dragenter","dragover","dragleave","selectedfiles","addedfile","removedfile","thumbnail","error","processingfile","uploadprogress","totaluploadprogress","sending","success","complete","reset"],b.prototype.defaultOptions={url:null,method:"post",parallelUploads:2,maxFilesize:256,paramName:"file",createImageThumbnails:!0,maxThumbnailFilesize:10,thumbnailWidth:100,thumbnailHeight:100,params:{},clickable:!0,acceptedMimeTypes:null,acceptParameter:null,enqueueForUpload:!0,previewsContainer:null,dictDefaultMessage:"Drop files here to upload",dictFallbackMessage:"Your browser does not support drag'n'drop file uploads.",dictFallbackText:"Please use the fallback form below to upload your files like in the olden days.",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.",accept:function(a,b){return b()},init:function(){return g},forceFallback:!1,fallback:function(){var a,c,d,e,f,g;for(this.element.className=""+this.element.className+" dz-browser-not-supported",g=this.element.getElementsByTagName("div"),e=0,f=g.length;f>e;e++)a=g[e],/(^| )message($| )/.test(a.className)&&(c=a,a.className="dz-message");return c||(c=b.createElement('
'),this.element.appendChild(c)),d=c.getElementsByTagName("span")[0],d&&(d.textContent=this.options.dictFallbackMessage),this.element.appendChild(this.getFallbackForm())},resize:function(a){var b,c,d;return b={srcX:0,srcY:0,srcWidth:a.width,srcHeight:a.height},c=a.width/a.height,d=this.options.thumbnailWidth/this.options.thumbnailHeight,a.heightd?(b.srcHeight=a.height,b.srcWidth=b.srcHeight*d):(b.srcWidth=a.width,b.srcHeight=b.srcWidth/d),b.srcX=(a.width-b.srcWidth)/2,b.srcY=(a.height-b.srcHeight)/2,b},drop:function(){return this.element.classList.remove("dz-drag-hover")},dragstart:g,dragend:function(){return this.element.classList.remove("dz-drag-hover")},dragenter:function(){return this.element.classList.add("dz-drag-hover")},dragover:function(){return this.element.classList.add("dz-drag-hover")},dragleave:function(){return this.element.classList.remove("dz-drag-hover")},selectedfiles:function(){return this.element===this.previewsContainer?this.element.classList.add("dz-started"):void 0},reset:function(){return this.element.classList.remove("dz-started")},addedfile:function(a){return a.previewElement=b.createElement(this.options.previewTemplate),a.previewTemplate=a.previewElement,this.previewsContainer.appendChild(a.previewElement),a.previewElement.querySelector("[data-dz-name]").textContent=a.name,a.previewElement.querySelector("[data-dz-size]").innerHTML=this.filesize(a.size)},removedfile:function(a){return a.previewElement.parentNode.removeChild(a.previewElement)},thumbnail:function(a,b){var c;return a.previewElement.classList.remove("dz-file-preview"),a.previewElement.classList.add("dz-image-preview"),c=a.previewElement.querySelector("[data-dz-thumbnail]"),c.alt=a.name,c.src=b},error:function(a,b){return a.previewElement.classList.add("dz-error"),a.previewElement.querySelector("[data-dz-errormessage]").textContent=b},processingfile:function(a){return a.previewElement.classList.add("dz-processing")},uploadprogress:function(a,b){return a.previewElement.querySelector("[data-dz-uploadprogress]").style.width=""+b+"%"},totaluploadprogress:g,sending:g,success:function(a){return a.previewElement.classList.add("dz-success")},complete:g,previewTemplate:'
\n
\n
\n
\n \n
\n
\n
\n
\n
\n
'},b.prototype.init=function(){var a,c,d,e,f,g,h,i=this;for("form"===this.element.tagName&&this.element.setAttribute("enctype","multipart/form-data"),this.element.classList.contains("dropzone")&&!this.element.querySelector("[data-dz-message]")&&this.element.appendChild(b.createElement('
'+this.options.dictDefaultMessage+"
")),this.clickableElements.length&&(d=function(){return i.hiddenFileInput&&document.body.removeChild(i.hiddenFileInput),i.hiddenFileInput=document.createElement("input"),i.hiddenFileInput.setAttribute("type","file"),i.hiddenFileInput.setAttribute("multiple","multiple"),null!=i.options.acceptedMimeTypes&&i.hiddenFileInput.setAttribute("accept",i.options.acceptedMimeTypes),null!=i.options.acceptParameter&&i.hiddenFileInput.setAttribute("accept",i.options.acceptParameter),i.hiddenFileInput.style.visibility="hidden",i.hiddenFileInput.style.position="absolute",i.hiddenFileInput.style.top="0",i.hiddenFileInput.style.left="0",i.hiddenFileInput.style.height="0",i.hiddenFileInput.style.width="0",document.body.appendChild(i.hiddenFileInput),i.hiddenFileInput.addEventListener("change",function(){var a;return a=i.hiddenFileInput.files,a.length&&(i.emit("selectedfiles",a),i.handleFiles(a)),d()})},d()),this.files=[],this.acceptedFiles=[],this.filesQueue=[],this.filesProcessing=[],this.URL=null!=(g=window.URL)?g:window.webkitURL,h=this.events,e=0,f=h.length;f>e;e++)a=h[e],this.on(a,this.options[a]);return this.on("uploadprogress",function(a){var b,c,d,e,f,g;for(c=0,b=0,g=i.acceptedFiles,e=0,f=g.length;f>e;e++)a=g[e],c+=a.upload.bytesSent,b+=a.upload.total;return d=100*c/b,i.emit("totaluploadprogress",d,b,c)}),c=function(a){return a.stopPropagation(),a.preventDefault?a.preventDefault():a.returnValue=!1},this.listeners=[{element:this.element,events:{dragstart:function(a){return i.emit("dragstart",a)},dragenter:function(a){return c(a),i.emit("dragenter",a)},dragover:function(a){return c(a),i.emit("dragover",a)},dragleave:function(a){return i.emit("dragleave",a)},drop:function(a){return c(a),i.drop(a),i.emit("drop",a)},dragend:function(a){return i.emit("dragend",a)}}}],this.clickableElements.forEach(function(a){return i.listeners.push({element:a,events:{click:function(c){return a!==i.element||c.target===i.element||b.elementInside(c.target,i.element.querySelector(".dz-message"))?i.hiddenFileInput.click():void 0}}})}),this.enable(),this.options.init.call(this)},b.prototype.getFallbackForm=function(){var a,c,d,e;return(a=this.getExistingFallback())?a:(d='
',this.options.dictFallbackText&&(d+="

"+this.options.dictFallbackText+"

"),d+='
',c=b.createElement(d),"FORM"!==this.element.tagName?(e=b.createElement('
'),e.appendChild(c)):(this.element.setAttribute("enctype","multipart/form-data"),this.element.setAttribute("method",this.options.method)),null!=e?e:c)},b.prototype.getExistingFallback=function(){var a,b,c,d,e,f;for(b=function(a){var b,c,d;for(c=0,d=a.length;d>c;c++)if(b=a[c],/(^| )fallback($| )/.test(b.className))return b},f=["div","form"],d=0,e=f.length;e>d;d++)if(c=f[d],a=b(this.element.getElementsByTagName(c)))return a},b.prototype.setupEventListeners=function(){var a,b,c,d,e,f,g;for(f=this.listeners,g=[],d=0,e=f.length;e>d;d++)a=f[d],g.push(function(){var d,e;d=a.events,e=[];for(b in d)c=d[b],e.push(a.element.addEventListener(b,c,!1));return e}());return g},b.prototype.removeEventListeners=function(){var a,b,c,d,e,f,g;for(f=this.listeners,g=[],d=0,e=f.length;e>d;d++)a=f[d],g.push(function(){var d,e;d=a.events,e=[];for(b in d)c=d[b],e.push(a.element.removeEventListener(b,c,!1));return e}());return g},b.prototype.disable=function(){return this.clickableElements.forEach(function(a){return a.classList.remove("dz-clickable")}),this.removeEventListeners(),this.filesProcessing=[],this.filesQueue=[]},b.prototype.enable=function(){return this.clickableElements.forEach(function(a){return a.classList.add("dz-clickable")}),this.setupEventListeners()},b.prototype.filesize=function(a){var b;return a>=1e11?(a/=1e11,b="TB"):a>=1e8?(a/=1e8,b="GB"):a>=1e5?(a/=1e5,b="MB"):a>=100?(a/=100,b="KB"):(a=10*a,b="b"),""+Math.round(a)/10+" "+b},b.prototype.drop=function(a){var b;if(a.dataTransfer)return b=a.dataTransfer.files,this.emit("selectedfiles",b),b.length?this.handleFiles(b):void 0},b.prototype.handleFiles=function(a){var b,c,d,e;for(e=[],c=0,d=a.length;d>c;c++)b=a[c],e.push(this.addFile(b));return e},b.prototype.accept=function(a,c){return a.size>1024*1024*this.options.maxFilesize?c(this.options.dictFileTooBig.replace("{{filesize}}",Math.round(a.size/1024/10.24)/100).replace("{{maxFilesize}}",this.options.maxFilesize)):b.isValidMimeType(a.type,this.options.acceptedMimeTypes)?this.options.accept.call(this,a,c):c(this.options.dictInvalidFileType)},b.prototype.addFile=function(a){var b=this;return a.upload={progress:0,total:a.size,bytesSent:0},this.files.push(a),this.emit("addedfile",a),this.options.createImageThumbnails&&a.type.match(/image.*/)&&a.size<=1024*1024*this.options.maxThumbnailFilesize&&this.createThumbnail(a),this.accept(a,function(c){return c?(a.accepted=!1,b.errorProcessing(a,c)):(a.accepted=!0,b.acceptedFiles.push(a),b.options.enqueueForUpload?(b.filesQueue.push(a),b.processQueue()):void 0)})},b.prototype.removeFile=function(a){if(a.processing)throw new Error("Can't remove file currently processing");return this.files=h(this.files,a),this.filesQueue=h(this.filesQueue,a),this.emit("removedfile",a),0===this.files.length?this.emit("reset"):void 0},b.prototype.removeAllFiles=function(){var a,b,c,d;for(d=this.files.slice(),b=0,c=d.length;c>b;b++)a=d[b],l.call(this.filesProcessing,a)<0&&this.removeFile(a);return null},b.prototype.createThumbnail=function(a){var b,c=this;return b=new FileReader,b.onload=function(){var d;return d=new Image,d.onload=function(){var b,e,f,g,h,i,j,k,l,m;return a.width=d.width,a.height=d.height,f=c.options.resize.call(c,a),null==(h=f.trgWidth)&&(f.trgWidth=c.options.thumbnailWidth),null==(i=f.trgHeight)&&(f.trgHeight=c.options.thumbnailHeight),b=document.createElement("canvas"),e=b.getContext("2d"),b.width=f.trgWidth,b.height=f.trgHeight,e.drawImage(d,null!=(j=f.srcX)?j:0,null!=(k=f.srcY)?k:0,f.srcWidth,f.srcHeight,null!=(l=f.trgX)?l:0,null!=(m=f.trgY)?m:0,f.trgWidth,f.trgHeight),g=b.toDataURL("image/png"),c.emit("thumbnail",a,g)},d.src=b.result},b.readAsDataURL(a)},b.prototype.processQueue=function(){var a,b,c;for(b=this.options.parallelUploads,c=this.filesProcessing.length,a=c;b>a;){if(!this.filesQueue.length)return;this.processFile(this.filesQueue.shift()),a++}},b.prototype.processFile=function(a){return this.filesProcessing.push(a),a.processing=!0,this.emit("processingfile",a),this.uploadFile(a)},b.prototype.uploadFile=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q=this;if(k=new XMLHttpRequest,k.open(this.options.method,this.options.url,!0),i=null,c=function(){return q.errorProcessing(a,i||q.options.dictResponseError.replace("{{statusCode}}",k.status),k)},k.onload=function(b){var d;if(i=k.responseText,k.getResponseHeader("content-type")&&~k.getResponseHeader("content-type").indexOf("application/json"))try{i=JSON.parse(i)}catch(e){b=e,i="Invalid JSON response from server."}return 200<=(d=k.status)&&300>d?q.finished(a,i,b):c()},k.onerror=function(){return c()},h=null!=(n=k.upload)?n:k,h.onprogress=function(b){var c;return a.upload={progress:c,total:b.total,bytesSent:b.loaded},c=100*b.loaded/b.total,q.emit("uploadprogress",a,c,b.loaded)},k.setRequestHeader("Accept","application/json"),k.setRequestHeader("Cache-Control","no-cache"),k.setRequestHeader("X-Requested-With","XMLHttpRequest"),k.setRequestHeader("X-File-Name",a.name),b=new FormData,this.options.params){o=this.options.params;for(g in o)j=o[g],b.append(g,j)}if("FORM"===this.element.tagName)for(p=this.element.querySelectorAll("input, textarea, select, button"),l=0,m=p.length;m>l;l++)d=p[l],e=d.getAttribute("name"),f=d.getAttribute("type"),(!f||"checkbox"!==f.toLowerCase()||d.checked)&&b.append(e,d.value);return this.emit("sending",a,k,b),b.append(this.options.paramName,a),k.send(b)},b.prototype.finished=function(a,b,c){return this.filesProcessing=h(this.filesProcessing,a),a.processing=!1,this.processQueue(),this.emit("success",a,b,c),this.emit("finished",a,b,c),this.emit("complete",a)},b.prototype.errorProcessing=function(a,b,c){return this.filesProcessing=h(this.filesProcessing,a),a.processing=!1,this.processQueue(),this.emit("error",a,b,c),this.emit("complete",a)},b}(d),a.version="3.1.1-dev",a.options={},a.optionsForElement=function(b){return b.id?a.options[e(b.id)]:void 0},a.instances=[],a.forElement=function(a){var b;return"string"==typeof a&&(a=document.querySelector(a)),null!=(b=a.dropzone)?b:null},a.autoDiscover=!0,a.discover=function(){var b,c,d,e,f,g;if(a.autoDiscover){for(document.querySelectorAll?d=document.querySelectorAll(".dropzone"):(d=[],b=function(a){var b,c,e,f;for(f=[],c=0,e=a.length;e>c;c++)b=a[c],/(^| )dropzone($| )/.test(b.className)?f.push(d.push(b)):f.push(void 0);return f},b(document.getElementsByTagName("div")),b(document.getElementsByTagName("form"))),g=[],e=0,f=d.length;f>e;e++)c=d[e],a.optionsForElement(c)!==!1?g.push(new a(c)):g.push(void 0);return g}},a.blacklistedBrowsers=[/opera.*Macintosh.*version\/12/i],a.isBrowserSupported=function(){var b,c,d,e,f;if(b=!0,window.File&&window.FileReader&&window.FileList&&window.Blob&&window.FormData&&document.querySelector)if("classList"in document.createElement("a"))for(f=a.blacklistedBrowsers,d=0,e=f.length;e>d;d++)c=f[d],c.test(navigator.userAgent)&&(b=!1);else b=!1;else b=!1;return b},h=function(a,b){var c,d,e,f;for(f=[],d=0,e=a.length;e>d;d++)c=a[d],c!==b&&f.push(c);return f},e=function(a){return a.replace(/[\-_](\w)/g,function(a){return a[1].toUpperCase()})},a.createElement=function(a){var b;return b=document.createElement("div"),b.innerHTML=a,b.childNodes[0]},a.elementInside=function(a,b){if(a===b)return!0;for(;a=a.parentNode;)if(a===b)return!0;return!1},a.getElement=function(a,b){var c;if("string"==typeof a?c=document.querySelector(a):null!=a.nodeType&&(c=a),null==c)throw new Error("Invalid `"+b+"` option provided. Please provide a CSS selector or a plain HTML element.");return c},a.getElements=function(a,b){var c,d,e,f,g,h,i,j;if(a instanceof Array){e=[];try{for(f=0,h=a.length;h>f;f++)d=a[f],e.push(this.getElement(d,b))}catch(k){c=k,e=null}}else if("string"==typeof a)for(e=[],j=document.querySelectorAll(a),g=0,i=j.length;i>g;g++)d=j[g],e.push(d);else null!=a.nodeType&&(e=[a]);if(null==e||!e.length)throw new Error("Invalid `"+b+"` option provided. Please provide a CSS selector, a plain HTML element or a list of those.");return e},a.isValidMimeType=function(a,b){var c,d,e,f;if(!b)return!0;for(b=b.split(","),c=a.replace(/\/.*$/,""),e=0,f=b.length;f>e;e++)if(d=b[e],d=d.trim(),/\/\*$/.test(d)){if(c===d.replace(/\/.*$/,""))return!0}else if(a===d)return!0;return!1},"undefined"!=typeof jQuery&&null!==jQuery&&(jQuery.fn.dropzone=function(b){return this.each(function(){return new a(this,b)})}),"undefined"!=typeof c&&null!==c?c.exports=a:window.Dropzone=a,f=function(a,b){var c,d,e,f,g,h,i,j,k;if(e=!1,k=!0,d=a.document,j=d.documentElement,c=d.addEventListener?"addEventListener":"attachEvent",i=d.addEventListener?"removeEventListener":"detachEvent",h=d.addEventListener?"":"on",f=function(c){return"readystatechange"!==c.type||"complete"===d.readyState?(("load"===c.type?a:d)[i](h+c.type,f,!1),!e&&(e=!0)?b.call(a,c.type||c):void 0):void 0},g=function(){var a;try{j.doScroll("left")}catch(b){return a=b,setTimeout(g,50),void 0}return f("poll")},"complete"!==d.readyState){if(d.createEventObject&&j.doScroll){try{k=!a.frameElement}catch(l){}k&&g()}return d[c](h+"DOMContentLoaded",f,!1),d[c](h+"readystatechange",f,!1),a[c](h+"load",f,!1)}},f(window,a.discover)}.call(this)}),a.alias("component-emitter/index.js","dropzone/deps/emitter/index.js"),a.alias("component-emitter/index.js","emitter/index.js"),"object"==typeof exports?module.exports=a("dropzone"):"function"==typeof define&&define.amd?define(function(){return a("dropzone")}):this.Dropzone=a("dropzone")}(); \ No newline at end of file +!function(){function a(b,c,d){var e=a.resolve(b);if(null==e){d=d||b,c=c||"root";var f=new Error('Failed to require "'+d+'" from "'+c+'"');throw f.path=d,f.parent=c,f.require=!0,f}var g=a.modules[e];return g.exports||(g.exports={},g.client=g.component=!0,g.call(this,g.exports,a.relative(e),g)),g.exports}a.modules={},a.aliases={},a.resolve=function(b){"/"===b.charAt(0)&&(b=b.slice(1));for(var c=b+"/index.js",d=[b,b+".js",b+".json",b+"/index.js",b+"/index.json"],e=0;ed;++d)c[d].apply(this,b)}return this},d.prototype.listeners=function(a){return this._callbacks=this._callbacks||{},this._callbacks[a]||[]},d.prototype.hasListeners=function(a){return!!this.listeners(a).length}}),a.register("dropzone/index.js",function(a,b,c){c.exports=b("./lib/dropzone.js")}),a.register("dropzone/lib/dropzone.js",function(a,b,c){!function(){var a,d,e,f,g,h,i={}.hasOwnProperty,j=function(a,b){function c(){this.constructor=a}for(var d in b)i.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},k=[].slice,l=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};d="undefined"!=typeof Emitter&&null!==Emitter?Emitter:b("emitter"),g=function(){},a=function(a){function b(a,c){var d,e,f,g;if(this.element=a,this.version=b.version,this.defaultOptions.previewTemplate=this.defaultOptions.previewTemplate.replace(/\n*/g,""),"string"==typeof this.element&&(this.element=document.querySelector(this.element)),!this.element||null==this.element.nodeType)throw new Error("Invalid dropzone element.");if(this.element.dropzone)throw new Error("Dropzone already attached.");if(b.instances.push(this),a.dropzone=this,d=null!=(g=b.optionsForElement(this.element))?g:{},e=function(){var a,b,c,d,e,f,g;for(d=arguments[0],c=2<=arguments.length?k.call(arguments,1):[],f=0,g=c.length;g>f;f++){b=c[f];for(a in b)e=b[a],d[a]=e}return d},this.options=e({},this.defaultOptions,d,null!=c?c:{}),null==this.options.url&&(this.options.url=this.element.action),!this.options.url)throw new Error("No URL provided.");if(this.options.acceptParameter&&this.options.acceptedMimeTypes)throw new Error("You can't provide both 'acceptParameter' and 'acceptedMimeTypes'. 'acceptParameter' is deprecated.");return this.options.method=this.options.method.toUpperCase(),this.options.forceFallback||!b.isBrowserSupported()?this.options.fallback.call(this):((f=this.getExistingFallback())&&f.parentNode&&f.parentNode.removeChild(f),this.previewsContainer=this.options.previewsContainer?b.getElement(this.options.previewsContainer,"previewsContainer"):this.element,this.clickableElements=this.options.clickable?this.options.clickable===!0?[this.element]:b.getElements(this.options.clickable,"clickable"):[],this.init(),void 0)}return j(b,a),b.prototype.events=["drop","dragstart","dragend","dragenter","dragover","dragleave","selectedfiles","addedfile","removedfile","thumbnail","error","processingfile","uploadprogress","totaluploadprogress","sending","success","complete","reset"],b.prototype.defaultOptions={url:null,method:"post",parallelUploads:2,maxFilesize:256,paramName:"file",createImageThumbnails:!0,maxThumbnailFilesize:10,thumbnailWidth:100,thumbnailHeight:100,params:{},clickable:!0,acceptedMimeTypes:null,acceptParameter:null,enqueueForUpload:!0,previewsContainer:null,dictDefaultMessage:"Drop files here to upload",dictFallbackMessage:"Your browser does not support drag'n'drop file uploads.",dictFallbackText:"Please use the fallback form below to upload your files like in the olden days.",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.",accept:function(a,b){return b()},init:function(){return g},forceFallback:!1,fallback:function(){var a,c,d,e,f,g;for(this.element.className=""+this.element.className+" dz-browser-not-supported",g=this.element.getElementsByTagName("div"),e=0,f=g.length;f>e;e++)a=g[e],/(^| )message($| )/.test(a.className)&&(c=a,a.className="dz-message");return c||(c=b.createElement('
'),this.element.appendChild(c)),d=c.getElementsByTagName("span")[0],d&&(d.textContent=this.options.dictFallbackMessage),this.element.appendChild(this.getFallbackForm())},resize:function(a){var b,c,d;return b={srcX:0,srcY:0,srcWidth:a.width,srcHeight:a.height},c=a.width/a.height,d=this.options.thumbnailWidth/this.options.thumbnailHeight,a.heightd?(b.srcHeight=a.height,b.srcWidth=b.srcHeight*d):(b.srcWidth=a.width,b.srcHeight=b.srcWidth/d),b.srcX=(a.width-b.srcWidth)/2,b.srcY=(a.height-b.srcHeight)/2,b},drop:function(){return this.element.classList.remove("dz-drag-hover")},dragstart:g,dragend:function(){return this.element.classList.remove("dz-drag-hover")},dragenter:function(){return this.element.classList.add("dz-drag-hover")},dragover:function(){return this.element.classList.add("dz-drag-hover")},dragleave:function(){return this.element.classList.remove("dz-drag-hover")},selectedfiles:function(){return this.element===this.previewsContainer?this.element.classList.add("dz-started"):void 0},reset:function(){return this.element.classList.remove("dz-started")},addedfile:function(a){return a.previewElement=b.createElement(this.options.previewTemplate),a.previewTemplate=a.previewElement,this.previewsContainer.appendChild(a.previewElement),a.previewElement.querySelector("[data-dz-name]").textContent=a.name,a.previewElement.querySelector("[data-dz-size]").innerHTML=this.filesize(a.size)},removedfile:function(a){return a.previewElement.parentNode.removeChild(a.previewElement)},thumbnail:function(a,b){var c;return a.previewElement.classList.remove("dz-file-preview"),a.previewElement.classList.add("dz-image-preview"),c=a.previewElement.querySelector("[data-dz-thumbnail]"),c.alt=a.name,c.src=b},error:function(a,b){return a.previewElement.classList.add("dz-error"),a.previewElement.querySelector("[data-dz-errormessage]").textContent=b},processingfile:function(a){return a.previewElement.classList.add("dz-processing")},uploadprogress:function(a,b){return a.previewElement.querySelector("[data-dz-uploadprogress]").style.width=""+b+"%"},totaluploadprogress:g,sending:g,success:function(a){return a.previewElement.classList.add("dz-success")},complete:g,previewTemplate:'
\n
\n
\n
\n \n
\n
\n
\n
\n
\n
'},b.prototype.init=function(){var a,c,d,e,f,g,h,i=this;for("form"===this.element.tagName&&this.element.setAttribute("enctype","multipart/form-data"),this.element.classList.contains("dropzone")&&!this.element.querySelector("[data-dz-message]")&&this.element.appendChild(b.createElement('
'+this.options.dictDefaultMessage+"
")),this.clickableElements.length&&(d=function(){return i.hiddenFileInput&&document.body.removeChild(i.hiddenFileInput),i.hiddenFileInput=document.createElement("input"),i.hiddenFileInput.setAttribute("type","file"),i.hiddenFileInput.setAttribute("multiple","multiple"),null!=i.options.acceptedMimeTypes&&i.hiddenFileInput.setAttribute("accept",i.options.acceptedMimeTypes),null!=i.options.acceptParameter&&i.hiddenFileInput.setAttribute("accept",i.options.acceptParameter),i.hiddenFileInput.style.visibility="hidden",i.hiddenFileInput.style.position="absolute",i.hiddenFileInput.style.top="0",i.hiddenFileInput.style.left="0",i.hiddenFileInput.style.height="0",i.hiddenFileInput.style.width="0",document.body.appendChild(i.hiddenFileInput),i.hiddenFileInput.addEventListener("change",function(){var a;return a=i.hiddenFileInput.files,a.length&&(i.emit("selectedfiles",a),i.handleFiles(a)),d()})},d()),this.files=[],this.acceptedFiles=[],this.filesQueue=[],this.filesProcessing=[],this.URL=null!=(g=window.URL)?g:window.webkitURL,h=this.events,e=0,f=h.length;f>e;e++)a=h[e],this.on(a,this.options[a]);return this.on("uploadprogress",function(a){var b,c,d,e,f,g;for(c=0,b=0,g=i.acceptedFiles,e=0,f=g.length;f>e;e++)a=g[e],c+=a.upload.bytesSent,b+=a.upload.total;return d=100*c/b,i.emit("totaluploadprogress",d,b,c)}),c=function(a){return a.stopPropagation(),a.preventDefault?a.preventDefault():a.returnValue=!1},this.listeners=[{element:this.element,events:{dragstart:function(a){return i.emit("dragstart",a)},dragenter:function(a){return c(a),i.emit("dragenter",a)},dragover:function(a){return c(a),i.emit("dragover",a)},dragleave:function(a){return i.emit("dragleave",a)},drop:function(a){return c(a),i.drop(a),i.emit("drop",a)},dragend:function(a){return i.emit("dragend",a)}}}],this.clickableElements.forEach(function(a){return i.listeners.push({element:a,events:{click:function(c){return a!==i.element||c.target===i.element||b.elementInside(c.target,i.element.querySelector(".dz-message"))?i.hiddenFileInput.click():void 0}}})}),this.enable(),this.options.init.call(this)},b.prototype.getFallbackForm=function(){var a,c,d,e;return(a=this.getExistingFallback())?a:(d='
',this.options.dictFallbackText&&(d+="

"+this.options.dictFallbackText+"

"),d+='
',c=b.createElement(d),"FORM"!==this.element.tagName?(e=b.createElement('
'),e.appendChild(c)):(this.element.setAttribute("enctype","multipart/form-data"),this.element.setAttribute("method",this.options.method)),null!=e?e:c)},b.prototype.getExistingFallback=function(){var a,b,c,d,e,f;for(b=function(a){var b,c,d;for(c=0,d=a.length;d>c;c++)if(b=a[c],/(^| )fallback($| )/.test(b.className))return b},f=["div","form"],d=0,e=f.length;e>d;d++)if(c=f[d],a=b(this.element.getElementsByTagName(c)))return a},b.prototype.setupEventListeners=function(){var a,b,c,d,e,f,g;for(f=this.listeners,g=[],d=0,e=f.length;e>d;d++)a=f[d],g.push(function(){var d,e;d=a.events,e=[];for(b in d)c=d[b],e.push(a.element.addEventListener(b,c,!1));return e}());return g},b.prototype.removeEventListeners=function(){var a,b,c,d,e,f,g;for(f=this.listeners,g=[],d=0,e=f.length;e>d;d++)a=f[d],g.push(function(){var d,e;d=a.events,e=[];for(b in d)c=d[b],e.push(a.element.removeEventListener(b,c,!1));return e}());return g},b.prototype.disable=function(){return this.clickableElements.forEach(function(a){return a.classList.remove("dz-clickable")}),this.removeEventListeners(),this.filesProcessing=[],this.filesQueue=[]},b.prototype.enable=function(){return this.clickableElements.forEach(function(a){return a.classList.add("dz-clickable")}),this.setupEventListeners()},b.prototype.filesize=function(a){var b;return a>=1e11?(a/=1e11,b="TB"):a>=1e8?(a/=1e8,b="GB"):a>=1e5?(a/=1e5,b="MB"):a>=100?(a/=100,b="KB"):(a=10*a,b="b"),""+Math.round(a)/10+" "+b},b.prototype.drop=function(a){var b;if(a.dataTransfer)return b=a.dataTransfer.files,this.emit("selectedfiles",b),b.length?this.handleFiles(b):void 0},b.prototype.handleFiles=function(a){var b,c,d,e;for(e=[],c=0,d=a.length;d>c;c++)b=a[c],e.push(this.addFile(b));return e},b.prototype.accept=function(a,c){return a.size>1024*1024*this.options.maxFilesize?c(this.options.dictFileTooBig.replace("{{filesize}}",Math.round(a.size/1024/10.24)/100).replace("{{maxFilesize}}",this.options.maxFilesize)):b.isValidMimeType(a.type,this.options.acceptedMimeTypes)?this.options.accept.call(this,a,c):c(this.options.dictInvalidFileType)},b.prototype.addFile=function(a){var b=this;return a.upload={progress:0,total:a.size,bytesSent:0},this.files.push(a),this.emit("addedfile",a),this.options.createImageThumbnails&&a.type.match(/image.*/)&&a.size<=1024*1024*this.options.maxThumbnailFilesize&&this.createThumbnail(a),this.accept(a,function(c){return c?(a.accepted=!1,b.errorProcessing(a,c)):(a.accepted=!0,b.acceptedFiles.push(a),b.options.enqueueForUpload?(b.filesQueue.push(a),b.processQueue()):void 0)})},b.prototype.removeFile=function(a){if(a.processing)throw new Error("Can't remove file currently processing");return this.files=h(this.files,a),this.filesQueue=h(this.filesQueue,a),this.emit("removedfile",a),0===this.files.length?this.emit("reset"):void 0},b.prototype.removeAllFiles=function(){var a,b,c,d;for(d=this.files.slice(),b=0,c=d.length;c>b;b++)a=d[b],l.call(this.filesProcessing,a)<0&&this.removeFile(a);return null},b.prototype.createThumbnail=function(a){var b,c=this;return b=new FileReader,b.onload=function(){var d;return d=new Image,d.onload=function(){var b,e,f,g,h,i,j,k,l,m;return a.width=d.width,a.height=d.height,f=c.options.resize.call(c,a),null==(h=f.trgWidth)&&(f.trgWidth=c.options.thumbnailWidth),null==(i=f.trgHeight)&&(f.trgHeight=c.options.thumbnailHeight),b=document.createElement("canvas"),e=b.getContext("2d"),b.width=f.trgWidth,b.height=f.trgHeight,e.drawImage(d,null!=(j=f.srcX)?j:0,null!=(k=f.srcY)?k:0,f.srcWidth,f.srcHeight,null!=(l=f.trgX)?l:0,null!=(m=f.trgY)?m:0,f.trgWidth,f.trgHeight),g=b.toDataURL("image/png"),c.emit("thumbnail",a,g)},d.src=b.result},b.readAsDataURL(a)},b.prototype.processQueue=function(){var a,b,c;for(b=this.options.parallelUploads,c=this.filesProcessing.length,a=c;b>a;){if(!this.filesQueue.length)return;this.processFile(this.filesQueue.shift()),a++}},b.prototype.processFile=function(a){return this.filesProcessing.push(a),a.processing=!0,this.emit("processingfile",a),this.uploadFile(a)},b.prototype.uploadFile=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q=this;if(k=new XMLHttpRequest,k.open(this.options.method,this.options.url,!0),i=null,c=function(){return q.errorProcessing(a,i||q.options.dictResponseError.replace("{{statusCode}}",k.status),k)},k.onload=function(b){var d;if(i=k.responseText,k.getResponseHeader("content-type")&&~k.getResponseHeader("content-type").indexOf("application/json"))try{i=JSON.parse(i)}catch(e){b=e,i="Invalid JSON response from server."}return 200<=(d=k.status)&&300>d?q.finished(a,i,b):c()},k.onerror=function(){return c()},h=null!=(n=k.upload)?n:k,h.onprogress=function(b){var c;return a.upload={progress:c,total:b.total,bytesSent:b.loaded},c=100*b.loaded/b.total,q.emit("uploadprogress",a,c,b.loaded)},k.setRequestHeader("Accept","application/json"),k.setRequestHeader("Cache-Control","no-cache"),k.setRequestHeader("X-Requested-With","XMLHttpRequest"),k.setRequestHeader("X-File-Name",a.name),b=new FormData,this.options.params){o=this.options.params;for(g in o)j=o[g],b.append(g,j)}if("FORM"===this.element.tagName)for(p=this.element.querySelectorAll("input, textarea, select, button"),l=0,m=p.length;m>l;l++)d=p[l],e=d.getAttribute("name"),f=d.getAttribute("type"),(!f||"checkbox"!==f.toLowerCase()||d.checked)&&b.append(e,d.value);return this.emit("sending",a,k,b),b.append(this.options.paramName,a),k.send(b)},b.prototype.finished=function(a,b,c){return this.filesProcessing=h(this.filesProcessing,a),a.processing=!1,this.processQueue(),this.emit("success",a,b,c),this.emit("finished",a,b,c),this.emit("complete",a)},b.prototype.errorProcessing=function(a,b,c){return this.filesProcessing=h(this.filesProcessing,a),a.processing=!1,this.processQueue(),this.emit("error",a,b,c),this.emit("complete",a)},b}(d),a.version="3.2.0",a.options={},a.optionsForElement=function(b){return b.id?a.options[e(b.id)]:void 0},a.instances=[],a.forElement=function(a){var b;return"string"==typeof a&&(a=document.querySelector(a)),null!=(b=a.dropzone)?b:null},a.autoDiscover=!0,a.discover=function(){var b,c,d,e,f,g;if(a.autoDiscover){for(document.querySelectorAll?d=document.querySelectorAll(".dropzone"):(d=[],b=function(a){var b,c,e,f;for(f=[],c=0,e=a.length;e>c;c++)b=a[c],/(^| )dropzone($| )/.test(b.className)?f.push(d.push(b)):f.push(void 0);return f},b(document.getElementsByTagName("div")),b(document.getElementsByTagName("form"))),g=[],e=0,f=d.length;f>e;e++)c=d[e],a.optionsForElement(c)!==!1?g.push(new a(c)):g.push(void 0);return g}},a.blacklistedBrowsers=[/opera.*Macintosh.*version\/12/i],a.isBrowserSupported=function(){var b,c,d,e,f;if(b=!0,window.File&&window.FileReader&&window.FileList&&window.Blob&&window.FormData&&document.querySelector)if("classList"in document.createElement("a"))for(f=a.blacklistedBrowsers,d=0,e=f.length;e>d;d++)c=f[d],c.test(navigator.userAgent)&&(b=!1);else b=!1;else b=!1;return b},h=function(a,b){var c,d,e,f;for(f=[],d=0,e=a.length;e>d;d++)c=a[d],c!==b&&f.push(c);return f},e=function(a){return a.replace(/[\-_](\w)/g,function(a){return a[1].toUpperCase()})},a.createElement=function(a){var b;return b=document.createElement("div"),b.innerHTML=a,b.childNodes[0]},a.elementInside=function(a,b){if(a===b)return!0;for(;a=a.parentNode;)if(a===b)return!0;return!1},a.getElement=function(a,b){var c;if("string"==typeof a?c=document.querySelector(a):null!=a.nodeType&&(c=a),null==c)throw new Error("Invalid `"+b+"` option provided. Please provide a CSS selector or a plain HTML element.");return c},a.getElements=function(a,b){var c,d,e,f,g,h,i,j;if(a instanceof Array){e=[];try{for(f=0,h=a.length;h>f;f++)d=a[f],e.push(this.getElement(d,b))}catch(k){c=k,e=null}}else if("string"==typeof a)for(e=[],j=document.querySelectorAll(a),g=0,i=j.length;i>g;g++)d=j[g],e.push(d);else null!=a.nodeType&&(e=[a]);if(null==e||!e.length)throw new Error("Invalid `"+b+"` option provided. Please provide a CSS selector, a plain HTML element or a list of those.");return e},a.isValidMimeType=function(a,b){var c,d,e,f;if(!b)return!0;for(b=b.split(","),c=a.replace(/\/.*$/,""),e=0,f=b.length;f>e;e++)if(d=b[e],d=d.trim(),/\/\*$/.test(d)){if(c===d.replace(/\/.*$/,""))return!0}else if(a===d)return!0;return!1},"undefined"!=typeof jQuery&&null!==jQuery&&(jQuery.fn.dropzone=function(b){return this.each(function(){return new a(this,b)})}),"undefined"!=typeof c&&null!==c?c.exports=a:window.Dropzone=a,f=function(a,b){var c,d,e,f,g,h,i,j,k;if(e=!1,k=!0,d=a.document,j=d.documentElement,c=d.addEventListener?"addEventListener":"attachEvent",i=d.addEventListener?"removeEventListener":"detachEvent",h=d.addEventListener?"":"on",f=function(c){return"readystatechange"!==c.type||"complete"===d.readyState?(("load"===c.type?a:d)[i](h+c.type,f,!1),!e&&(e=!0)?b.call(a,c.type||c):void 0):void 0},g=function(){var a;try{j.doScroll("left")}catch(b){return a=b,setTimeout(g,50),void 0}return f("poll")},"complete"!==d.readyState){if(d.createEventObject&&j.doScroll){try{k=!a.frameElement}catch(l){}k&&g()}return d[c](h+"DOMContentLoaded",f,!1),d[c](h+"readystatechange",f,!1),a[c](h+"load",f,!1)}},f(window,a.discover)}.call(this)}),a.alias("component-emitter/index.js","dropzone/deps/emitter/index.js"),a.alias("component-emitter/index.js","emitter/index.js"),"object"==typeof exports?module.exports=a("dropzone"):"function"==typeof define&&define.amd?define(function(){return a("dropzone")}):this.Dropzone=a("dropzone")}(); \ No newline at end of file diff --git a/lib/dropzone.js b/lib/dropzone.js index 963b761db..7d1f97161 100644 --- a/lib/dropzone.js +++ b/lib/dropzone.js @@ -747,7 +747,7 @@ })(Em); - Dropzone.version = "3.1.1-dev"; + Dropzone.version = "3.2.0"; Dropzone.options = {}; diff --git a/package.json b/package.json index 6e070eef5..2bb0ad1d1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dropzone", - "version": "3.1.1-dev", + "version": "3.2.0", "description": "Handles drag and drop of files for you.", "keywords": [ "dragndrop", "drag and drop", "file upload", "upload" ], "homepage": "http://www.dropzonejs.com", diff --git a/readme.md b/readme.md index 50e42bf01..ac04c4b48 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@ # Dropzone.js -*Version 3.1.1-dev* +*Version 3.2.0* 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. diff --git a/src/dropzone.coffee b/src/dropzone.coffee index 37c370c6f..1bd08ebcb 100644 --- a/src/dropzone.coffee +++ b/src/dropzone.coffee @@ -760,7 +760,7 @@ class Dropzone extends Em -Dropzone.version = "3.1.1-dev" +Dropzone.version = "3.2.0" # This is a map of options for your different dropzones. Add configurations