forked from ChrisMBarr/FileDrop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jQuery.FileDrop.min.js
1 lines (1 loc) · 1.7 KB
/
jQuery.FileDrop.min.js
1
(function(e){"use strict";function r(t,n,r,i){return function(s){n.push({name:t.name,size:t.size,type:t.type,lastModified:t.lastModifiedDate,data:s.target.result});n.length===r&&e.isFunction(i.onFileRead)&&i.onFileRead(n,i)}}function i(e){e.stopPropagation();e.preventDefault()}var t=null;e.fn.fileDragAndDrop=function(t){if(e.isFunction(t)){var r={};r.onFileRead=t;t=r}return this.each(function(){var r=e(this),i=e.extend({},e.fn.fileDragAndDrop.defaults,t);i.addClassTo.length===0&&(i.addClassTo=r);this.addEventListener("dragenter",function(e){n._over(e,r,i)},!1);this.addEventListener("dragover",function(e){n._exit(e,r,i)},!1);this.addEventListener("drop",function(e){n._drop(e,r,i)},!1)})};e.fn.fileDragAndDrop.defaults={overClass:"over",addClassTo:e([]),onFileRead:null};var n={_over:function(t,n,r){e(r.addClassTo).addClass(r.overClass);i(t)},_exit:function(n,r,s){clearTimeout(t);t=setTimeout(function(){e(s.addClassTo).removeClass(s.overClass)},100);i(n)},_drop:function(t,n,s){e(s.addClassTo).removeClass(s.overClass);i(t);var o=t.dataTransfer.files,u=[];for(var a=0;a<=o.length-1;a++){var f=new FileReader,l=r(o[a],u,o.length,s);f.addEventListener?f.addEventListener("loadend",l,!1):f.onloadend=l;f.readAsDataURL(o[a])}}}})(jQuery);(function(e){function t(e){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n,r,i,s,o,u,a,f,l=0,c=0,h="",p=[];if(!e)return e;e+="";do{s=t.indexOf(e.charAt(l++));o=t.indexOf(e.charAt(l++));u=t.indexOf(e.charAt(l++));a=t.indexOf(e.charAt(l++));f=s<<18|o<<12|u<<6|a;n=f>>16&255;r=f>>8&255;i=f&255;u==64?p[c++]=String.fromCharCode(n):a==64?p[c++]=String.fromCharCode(n,r):p[c++]=String.fromCharCode(n,r,i)}while(l<e.length);h=p.join("");return h}e.atob||(e.atob=t)})(window);