|
@@ -2246,10 +2246,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
});
|
|
|
exports.DownloadManager = undefined;
|
|
|
|
|
|
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
|
+
|
|
|
var _pdfjsLib = __w_pdfjs_require__(0);
|
|
|
|
|
|
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
+
|
|
|
;
|
|
|
-function download(blobUrl, filename) {
|
|
|
+function _download(blobUrl, filename) {
|
|
|
var a = document.createElement('a');
|
|
|
if (a.click) {
|
|
|
a.href = blobUrl;
|
|
@@ -2268,36 +2272,50 @@ function download(blobUrl, filename) {
|
|
|
window.open(blobUrl, '_parent');
|
|
|
}
|
|
|
}
|
|
|
-function DownloadManager() {}
|
|
|
-DownloadManager.prototype = {
|
|
|
- downloadUrl: function DownloadManager_downloadUrl(url, filename) {
|
|
|
- if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, 'http://example.com')) {
|
|
|
- return;
|
|
|
+
|
|
|
+var DownloadManager = function () {
|
|
|
+ function DownloadManager() {
|
|
|
+ _classCallCheck(this, DownloadManager);
|
|
|
+ }
|
|
|
+
|
|
|
+ _createClass(DownloadManager, [{
|
|
|
+ key: 'downloadUrl',
|
|
|
+ value: function downloadUrl(url, filename) {
|
|
|
+ if (!(0, _pdfjsLib.createValidAbsoluteUrl)(url, 'http://example.com')) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ _download(url + '#pdfjs.action=download', filename);
|
|
|
}
|
|
|
- download(url + '#pdfjs.action=download', filename);
|
|
|
- },
|
|
|
- downloadData: function DownloadManager_downloadData(data, filename, contentType) {
|
|
|
- if (navigator.msSaveBlob) {
|
|
|
- return navigator.msSaveBlob(new Blob([data], { type: contentType }), filename);
|
|
|
+ }, {
|
|
|
+ key: 'downloadData',
|
|
|
+ value: function downloadData(data, filename, contentType) {
|
|
|
+ if (navigator.msSaveBlob) {
|
|
|
+ return navigator.msSaveBlob(new Blob([data], { type: contentType }), filename);
|
|
|
+ }
|
|
|
+ var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, _pdfjsLib.PDFJS.disableCreateObjectURL);
|
|
|
+ _download(blobUrl, filename);
|
|
|
}
|
|
|
- var blobUrl = (0, _pdfjsLib.createObjectURL)(data, contentType, _pdfjsLib.PDFJS.disableCreateObjectURL);
|
|
|
- download(blobUrl, filename);
|
|
|
- },
|
|
|
- download: function DownloadManager_download(blob, url, filename) {
|
|
|
- if (navigator.msSaveBlob) {
|
|
|
- if (!navigator.msSaveBlob(blob, filename)) {
|
|
|
+ }, {
|
|
|
+ key: 'download',
|
|
|
+ value: function download(blob, url, filename) {
|
|
|
+ if (navigator.msSaveBlob) {
|
|
|
+ if (!navigator.msSaveBlob(blob, filename)) {
|
|
|
+ this.downloadUrl(url, filename);
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (_pdfjsLib.PDFJS.disableCreateObjectURL) {
|
|
|
this.downloadUrl(url, filename);
|
|
|
+ return;
|
|
|
}
|
|
|
- return;
|
|
|
- }
|
|
|
- if (_pdfjsLib.PDFJS.disableCreateObjectURL) {
|
|
|
- this.downloadUrl(url, filename);
|
|
|
- return;
|
|
|
+ var blobUrl = URL.createObjectURL(blob);
|
|
|
+ _download(blobUrl, filename);
|
|
|
}
|
|
|
- var blobUrl = URL.createObjectURL(blob);
|
|
|
- download(blobUrl, filename);
|
|
|
- }
|
|
|
-};
|
|
|
+ }]);
|
|
|
+
|
|
|
+ return DownloadManager;
|
|
|
+}();
|
|
|
+
|
|
|
exports.DownloadManager = DownloadManager;
|
|
|
|
|
|
/***/ }),
|