-
Notifications
You must be signed in to change notification settings - Fork 2
/
filepicker.js
2 lines (2 loc) · 929 Bytes
/
filepicker.js
1
2
/*! Mini-utils 2014-02-06 */
define(["./promise","./alchemy"],function(a,b){var c,d,e,f,g,h,i;return window.URL||(window.URL=window.webkitURL),i=b.zip,d=1048576,c="File exceeds maximum size",g=function(a){return[a,window.URL.createObjectURL(a)]},h=function(a,b){if(a.size>((null!=b?b.maxsize:void 0)||d))throw c},f=function(b){var c,d,e;return c=function(){return e.resolve(d.files)},d=document.createElement("input"),d.setAttribute("type","file"),d.setAttribute("accept",null!=b?b.mimetypes:void 0),(null!=b?b.multiple:void 0)&&d.setAttribute("multiple","true"),d.style.display="none",d.addEventListener("change",c),document.body.appendChild(d),d.click(),d.parentNode.removeChild(d),e=new a},e=function(b){var c;return f(b).then(function(a){var d,e,f,i,j;try{for(i=0,j=a.length;j>i;i++)e=a[i],h(e,b)}catch(k){return d=k,c.reject(d),void 0}return f=Array.prototype.map.call(a,g),c.resolve(f)}),c=new a},{FILE_TOO_BIG:c,open:e}});