1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 01:58:06 +02:00

Button widget annotations: improve unit tests, simplify code and remove labels

Modern browsers support styling radio buttons and checkboxes with CSS.
This makes the implementation much easier, and the fallback for older
browsers is still decent.
This commit is contained in:
Tim van der Meij 2016-12-15 23:49:46 +01:00
parent 77148c7880
commit a428899b3c
5 changed files with 88 additions and 184 deletions

View file

@ -773,17 +773,18 @@ var ButtonWidgetAnnotation = (function ButtonWidgetAnnotationClosure() {
function ButtonWidgetAnnotation(params) {
WidgetAnnotation.call(this, params);
this.data.pushbutton = this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
this.data.radio = !this.data.pushbutton &&
this.hasFieldFlag(AnnotationFieldFlag.RADIO);
if (isName(this.data.fieldValue)) {
this.data.checkBox = !this.hasFieldFlag(AnnotationFieldFlag.RADIO) &&
!this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
if (this.data.checkBox) {
if (!isName(this.data.fieldValue)) {
return;
}
this.data.fieldValue = this.data.fieldValue.name;
} else {
warn('Button widget annotation: field value is not a `Name` object.');
}
if (this.data.radio) {
this.data.radioButton = this.hasFieldFlag(AnnotationFieldFlag.RADIO) &&
!this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
if (this.data.radioButton) {
this.data.fieldValue = this.data.buttonValue = null;
// The parent field's `V` entry holds a `Name` object with the appearance
@ -831,7 +832,7 @@ var ButtonWidgetAnnotation = (function ButtonWidgetAnnotationClosure() {
if (this.appearance) {
return Annotation.prototype.getOperatorList.call(this, evaluator, task,
renderForms);
renderForms);
}
return Promise.resolve(operatorList);
}