mirror of
https://github.com/twbs/bootstrap.git
synced 2025-01-28 20:52:21 +01:00
Update filesaver.js to v2014-05-27.
[ci skip]
This commit is contained in:
parent
91bed93d55
commit
8cdc34f6e3
@ -1,37 +1,37 @@
|
|||||||
/* FileSaver.js
|
/* FileSaver.js
|
||||||
* A saveAs() FileSaver implementation.
|
* A saveAs() FileSaver implementation.
|
||||||
* 2014-01-24
|
* 2014-05-27
|
||||||
*
|
*
|
||||||
* By Eli Grey, http://eligrey.com
|
* By Eli Grey, http://eligrey.com
|
||||||
* License: X11/MIT
|
* License: X11/MIT
|
||||||
* See LICENSE.md
|
* See https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*global self */
|
/*global self */
|
||||||
/*jslint bitwise: true, regexp: true, confusion: true, es5: true, vars: true, white: true,
|
/*jslint bitwise: true, indent: 4, laxbreak: true, laxcomma: true, smarttabs: true, plusplus: true */
|
||||||
plusplus: true */
|
|
||||||
|
|
||||||
/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
|
/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
|
||||||
|
|
||||||
var saveAs = saveAs
|
var saveAs = saveAs
|
||||||
// IE 10+ (native saveAs)
|
// IE 10+ (native saveAs)
|
||||||
|| (navigator.msSaveOrOpenBlob && navigator.msSaveOrOpenBlob.bind(navigator))
|
|| (typeof navigator !== "undefined" &&
|
||||||
|
navigator.msSaveOrOpenBlob && navigator.msSaveOrOpenBlob.bind(navigator))
|
||||||
// Everyone else
|
// Everyone else
|
||||||
|| (function(view) {
|
|| (function(view) {
|
||||||
"use strict";
|
"use strict";
|
||||||
// IE <10 is explicitly unsupported
|
// IE <10 is explicitly unsupported
|
||||||
if (/MSIE [1-9]\./.test(navigator.userAgent)) {
|
if (typeof navigator !== "undefined" &&
|
||||||
|
/MSIE [1-9]\./.test(navigator.userAgent)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var
|
var
|
||||||
doc = view.document
|
doc = view.document
|
||||||
// only get URL when necessary in case BlobBuilder.js hasn't overridden it yet
|
// only get URL when necessary in case Blob.js hasn't overridden it yet
|
||||||
, get_URL = function() {
|
, get_URL = function() {
|
||||||
return view.URL || view.webkitURL || view;
|
return view.URL || view.webkitURL || view;
|
||||||
}
|
}
|
||||||
, URL = view.URL || view.webkitURL || view
|
|
||||||
, save_link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a")
|
, 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 = !view.externalHost && "download" in save_link
|
||||||
, click = function(node) {
|
, click = function(node) {
|
||||||
var event = doc.createEvent("MouseEvents");
|
var event = doc.createEvent("MouseEvents");
|
||||||
event.initMouseEvent(
|
event.initMouseEvent(
|
||||||
@ -42,7 +42,7 @@ var saveAs = saveAs
|
|||||||
}
|
}
|
||||||
, webkit_req_fs = view.webkitRequestFileSystem
|
, webkit_req_fs = view.webkitRequestFileSystem
|
||||||
, req_fs = view.requestFileSystem || webkit_req_fs || view.mozRequestFileSystem
|
, req_fs = view.requestFileSystem || webkit_req_fs || view.mozRequestFileSystem
|
||||||
, throw_outside = function (ex) {
|
, throw_outside = function(ex) {
|
||||||
(view.setImmediate || view.setTimeout)(function() {
|
(view.setImmediate || view.setTimeout)(function() {
|
||||||
throw ex;
|
throw ex;
|
||||||
}, 0);
|
}, 0);
|
||||||
@ -55,7 +55,7 @@ var saveAs = saveAs
|
|||||||
while (i--) {
|
while (i--) {
|
||||||
var file = deletion_queue[i];
|
var file = deletion_queue[i];
|
||||||
if (typeof file === "string") { // file is an object URL
|
if (typeof file === "string") { // file is an object URL
|
||||||
URL.revokeObjectURL(file);
|
get_URL().revokeObjectURL(file);
|
||||||
} else { // file is a File
|
} else { // file is a File
|
||||||
file.remove();
|
file.remove();
|
||||||
}
|
}
|
||||||
@ -101,8 +101,8 @@ var saveAs = saveAs
|
|||||||
if (target_view) {
|
if (target_view) {
|
||||||
target_view.location.href = object_url;
|
target_view.location.href = object_url;
|
||||||
} else {
|
} else {
|
||||||
window.open(object_url, "_blank");
|
window.open(object_url, "_blank");
|
||||||
}
|
}
|
||||||
filesaver.readyState = filesaver.DONE;
|
filesaver.readyState = filesaver.DONE;
|
||||||
dispatch_all();
|
dispatch_all();
|
||||||
}
|
}
|
||||||
@ -122,20 +122,9 @@ var saveAs = saveAs
|
|||||||
}
|
}
|
||||||
if (can_use_save_link) {
|
if (can_use_save_link) {
|
||||||
object_url = get_object_url(blob);
|
object_url = get_object_url(blob);
|
||||||
// FF for Android has a nasty garbage collection mechanism
|
|
||||||
// that turns all objects that are not pure javascript into 'deadObject'
|
|
||||||
// this means `doc` and `save_link` are unusable and need to be recreated
|
|
||||||
// `view` is usable though:
|
|
||||||
doc = view.document;
|
|
||||||
save_link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a");
|
|
||||||
save_link.href = object_url;
|
save_link.href = object_url;
|
||||||
save_link.download = name;
|
save_link.download = name;
|
||||||
var event = doc.createEvent("MouseEvents");
|
click(save_link);
|
||||||
event.initMouseEvent(
|
|
||||||
"click", true, false, view, 0, 0, 0, 0, 0
|
|
||||||
, false, false, false, false, 0, null
|
|
||||||
);
|
|
||||||
save_link.dispatchEvent(event);
|
|
||||||
filesaver.readyState = filesaver.DONE;
|
filesaver.readyState = filesaver.DONE;
|
||||||
dispatch_all();
|
dispatch_all();
|
||||||
return;
|
return;
|
||||||
@ -229,6 +218,10 @@ var saveAs = saveAs
|
|||||||
null;
|
null;
|
||||||
|
|
||||||
view.addEventListener("unload", process_deletion_queue, false);
|
view.addEventListener("unload", process_deletion_queue, false);
|
||||||
|
saveAs.unload = function() {
|
||||||
|
process_deletion_queue();
|
||||||
|
view.removeEventListener("unload", process_deletion_queue, false);
|
||||||
|
};
|
||||||
return saveAs;
|
return saveAs;
|
||||||
}(
|
}(
|
||||||
typeof self !== "undefined" && self
|
typeof self !== "undefined" && self
|
||||||
@ -239,4 +232,10 @@ var saveAs = saveAs
|
|||||||
// while `this` is nsIContentFrameMessageManager
|
// while `this` is nsIContentFrameMessageManager
|
||||||
// with an attribute `content` that corresponds to the window
|
// with an attribute `content` that corresponds to the window
|
||||||
|
|
||||||
if (typeof module !== "undefined") module.exports = saveAs;
|
if (typeof module !== "undefined" && module !== null) {
|
||||||
|
module.exports = saveAs;
|
||||||
|
} else if ((typeof define !== "undefined" && define !== null) && (define.amd != null)) {
|
||||||
|
define([], function() {
|
||||||
|
return saveAs;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user