lemonldap-ng/lemonldap-ng-manager/site/htdocs/static/bwr/file-saver.js/FileSaver.min.js
Xavier Guimard 7464f26861 Update JS
2018-01-11 06:44:50 +01:00

2 lines
3.0 KiB
JavaScript

/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
var saveAs=saveAs||(function(g){if(typeof navigator!=="undefined"&&/MSIE [1-9]\./.test(navigator.userAgent)){return}var r=g.document,l=function(){return g.URL||g.webkitURL||g},n=r.createElementNS("http://www.w3.org/1999/xhtml","a"),e="download" in n,j=function(t){var s=r.createEvent("MouseEvents");s.initMouseEvent("click",true,false,g,0,0,0,0,0,false,false,false,false,0,null);t.dispatchEvent(s)},o=g.webkitRequestFileSystem,p=g.requestFileSystem||o||g.mozRequestFileSystem,m=function(s){(g.setImmediate||g.setTimeout)(function(){throw s},0)},b="application/octet-stream",k=0,h=500,i=function(t){var s=function(){if(typeof t==="string"){l().revokeObjectURL(t)}else{t.remove()}};if(g.chrome){s()}else{setTimeout(s,h)}},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(s){if(/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(s.type)){return new Blob(["\ufeff",s],{type:s.type})}return s},d=function(s,t){s=f(s);var u=this,A=s.type,D=false,w,v,z=function(){q(u,"writestart progress write writeend".split(" "))},C=function(){if(D||!w){w=l().createObjectURL(s)}if(v){v.location.href=w}else{var E=g.open(w,"_blank");if(E==undefined&&typeof safari!=="undefined"){g.location.href=w}}u.readyState=u.DONE;z();i(w)},y=function(E){return function(){if(u.readyState!==u.DONE){return E.apply(this,arguments)}}},x={create:true,exclusive:false},B;u.readyState=u.INIT;if(!t){t="download"}if(e){w=l().createObjectURL(s);n.href=w;n.download=t;j(n);u.readyState=u.DONE;z();i(w);return}if(g.chrome&&A&&A!==b){B=s.slice||s.webkitSlice;s=B.call(s,0,s.size,b);D=true}if(o&&t!=="download"){t+=".download"}if(A===b||o){v=g}if(!p){C();return}k+=s.size;p(g.TEMPORARY,k,y(function(E){E.root.getDirectory("saved",x,y(function(F){var G=function(){F.getFile(t,x,y(function(H){H.createWriter(y(function(I){I.onwriteend=function(J){v.location.href=H.toURL();u.readyState=u.DONE;q(u,"writeend",J);i(H)};I.onerror=function(){var J=I.error;if(J.code!==J.ABORT_ERR){C()}};"writestart progress write abort".split(" ").forEach(function(J){I["on"+J]=u["on"+J]});I.write(s);u.abort=function(){I.abort();u.readyState=u.DONE};u.readyState=u.WRITING}),C)}),C)};F.getFile(t,{create:false},y(function(H){H.remove();G()}),y(function(H){if(H.code===H.NOT_FOUND_ERR){G()}else{C()}}))}),C)}),C)},c=d.prototype,a=function(s,t){return new d(s,t)};if(typeof navigator!=="undefined"&&navigator.msSaveOrOpenBlob){return function(s,t){return navigator.msSaveOrOpenBlob(f(s),t)}}c.abort=function(){var s=this;s.readyState=s.DONE;q(s,"abort")};c.readyState=c.INIT=0;c.WRITING=1;c.DONE=2;c.error=c.onwritestart=c.onprogress=c.onwrite=c.onabort=c.onerror=c.onwriteend=null;return a}(typeof self!=="undefined"&&self||typeof window!=="undefined"&&window||this.content));if(typeof module!=="undefined"&&module.exports){module.exports.saveAs=saveAs}else{if((typeof define!=="undefined"&&define!==null)&&(define.amd!=null)){define([],function(){return saveAs})}};