-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcheckbox.js
executable file
·32 lines (28 loc) · 1.22 KB
/
checkbox.js
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
class CheckBox{
constructor(params) {
this.id = params.id ? params.id : 'checkbox-' + Math.floor(Math.random() * 101);
this.holder = params.holder ? params.holder : '';
this.title = params.title ? params.title : undefined;
this.type = params.type ? params.type : undefined;
this.placeholder = params.placeholder ? params.placeholder : undefined;
this.hint = params.hint ? params.hint : undefined;
this.readonly = params.readonly ? 'disabled' : undefined;
if(this.holder){
$('#' + this.holder).html(this.render());
}
}
render() {
return `<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="defaultCheck1" ${this.readonly}>
<label class="form-check-label" for="defaultCheck1">
Default checkbox
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="defaultCheck2" disabled>
<label class="form-check-label" for="defaultCheck2">
Disabled checkbox
</label>
</div>`;
}
}