[JS] Fix several issues found in pdf in #13269

- app.alert and few other function can use an object as parameter ({cMsg: ...});
  - support app.alert with a question and a yes/no answer;
  - update field siblings when one is changed in an action;
  - stop calculation if calculate is set to false in the middle of calculations;
  - get a boolean for checkboxes when they've been set through annotationStorage instead of a string.
This commit is contained in:
Calixte Denizet 2021-04-20 19:21:52 +02:00
parent 3f187c2c6d
commit 3f29892d63
12 changed files with 224 additions and 50 deletions

View file

@ -922,12 +922,17 @@ class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement {
const storage = this.annotationStorage;
const data = this.data;
const id = data.id;
const value = storage.getValue(id, {
let value = storage.getValue(id, {
value:
data.fieldValue &&
((data.exportValue && data.exportValue === data.fieldValue) ||
(!data.exportValue && data.fieldValue !== "Off")),
}).value;
if (typeof value === "string") {
// The value has been changed through js and set in annotationStorage.
value = value !== "Off";
storage.setValue(id, { value });
}
this.container.className = "buttonWidgetAnnotation checkBox";
@ -1012,9 +1017,14 @@ class RadioButtonWidgetAnnotationElement extends WidgetAnnotationElement {
const storage = this.annotationStorage;
const data = this.data;
const id = data.id;
const value = storage.getValue(id, {
let value = storage.getValue(id, {
value: data.fieldValue === data.buttonValue,
}).value;
if (typeof value === "string") {
// The value has been changed through js and set in annotationStorage.
value = value !== data.buttonValue;
storage.setValue(id, { value });
}
const element = document.createElement("input");
element.disabled = data.readOnly;