Skip to content

Commit

Permalink
Update FileSaver.js v2014-08-29.
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Oct 9, 2014
1 parent 7ded2d1 commit 924c68f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ module.exports = function (grunt) {
'docs/assets/js/vendor/jszip.min.js',
'docs/assets/js/vendor/uglify.min.js',
'docs/assets/js/vendor/Blob.js',
'docs/assets/js/vendor/filesaver.js',
'docs/assets/js/vendor/FileSaver.js',
'docs/assets/js/raw-files.min.js',
'docs/assets/js/src/customizer.js'
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* FileSaver.js
* A saveAs() FileSaver implementation.
* 2014-07-21
* 2014-08-29
*
* By Eli Grey, http://eligrey.com
* License: X11/MIT
Expand Down Expand Up @@ -31,7 +31,7 @@ var saveAs = saveAs
return view.URL || view.webkitURL || view;
}
, save_link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a")
, can_use_save_link = !view.externalHost && "download" in save_link
, can_use_save_link = "download" in save_link
, click = function(node) {
var event = doc.createEvent("MouseEvents");
event.initMouseEvent(
Expand All @@ -53,13 +53,18 @@ var saveAs = saveAs
// the reasoning behind the timeout and revocation flow
, arbitrary_revoke_timeout = 10
, revoke = function(file) {
setTimeout(function() {
var revoker = function() {
if (typeof file === "string") { // file is an object URL
get_URL().revokeObjectURL(file);
} else { // file is a File
file.remove();
}
}, arbitrary_revoke_timeout);
};
if (view.chrome) {
revoker();
} else {
setTimeout(revoker, arbitrary_revoke_timeout);
}
}
, dispatch = function(filesaver, event_types, event) {
event_types = [].concat(event_types);
Expand Down Expand Up @@ -95,7 +100,11 @@ var saveAs = saveAs
if (target_view) {
target_view.location.href = object_url;
} else {
view.open(object_url, "_blank");
var new_tab = view.open(object_url, "_blank");
if (new_tab == undefined && typeof safari !== "undefined") {
//Apple do not allow window.open, see http://bit.ly/1kZffRI
view.location.href = object_url
}
}
filesaver.readyState = filesaver.DONE;
dispatch_all();
Expand Down

0 comments on commit 924c68f

Please sign in to comment.