[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

@ -96,23 +96,33 @@ class EventDispatcher {
}
}
if (name === "Keystroke") {
savedChange = {
value: event.value,
change: event.change,
selStart: event.selStart,
selEnd: event.selEnd,
};
} else if (name === "Blur" || name === "Focus") {
Object.defineProperty(event, "value", {
configurable: false,
writable: false,
enumerable: true,
value: event.value,
});
} else if (name === "Validate") {
this.runValidation(source, event);
return;
switch (name) {
case "Keystroke":
savedChange = {
value: event.value,
change: event.change,
selStart: event.selStart,
selEnd: event.selEnd,
};
break;
case "Blur":
case "Focus":
Object.defineProperty(event, "value", {
configurable: false,
writable: false,
enumerable: true,
value: event.value,
});
break;
case "Validate":
this.runValidation(source, event);
return;
case "Action":
this.runActions(source, source, event, name);
if (this._document.obj.calculate) {
this.runCalculate(source, event);
}
return;
}
this.runActions(source, source, event, name);
@ -143,8 +153,10 @@ class EventDispatcher {
if (event.rc) {
if (hasRan) {
source.wrapped.value = event.value;
source.wrapped.valueAsString = event.value;
} else {
source.obj.value = event.value;
source.obj.valueAsString = event.value;
}
if (this._document.obj.calculate) {
@ -187,6 +199,11 @@ class EventDispatcher {
continue;
}
if (!this._document.obj.calculate) {
// An action may have changed calculate value.
continue;
}
event.value = null;
const target = this._objects[targetId];
this.runActions(source, target, event, "Calculate");