@@ -134,8 +134,8 @@ export class Timepicker extends Component<TimepickerOptions> {
134
134
id : string ;
135
135
modal : Modal ;
136
136
modalEl : HTMLElement ;
137
- plate : any ;
138
- digitalClock : any ;
137
+ plate : HTMLElement ;
138
+ digitalClock : HTMLElement ;
139
139
inputHours : HTMLInputElement ;
140
140
inputMinutes : HTMLInputElement ;
141
141
x0 : number ;
@@ -148,24 +148,24 @@ export class Timepicker extends Component<TimepickerOptions> {
148
148
* @default 'hours'
149
149
*/
150
150
currentView : Views ;
151
- hand : any ;
151
+ hand : SVGElement ;
152
152
minutesView : HTMLElement ;
153
- hours : any ;
154
- minutes : any ;
153
+ hours : number ;
154
+ minutes : number ;
155
155
/** The selected time. */
156
156
time : string ;
157
157
/**
158
158
* If the time is AM or PM on twelve-hour clock.
159
159
* @default 'PM'
160
160
*/
161
161
amOrPm : "AM" | "PM" ;
162
- static _template : any ;
162
+ static _template : string ;
163
163
/** If the picker is open. */
164
164
isOpen : boolean ;
165
165
/** Vibrate device when dragging clock hand. */
166
166
vibrate : "vibrate" | "webkitVibrate" | null ;
167
167
_canvas : HTMLElement ;
168
- hoursView : any ;
168
+ hoursView : HTMLElement ;
169
169
spanAmPm : HTMLSpanElement ;
170
170
footer : HTMLElement ;
171
171
private _amBtn : HTMLElement ;
@@ -174,8 +174,7 @@ export class Timepicker extends Component<TimepickerOptions> {
174
174
bearing : Element ;
175
175
g : Element ;
176
176
toggleViewTimer : string | number | NodeJS . Timeout ;
177
- canvas : any ;
178
- vibrateTimer : any ;
177
+ vibrateTimer : NodeJS . Timeout | number ;
179
178
180
179
constructor ( el : HTMLInputElement , options : Partial < TimepickerOptions > ) {
181
180
super ( el , options , Timepicker ) ;
@@ -433,7 +432,7 @@ export class Timepicker extends Component<TimepickerOptions> {
433
432
434
433
const doneButton = this . _createButton ( this . options . i18n . done , '' ) ;
435
434
doneButton . classList . add ( 'timepicker-close' ) ;
436
- doneButton . addEventListener ( 'click' , this . done ) ;
435
+ doneButton . addEventListener ( 'click' , this . _finishSelection ) ;
437
436
confirmationBtnsContainer . appendChild ( doneButton ) ;
438
437
}
439
438
@@ -491,36 +490,37 @@ export class Timepicker extends Component<TimepickerOptions> {
491
490
}
492
491
493
492
_buildHoursView ( ) {
494
- const $tick = document . createElement ( 'div' ) ;
495
- $tick . classList . add ( 'timepicker-tick' ) ;
493
+ // const $tick = document.createElement('div');
494
+ // $tick.classList.add('timepicker-tick');
496
495
// Hours view
497
496
if ( this . options . twelveHour ) {
498
497
for ( let i = 1 ; i < 13 ; i += 1 ) {
499
- const tick = < HTMLElement > $tick . cloneNode ( true ) ;
498
+ // const tick = <HTMLElement>$tick.cloneNode(true);
500
499
const radian = ( i / 6 ) * Math . PI ;
501
500
const radius = this . options . outerRadius ;
502
- tick . style . left = this . options . dialRadius + Math . sin ( radian ) * radius - this . options . tickRadius + 'px' ;
503
- tick . style . top = this . options . dialRadius - Math . cos ( radian ) * radius - this . options . tickRadius + 'px' ;
504
- tick . innerHTML = i === 0 ? '00' : i . toString ( ) ;
505
- this . hoursView . appendChild ( tick ) ;
506
- // tick.on(mousedownEvent, mousedown);
501
+ this . _buildHoursTick ( i , radian , radius ) ;
507
502
}
508
503
}
509
504
else {
510
505
for ( let i = 0 ; i < 24 ; i += 1 ) {
511
- const tick = < HTMLElement > $tick . cloneNode ( true ) ;
506
+ // const tick = <HTMLElement>$tick.cloneNode(true);
512
507
const radian = ( i / 6 ) * Math . PI ;
513
508
const inner = i > 0 && i < 13 ;
514
509
const radius = inner ? this . options . innerRadius : this . options . outerRadius ;
515
- tick . style . left = this . options . dialRadius + Math . sin ( radian ) * radius - this . options . tickRadius + 'px' ;
516
- tick . style . top = this . options . dialRadius - Math . cos ( radian ) * radius - this . options . tickRadius + 'px' ;
517
- tick . innerHTML = i === 0 ? '00' : i . toString ( ) ;
518
- this . hoursView . appendChild ( tick ) ;
519
- // tick.on(mousedownEvent, mousedown);
510
+ this . _buildHoursTick ( i , radian , radius ) ;
520
511
}
521
512
}
522
513
}
523
514
515
+ _buildHoursTick ( i : number , radian : number , radius : number ) {
516
+ const tick = document . createElement ( 'div' ) ;
517
+ tick . classList . add ( 'timepicker-tick' ) ;
518
+ tick . style . left = this . options . dialRadius + Math . sin ( radian ) * radius - this . options . tickRadius + 'px' ;
519
+ tick . style . top = this . options . dialRadius - Math . cos ( radian ) * radius - this . options . tickRadius + 'px' ;
520
+ tick . innerHTML = i === 0 ? '00' : i . toString ( ) ;
521
+ this . hoursView . appendChild ( tick ) ;
522
+ }
523
+
524
524
_buildMinutesView ( ) {
525
525
const _tick = document . createElement ( 'div' ) ;
526
526
_tick . classList . add ( 'timepicker-tick' ) ;
@@ -591,6 +591,7 @@ export class Timepicker extends Component<TimepickerOptions> {
591
591
/**
592
592
* Show hours or minutes view on timepicker.
593
593
* @param view The name of the view you want to switch to, 'hours' or 'minutes'.
594
+ * @param delay
594
595
*/
595
596
showView = ( view : Views , delay : number = null ) => {
596
597
if ( view === 'minutes' && getComputedStyle ( this . hoursView ) . visibility === 'visible' ) {
@@ -634,14 +635,13 @@ export class Timepicker extends Component<TimepickerOptions> {
634
635
radius =
635
636
isHours && value > 0 && value < 13 ? this . options . innerRadius : this . options . outerRadius ,
636
637
x = Math . sin ( radian ) * radius ,
637
- y = - Math . cos ( radian ) * radius ,
638
- self = this ;
638
+ y = - Math . cos ( radian ) * radius ;
639
639
640
640
if ( delay ) {
641
- this . canvas ?. classList . add ( 'timepicker-canvas-out' ) ;
641
+ this . _canvas ?. classList . add ( 'timepicker-canvas-out' ) ;
642
642
setTimeout ( ( ) => {
643
- self . canvas ?. classList . remove ( 'timepicker-canvas-out' ) ;
644
- self . setHand ( x , y ) ;
643
+ this . _canvas ?. classList . remove ( 'timepicker-canvas-out' ) ;
644
+ this . setHand ( x , y ) ;
645
645
} , delay ) ;
646
646
}
647
647
else {
@@ -668,7 +668,7 @@ export class Timepicker extends Component<TimepickerOptions> {
668
668
}
669
669
else {
670
670
this . minutes = new Date ( ) . getMinutes ( ) ;
671
- this . inputMinutes . value = this . minutes ;
671
+ this . inputMinutes . value = this . minutes . toString ( ) ;
672
672
}
673
673
this . drawClockFromTimeInput ( this . minutes , isHours ) ;
674
674
}
@@ -687,11 +687,11 @@ export class Timepicker extends Component<TimepickerOptions> {
687
687
}
688
688
689
689
setHand ( x , y , roundBy5 : boolean = false ) {
690
- let radian = Math . atan2 ( x , - y ) ,
691
- isHours = this . currentView === 'hours' ,
690
+ const isHours = this . currentView === 'hours' ,
692
691
unit = Math . PI / ( isHours || roundBy5 ? 6 : 30 ) ,
693
692
z = Math . sqrt ( x * x + y * y ) ,
694
- inner = isHours && z < ( this . options . outerRadius + this . options . innerRadius ) / 2 ,
693
+ inner = isHours && z < ( this . options . outerRadius + this . options . innerRadius ) / 2 ;
694
+ let radian = Math . atan2 ( x , - y ) ,
695
695
radius = inner ? this . options . innerRadius : this . options . outerRadius ;
696
696
697
697
if ( this . options . twelveHour ) {
@@ -784,6 +784,10 @@ export class Timepicker extends Component<TimepickerOptions> {
784
784
this . inputHours . value = ( this . hours % ( this . options . twelveHour ? 12 : 24 ) ) . toString ( ) ;
785
785
}
786
786
787
+ _finishSelection = ( ) => {
788
+ this . done ( ) ;
789
+ }
790
+
787
791
/**
788
792
* Open timepicker.
789
793
*/
@@ -804,7 +808,7 @@ export class Timepicker extends Component<TimepickerOptions> {
804
808
this . modal . close ( ) ;
805
809
}
806
810
807
- done = ( e = null , clearValue = null ) => {
811
+ done = ( clearValue = null ) => {
808
812
// Set input value
809
813
const last = this . el . value ;
810
814
let value = clearValue
@@ -824,7 +828,7 @@ export class Timepicker extends Component<TimepickerOptions> {
824
828
}
825
829
826
830
clear = ( ) => {
827
- this . done ( null , true ) ;
831
+ this . done ( true ) ;
828
832
}
829
833
830
834
static {
0 commit comments