(
e: MouseEvent | KeyboardEvent | FocusEvent | IncrementEvent
)
| 2869 | } |
| 2870 | |
| 2871 | function timeWrapper( |
| 2872 | e: MouseEvent | KeyboardEvent | FocusEvent | IncrementEvent |
| 2873 | ): void { |
| 2874 | e.preventDefault(); |
| 2875 | |
| 2876 | const isKeyDown = e.type === "keydown", |
| 2877 | eventTarget = getEventTarget(e), |
| 2878 | input = eventTarget as HTMLInputElement; |
| 2879 | |
| 2880 | if (self.amPM !== undefined && eventTarget === self.amPM) { |
| 2881 | self.amPM.textContent = |
| 2882 | self.l10n.amPM[int(self.amPM.textContent === self.l10n.amPM[0])]; |
| 2883 | } |
| 2884 | |
| 2885 | const min = parseFloat(input.getAttribute("min") as string), |
| 2886 | max = parseFloat(input.getAttribute("max") as string), |
| 2887 | step = parseFloat(input.getAttribute("step") as string), |
| 2888 | curValue = parseInt(input.value, 10), |
| 2889 | delta = |
| 2890 | (e as IncrementEvent).delta || |
| 2891 | (isKeyDown ? ((e as KeyboardEvent).which === 38 ? 1 : -1) : 0); |
| 2892 | |
| 2893 | let newValue = curValue + step * delta; |
| 2894 | |
| 2895 | if (typeof input.value !== "undefined" && input.value.length === 2) { |
| 2896 | const isHourElem = input === self.hourElement, |
| 2897 | isMinuteElem = input === self.minuteElement; |
| 2898 | |
| 2899 | if (newValue < min) { |
| 2900 | newValue = |
| 2901 | max + |
| 2902 | newValue + |
| 2903 | int(!isHourElem) + |
| 2904 | (int(isHourElem) && int(!self.amPM)); |
| 2905 | |
| 2906 | if (isMinuteElem) incrementNumInput(undefined, -1, self.hourElement); |
| 2907 | } else if (newValue > max) { |
| 2908 | newValue = |
| 2909 | input === self.hourElement ? newValue - max - int(!self.amPM) : min; |
| 2910 | |
| 2911 | if (isMinuteElem) incrementNumInput(undefined, 1, self.hourElement); |
| 2912 | } |
| 2913 | |
| 2914 | if ( |
| 2915 | self.amPM && |
| 2916 | isHourElem && |
| 2917 | (step === 1 |
| 2918 | ? newValue + curValue === 23 |
| 2919 | : Math.abs(newValue - curValue) > step) |
| 2920 | ) { |
| 2921 | self.amPM.textContent = |
| 2922 | self.l10n.amPM[int(self.amPM.textContent === self.l10n.amPM[0])]; |
| 2923 | } |
| 2924 | |
| 2925 | input.value = pad(newValue); |
| 2926 | } |
| 2927 | } |
| 2928 |
no test coverage detected
searching dependent graphs…