-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Copy pathdate-timepicker-dynamic-inputs-showcase.component.ts
116 lines (98 loc) · 2.67 KB
/
date-timepicker-dynamic-inputs-showcase.component.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
* @license
* Copyright Akveo. All Rights Reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/
import { Component } from '@angular/core';
@Component({
selector: 'npg-date-timepicker-dynamic-inputs-showcase',
templateUrl: './date-timepicker-dynamic-inputs-showcase.component.html',
styles: [
`
section {
margin-bottom: 2rem;
}
button + button {
margin-left: 1rem;
}
`,
],
})
export class DateTimepickerDynamicInputsShowcaseComponent {
now = new Date();
withSeconds = true;
secondsToggleTimer = null;
toggleSecondsSwitching() {
if (this.secondsToggleTimer == null) {
this.secondsToggleTimer = setInterval(() => {
this.toggleWithSeconds();
}, 1000);
} else {
clearInterval(this.secondsToggleTimer);
this.secondsToggleTimer = null;
}
}
toggleWithSeconds() {
this.withSeconds = !this.withSeconds;
}
singleColumn = false;
singleColumnToggleTimer = null;
toggleSingleColumnSwitching() {
if (this.singleColumnToggleTimer == null) {
this.singleColumnToggleTimer = setInterval(() => {
this.toggleSingleColumn();
}, 1000);
} else {
clearInterval(this.singleColumnToggleTimer);
this.singleColumnToggleTimer = null;
}
}
toggleSingleColumn() {
this.singleColumn = !this.singleColumn;
}
step = 45;
stepToggleTimer = null;
toggleStepSwitching() {
if (this.stepToggleTimer == null) {
this.stepToggleTimer = setInterval(() => {
this.toggleStep();
}, 1000);
} else {
clearInterval(this.stepToggleTimer);
this.stepToggleTimer = null;
}
}
toggleStep() {
this.step = this.step === 45 ? 15 : 45;
}
twelveHoursFormat = true;
twelveHoursFormatToggleTimer = null;
toggleTwelveHoursFormatSwitching() {
if (this.twelveHoursFormatToggleTimer == null) {
this.twelveHoursFormatToggleTimer = setInterval(() => {
this.toggleTwelveHoursFormat();
}, 1000);
} else {
clearInterval(this.twelveHoursFormatToggleTimer);
this.twelveHoursFormatToggleTimer = null;
}
}
toggleTwelveHoursFormat() {
this.twelveHoursFormat = !this.twelveHoursFormat;
}
format = 'dd/MM/yyyy HH:mm';
formatToggleTimer = null;
toggleFormatSwitching() {
if (this.formatToggleTimer == null) {
this.formatToggleTimer = setInterval(() => {
this.toggleFormat();
}, 1000);
} else {
clearInterval(this.formatToggleTimer);
this.formatToggleTimer = null;
}
}
toggleFormat() {
this.format = this.format === 'dd/MM/yyyy HH:mm' ? 'HH:mm dd/MM/yyyy' : 'dd/MM/yyyy HH:mm';
}
}