Added <a>.download support and support for loading BlobBuilder.js asynchronously.
This commit is contained in:
Vendored
+1
-1
@@ -1,2 +1,2 @@
|
||||
/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
|
||||
var saveAs=saveAs||(function(l){"use strict";var k=l.URL||l.webkitURL||l,f=l.webkitRequestFileSystem,m=l.requestFileSystem||f||l.mozRequestFileSystem,c=function(n){(l.setImmediate||setTimeout)(function(){throw n},0)},j="application/octet-stream",h=0,g=[],e=function(){var o=g.length;while(o--){var n=g[o];if(typeof n==="string"){k.revokeObjectURL(n)}else{n.remove()}}g.length=0},i=function(o,n,r){n=[].concat(n);var q=n.length;while(q--){var s=o["on"+n[q]];if(typeof s==="function"){try{s.call(o,r||o)}catch(p){c(p)}}}},b=function(o,q){var n=this,r=o.type,u=function(){var v=k.createObjectURL(o);p.location.href=v;g.push(v);n.readyState=n.DONE;i(n,"writestart progress write writeend".split(" "))},s=function(v){return function(){if(n.readyState!==n.DONE){return v.apply(this,arguments)}}},p,t;n.readyState=n.INIT;if(!q){q="download"}if(l.chrome&&r!==j){t=o.slice||o.webkitSlice;o=t.call(o,0,o.size,j)}if(f&&q!=="download"){q+=".download"}if(r===j||f){p=self}else{p=open()}if(!m){u();return}h+=o.size;m(l.TEMPORARY,h,s(function(v){v.root.getDirectory("saved",{create:true,exclusive:false},s(function(w){var x=function(){w.getFile(q,{create:true,exclusive:false},s(function(y){y.createWriter(s(function(z){z.onwriteend=function(A){p.location.href=y.toURL();g.push(y);n.readyState=n.DONE;i(n,"writeend",A)};z.onerror=function(){var A=z.error;if(A.code!==A.ABORT_ERR){u()}};"writestart progress write abort".split(" ").forEach(function(A){z["on"+A]=n["on"+A]});z.write(o);n.abort=function(){z.abort();n.readyState=n.DONE};n.readyState=n.WRITING}),u)}),u)};w.getFile(q,{create:false},s(function(y){y.remove();x()}),s(function(y){if(y.code===y.NOT_FOUND_ERR){x()}else{u()}}))}),u)}),u)},a=b.prototype,d=function(n,o){return new b(n,o)};a.abort=function(){var n=this;n.readyState=n.DONE;i(n,"abort")};a.readyState=a.INIT=0;a.WRITING=1;a.DONE=2;a.error=a.onwritestart=a.onprogress=a.onwrite=a.onabort=a.onerror=a.onwriteend=null;l.addEventListener("unload",e,false);return d}(self));
|
||||
var saveAs=saveAs||(function(h){"use strict";var r=h.document,l=function(){return h.URL||h.webkitURL||h},e=h.URL||h.webkitURL||h,n=r.createElementNS("http://www.w3.org/1999/xhtml","a"),g="download" in n,j=function(t){var s=document.createEvent("MouseEvents");s.initMouseEvent("click",true,false,h,0,0,0,0,0,false,false,false,false,0,null);return t.dispatchEvent(s)},o=h.webkitRequestFileSystem,p=h.requestFileSystem||o||h.mozRequestFileSystem,m=function(s){(h.setImmediate||h.setTimeout)(function(){throw s},0)},c="application/octet-stream",k=0,b=[],i=function(){var t=b.length;while(t--){var s=b[t];if(typeof s==="string"){e.revokeObjectURL(s)}else{s.remove()}}b.length=0},q=function(t,s,w){s=[].concat(s);var v=s.length;while(v--){var x=t["on"+s[v]];if(typeof x==="function"){try{x.call(t,w||t)}catch(u){m(u)}}}},f=function(t,u){var v=this,B=t.type,E=false,x,s=function(){var F=l().createObjectURL(t);b.push(F);return F},A=function(){q(v,"writestart progress write writeend".split(" "))},D=function(){if(E||!x){x=s(t)}w.location.href=x;v.readyState=v.DONE;A()},z=function(F){return function(){if(v.readyState!==v.DONE){return F.apply(this,arguments)}}},y={create:true,exclusive:false},w,C;v.readyState=v.INIT;if(!u){u="download"}if(g){x=s(t);n.href=x;n.download=u;if(j(n)){v.readyState=v.DONE;A();return}}if(h.chrome&&B&&B!==c){C=t.slice||t.webkitSlice;t=C.call(t,0,t.size,c);E=true}if(o&&u!=="download"){u+=".download"}if(B===c||o){w=h}else{w=h.open()}if(!p){D();return}k+=t.size;p(h.TEMPORARY,k,z(function(F){F.root.getDirectory("saved",y,z(function(G){var H=function(){G.getFile(u,y,z(function(I){I.createWriter(z(function(J){J.onwriteend=function(K){w.location.href=I.toURL();b.push(I);v.readyState=v.DONE;q(v,"writeend",K)};J.onerror=function(){var K=J.error;if(K.code!==K.ABORT_ERR){D()}};"writestart progress write abort".split(" ").forEach(function(K){J["on"+K]=v["on"+K]});J.write(t);v.abort=function(){J.abort();v.readyState=v.DONE};v.readyState=v.WRITING}),D)}),D)};G.getFile(u,{create:false},z(function(I){I.remove();H()}),z(function(I){if(I.code===I.NOT_FOUND_ERR){H()}else{D()}}))}),D)}),D)},d=f.prototype,a=function(s,t){return new f(s,t)};d.abort=function(){var s=this;s.readyState=s.DONE;q(s,"abort")};d.readyState=d.INIT=0;d.WRITING=1;d.DONE=2;d.error=d.onwritestart=d.onprogress=d.onwrite=d.onabort=d.onerror=d.onwriteend=null;h.addEventListener("unload",i,false);return a}(self));
|
||||
Reference in New Issue
Block a user