mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 09:20:06 +02:00
[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:
parent
3f187c2c6d
commit
3f29892d63
12 changed files with 224 additions and 50 deletions
|
@ -81,12 +81,14 @@ class Field extends PDFObject {
|
|||
this._strokeColor = data.strokeColor || ["G", 0];
|
||||
this._textColor = data.textColor || ["G", 0];
|
||||
this._value = data.value || "";
|
||||
this._valueAsString = data.valueAsString;
|
||||
this._kidIds = data.kidIds || null;
|
||||
this._fieldType = getFieldType(this._actions);
|
||||
this._siblings = data.siblings || null;
|
||||
|
||||
this._globalEval = data.globalEval;
|
||||
this._appObjects = data.appObjects;
|
||||
|
||||
this.valueAsString = data.valueAsString || this._value;
|
||||
}
|
||||
|
||||
get currentValueIndices() {
|
||||
|
@ -246,6 +248,9 @@ class Field extends PDFObject {
|
|||
}
|
||||
|
||||
get valueAsString() {
|
||||
if (this._valueAsString === undefined) {
|
||||
this._valueAsString = this._value ? this._value.toString() : "";
|
||||
}
|
||||
return this._valueAsString;
|
||||
}
|
||||
|
||||
|
@ -286,6 +291,9 @@ class Field extends PDFObject {
|
|||
}
|
||||
this._buttonCaption[nFace] = cCaption;
|
||||
// TODO: send to the annotation layer
|
||||
// Right now the button is drawn on the canvas using its appearance so
|
||||
// update the caption means redraw...
|
||||
// We should probably have an html button for this annotation.
|
||||
}
|
||||
|
||||
buttonSetIcon(oIcon, nFace = 0) {
|
||||
|
@ -512,7 +520,7 @@ class RadioButtonField extends Field {
|
|||
}
|
||||
|
||||
set value(value) {
|
||||
if (value === null) {
|
||||
if (value === null || value === undefined) {
|
||||
this._value = "";
|
||||
}
|
||||
const i = this.exportValues.indexOf(value);
|
||||
|
@ -574,7 +582,7 @@ class CheckboxField extends RadioButtonField {
|
|||
}
|
||||
|
||||
set value(value) {
|
||||
if (value === "Off") {
|
||||
if (!value || value === "Off") {
|
||||
this._value = "Off";
|
||||
} else {
|
||||
super.value = value;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue