-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextField.js
More file actions
58 lines (57 loc) · 1.84 KB
/
TextField.js
File metadata and controls
58 lines (57 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { UIElement } from './UIElement.js';
import { BORDER_BOX } from '../Utilities_JS/constants.js';
export class TextField extends UIElement {
static AUTO = 'auto';
static BREAK_WORD = 'break-word';
static NORMAL = 'normal';
static NO_WRAP = 'nowrap';
constructor(options) {
super();
const {
text = '',
width = TextField.AUTO,
height = TextField.AUTO,
fontFamily = 'Arial, sans-serif',
fontWeight = TextField.NORMAL, // 'bold' , 'bolder', 'lighter'
fontStyle = TextField.NORMAL, // 'normal', 'italic', 'oblique', 'inherit'
fontSize = '16px',
color = '#000000',
textShadow = 'none',
textAlign = 'left', // 'center', 'right', 'justify'
whiteSpace = TextField.NO_WRAP, // 'normal'
left = '',
right = '',
top = '',
bottom = '',
transform = 'none'
} = options;
this.assignStyles({
width,
height,
fontFamily,
fontWeight,
fontStyle,
fontSize,
color,
textShadow,
textAlign,
whiteSpace,
left,
right,
top,
bottom,
transform,
userSelect: 'none',
overflow: 'hidden'
//, lineHeight,
//letterSpacing,
//,border: '2px dotted red'
//,boxSizing: BORDER_BOX
});
if (text !== '') this.text = text;
}
set text(newText) {this._element.innerText = newText;}
get text() {return this._element.innerText;}
set htmlText(newText) {this._element.innerHTML = newText;}
get htmlText() {return this._element.innerHTML;}
}