Text widget annotations: support multiline and read-only fields
Moreover, this patch provides us with a framework for handling field flags in general for all types of widget annotations.
This commit is contained in:
parent
a7c35025fe
commit
f6965fadc0
@ -33,6 +33,7 @@
|
||||
coreColorSpace, coreObj, coreEvaluator) {
|
||||
|
||||
var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
|
||||
var AnnotationFieldFlag = sharedUtil.AnnotationFieldFlag;
|
||||
var AnnotationFlag = sharedUtil.AnnotationFlag;
|
||||
var AnnotationType = sharedUtil.AnnotationType;
|
||||
var OPS = sharedUtil.OPS;
|
||||
@ -621,9 +622,13 @@ var WidgetAnnotation = (function WidgetAnnotationClosure() {
|
||||
data.defaultAppearance = Util.getInheritableProperty(dict, 'DA') || '';
|
||||
var fieldType = Util.getInheritableProperty(dict, 'FT');
|
||||
data.fieldType = isName(fieldType) ? fieldType.name : null;
|
||||
data.fieldFlags = Util.getInheritableProperty(dict, 'Ff') || 0;
|
||||
this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty;
|
||||
|
||||
data.fieldFlags = Util.getInheritableProperty(dict, 'Ff');
|
||||
if (!isInt(data.fieldFlags) || data.fieldFlags < 0) {
|
||||
data.fieldFlags = 0;
|
||||
}
|
||||
|
||||
// Hide signatures because we cannot validate them.
|
||||
if (data.fieldType === 'Sig') {
|
||||
this.setFlags(AnnotationFlag.HIDDEN);
|
||||
@ -662,7 +667,22 @@ var WidgetAnnotation = (function WidgetAnnotationClosure() {
|
||||
data.fullName = fieldName.join('.');
|
||||
}
|
||||
|
||||
Util.inherit(WidgetAnnotation, Annotation, {});
|
||||
Util.inherit(WidgetAnnotation, Annotation, {
|
||||
/**
|
||||
* Check if a provided field flag is set.
|
||||
*
|
||||
* @public
|
||||
* @memberof WidgetAnnotation
|
||||
* @param {number} flag - Bit position, numbered from one instead of
|
||||
* zero, to check
|
||||
* @return {boolean}
|
||||
* @see {@link shared/util.js}
|
||||
*/
|
||||
hasFieldFlag: function WidgetAnnotation_hasFieldFlag(flag) {
|
||||
var mask = 1 << (flag - 1);
|
||||
return !!(this.data.fieldFlags & mask);
|
||||
},
|
||||
});
|
||||
|
||||
return WidgetAnnotation;
|
||||
})();
|
||||
@ -684,6 +704,10 @@ var TextWidgetAnnotation = (function TextWidgetAnnotationClosure() {
|
||||
maximumLength = null;
|
||||
}
|
||||
this.data.maxLen = maximumLength;
|
||||
|
||||
// Process field flags for the display layer.
|
||||
this.data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
|
||||
this.data.multiLine = this.hasFieldFlag(AnnotationFieldFlag.MULTILINE);
|
||||
}
|
||||
|
||||
Util.inherit(TextWidgetAnnotation, WidgetAnnotation, {
|
||||
|
@ -446,9 +446,15 @@ var TextWidgetAnnotationElement = (
|
||||
|
||||
var element = null;
|
||||
if (this.renderInteractiveForms) {
|
||||
element = document.createElement('input');
|
||||
element.type = 'text';
|
||||
if (this.data.multiLine) {
|
||||
element = document.createElement('textarea');
|
||||
} else {
|
||||
element = document.createElement('input');
|
||||
element.type = 'text';
|
||||
}
|
||||
|
||||
element.value = this.data.fieldValue;
|
||||
element.disabled = this.data.readOnly;
|
||||
|
||||
if (this.data.maxLen !== null) {
|
||||
element.maxLength = this.data.maxLen;
|
||||
|
@ -93,6 +93,28 @@ var AnnotationFlag = {
|
||||
LOCKEDCONTENTS: 0x200
|
||||
};
|
||||
|
||||
var AnnotationFieldFlag = {
|
||||
READONLY: 1,
|
||||
REQUIRED: 2,
|
||||
NOEXPORT: 3,
|
||||
MULTILINE: 13,
|
||||
PASSWORD: 14,
|
||||
NOTOGGLETOOFF: 15,
|
||||
RADIO: 16,
|
||||
PUSHBUTTON: 17,
|
||||
COMBO: 18,
|
||||
EDIT: 19,
|
||||
SORT: 20,
|
||||
FILESELECT: 21,
|
||||
MULTISELECT: 22,
|
||||
DONOTSPELLCHECK: 23,
|
||||
DONOTSCROLL: 24,
|
||||
COMB: 25,
|
||||
RICHTEXT: 26,
|
||||
RADIOSINUNISON: 26,
|
||||
COMMITONSELCHANGE: 27,
|
||||
};
|
||||
|
||||
var AnnotationBorderStyleType = {
|
||||
SOLID: 1,
|
||||
DASHED: 2,
|
||||
@ -2364,6 +2386,7 @@ exports.OPS = OPS;
|
||||
exports.VERBOSITY_LEVELS = VERBOSITY_LEVELS;
|
||||
exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
|
||||
exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
|
||||
exports.AnnotationFieldFlag = AnnotationFieldFlag;
|
||||
exports.AnnotationFlag = AnnotationFlag;
|
||||
exports.AnnotationType = AnnotationType;
|
||||
exports.FontType = FontType;
|
||||
|
@ -41,7 +41,8 @@
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.annotationLayer .textWidgetAnnotation input {
|
||||
.annotationLayer .textWidgetAnnotation input,
|
||||
.annotationLayer .textWidgetAnnotation textarea {
|
||||
background-color: rgba(0, 54, 255, 0.13);
|
||||
border: 1px solid transparent;
|
||||
box-sizing: border-box;
|
||||
@ -52,11 +53,26 @@
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.annotationLayer .textWidgetAnnotation input:hover {
|
||||
.annotationLayer .textWidgetAnnotation textarea {
|
||||
font: message-box;
|
||||
font-size: 9px;
|
||||
resize: none;
|
||||
}
|
||||
|
||||
.annotationLayer .textWidgetAnnotation input[disabled],
|
||||
.annotationLayer .textWidgetAnnotation textarea[disabled] {
|
||||
background: none;
|
||||
border: 1px solid transparent;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.annotationLayer .textWidgetAnnotation input:hover,
|
||||
.annotationLayer .textWidgetAnnotation textarea:hover {
|
||||
border: 1px solid #000;
|
||||
}
|
||||
|
||||
.annotationLayer .textWidgetAnnotation input:focus {
|
||||
.annotationLayer .textWidgetAnnotation input:focus,
|
||||
.annotationLayer .textWidgetAnnotation textarea:focus {
|
||||
background: none;
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user