|
|
@ -32,6 +32,7 @@ var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType; |
|
|
|
var AnnotationType = sharedUtil.AnnotationType; |
|
|
|
var AnnotationType = sharedUtil.AnnotationType; |
|
|
|
var Util = sharedUtil.Util; |
|
|
|
var Util = sharedUtil.Util; |
|
|
|
var addLinkAttributes = sharedUtil.addLinkAttributes; |
|
|
|
var addLinkAttributes = sharedUtil.addLinkAttributes; |
|
|
|
|
|
|
|
var getFilenameFromUrl = sharedUtil.getFilenameFromUrl; |
|
|
|
var warn = sharedUtil.warn; |
|
|
|
var warn = sharedUtil.warn; |
|
|
|
var CustomStyle = displayDOMUtils.CustomStyle; |
|
|
|
var CustomStyle = displayDOMUtils.CustomStyle; |
|
|
|
|
|
|
|
|
|
|
@ -42,6 +43,7 @@ var CustomStyle = displayDOMUtils.CustomStyle; |
|
|
|
* @property {PDFPage} page |
|
|
|
* @property {PDFPage} page |
|
|
|
* @property {PageViewport} viewport |
|
|
|
* @property {PageViewport} viewport |
|
|
|
* @property {IPDFLinkService} linkService |
|
|
|
* @property {IPDFLinkService} linkService |
|
|
|
|
|
|
|
* @property {DownloadManager} downloadManager |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -83,6 +85,9 @@ AnnotationElementFactory.prototype = |
|
|
|
case AnnotationType.STRIKEOUT: |
|
|
|
case AnnotationType.STRIKEOUT: |
|
|
|
return new StrikeOutAnnotationElement(parameters); |
|
|
|
return new StrikeOutAnnotationElement(parameters); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case AnnotationType.FILEATTACHMENT: |
|
|
|
|
|
|
|
return new FileAttachmentAnnotationElement(parameters); |
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
default: |
|
|
|
return new AnnotationElement(parameters); |
|
|
|
return new AnnotationElement(parameters); |
|
|
|
} |
|
|
|
} |
|
|
@ -101,6 +106,7 @@ var AnnotationElement = (function AnnotationElementClosure() { |
|
|
|
this.page = parameters.page; |
|
|
|
this.page = parameters.page; |
|
|
|
this.viewport = parameters.viewport; |
|
|
|
this.viewport = parameters.viewport; |
|
|
|
this.linkService = parameters.linkService; |
|
|
|
this.linkService = parameters.linkService; |
|
|
|
|
|
|
|
this.downloadManager = parameters.downloadManager; |
|
|
|
|
|
|
|
|
|
|
|
if (isRenderable) { |
|
|
|
if (isRenderable) { |
|
|
|
this.container = this._createContainer(); |
|
|
|
this.container = this._createContainer(); |
|
|
@ -721,6 +727,76 @@ var StrikeOutAnnotationElement = ( |
|
|
|
return StrikeOutAnnotationElement; |
|
|
|
return StrikeOutAnnotationElement; |
|
|
|
})(); |
|
|
|
})(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @class |
|
|
|
|
|
|
|
* @alias FileAttachmentAnnotationElement |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
var FileAttachmentAnnotationElement = ( |
|
|
|
|
|
|
|
function FileAttachmentAnnotationElementClosure() { |
|
|
|
|
|
|
|
function FileAttachmentAnnotationElement(parameters) { |
|
|
|
|
|
|
|
AnnotationElement.call(this, parameters, true); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.filename = getFilenameFromUrl(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 |
|
|
|
* @typedef {Object} AnnotationLayerParameters |
|
|
|
* @property {PageViewport} viewport |
|
|
|
* @property {PageViewport} viewport |
|
|
@ -757,7 +833,8 @@ var AnnotationLayer = (function AnnotationLayerClosure() { |
|
|
|
layer: parameters.div, |
|
|
|
layer: parameters.div, |
|
|
|
page: parameters.page, |
|
|
|
page: parameters.page, |
|
|
|
viewport: parameters.viewport, |
|
|
|
viewport: parameters.viewport, |
|
|
|
linkService: parameters.linkService |
|
|
|
linkService: parameters.linkService, |
|
|
|
|
|
|
|
downloadManager: parameters.downloadManager |
|
|
|
}; |
|
|
|
}; |
|
|
|
var element = annotationElementFactory.create(properties); |
|
|
|
var element = annotationElementFactory.create(properties); |
|
|
|
if (element.isRenderable) { |
|
|
|
if (element.isRenderable) { |
|
|
|