-
Notifications
You must be signed in to change notification settings - Fork 2
/
checkbox.ts
41 lines (32 loc) · 965 Bytes
/
checkbox.ts
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
import { Component, log } from "./core";
class CheckBox extends Component {
text : string;
checked:boolean=false;
constructor(props:any=null) {
super(props);
this.text = "[ ]";
this.htmlString = /*html*/ `<button>${this.text}</button>`;
this.createNode();
//console.log(this.htmlString);
if (props) {
if (props.parent) {
this.appendTo(props.parent);
}
if (props.text){
this.text = props.text;
}
}
}
isChecked() : boolean {
return this.checked;
}
setChecked(choice:boolean) {
this.checked = choice;
if (choice === true) {
this.node.innerHTML = /*html*/ `<button>[x]</button>`;
} else {
this.node.innerHTML = /*html*/ `<button>[ ]</button>`;
}
}
}
export { CheckBox };