|
|
|
@ -42,6 +42,7 @@ var CustomStyle = displayDOMUtils.CustomStyle;
@@ -42,6 +42,7 @@ var CustomStyle = displayDOMUtils.CustomStyle;
|
|
|
|
|
* @property {PDFPage} page |
|
|
|
|
* @property {PageViewport} viewport |
|
|
|
|
* @property {IPDFLinkService} linkService |
|
|
|
|
* @property {DownloadManager} downloadManager |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -83,6 +84,9 @@ AnnotationElementFactory.prototype =
@@ -83,6 +84,9 @@ AnnotationElementFactory.prototype =
|
|
|
|
|
case AnnotationType.STRIKEOUT: |
|
|
|
|
return new StrikeOutAnnotationElement(parameters); |
|
|
|
|
|
|
|
|
|
case AnnotationType.FILEATTACHMENT: |
|
|
|
|
return new FileAttachmentAnnotationElement(parameters); |
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
return new AnnotationElement(parameters); |
|
|
|
|
} |
|
|
|
@ -101,6 +105,7 @@ var AnnotationElement = (function AnnotationElementClosure() {
@@ -101,6 +105,7 @@ var AnnotationElement = (function AnnotationElementClosure() {
|
|
|
|
|
this.page = parameters.page; |
|
|
|
|
this.viewport = parameters.viewport; |
|
|
|
|
this.linkService = parameters.linkService; |
|
|
|
|
this.downloadManager = parameters.downloadManager; |
|
|
|
|
|
|
|
|
|
if (isRenderable) { |
|
|
|
|
this.container = this._createContainer(); |
|
|
|
@ -717,6 +722,76 @@ var StrikeOutAnnotationElement = (
@@ -717,6 +722,76 @@ var StrikeOutAnnotationElement = (
|
|
|
|
|
return StrikeOutAnnotationElement; |
|
|
|
|
})(); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @class |
|
|
|
|
* @alias FileAttachmentAnnotationElement |
|
|
|
|
*/ |
|
|
|
|
var FileAttachmentAnnotationElement = ( |
|
|
|
|
function FileAttachmentAnnotationElementClosure() { |
|
|
|
|
function FileAttachmentAnnotationElement(parameters) { |
|
|
|
|
AnnotationElement.call(this, parameters, true); |
|
|
|
|
|
|
|
|
|
this.filename = parameters.data.file.filename; |
|
|
|
|
this.content = parameters.data.file.content; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Util.inherit(FileAttachmentAnnotationElement, AnnotationElement, { |
|
|
|
|
/** |
|
|
|
|
* Render the file attachment annotation's HTML element in the empty |
|
|
|
|
* container. |
|
|
|
|
* |
|
|
|
|
* @public |
|
|
|
|
* @memberof FileAttachmentAnnotationElement |
|
|
|
|
* @returns {HTMLSectionElement} |
|
|
|
|
*/ |
|
|
|
|
render: function FileAttachmentAnnotationElement_render() { |
|
|
|
|
this.container.className = 'fileAttachmentAnnotation'; |
|
|
|
|
|
|
|
|
|
var trigger = document.createElement('div'); |
|
|
|
|
trigger.style.height = this.container.style.height; |
|
|
|
|
trigger.style.width = this.container.style.width; |
|
|
|
|
trigger.addEventListener('dblclick', this._download.bind(this)); |
|
|
|
|
|
|
|
|
|
if (!this.data.hasPopup && (this.data.title || this.data.contents)) { |
|
|
|
|
var popupElement = new PopupElement({ |
|
|
|
|
container: this.container, |
|
|
|
|
trigger: trigger, |
|
|
|
|
color: this.data.color, |
|
|
|
|
title: this.data.title, |
|
|
|
|
contents: this.data.contents, |
|
|
|
|
hideWrapper: true |
|
|
|
|
}); |
|
|
|
|
var popup = popupElement.render(); |
|
|
|
|
|
|
|
|
|
// Position the popup next to the FileAttachment annotation's
|
|
|
|
|
// container.
|
|
|
|
|
popup.style.left = this.container.style.width; |
|
|
|
|
|
|
|
|
|
this.container.appendChild(popup); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.container.appendChild(trigger); |
|
|
|
|
return this.container; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Download the file attachment associated with this annotation. |
|
|
|
|
* |
|
|
|
|
* @private |
|
|
|
|
* @memberof FileAttachmentAnnotationElement |
|
|
|
|
*/ |
|
|
|
|
_download: function FileAttachmentAnnotationElement_download() { |
|
|
|
|
if (!this.downloadManager) { |
|
|
|
|
warn('Download cannot be started due to unavailable download manager'); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
this.downloadManager.downloadData(this.content, this.filename, ''); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return FileAttachmentAnnotationElement; |
|
|
|
|
})(); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @typedef {Object} AnnotationLayerParameters |
|
|
|
|
* @property {PageViewport} viewport |
|
|
|
@ -753,7 +828,8 @@ var AnnotationLayer = (function AnnotationLayerClosure() {
@@ -753,7 +828,8 @@ var AnnotationLayer = (function AnnotationLayerClosure() {
|
|
|
|
|
layer: parameters.div, |
|
|
|
|
page: parameters.page, |
|
|
|
|
viewport: parameters.viewport, |
|
|
|
|
linkService: parameters.linkService |
|
|
|
|
linkService: parameters.linkService, |
|
|
|
|
downloadManager: parameters.downloadManager |
|
|
|
|
}; |
|
|
|
|
var element = annotationElementFactory.create(properties); |
|
|
|
|
if (element.isRenderable) { |
|
|
|
|