mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Merge pull request #12333 from calixteman/tooltip
Add tooltip if any in annotations layer
This commit is contained in:
commit
6ff1fe4ea9
3 changed files with 61 additions and 3 deletions
|
@ -1533,6 +1533,7 @@ class ButtonWidgetAnnotation extends WidgetAnnotation {
|
|||
this.hasFieldFlag(AnnotationFieldFlag.RADIO) &&
|
||||
!this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
|
||||
this.data.pushButton = this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
|
||||
this.data.isTooltipOnly = false;
|
||||
|
||||
if (this.data.checkBox) {
|
||||
this._processCheckBox(params);
|
||||
|
@ -1780,11 +1781,13 @@ class ButtonWidgetAnnotation extends WidgetAnnotation {
|
|||
}
|
||||
|
||||
_processPushButton(params) {
|
||||
if (!params.dict.has("A")) {
|
||||
if (!params.dict.has("A") && !this.data.alternativeText) {
|
||||
warn("Push buttons without action dictionaries are not supported");
|
||||
return;
|
||||
}
|
||||
|
||||
this.data.isTooltipOnly = !params.dict.has("A");
|
||||
|
||||
Catalog.parseDestDictionary({
|
||||
destDict: params.dict,
|
||||
resultObj: this.data,
|
||||
|
|
|
@ -293,7 +293,8 @@ class LinkAnnotationElement extends AnnotationElement {
|
|||
const isRenderable = !!(
|
||||
parameters.data.url ||
|
||||
parameters.data.dest ||
|
||||
parameters.data.action
|
||||
parameters.data.action ||
|
||||
parameters.data.isTooltipOnly
|
||||
);
|
||||
super(parameters, isRenderable);
|
||||
}
|
||||
|
@ -322,8 +323,10 @@ class LinkAnnotationElement extends AnnotationElement {
|
|||
});
|
||||
} else if (data.action) {
|
||||
this._bindNamedAction(link, data.action);
|
||||
} else {
|
||||
} else if (data.dest) {
|
||||
this._bindLink(link, data.dest);
|
||||
} else {
|
||||
this._bindLink(link, "");
|
||||
}
|
||||
|
||||
this.container.appendChild(link);
|
||||
|
@ -420,6 +423,10 @@ class WidgetAnnotationElement extends AnnotationElement {
|
|||
*/
|
||||
render() {
|
||||
// Show only the container for unsupported field types.
|
||||
if (this.data.alternativeText) {
|
||||
this.container.title = this.data.alternativeText;
|
||||
}
|
||||
|
||||
return this.container;
|
||||
}
|
||||
}
|
||||
|
@ -647,6 +654,11 @@ class PushButtonWidgetAnnotationElement extends LinkAnnotationElement {
|
|||
// as performing actions on form fields (resetting, submitting, et cetera).
|
||||
const container = super.render();
|
||||
container.className = "buttonWidgetAnnotation pushButton";
|
||||
|
||||
if (this.data.alternativeText) {
|
||||
container.title = this.data.alternativeText;
|
||||
}
|
||||
|
||||
return container;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue