mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 01:35:43 +02:00
move hasHtml to AnnotationElement
This commit is contained in:
parent
acf74d40b1
commit
e42da0f5e9
2 changed files with 23 additions and 23 deletions
|
@ -84,7 +84,7 @@ AnnotationElementFactory.prototype =
|
|||
return new StrikeOutAnnotationElement(parameters);
|
||||
|
||||
default:
|
||||
throw new Error('Unimplemented annotation type "' + subtype + '"');
|
||||
return new AnnotationElement(parameters);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -94,14 +94,17 @@ AnnotationElementFactory.prototype =
|
|||
* @alias AnnotationElement
|
||||
*/
|
||||
var AnnotationElement = (function AnnotationElementClosure() {
|
||||
function AnnotationElement(parameters) {
|
||||
function AnnotationElement(parameters, isRenderable) {
|
||||
this.isRenderable = isRenderable || false;
|
||||
this.data = parameters.data;
|
||||
this.layer = parameters.layer;
|
||||
this.page = parameters.page;
|
||||
this.viewport = parameters.viewport;
|
||||
this.linkService = parameters.linkService;
|
||||
|
||||
this.container = this._createContainer();
|
||||
if (isRenderable) {
|
||||
this.container = this._createContainer();
|
||||
}
|
||||
}
|
||||
|
||||
AnnotationElement.prototype = /** @lends AnnotationElement.prototype */ {
|
||||
|
@ -216,7 +219,7 @@ var AnnotationElement = (function AnnotationElementClosure() {
|
|||
*/
|
||||
var LinkAnnotationElement = (function LinkAnnotationElementClosure() {
|
||||
function LinkAnnotationElement(parameters) {
|
||||
AnnotationElement.call(this, parameters);
|
||||
AnnotationElement.call(this, parameters, true);
|
||||
}
|
||||
|
||||
Util.inherit(LinkAnnotationElement, AnnotationElement, {
|
||||
|
@ -298,7 +301,9 @@ var LinkAnnotationElement = (function LinkAnnotationElementClosure() {
|
|||
*/
|
||||
var TextAnnotationElement = (function TextAnnotationElementClosure() {
|
||||
function TextAnnotationElement(parameters) {
|
||||
AnnotationElement.call(this, parameters);
|
||||
var isRenderable = !!(parameters.data.hasPopup ||
|
||||
parameters.data.title || parameters.data.contents);
|
||||
AnnotationElement.call(this, parameters, isRenderable);
|
||||
}
|
||||
|
||||
Util.inherit(TextAnnotationElement, AnnotationElement, {
|
||||
|
@ -352,7 +357,9 @@ var TextAnnotationElement = (function TextAnnotationElementClosure() {
|
|||
*/
|
||||
var WidgetAnnotationElement = (function WidgetAnnotationElementClosure() {
|
||||
function WidgetAnnotationElement(parameters) {
|
||||
AnnotationElement.call(this, parameters);
|
||||
var isRenderable = !parameters.data.hasAppearance &&
|
||||
!!parameters.data.fieldValue;
|
||||
AnnotationElement.call(this, parameters, isRenderable);
|
||||
}
|
||||
|
||||
Util.inherit(WidgetAnnotationElement, AnnotationElement, {
|
||||
|
@ -419,7 +426,8 @@ var WidgetAnnotationElement = (function WidgetAnnotationElementClosure() {
|
|||
*/
|
||||
var PopupAnnotationElement = (function PopupAnnotationElementClosure() {
|
||||
function PopupAnnotationElement(parameters) {
|
||||
AnnotationElement.call(this, parameters);
|
||||
var isRenderable = !!(parameters.data.title || parameters.data.contents);
|
||||
AnnotationElement.call(this, parameters, isRenderable);
|
||||
}
|
||||
|
||||
Util.inherit(PopupAnnotationElement, AnnotationElement, {
|
||||
|
@ -609,7 +617,7 @@ var PopupElement = (function PopupElementClosure() {
|
|||
var HighlightAnnotationElement = (
|
||||
function HighlightAnnotationElementClosure() {
|
||||
function HighlightAnnotationElement(parameters) {
|
||||
AnnotationElement.call(this, parameters);
|
||||
AnnotationElement.call(this, parameters, true);
|
||||
}
|
||||
|
||||
Util.inherit(HighlightAnnotationElement, AnnotationElement, {
|
||||
|
@ -636,7 +644,7 @@ var HighlightAnnotationElement = (
|
|||
var UnderlineAnnotationElement = (
|
||||
function UnderlineAnnotationElementClosure() {
|
||||
function UnderlineAnnotationElement(parameters) {
|
||||
AnnotationElement.call(this, parameters);
|
||||
AnnotationElement.call(this, parameters, true);
|
||||
}
|
||||
|
||||
Util.inherit(UnderlineAnnotationElement, AnnotationElement, {
|
||||
|
@ -662,7 +670,7 @@ var UnderlineAnnotationElement = (
|
|||
*/
|
||||
var SquigglyAnnotationElement = (function SquigglyAnnotationElementClosure() {
|
||||
function SquigglyAnnotationElement(parameters) {
|
||||
AnnotationElement.call(this, parameters);
|
||||
AnnotationElement.call(this, parameters, true);
|
||||
}
|
||||
|
||||
Util.inherit(SquigglyAnnotationElement, AnnotationElement, {
|
||||
|
@ -689,7 +697,7 @@ var SquigglyAnnotationElement = (function SquigglyAnnotationElementClosure() {
|
|||
var StrikeOutAnnotationElement = (
|
||||
function StrikeOutAnnotationElementClosure() {
|
||||
function StrikeOutAnnotationElement(parameters) {
|
||||
AnnotationElement.call(this, parameters);
|
||||
AnnotationElement.call(this, parameters, true);
|
||||
}
|
||||
|
||||
Util.inherit(StrikeOutAnnotationElement, AnnotationElement, {
|
||||
|
@ -736,7 +744,7 @@ var AnnotationLayer = (function AnnotationLayerClosure() {
|
|||
|
||||
for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
|
||||
var data = parameters.annotations[i];
|
||||
if (!data || !data.hasHtml) {
|
||||
if (!data) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -748,7 +756,9 @@ var AnnotationLayer = (function AnnotationLayerClosure() {
|
|||
linkService: parameters.linkService
|
||||
};
|
||||
var element = annotationElementFactory.create(properties);
|
||||
parameters.div.appendChild(element.render());
|
||||
if (element.isRenderable) {
|
||||
parameters.div.appendChild(element.render());
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue