diff --git a/public/js/FileSaver.js b/public/js/FileSaver.js index 11081a8..6528152 100644 --- a/public/js/FileSaver.js +++ b/public/js/FileSaver.js @@ -1,6 +1,6 @@ /* FileSaver.js * A saveAs() FileSaver implementation. - * 2015-05-07.2 + * 1.1.20150716 * * By Eli Grey, http://eligrey.com * License: X11/MIT @@ -27,11 +27,7 @@ var saveAs = saveAs || (function(view) { , save_link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a") , can_use_save_link = "download" in save_link , click = function(node) { - var event = doc.createEvent("MouseEvents"); - event.initMouseEvent( - "click", true, false, view, 0, 0, 0, 0, 0 - , false, false, false, false, 0, null - ); + var event = new MouseEvent("click"); node.dispatchEvent(event); } , webkit_req_fs = view.webkitRequestFileSystem @@ -82,8 +78,10 @@ var saveAs = saveAs || (function(view) { } return blob; } - , FileSaver = function(blob, name) { - blob = auto_bom(blob); + , FileSaver = function(blob, name, no_auto_bom) { + if (!no_auto_bom) { + blob = auto_bom(blob); + } // First try a.download, then web filesystem, then object URLs var filesaver = this @@ -131,10 +129,12 @@ var saveAs = saveAs || (function(view) { object_url = get_URL().createObjectURL(blob); save_link.href = object_url; save_link.download = name; - click(save_link); - filesaver.readyState = filesaver.DONE; - dispatch_all(); - revoke(object_url); + setTimeout(function() { + click(save_link); + dispatch_all(); + revoke(object_url); + filesaver.readyState = filesaver.DONE; + }); return; } // Object and web filesystem URLs have a problem saving in Google Chrome when @@ -205,14 +205,17 @@ var saveAs = saveAs || (function(view) { }), fs_error); } , FS_proto = FileSaver.prototype - , saveAs = function(blob, name) { - return new FileSaver(blob, name); + , saveAs = function(blob, name, no_auto_bom) { + return new FileSaver(blob, name, no_auto_bom); } ; // IE 10+ (native saveAs) if (typeof navigator !== "undefined" && navigator.msSaveOrOpenBlob) { - return function(blob, name) { - return navigator.msSaveOrOpenBlob(auto_bom(blob), name); + return function(blob, name, no_auto_bom) { + if (!no_auto_bom) { + blob = auto_bom(blob); + } + return navigator.msSaveOrOpenBlob(blob, name || "download"); }; } @@ -250,4 +253,4 @@ if (typeof module !== "undefined" && module.exports) { define([], function() { return saveAs; }); -} \ No newline at end of file +}