-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdatepicker.js
executable file
·38 lines (33 loc) · 1.43 KB
/
datepicker.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
33
34
35
36
37
38
class DatePicker {
constructor(params) {
this.id = params.id ? params.id : 'datepicker-' + Math.floor(Math.random() * 101);
this.holder = params.holder ? params.holder : '';
this.title = params.title ? params.title : '';
this.placeholder = params.placeholder ? params.placeholder : '';
this.hint = params.hint ? params.hint : '';
this.disable = params.disable ? 'readonly' : '';
this.col = params.col ? params.col : undefined;
if (this.holder) {
$('#' + this.holder).html(this.render());
}
}
render() {
let col = '';
if (this.col) {
col = `col-md-${this.col}`;
}
return `<div class="input-group date" id="${this.id}" data-target-input="nearest">
<label for="${this.id}">${this.title}</label>
<input type="text" class="form-control datetimepicker-input" data-target="#${this.id}"/>
<div class="input-group-append" data-target="#${this.id}" data-toggle="datetimepicker">
<div class="input-group-text"><i class="fa fa-calendar"></i></div>
</div>
<small id="${this.id}Help" class="form-text text-muted">${this.hint}</small>
</div>`
}
init() {
$('#' + this.id).on("init-" + this.id, function () {
$(`#${this.id}`).datetimepicker({});
});
}
}