equal
deleted
inserted
replaced
1 /* FileSaver.js |
1 /* FileSaver.js |
2 * A saveAs() FileSaver implementation. |
2 * A saveAs() FileSaver implementation. |
3 * 2015-03-04 |
3 * 2014-12-17 |
4 * |
4 * |
5 * By Eli Grey, http://eligrey.com |
5 * By Eli Grey, http://eligrey.com |
6 * License: X11/MIT |
6 * License: X11/MIT |
7 * See https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md |
7 * See https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md |
8 */ |
8 */ |
132 click(save_link); |
132 click(save_link); |
133 filesaver.readyState = filesaver.DONE; |
133 filesaver.readyState = filesaver.DONE; |
134 dispatch_all(); |
134 dispatch_all(); |
135 revoke(object_url); |
135 revoke(object_url); |
136 return; |
136 return; |
137 } |
|
138 // prepend BOM for UTF-8 XML and text/plain types |
|
139 if (/^\s*(?:text\/(?:plain|xml)|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) { |
|
140 blob = new Blob(["\ufeff", blob], {type: blob.type}); |
|
141 } |
137 } |
142 // Object and web filesystem URLs have a problem saving in Google Chrome when |
138 // Object and web filesystem URLs have a problem saving in Google Chrome when |
143 // viewed in a tab, so I force save with application/octet-stream |
139 // viewed in a tab, so I force save with application/octet-stream |
144 // http://code.google.com/p/chromium/issues/detail?id=91158 |
140 // http://code.google.com/p/chromium/issues/detail?id=91158 |
145 // Update: Google errantly closed 91158, I submitted it again: |
141 // Update: Google errantly closed 91158, I submitted it again: |
238 // `self` is undefined in Firefox for Android content script context |
234 // `self` is undefined in Firefox for Android content script context |
239 // while `this` is nsIContentFrameMessageManager |
235 // while `this` is nsIContentFrameMessageManager |
240 // with an attribute `content` that corresponds to the window |
236 // with an attribute `content` that corresponds to the window |
241 |
237 |
242 if (typeof module !== "undefined" && module.exports) { |
238 if (typeof module !== "undefined" && module.exports) { |
243 module.exports.saveAs = saveAs; |
239 module.exports = saveAs; |
244 } else if ((typeof define !== "undefined" && define !== null) && (define.amd != null)) { |
240 } else if ((typeof define !== "undefined" && define !== null) && (define.amd != null)) { |
245 define([], function() { |
241 define([], function() { |
246 return saveAs; |
242 return saveAs; |
247 }); |
243 }); |
248 } |
244 } |