From 924c68f8bb32fda7df1d96a779af1590b968cf26 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Fri, 25 Jul 2014 08:40:14 +0300 Subject: [PATCH] Update FileSaver.js v2014-08-29. --- Gruntfile.js | 2 +- .../js/vendor/{filesaver.js => FileSaver.js} | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) rename docs/assets/js/vendor/{filesaver.js => FileSaver.js} (94%) diff --git a/Gruntfile.js b/Gruntfile.js index 08da04ce56..e945b9d480 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -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' ], diff --git a/docs/assets/js/vendor/filesaver.js b/docs/assets/js/vendor/FileSaver.js similarity index 94% rename from docs/assets/js/vendor/filesaver.js rename to docs/assets/js/vendor/FileSaver.js index e7c05d593f..1095873014 100644 --- a/docs/assets/js/vendor/filesaver.js +++ b/docs/assets/js/vendor/FileSaver.js @@ -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 @@ -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( @@ -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); @@ -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();