Skip to content

Commit

Permalink
Add support for radios printing
Browse files Browse the repository at this point in the history
  • Loading branch information
calixteman committed Jul 24, 2020
1 parent abb2825 commit 8f19bef
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/core/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -1076,6 +1076,7 @@ class ButtonWidgetAnnotation extends WidgetAnnotation {
break;
}
}
this.checkedAppearance = normalAppearanceState.get(this.data.buttonValue);
}

_processPushButton(params) {
Expand Down
23 changes: 20 additions & 3 deletions src/display/annotation_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -584,15 +584,32 @@ class RadioButtonWidgetAnnotationElement extends WidgetAnnotationElement {
*/
render() {
this.container.className = "buttonWidgetAnnotation radioButton";
const storage = this.annotationStorage;
const data = this.data;
const id = data.id;
const value = storage.getOrCreateValue(id, data.fieldValue === data.buttonValue);

const element = document.createElement("input");
element.disabled = this.data.readOnly;
element.disabled = data.readOnly;
element.type = "radio";
element.name = this.data.fieldName;
if (this.data.fieldValue === this.data.buttonValue) {
element.name = data.fieldName;
if (value) {
element.setAttribute("checked", true);
}

element.addEventListener("change", function (event) {
const name = event.target.name;
for (const el of document.getElementsByName(name)) {
if (el !== event.target) {
storage.setValue(
el.parentNode.getAttribute("data-annotation-id"),
false
);
}
}
storage.setValue(id, event.target.checked);
});

this.container.appendChild(element);
return this.container;
}
Expand Down

0 comments on commit 8f19bef

Please sign in to comment.