sogo/UI/WebServerResources/js/vendor/FileSaver.min.js
2018-07-29 00:29:49 -04:00

2 lines
2.8 KiB
JavaScript

var saveAs=saveAs||function(v){"use strict";if("undefined"==typeof navigator||!/MSIE [1-9]\./.test(navigator.userAgent)){var w=v.document,y=function(){return v.URL||v.webkitURL||v},m=w.createElementNS("http://www.w3.org/1999/xhtml","a"),h="download"in m,S=v.webkitRequestFileSystem,O=v.requestFileSystem||S||v.mozRequestFileSystem,i=function(e){(v.setImmediate||v.setTimeout)(function(){throw e},0)},E="application/octet-stream",R=0,b=function(e){var t=function(){"string"==typeof e?y().revokeObjectURL(e):e.remove()};v.chrome?t():setTimeout(t,500)},g=function(e,t,n){for(var o=(t=[].concat(t)).length;o--;){var r=e["on"+t[o]];if("function"==typeof r)try{r.call(e,n||e)}catch(e){i(e)}}},N=function(e){return/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\ufeff",e],{type:e.type}):e},n=function(o,n){o=N(o);var e,r,t,i,a,c=this,f=o.type,u=!1,s=function(){g(c,"writestart progress write writeend".split(" "))},d=function(){(!u&&e||(e=y().createObjectURL(o)),r)?r.location.href=e:null==v.open(e,"_blank")&&"undefined"!=typeof safari&&(v.location.href=e);c.readyState=c.DONE,s(),b(e)},l=function(e){return function(){if(c.readyState!==c.DONE)return e.apply(this,arguments)}},p={create:!0,exclusive:!1};if(c.readyState=c.INIT,n||(n="download"),h)return e=y().createObjectURL(o),m.href=e,m.download=n,i=m,(a=w.createEvent("MouseEvents")).initMouseEvent("click",!0,!1,v,0,0,0,0,0,!1,!1,!1,!1,0,null),i.dispatchEvent(a),c.readyState=c.DONE,s(),void b(e);v.chrome&&f&&f!==E&&(t=o.slice||o.webkitSlice,o=t.call(o,0,o.size,E),u=!0),S&&"download"!==n&&(n+=".download"),(f===E||S)&&(r=v),O?(R+=o.size,O(v.TEMPORARY,R,l(function(e){e.root.getDirectory("saved",p,l(function(e){var t=function(){e.getFile(n,p,l(function(n){n.createWriter(l(function(t){t.onwriteend=function(e){r.location.href=n.toURL(),c.readyState=c.DONE,g(c,"writeend",e),b(n)},t.onerror=function(){var e=t.error;e.code!==e.ABORT_ERR&&d()},"writestart progress write abort".split(" ").forEach(function(e){t["on"+e]=c["on"+e]}),t.write(o),c.abort=function(){t.abort(),c.readyState=c.DONE},c.readyState=c.WRITING}),d)}),d)};e.getFile(n,{create:!1},l(function(e){e.remove(),t()}),l(function(e){e.code===e.NOT_FOUND_ERR?t():d()}))}),d)}),d)):d()},e=n.prototype;return"undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob?function(e,t){return navigator.msSaveOrOpenBlob(N(e),t)}:(e.abort=function(){this.readyState=this.DONE,g(this,"abort")},e.readyState=e.INIT=0,e.WRITING=1,e.DONE=2,e.error=e.onwritestart=e.onprogress=e.onwrite=e.onabort=e.onerror=e.onwriteend=null,function(e,t){return new n(e,t)})}}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this.content);"undefined"!=typeof module&&module.exports?module.exports.saveAs=saveAs:"undefined"!=typeof define&&null!==define&&null!=define.amd&&define([],function(){return saveAs});
//# sourceMappingURL=FileSaver.min.js.map