|
|
@ -93,6 +93,9 @@ AnnotationElementFactory.prototype = |
|
|
|
case AnnotationType.POPUP: |
|
|
|
case AnnotationType.POPUP: |
|
|
|
return new PopupAnnotationElement(parameters); |
|
|
|
return new PopupAnnotationElement(parameters); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case AnnotationType.LINE: |
|
|
|
|
|
|
|
return new LineAnnotationElement(parameters); |
|
|
|
|
|
|
|
|
|
|
|
case AnnotationType.HIGHLIGHT: |
|
|
|
case AnnotationType.HIGHLIGHT: |
|
|
|
return new HighlightAnnotationElement(parameters); |
|
|
|
return new HighlightAnnotationElement(parameters); |
|
|
|
|
|
|
|
|
|
|
@ -119,7 +122,7 @@ AnnotationElementFactory.prototype = |
|
|
|
* @alias AnnotationElement |
|
|
|
* @alias AnnotationElement |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
var AnnotationElement = (function AnnotationElementClosure() { |
|
|
|
var AnnotationElement = (function AnnotationElementClosure() { |
|
|
|
function AnnotationElement(parameters, isRenderable) { |
|
|
|
function AnnotationElement(parameters, isRenderable, ignoreBorder) { |
|
|
|
this.isRenderable = isRenderable || false; |
|
|
|
this.isRenderable = isRenderable || false; |
|
|
|
this.data = parameters.data; |
|
|
|
this.data = parameters.data; |
|
|
|
this.layer = parameters.layer; |
|
|
|
this.layer = parameters.layer; |
|
|
@ -131,7 +134,7 @@ var AnnotationElement = (function AnnotationElementClosure() { |
|
|
|
this.renderInteractiveForms = parameters.renderInteractiveForms; |
|
|
|
this.renderInteractiveForms = parameters.renderInteractiveForms; |
|
|
|
|
|
|
|
|
|
|
|
if (isRenderable) { |
|
|
|
if (isRenderable) { |
|
|
|
this.container = this._createContainer(); |
|
|
|
this.container = this._createContainer(ignoreBorder); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -140,10 +143,12 @@ var AnnotationElement = (function AnnotationElementClosure() { |
|
|
|
* Create an empty container for the annotation's HTML element. |
|
|
|
* Create an empty container for the annotation's HTML element. |
|
|
|
* |
|
|
|
* |
|
|
|
* @private |
|
|
|
* @private |
|
|
|
|
|
|
|
* @param {boolean} ignoreBorder |
|
|
|
* @memberof AnnotationElement |
|
|
|
* @memberof AnnotationElement |
|
|
|
* @returns {HTMLSectionElement} |
|
|
|
* @returns {HTMLSectionElement} |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
_createContainer: function AnnotationElement_createContainer() { |
|
|
|
_createContainer: |
|
|
|
|
|
|
|
function AnnotationElement_createContainer(ignoreBorder) { |
|
|
|
var data = this.data, page = this.page, viewport = this.viewport; |
|
|
|
var data = this.data, page = this.page, viewport = this.viewport; |
|
|
|
var container = document.createElement('section'); |
|
|
|
var container = document.createElement('section'); |
|
|
|
var width = data.rect[2] - data.rect[0]; |
|
|
|
var width = data.rect[2] - data.rect[0]; |
|
|
@ -165,7 +170,7 @@ var AnnotationElement = (function AnnotationElementClosure() { |
|
|
|
CustomStyle.setProp('transformOrigin', container, |
|
|
|
CustomStyle.setProp('transformOrigin', container, |
|
|
|
-rect[0] + 'px ' + -rect[1] + 'px'); |
|
|
|
-rect[0] + 'px ' + -rect[1] + 'px'); |
|
|
|
|
|
|
|
|
|
|
|
if (data.borderStyle.width > 0) { |
|
|
|
if (!ignoreBorder && data.borderStyle.width > 0) { |
|
|
|
container.style.borderWidth = data.borderStyle.width + 'px'; |
|
|
|
container.style.borderWidth = data.borderStyle.width + 'px'; |
|
|
|
if (data.borderStyle.style !== AnnotationBorderStyleType.UNDERLINE) { |
|
|
|
if (data.borderStyle.style !== AnnotationBorderStyleType.UNDERLINE) { |
|
|
|
// Underline styles only have a bottom border, so we do not need
|
|
|
|
// Underline styles only have a bottom border, so we do not need
|
|
|
@ -679,6 +684,10 @@ var ChoiceWidgetAnnotationElement = ( |
|
|
|
* @alias PopupAnnotationElement |
|
|
|
* @alias PopupAnnotationElement |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
var PopupAnnotationElement = (function PopupAnnotationElementClosure() { |
|
|
|
var PopupAnnotationElement = (function PopupAnnotationElementClosure() { |
|
|
|
|
|
|
|
// Do not render popup annotations for parent elements with these types as
|
|
|
|
|
|
|
|
// they create the popups themselves (because of custom trigger divs).
|
|
|
|
|
|
|
|
var IGNORE_TYPES = ['Line']; |
|
|
|
|
|
|
|
|
|
|
|
function PopupAnnotationElement(parameters) { |
|
|
|
function PopupAnnotationElement(parameters) { |
|
|
|
var isRenderable = !!(parameters.data.title || parameters.data.contents); |
|
|
|
var isRenderable = !!(parameters.data.title || parameters.data.contents); |
|
|
|
AnnotationElement.call(this, parameters, isRenderable); |
|
|
|
AnnotationElement.call(this, parameters, isRenderable); |
|
|
@ -695,6 +704,10 @@ var PopupAnnotationElement = (function PopupAnnotationElementClosure() { |
|
|
|
render: function PopupAnnotationElement_render() { |
|
|
|
render: function PopupAnnotationElement_render() { |
|
|
|
this.container.className = 'popupAnnotation'; |
|
|
|
this.container.className = 'popupAnnotation'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (IGNORE_TYPES.indexOf(this.data.parentType) >= 0) { |
|
|
|
|
|
|
|
return this.container; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var selector = '[data-annotation-id="' + this.data.parentId + '"]'; |
|
|
|
var selector = '[data-annotation-id="' + this.data.parentId + '"]'; |
|
|
|
var parentElement = this.layer.querySelector(selector); |
|
|
|
var parentElement = this.layer.querySelector(selector); |
|
|
|
if (!parentElement) { |
|
|
|
if (!parentElement) { |
|
|
@ -864,6 +877,69 @@ var PopupElement = (function PopupElementClosure() { |
|
|
|
return PopupElement; |
|
|
|
return PopupElement; |
|
|
|
})(); |
|
|
|
})(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @class |
|
|
|
|
|
|
|
* @alias LineAnnotationElement |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
var LineAnnotationElement = (function LineAnnotationElementClosure() { |
|
|
|
|
|
|
|
var SVG_NS = 'http://www.w3.org/2000/svg'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function LineAnnotationElement(parameters) { |
|
|
|
|
|
|
|
var isRenderable = !!(parameters.data.hasPopup || |
|
|
|
|
|
|
|
parameters.data.title || parameters.data.contents); |
|
|
|
|
|
|
|
AnnotationElement.call(this, parameters, isRenderable, |
|
|
|
|
|
|
|
/* ignoreBorder = */ true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Util.inherit(LineAnnotationElement, AnnotationElement, { |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Render the line annotation's HTML element in the empty container. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @public |
|
|
|
|
|
|
|
* @memberof LineAnnotationElement |
|
|
|
|
|
|
|
* @returns {HTMLSectionElement} |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
render: function LineAnnotationElement_render() { |
|
|
|
|
|
|
|
this.container.className = 'lineAnnotation'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Create an invisible line with the same starting and ending coordinates
|
|
|
|
|
|
|
|
// that acts as the trigger for the popup. Only the line itself should
|
|
|
|
|
|
|
|
// trigger the popup, not the entire container.
|
|
|
|
|
|
|
|
var data = this.data; |
|
|
|
|
|
|
|
var width = data.rect[2] - data.rect[0]; |
|
|
|
|
|
|
|
var height = data.rect[3] - data.rect[1]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var svg = document.createElementNS(SVG_NS, 'svg:svg'); |
|
|
|
|
|
|
|
svg.setAttributeNS(null, 'version', '1.1'); |
|
|
|
|
|
|
|
svg.setAttributeNS(null, 'width', width + 'px'); |
|
|
|
|
|
|
|
svg.setAttributeNS(null, 'height', height + 'px'); |
|
|
|
|
|
|
|
svg.setAttributeNS(null, 'preserveAspectRatio', 'none'); |
|
|
|
|
|
|
|
svg.setAttributeNS(null, 'viewBox', '0 0 ' + width + ' ' + height); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// PDF coordinates are calculated from a bottom left origin, so transform
|
|
|
|
|
|
|
|
// the line coordinates to a top left origin for the SVG element.
|
|
|
|
|
|
|
|
var line = document.createElementNS(SVG_NS, 'svg:line'); |
|
|
|
|
|
|
|
line.setAttributeNS(null, 'x1', data.rect[2] - data.lineCoordinates[0]); |
|
|
|
|
|
|
|
line.setAttributeNS(null, 'y1', data.rect[3] - data.lineCoordinates[1]); |
|
|
|
|
|
|
|
line.setAttributeNS(null, 'x2', data.rect[2] - data.lineCoordinates[2]); |
|
|
|
|
|
|
|
line.setAttributeNS(null, 'y2', data.rect[3] - data.lineCoordinates[3]); |
|
|
|
|
|
|
|
line.setAttributeNS(null, 'stroke-width', data.borderStyle.width); |
|
|
|
|
|
|
|
line.setAttributeNS(null, 'stroke', 'transparent'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
svg.appendChild(line); |
|
|
|
|
|
|
|
this.container.append(svg); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Create the popup ourselves so that we can bind it to the line instead
|
|
|
|
|
|
|
|
// of to the entire container (which is the default).
|
|
|
|
|
|
|
|
this._createPopup(this.container, line, this.data); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return this.container; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return LineAnnotationElement; |
|
|
|
|
|
|
|
})(); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @class |
|
|
|
* @class |
|
|
|
* @alias HighlightAnnotationElement |
|
|
|
* @alias HighlightAnnotationElement |
|
|
@ -873,7 +949,8 @@ var HighlightAnnotationElement = ( |
|
|
|
function HighlightAnnotationElement(parameters) { |
|
|
|
function HighlightAnnotationElement(parameters) { |
|
|
|
var isRenderable = !!(parameters.data.hasPopup || |
|
|
|
var isRenderable = !!(parameters.data.hasPopup || |
|
|
|
parameters.data.title || parameters.data.contents); |
|
|
|
parameters.data.title || parameters.data.contents); |
|
|
|
AnnotationElement.call(this, parameters, isRenderable); |
|
|
|
AnnotationElement.call(this, parameters, isRenderable, |
|
|
|
|
|
|
|
/* ignoreBorder = */ true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Util.inherit(HighlightAnnotationElement, AnnotationElement, { |
|
|
|
Util.inherit(HighlightAnnotationElement, AnnotationElement, { |
|
|
@ -890,7 +967,6 @@ var HighlightAnnotationElement = ( |
|
|
|
if (!this.data.hasPopup) { |
|
|
|
if (!this.data.hasPopup) { |
|
|
|
this._createPopup(this.container, null, this.data); |
|
|
|
this._createPopup(this.container, null, this.data); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return this.container; |
|
|
|
return this.container; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
@ -907,7 +983,8 @@ var UnderlineAnnotationElement = ( |
|
|
|
function UnderlineAnnotationElement(parameters) { |
|
|
|
function UnderlineAnnotationElement(parameters) { |
|
|
|
var isRenderable = !!(parameters.data.hasPopup || |
|
|
|
var isRenderable = !!(parameters.data.hasPopup || |
|
|
|
parameters.data.title || parameters.data.contents); |
|
|
|
parameters.data.title || parameters.data.contents); |
|
|
|
AnnotationElement.call(this, parameters, isRenderable); |
|
|
|
AnnotationElement.call(this, parameters, isRenderable, |
|
|
|
|
|
|
|
/* ignoreBorder = */ true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Util.inherit(UnderlineAnnotationElement, AnnotationElement, { |
|
|
|
Util.inherit(UnderlineAnnotationElement, AnnotationElement, { |
|
|
@ -924,7 +1001,6 @@ var UnderlineAnnotationElement = ( |
|
|
|
if (!this.data.hasPopup) { |
|
|
|
if (!this.data.hasPopup) { |
|
|
|
this._createPopup(this.container, null, this.data); |
|
|
|
this._createPopup(this.container, null, this.data); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return this.container; |
|
|
|
return this.container; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
@ -940,7 +1016,8 @@ var SquigglyAnnotationElement = (function SquigglyAnnotationElementClosure() { |
|
|
|
function SquigglyAnnotationElement(parameters) { |
|
|
|
function SquigglyAnnotationElement(parameters) { |
|
|
|
var isRenderable = !!(parameters.data.hasPopup || |
|
|
|
var isRenderable = !!(parameters.data.hasPopup || |
|
|
|
parameters.data.title || parameters.data.contents); |
|
|
|
parameters.data.title || parameters.data.contents); |
|
|
|
AnnotationElement.call(this, parameters, isRenderable); |
|
|
|
AnnotationElement.call(this, parameters, isRenderable, |
|
|
|
|
|
|
|
/* ignoreBorder = */ true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Util.inherit(SquigglyAnnotationElement, AnnotationElement, { |
|
|
|
Util.inherit(SquigglyAnnotationElement, AnnotationElement, { |
|
|
@ -957,7 +1034,6 @@ var SquigglyAnnotationElement = (function SquigglyAnnotationElementClosure() { |
|
|
|
if (!this.data.hasPopup) { |
|
|
|
if (!this.data.hasPopup) { |
|
|
|
this._createPopup(this.container, null, this.data); |
|
|
|
this._createPopup(this.container, null, this.data); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return this.container; |
|
|
|
return this.container; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
@ -974,7 +1050,8 @@ var StrikeOutAnnotationElement = ( |
|
|
|
function StrikeOutAnnotationElement(parameters) { |
|
|
|
function StrikeOutAnnotationElement(parameters) { |
|
|
|
var isRenderable = !!(parameters.data.hasPopup || |
|
|
|
var isRenderable = !!(parameters.data.hasPopup || |
|
|
|
parameters.data.title || parameters.data.contents); |
|
|
|
parameters.data.title || parameters.data.contents); |
|
|
|
AnnotationElement.call(this, parameters, isRenderable); |
|
|
|
AnnotationElement.call(this, parameters, isRenderable, |
|
|
|
|
|
|
|
/* ignoreBorder = */ true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Util.inherit(StrikeOutAnnotationElement, AnnotationElement, { |
|
|
|
Util.inherit(StrikeOutAnnotationElement, AnnotationElement, { |
|
|
@ -991,7 +1068,6 @@ var StrikeOutAnnotationElement = ( |
|
|
|
if (!this.data.hasPopup) { |
|
|
|
if (!this.data.hasPopup) { |
|
|
|
this._createPopup(this.container, null, this.data); |
|
|
|
this._createPopup(this.container, null, this.data); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return this.container; |
|
|
|
return this.container; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|