|
|
@ -26,13 +26,17 @@ var _pdf = require('../pdf'); |
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
|
|
|
|
|
|
|
|
|
|
|
var PDFAttachmentViewer = function () { |
|
|
|
var PDFAttachmentViewer = function () { |
|
|
|
function PDFAttachmentViewer(options) { |
|
|
|
function PDFAttachmentViewer(_ref) { |
|
|
|
|
|
|
|
var container = _ref.container, |
|
|
|
|
|
|
|
eventBus = _ref.eventBus, |
|
|
|
|
|
|
|
downloadManager = _ref.downloadManager; |
|
|
|
|
|
|
|
|
|
|
|
_classCallCheck(this, PDFAttachmentViewer); |
|
|
|
_classCallCheck(this, PDFAttachmentViewer); |
|
|
|
|
|
|
|
|
|
|
|
this.attachments = null; |
|
|
|
this.attachments = null; |
|
|
|
this.container = options.container; |
|
|
|
this.container = container; |
|
|
|
this.eventBus = options.eventBus; |
|
|
|
this.eventBus = eventBus; |
|
|
|
this.downloadManager = options.downloadManager; |
|
|
|
this.downloadManager = downloadManager; |
|
|
|
this._renderedCapability = (0, _pdf.createPromiseCapability)(); |
|
|
|
this._renderedCapability = (0, _pdf.createPromiseCapability)(); |
|
|
|
this.eventBus.on('fileattachmentannotation', this._appendAttachment.bind(this)); |
|
|
|
this.eventBus.on('fileattachmentannotation', this._appendAttachment.bind(this)); |
|
|
|
} |
|
|
|
} |
|
|
@ -63,12 +67,12 @@ var PDFAttachmentViewer = function () { |
|
|
|
if (_pdf.PDFJS.disableCreateObjectURL) { |
|
|
|
if (_pdf.PDFJS.disableCreateObjectURL) { |
|
|
|
throw new Error('bindPdfLink: ' + 'Unsupported "PDFJS.disableCreateObjectURL" value.'); |
|
|
|
throw new Error('bindPdfLink: ' + 'Unsupported "PDFJS.disableCreateObjectURL" value.'); |
|
|
|
} |
|
|
|
} |
|
|
|
var blobUrl; |
|
|
|
var blobUrl = void 0; |
|
|
|
button.onclick = function () { |
|
|
|
button.onclick = function () { |
|
|
|
if (!blobUrl) { |
|
|
|
if (!blobUrl) { |
|
|
|
blobUrl = (0, _pdf.createObjectURL)(content, 'application/pdf'); |
|
|
|
blobUrl = (0, _pdf.createObjectURL)(content, 'application/pdf'); |
|
|
|
} |
|
|
|
} |
|
|
|
var viewerUrl; |
|
|
|
var viewerUrl = void 0; |
|
|
|
viewerUrl = '?file=' + encodeURIComponent(blobUrl + '#' + filename); |
|
|
|
viewerUrl = '?file=' + encodeURIComponent(blobUrl + '#' + filename); |
|
|
|
window.open(viewerUrl); |
|
|
|
window.open(viewerUrl); |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -86,16 +90,16 @@ var PDFAttachmentViewer = function () { |
|
|
|
} |
|
|
|
} |
|
|
|
}, { |
|
|
|
}, { |
|
|
|
key: 'render', |
|
|
|
key: 'render', |
|
|
|
value: function render() { |
|
|
|
value: function render(_ref2) { |
|
|
|
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
|
|
var attachments = _ref2.attachments, |
|
|
|
|
|
|
|
_ref2$keepRenderedCap = _ref2.keepRenderedCapability, |
|
|
|
|
|
|
|
keepRenderedCapability = _ref2$keepRenderedCap === undefined ? false : _ref2$keepRenderedCap; |
|
|
|
|
|
|
|
|
|
|
|
var attachments = params.attachments || null; |
|
|
|
|
|
|
|
var attachmentsCount = 0; |
|
|
|
var attachmentsCount = 0; |
|
|
|
if (this.attachments) { |
|
|
|
if (this.attachments) { |
|
|
|
var keepRenderedCapability = params.keepRenderedCapability === true; |
|
|
|
this.reset(keepRenderedCapability === true); |
|
|
|
this.reset(keepRenderedCapability); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
this.attachments = attachments; |
|
|
|
this.attachments = attachments || null; |
|
|
|
if (!attachments) { |
|
|
|
if (!attachments) { |
|
|
|
this._dispatchEvent(attachmentsCount); |
|
|
|
this._dispatchEvent(attachmentsCount); |
|
|
|
return; |
|
|
|
return; |
|
|
@ -123,12 +127,12 @@ var PDFAttachmentViewer = function () { |
|
|
|
} |
|
|
|
} |
|
|
|
}, { |
|
|
|
}, { |
|
|
|
key: '_appendAttachment', |
|
|
|
key: '_appendAttachment', |
|
|
|
value: function _appendAttachment(_ref) { |
|
|
|
value: function _appendAttachment(_ref3) { |
|
|
|
var _this2 = this; |
|
|
|
var _this2 = this; |
|
|
|
|
|
|
|
|
|
|
|
var id = _ref.id, |
|
|
|
var id = _ref3.id, |
|
|
|
filename = _ref.filename, |
|
|
|
filename = _ref3.filename, |
|
|
|
content = _ref.content; |
|
|
|
content = _ref3.content; |
|
|
|
|
|
|
|
|
|
|
|
this._renderedCapability.promise.then(function () { |
|
|
|
this._renderedCapability.promise.then(function () { |
|
|
|
var attachments = _this2.attachments; |
|
|
|
var attachments = _this2.attachments; |
|
|
|