@syncfusion/ej2-calendars 31.1.17 → 31.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/aceconfig.js +17 -0
- package/dist/ej2-calendars.min.js +2 -2
- package/dist/ej2-calendars.umd.min.js +2 -2
- package/dist/ej2-calendars.umd.min.js.map +1 -1
- package/dist/es6/ej2-calendars.es2015.js +36 -13
- package/dist/es6/ej2-calendars.es2015.js.map +1 -1
- package/dist/es6/ej2-calendars.es5.js +36 -13
- package/dist/es6/ej2-calendars.es5.js.map +1 -1
- package/dist/global/ej2-calendars.min.js +2 -2
- package/dist/global/ej2-calendars.min.js.map +1 -1
- package/dist/global/index.d.ts +1 -1
- package/package.json +11 -54
- package/src/datepicker/datepicker.js +28 -13
- package/src/daterangepicker/daterangepicker.js +8 -0
- package/dist/ts/calendar/calendar-model.d.ts +0 -340
- package/dist/ts/calendar/calendar.d.ts +0 -733
- package/dist/ts/calendar/calendar.ts +0 -3009
- package/dist/ts/calendar/index.d.ts +0 -6
- package/dist/ts/calendar/index.ts +0 -6
- package/dist/ts/calendar/islamic.d.ts +0 -28
- package/dist/ts/calendar/islamic.ts +0 -597
- package/dist/ts/common/index.d.ts +0 -5
- package/dist/ts/common/index.ts +0 -5
- package/dist/ts/common/maskplaceholder-model.d.ts +0 -57
- package/dist/ts/common/maskplaceholder.d.ts +0 -45
- package/dist/ts/common/maskplaceholder.ts +0 -54
- package/dist/ts/datepicker/datepicker-model.d.ts +0 -364
- package/dist/ts/datepicker/datepicker.d.ts +0 -583
- package/dist/ts/datepicker/datepicker.ts +0 -2528
- package/dist/ts/datepicker/index.d.ts +0 -5
- package/dist/ts/datepicker/index.ts +0 -5
- package/dist/ts/daterangepicker/daterangepicker-model.d.ts +0 -496
- package/dist/ts/daterangepicker/daterangepicker.d.ts +0 -857
- package/dist/ts/daterangepicker/daterangepicker.ts +0 -5096
- package/dist/ts/daterangepicker/index.d.ts +0 -5
- package/dist/ts/daterangepicker/index.ts +0 -5
- package/dist/ts/datetimepicker/datetimepicker-model.d.ts +0 -479
- package/dist/ts/datetimepicker/datetimepicker.d.ts +0 -626
- package/dist/ts/datetimepicker/datetimepicker.ts +0 -2212
- package/dist/ts/datetimepicker/index.d.ts +0 -5
- package/dist/ts/datetimepicker/index.ts +0 -5
- package/dist/ts/index.d.ts +0 -9
- package/dist/ts/index.ts +0 -9
- package/dist/ts/maskbase/index.d.ts +0 -5
- package/dist/ts/maskbase/index.ts +0 -5
- package/dist/ts/maskbase/interface.d.ts +0 -28
- package/dist/ts/maskbase/interface.ts +0 -29
- package/dist/ts/maskbase/masked-date-time.d.ts +0 -77
- package/dist/ts/maskbase/masked-date-time.ts +0 -1013
- package/dist/ts/timepicker/index.d.ts +0 -5
- package/dist/ts/timepicker/index.ts +0 -5
- package/dist/ts/timepicker/timepicker-model.d.ts +0 -393
- package/dist/ts/timepicker/timepicker.d.ts +0 -681
- package/dist/ts/timepicker/timepicker.ts +0 -2944
|
@@ -1,2212 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
|
|
2
|
-
///<reference path='../datepicker/datepicker-model.d.ts'/>
|
|
3
|
-
import { EventHandler, Internationalization, Property, NotifyPropertyChanges, Browser, RippleOptions } from '@syncfusion/ej2-base';
|
|
4
|
-
import { Animation, EmitType, Event, AnimationModel, cldrData, getDefaultDateObject, detach } from '@syncfusion/ej2-base';
|
|
5
|
-
import { createElement, remove, addClass, L10n, removeClass, closest, append, attributes } from '@syncfusion/ej2-base';
|
|
6
|
-
import { KeyboardEvents, KeyboardEventArgs, isNullOrUndefined, formatUnit, getValue, rippleEffect } from '@syncfusion/ej2-base';
|
|
7
|
-
import { ModuleDeclaration, extend, Touch, SwipeEventArgs } from '@syncfusion/ej2-base';
|
|
8
|
-
import { Popup } from '@syncfusion/ej2-popups';
|
|
9
|
-
import { Input } from '@syncfusion/ej2-inputs';
|
|
10
|
-
import { BlurEventArgs, ClearedEventArgs, CalendarType, CalendarView, DayHeaderFormats } from '../calendar/calendar';
|
|
11
|
-
import { DatePicker, PopupObjectArgs } from '../datepicker/datepicker';
|
|
12
|
-
import { TimePickerBase } from '../timepicker/timepicker';
|
|
13
|
-
import { DateTimePickerModel } from './datetimepicker-model';
|
|
14
|
-
import {MaskPlaceholderModel} from '../common/maskplaceholder-model';
|
|
15
|
-
|
|
16
|
-
//class constant defination
|
|
17
|
-
const DATEWRAPPER: string = 'e-date-wrapper';
|
|
18
|
-
const DATEPICKERROOT: string = 'e-datepicker';
|
|
19
|
-
const DATETIMEWRAPPER: string = 'e-datetime-wrapper';
|
|
20
|
-
const DAY: number = new Date().getDate();
|
|
21
|
-
const MONTH: number = new Date().getMonth();
|
|
22
|
-
const YEAR: number = new Date().getFullYear();
|
|
23
|
-
const HOUR: number = new Date().getHours();
|
|
24
|
-
const MINUTE: number = new Date().getMinutes();
|
|
25
|
-
const SECOND: number = new Date().getSeconds();
|
|
26
|
-
const MILLISECOND: number = new Date().getMilliseconds();
|
|
27
|
-
const ROOT: string = 'e-datetimepicker';
|
|
28
|
-
const DATETIMEPOPUPWRAPPER: string = 'e-datetimepopup-wrapper';
|
|
29
|
-
const INPUTWRAPPER: string = 'e-input-group-icon';
|
|
30
|
-
const POPUP: string = 'e-popup';
|
|
31
|
-
const TIMEICON: string = 'e-time-icon';
|
|
32
|
-
const INPUTFOCUS: string = 'e-input-focus';
|
|
33
|
-
const POPUPDIMENSION: string = '250px';
|
|
34
|
-
const ICONANIMATION: string = 'e-icon-anim';
|
|
35
|
-
const DISABLED: string = 'e-disabled';
|
|
36
|
-
const ERROR: string = 'e-error';
|
|
37
|
-
const CONTENT: string = 'e-content';
|
|
38
|
-
const NAVIGATION: string = 'e-navigation';
|
|
39
|
-
const ACTIVE: string = 'e-active';
|
|
40
|
-
const HOVER: string = 'e-hover';
|
|
41
|
-
const ICONS: string = 'e-icons';
|
|
42
|
-
const HALFPOSITION: number = 2;
|
|
43
|
-
const LISTCLASS: string = 'e-list-item';
|
|
44
|
-
const ANIMATIONDURATION: number = 100;
|
|
45
|
-
const OVERFLOW: string = 'e-time-overflow';
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Represents the DateTimePicker component that allows user to select
|
|
49
|
-
* or enter a date time value.
|
|
50
|
-
* ```html
|
|
51
|
-
* <input id="dateTimePicker"/>
|
|
52
|
-
* ```
|
|
53
|
-
* ```typescript
|
|
54
|
-
* <script>
|
|
55
|
-
* let dateTimePickerObject:DateTimePicker = new DateTimePicker({ value: new Date() });
|
|
56
|
-
* dateTimePickerObject.appendTo("#dateTimePicker");
|
|
57
|
-
* </script>
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
@NotifyPropertyChanges
|
|
61
|
-
export class DateTimePicker extends DatePicker {
|
|
62
|
-
private timeIcon: HTMLElement;
|
|
63
|
-
private cloneElement: HTMLElement;
|
|
64
|
-
private dateTimeWrapper: HTMLElement;
|
|
65
|
-
private rippleFn: Function;
|
|
66
|
-
private listWrapper: HTMLElement;
|
|
67
|
-
private liCollections: HTMLElement[];
|
|
68
|
-
private timeCollections: number[];
|
|
69
|
-
private listTag: HTMLElement;
|
|
70
|
-
private selectedElement: HTMLElement;
|
|
71
|
-
private containerStyle: ClientRect;
|
|
72
|
-
private popupObject: Popup;
|
|
73
|
-
protected timeModal: HTMLElement;
|
|
74
|
-
protected modelWrapper: HTMLElement;
|
|
75
|
-
private isNavigate: boolean;
|
|
76
|
-
protected isPreventBlur: boolean;
|
|
77
|
-
private timeValue: string;
|
|
78
|
-
protected l10n: L10n;
|
|
79
|
-
private keyboardHandler: KeyboardEvents;
|
|
80
|
-
protected inputEvent: KeyboardEvents;
|
|
81
|
-
private activeIndex: number;
|
|
82
|
-
private valueWithMinutes: Date = null;
|
|
83
|
-
private initValue: Date;
|
|
84
|
-
protected tabIndex: string;
|
|
85
|
-
private isValidState: boolean;
|
|
86
|
-
protected timekeyConfigure: { [key: string]: string };
|
|
87
|
-
protected preventArgs: PopupObjectArgs;
|
|
88
|
-
private dateTimeOptions: DateTimePickerModel;
|
|
89
|
-
protected scrollInvoked: boolean = false;
|
|
90
|
-
protected maskedDateValue: string;
|
|
91
|
-
protected moduleName: string = this.getModuleName();
|
|
92
|
-
protected touchDTModule: Touch;
|
|
93
|
-
protected touchDTStart: boolean;
|
|
94
|
-
private formatRegex : RegExp = /dddd|ddd|dd|d|MMMM|MMM|MM|M|yyyy|yyy|yy|y|'[^']*'|'[^']*'/g;
|
|
95
|
-
private dateFormatString : string = '';
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Specifies the format of the time value that to be displayed in time popup list.
|
|
99
|
-
*
|
|
100
|
-
* @default null
|
|
101
|
-
*/
|
|
102
|
-
@Property(null)
|
|
103
|
-
public timeFormat: string;
|
|
104
|
-
/**
|
|
105
|
-
* Specifies the time interval between the two adjacent time values in the time popup list .
|
|
106
|
-
*
|
|
107
|
-
* @default 30
|
|
108
|
-
*/
|
|
109
|
-
@Property(30)
|
|
110
|
-
public step: number;
|
|
111
|
-
/**
|
|
112
|
-
* Specifies the scroll bar position if there is no value is selected in the timepicker popup list or
|
|
113
|
-
* the given value is not present in the timepicker popup list.
|
|
114
|
-
* {% codeBlock src='datetimepicker/scrollTo/index.md' %}{% endcodeBlock %}
|
|
115
|
-
*
|
|
116
|
-
* @default null
|
|
117
|
-
*/
|
|
118
|
-
@Property(null)
|
|
119
|
-
public scrollTo: Date;
|
|
120
|
-
/**
|
|
121
|
-
* specifies the z-index value of the popup element.
|
|
122
|
-
*
|
|
123
|
-
* @default 1000
|
|
124
|
-
* @aspType int
|
|
125
|
-
*/
|
|
126
|
-
@Property(1000)
|
|
127
|
-
public zIndex: number;
|
|
128
|
-
/**
|
|
129
|
-
* Gets or sets the selected date of the Calendar.
|
|
130
|
-
*
|
|
131
|
-
* @default null
|
|
132
|
-
* @isGenericType true
|
|
133
|
-
*/
|
|
134
|
-
@Property(null)
|
|
135
|
-
public value: Date;
|
|
136
|
-
/**
|
|
137
|
-
* Customizes the key actions in DateTimePicker.
|
|
138
|
-
* For example, when using German keyboard, the key actions can be customized using these shortcuts.
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
* Input Navigation
|
|
142
|
-
* <table>
|
|
143
|
-
* <tr>
|
|
144
|
-
* <td colSpan=1 rowSpan=1>
|
|
145
|
-
* Key action<br/></td><td colSpan=1 rowSpan=1>
|
|
146
|
-
* Key<br/></td></tr>
|
|
147
|
-
* <tr>
|
|
148
|
-
* <td colSpan=1 rowSpan=1>
|
|
149
|
-
* altUpArrow<br/></td><td colSpan=1 rowSpan=1>
|
|
150
|
-
* alt+uparrow<br/></td></tr>
|
|
151
|
-
* <tr>
|
|
152
|
-
* <td colSpan=1 rowSpan=1>
|
|
153
|
-
* altDownArrow<br/></td><td colSpan=1 rowSpan=1>
|
|
154
|
-
* alt+downarrow<br/></td></tr>
|
|
155
|
-
* <tr>
|
|
156
|
-
* <td colSpan=1 rowSpan=1>
|
|
157
|
-
* escape<br/></td><td colSpan=1 rowSpan=1>
|
|
158
|
-
* escape<br/></td></tr>
|
|
159
|
-
* </table>
|
|
160
|
-
*
|
|
161
|
-
* Calendar Navigation (Use the following list of keys to navigate the currently focused Calendar after the popup has opened).
|
|
162
|
-
* <table>
|
|
163
|
-
* <tr>
|
|
164
|
-
* <td colSpan=1 rowSpan=1>
|
|
165
|
-
* Key action<br/></td><td colSpan=1 rowSpan=1>
|
|
166
|
-
* Key<br/></td></tr>
|
|
167
|
-
* <tr>
|
|
168
|
-
* <td colSpan=1 rowSpan=1>
|
|
169
|
-
* controlUp<br/></td><td colSpan=1 rowSpan=1>
|
|
170
|
-
* ctrl+38<br/></td></tr>
|
|
171
|
-
* <tr>
|
|
172
|
-
* <td colSpan=1 rowSpan=1>
|
|
173
|
-
* controlDown<br/></td><td colSpan=1 rowSpan=1>
|
|
174
|
-
* ctrl+40<br/></td></tr>
|
|
175
|
-
* <tr>
|
|
176
|
-
* <td colSpan=1 rowSpan=1>
|
|
177
|
-
* moveDown<br/></td><td colSpan=1 rowSpan=1>
|
|
178
|
-
* downarrow<br/></td></tr>
|
|
179
|
-
* <tr>
|
|
180
|
-
* <td colSpan=1 rowSpan=1>
|
|
181
|
-
* moveUp<br/></td><td colSpan=1 rowSpan=1>
|
|
182
|
-
* uparrow<br/></td></tr>
|
|
183
|
-
* <tr>
|
|
184
|
-
* <td colSpan=1 rowSpan=1>
|
|
185
|
-
* moveLeft<br/></td><td colSpan=1 rowSpan=1>
|
|
186
|
-
* leftarrow<br/></td></tr>
|
|
187
|
-
* <tr>
|
|
188
|
-
* <td colSpan=1 rowSpan=1>
|
|
189
|
-
* moveRight<br/></td><td colSpan=1 rowSpan=1>
|
|
190
|
-
* rightarrow<br/></td></tr>
|
|
191
|
-
* <tr>
|
|
192
|
-
* <td colSpan=1 rowSpan=1>
|
|
193
|
-
* select<br/></td><td colSpan=1 rowSpan=1>
|
|
194
|
-
* enter<br/></td></tr>
|
|
195
|
-
* <tr>
|
|
196
|
-
* <td colSpan=1 rowSpan=1>
|
|
197
|
-
* home<br/></td><td colSpan=1 rowSpan=1>
|
|
198
|
-
* home<br/></td></tr>
|
|
199
|
-
* <tr>
|
|
200
|
-
* <td colSpan=1 rowSpan=1>
|
|
201
|
-
* end<br/></td><td colSpan=1 rowSpan=1>
|
|
202
|
-
* end<br/></td></tr>
|
|
203
|
-
* <tr>
|
|
204
|
-
* <td colSpan=1 rowSpan=1>
|
|
205
|
-
* pageUp<br/></td><td colSpan=1 rowSpan=1>
|
|
206
|
-
* pageup<br/></td></tr>
|
|
207
|
-
* <tr>
|
|
208
|
-
* <td colSpan=1 rowSpan=1>
|
|
209
|
-
* pageDown<br/></td><td colSpan=1 rowSpan=1>
|
|
210
|
-
* pagedown<br/></td></tr>
|
|
211
|
-
* <tr>
|
|
212
|
-
* <td colSpan=1 rowSpan=1>
|
|
213
|
-
* shiftPageUp<br/></td><td colSpan=1 rowSpan=1>
|
|
214
|
-
* shift+pageup<br/></td></tr>
|
|
215
|
-
* <tr>
|
|
216
|
-
* <td colSpan=1 rowSpan=1>
|
|
217
|
-
* shiftPageDown<br/></td><td colSpan=1 rowSpan=1>
|
|
218
|
-
* shift+pagedown<br/></td></tr>
|
|
219
|
-
* <tr>
|
|
220
|
-
* <td colSpan=1 rowSpan=1>
|
|
221
|
-
* controlHome<br/></td><td colSpan=1 rowSpan=1>
|
|
222
|
-
* ctrl+home<br/></td></tr>
|
|
223
|
-
* <tr>
|
|
224
|
-
* <td colSpan=1 rowSpan=1>
|
|
225
|
-
* controlEnd<br/></td><td colSpan=1 rowSpan=1>
|
|
226
|
-
* ctrl+end<br/></td></tr>
|
|
227
|
-
* <tr>
|
|
228
|
-
* <td colSpan=1 rowSpan=1>
|
|
229
|
-
* altUpArrow<br/></td><td colSpan=1 rowSpan=1>
|
|
230
|
-
* alt+uparrow<br/></td></tr>
|
|
231
|
-
* <tr>
|
|
232
|
-
* <td colSpan=1 rowSpan=1>
|
|
233
|
-
* spacebar<br/></td><td colSpan=1 rowSpan=1>
|
|
234
|
-
* space<br/></td></tr>
|
|
235
|
-
* <tr>
|
|
236
|
-
* <td colSpan=1 rowSpan=1>
|
|
237
|
-
* altRightArrow<br/></td><td colSpan=1 rowSpan=1>
|
|
238
|
-
* alt+rightarrow<br/></td></tr>
|
|
239
|
-
* <tr>
|
|
240
|
-
* <td colSpan=1 rowSpan=1>
|
|
241
|
-
* altLeftArrow<br/></td><td colSpan=1 rowSpan=1>
|
|
242
|
-
* alt+leftarrow<br/></td></tr>
|
|
243
|
-
* </table>
|
|
244
|
-
*
|
|
245
|
-
* TimePicker Navigation (Use the below list of shortcut keys to interact with the TimePicker after the TimePicker Popup has opened).
|
|
246
|
-
* <table>
|
|
247
|
-
* <tr>
|
|
248
|
-
* <td colSpan=1 rowSpan=1>
|
|
249
|
-
* Key action<br/></td><td colSpan=1 rowSpan=1>
|
|
250
|
-
* Key<br/></td></tr>
|
|
251
|
-
* <tr>
|
|
252
|
-
* <td colSpan=1 rowSpan=1>
|
|
253
|
-
* down<br/></td><td colSpan=1 rowSpan=1>
|
|
254
|
-
* downarrow<br/></td></tr>
|
|
255
|
-
* <tr>
|
|
256
|
-
* <td colSpan=1 rowSpan=1>
|
|
257
|
-
* up<br/></td><td colSpan=1 rowSpan=1>
|
|
258
|
-
* uparrow<br/></td></tr>
|
|
259
|
-
* <tr>
|
|
260
|
-
* <td colSpan=1 rowSpan=1>
|
|
261
|
-
* left<br/></td><td colSpan=1 rowSpan=1>
|
|
262
|
-
* leftarrow<br/></td></tr>
|
|
263
|
-
* <tr>
|
|
264
|
-
* <td colSpan=1 rowSpan=1>
|
|
265
|
-
* right<br/></td><td colSpan=1 rowSpan=1>
|
|
266
|
-
* rightarrow<br/></td></tr>
|
|
267
|
-
* </table>
|
|
268
|
-
*
|
|
269
|
-
* {% codeBlock src='datetimepicker/keyConfigs/index.md' %}{% endcodeBlock %}
|
|
270
|
-
*
|
|
271
|
-
* @default null
|
|
272
|
-
*/
|
|
273
|
-
@Property(null)
|
|
274
|
-
public keyConfigs: { [key: string]: string };
|
|
275
|
-
/**
|
|
276
|
-
* You can add the additional html attributes such as disabled, value etc., to the element.
|
|
277
|
-
* If you configured both property and equivalent html attribute then the component considers the property value.
|
|
278
|
-
* {% codeBlock src='datetimepicker/htmlAttributes/index.md' %}{% endcodeBlock %}
|
|
279
|
-
*
|
|
280
|
-
* @default {}
|
|
281
|
-
*/
|
|
282
|
-
@Property({})
|
|
283
|
-
public htmlAttributes: { [key: string]: string };
|
|
284
|
-
/**
|
|
285
|
-
* Enable or disable persisting component's state between page reloads. If enabled, following list of states will be persisted.
|
|
286
|
-
* 1. value
|
|
287
|
-
*
|
|
288
|
-
* @default false
|
|
289
|
-
*/
|
|
290
|
-
@Property(false)
|
|
291
|
-
public enablePersistence: boolean;
|
|
292
|
-
/**
|
|
293
|
-
* > Support for `allowEdit` has been provided from
|
|
294
|
-
* [`v16.2.46`](https://ej2.syncfusion.com/angular/documentation/release-notes/16.2.46/#datetimepicker).
|
|
295
|
-
*
|
|
296
|
-
* Specifies whether the input textbox is editable or not. Here the user can select the value from the
|
|
297
|
-
* popup and cannot edit in the input textbox.
|
|
298
|
-
*
|
|
299
|
-
* @default true
|
|
300
|
-
*/
|
|
301
|
-
@Property(true)
|
|
302
|
-
public allowEdit: boolean;
|
|
303
|
-
/**
|
|
304
|
-
* Specifies the option to enable the multiple dates selection of the calendar.
|
|
305
|
-
*
|
|
306
|
-
* @default false
|
|
307
|
-
* @private
|
|
308
|
-
*/
|
|
309
|
-
@Property(false)
|
|
310
|
-
public isMultiSelection: boolean;
|
|
311
|
-
/**
|
|
312
|
-
* Gets or sets multiple selected dates of the calendar.
|
|
313
|
-
*
|
|
314
|
-
* @default null
|
|
315
|
-
* @private
|
|
316
|
-
*/
|
|
317
|
-
@Property(null)
|
|
318
|
-
public values: Date[];
|
|
319
|
-
/**
|
|
320
|
-
* Specifies whether to show or hide the clear icon in textbox.
|
|
321
|
-
*
|
|
322
|
-
* @default true
|
|
323
|
-
*/
|
|
324
|
-
@Property(true)
|
|
325
|
-
public showClearButton: boolean;
|
|
326
|
-
/**
|
|
327
|
-
* Specifies the placeholder text that to be is displayed in textbox.
|
|
328
|
-
*
|
|
329
|
-
* @default null
|
|
330
|
-
*/
|
|
331
|
-
@Property(null)
|
|
332
|
-
public placeholder: string;
|
|
333
|
-
/**
|
|
334
|
-
* Specifies the component to act as strict. So that, it allows to enter only a valid
|
|
335
|
-
* date and time value within a specified range or else it
|
|
336
|
-
* will resets to previous value. By default, strictMode is in false.
|
|
337
|
-
* it allows invalid or out-of-range value with highlighted error class.
|
|
338
|
-
*
|
|
339
|
-
* @default false
|
|
340
|
-
* > For more details refer to
|
|
341
|
-
* [`Strict Mode`](../../datetimepicker/strict-mode/) documentation.
|
|
342
|
-
*/
|
|
343
|
-
@Property(false)
|
|
344
|
-
public strictMode: boolean;
|
|
345
|
-
/**
|
|
346
|
-
* Specifies the component popup display full screen in mobile devices.
|
|
347
|
-
*
|
|
348
|
-
* @default false
|
|
349
|
-
*/
|
|
350
|
-
@Property(false)
|
|
351
|
-
public fullScreenMode : boolean;
|
|
352
|
-
/**
|
|
353
|
-
* By default, the date value will be processed based on system time zone.
|
|
354
|
-
* If you want to process the initial date value using server time zone
|
|
355
|
-
* then specify the time zone value to `serverTimezoneOffset` property.
|
|
356
|
-
*
|
|
357
|
-
* @default null
|
|
358
|
-
*/
|
|
359
|
-
@Property(null)
|
|
360
|
-
public serverTimezoneOffset: number;
|
|
361
|
-
/**
|
|
362
|
-
* Gets or sets the minimum date that can be selected in the DateTimePicker.
|
|
363
|
-
*
|
|
364
|
-
* @default new Date(1900, 00, 01)
|
|
365
|
-
*/
|
|
366
|
-
@Property(new Date(1900, 0, 1))
|
|
367
|
-
public min: Date;
|
|
368
|
-
/**
|
|
369
|
-
* Gets or sets the maximum date that can be selected in the DateTimePicker.
|
|
370
|
-
*
|
|
371
|
-
* @default new Date(2099, 11, 31)
|
|
372
|
-
*/
|
|
373
|
-
@Property(new Date(2099, 11, 31))
|
|
374
|
-
public max: Date;
|
|
375
|
-
/**
|
|
376
|
-
* Gets or sets the minimum time that can be selected in the time popup of the DateTimePicker.
|
|
377
|
-
*
|
|
378
|
-
* @default null
|
|
379
|
-
*/
|
|
380
|
-
@Property(null)
|
|
381
|
-
public minTime: Date;
|
|
382
|
-
/**
|
|
383
|
-
* Gets or sets the maximum time that can be selected in the time popup of the DateTimePicker.
|
|
384
|
-
*
|
|
385
|
-
* @default null
|
|
386
|
-
*/
|
|
387
|
-
@Property(null)
|
|
388
|
-
public maxTime: Date;
|
|
389
|
-
/**
|
|
390
|
-
* Gets or sets the Calendar's first day of the week. By default, the first day of the week will be based on the current culture.
|
|
391
|
-
*
|
|
392
|
-
* @default 0
|
|
393
|
-
* @aspType int
|
|
394
|
-
* > For more details about firstDayOfWeek refer to
|
|
395
|
-
* [`First day of week`](../../calendar/how-to/first-day-of-week#change-the-first-day-of-the-week) documentation.
|
|
396
|
-
*/
|
|
397
|
-
@Property(null)
|
|
398
|
-
public firstDayOfWeek: number;
|
|
399
|
-
/**
|
|
400
|
-
* Gets or sets the Calendar's Type like gregorian or islamic.
|
|
401
|
-
*
|
|
402
|
-
* @default Gregorian
|
|
403
|
-
*/
|
|
404
|
-
@Property('Gregorian')
|
|
405
|
-
public calendarMode: CalendarType;
|
|
406
|
-
/**
|
|
407
|
-
* Specifies the initial view of the Calendar when it is opened.
|
|
408
|
-
* With the help of this property, initial view can be changed to year or decade view.
|
|
409
|
-
*
|
|
410
|
-
* @default Month
|
|
411
|
-
*
|
|
412
|
-
* <table>
|
|
413
|
-
* <tr>
|
|
414
|
-
* <td colSpan=1 rowSpan=1>
|
|
415
|
-
* View<br/></td><td colSpan=1 rowSpan=1>
|
|
416
|
-
* Description<br/></td></tr>
|
|
417
|
-
* <tr>
|
|
418
|
-
* <td colSpan=1 rowSpan=1>
|
|
419
|
-
* Month<br/></td><td colSpan=1 rowSpan=1>
|
|
420
|
-
* Calendar view shows the days of the month.<br/></td></tr>
|
|
421
|
-
* <tr>
|
|
422
|
-
* <td colSpan=1 rowSpan=1>
|
|
423
|
-
* Year<br/></td><td colSpan=1 rowSpan=1>
|
|
424
|
-
* Calendar view shows the months of the year.<br/></td></tr>
|
|
425
|
-
* <tr>
|
|
426
|
-
* <td colSpan=1 rowSpan=1>
|
|
427
|
-
* Decade<br/></td><td colSpan=1 rowSpan=1>
|
|
428
|
-
* Calendar view shows the years of the decade.<br/></td></tr>
|
|
429
|
-
* </table>
|
|
430
|
-
*
|
|
431
|
-
* > For more details about start refer to
|
|
432
|
-
* [`calendarView`](../../calendar/calendar-views#view-restriction)documentation.
|
|
433
|
-
*/
|
|
434
|
-
@Property('Month')
|
|
435
|
-
public start: CalendarView;
|
|
436
|
-
/**
|
|
437
|
-
* Sets the maximum level of view such as month, year, and decade in the Calendar.
|
|
438
|
-
* Depth view should be smaller than the start view to restrict its view navigation.
|
|
439
|
-
*
|
|
440
|
-
* @default Month
|
|
441
|
-
*
|
|
442
|
-
* <table>
|
|
443
|
-
* <tr>
|
|
444
|
-
* <td colSpan=1 rowSpan=1>
|
|
445
|
-
* view<br/></td><td colSpan=1 rowSpan=1>
|
|
446
|
-
* Description<br/></td></tr>
|
|
447
|
-
* <tr>
|
|
448
|
-
* <td colSpan=1 rowSpan=1>
|
|
449
|
-
* Month<br/></td><td colSpan=1 rowSpan=1>
|
|
450
|
-
* Calendar view shows up to the days of the month.<br/></td></tr>
|
|
451
|
-
* <tr>
|
|
452
|
-
* <td colSpan=1 rowSpan=1>
|
|
453
|
-
* Year<br/></td><td colSpan=1 rowSpan=1>
|
|
454
|
-
* Calendar view shows up to the months of the year.<br/></td></tr>
|
|
455
|
-
* <tr>
|
|
456
|
-
* <td colSpan=1 rowSpan=1>
|
|
457
|
-
* Decade<br/></td><td colSpan=1 rowSpan=1>
|
|
458
|
-
* Calendar view shows up to the years of the decade.<br/></td></tr>
|
|
459
|
-
* </table>
|
|
460
|
-
*
|
|
461
|
-
* > For more details about depth refer to
|
|
462
|
-
* [`calendarView`](../../calendar/calendar-views#view-restriction)documentation.
|
|
463
|
-
*/
|
|
464
|
-
@Property('Month')
|
|
465
|
-
public depth: CalendarView;
|
|
466
|
-
/**
|
|
467
|
-
* Determines whether the week number of the year is to be displayed in the calendar or not.
|
|
468
|
-
*
|
|
469
|
-
* @default false
|
|
470
|
-
* > For more details about weekNumber refer to
|
|
471
|
-
* [`Calendar with week number`](../../calendar/how-to/render-the-calendar-with-week-numbers)documentation.
|
|
472
|
-
*/
|
|
473
|
-
@Property(false)
|
|
474
|
-
public weekNumber: boolean;
|
|
475
|
-
/**
|
|
476
|
-
* Specifies whether the today button is to be displayed or not.
|
|
477
|
-
*
|
|
478
|
-
* @default true
|
|
479
|
-
*/
|
|
480
|
-
@Property(true)
|
|
481
|
-
public showTodayButton: boolean;
|
|
482
|
-
/**
|
|
483
|
-
* Specifies the format of the day that to be displayed in header. By default, the format is ‘short’.
|
|
484
|
-
* Possible formats are:
|
|
485
|
-
* * `Short` - Sets the short format of day name (like Su ) in day header.
|
|
486
|
-
* * `Narrow` - Sets the single character of day name (like S ) in day header.
|
|
487
|
-
* * `Abbreviated` - Sets the min format of day name (like Sun ) in day header.
|
|
488
|
-
* * `Wide` - Sets the long format of day name (like Sunday ) in day header.
|
|
489
|
-
*
|
|
490
|
-
* @default Short
|
|
491
|
-
*/
|
|
492
|
-
@Property('Short')
|
|
493
|
-
public dayHeaderFormat: DayHeaderFormats;
|
|
494
|
-
/**
|
|
495
|
-
* By default, the popup opens while clicking on the datetimepicker icon.
|
|
496
|
-
* If you want to open the popup while focusing the datetime input then specify its value as true.
|
|
497
|
-
*
|
|
498
|
-
* @default false
|
|
499
|
-
*/
|
|
500
|
-
@Property(false)
|
|
501
|
-
public openOnFocus : boolean;
|
|
502
|
-
/**
|
|
503
|
-
* Specifies whether it is a masked datetimepicker or not.
|
|
504
|
-
* By default the datetimepicker component render without masked input.
|
|
505
|
-
* If you need masked datetimepicker input then specify it as true.
|
|
506
|
-
*
|
|
507
|
-
* @default false
|
|
508
|
-
*/
|
|
509
|
-
@Property(false)
|
|
510
|
-
public enableMask: boolean;
|
|
511
|
-
|
|
512
|
-
/**
|
|
513
|
-
* Specifies the mask placeholder to be displayed on masked datetimepicker.
|
|
514
|
-
*
|
|
515
|
-
* @default {day:'day' , month:'month', year: 'year', hour:'hour',minute:'minute',second:'second',dayOfTheWeek: 'day of the week'}
|
|
516
|
-
*/
|
|
517
|
-
@Property({day: 'day' , month: 'month', year: 'year', hour: 'hour', minute: 'minute', second: 'second', dayOfTheWeek: 'day of the week'})
|
|
518
|
-
public maskPlaceholder: MaskPlaceholderModel;
|
|
519
|
-
|
|
520
|
-
/**
|
|
521
|
-
* Triggers when popup is opened.
|
|
522
|
-
*
|
|
523
|
-
* @event open
|
|
524
|
-
*/
|
|
525
|
-
@Event()
|
|
526
|
-
public open: EmitType<Object>;
|
|
527
|
-
/**
|
|
528
|
-
* Triggers when popup is closed.
|
|
529
|
-
*
|
|
530
|
-
* @event close
|
|
531
|
-
*/
|
|
532
|
-
@Event()
|
|
533
|
-
public close: EmitType<Object>;
|
|
534
|
-
/**
|
|
535
|
-
* Triggers when datetimepicker value is cleared using clear button.
|
|
536
|
-
*
|
|
537
|
-
* @event cleared
|
|
538
|
-
*/
|
|
539
|
-
@Event()
|
|
540
|
-
public cleared: EmitType<ClearedEventArgs>;
|
|
541
|
-
/**
|
|
542
|
-
* Triggers when input loses the focus.
|
|
543
|
-
*
|
|
544
|
-
* @event blur
|
|
545
|
-
*/
|
|
546
|
-
@Event()
|
|
547
|
-
public blur: EmitType<Object>;
|
|
548
|
-
/**
|
|
549
|
-
* Triggers when input gets focus.
|
|
550
|
-
*
|
|
551
|
-
* @event focus
|
|
552
|
-
*/
|
|
553
|
-
@Event()
|
|
554
|
-
public focus: EmitType<Object>;
|
|
555
|
-
/**
|
|
556
|
-
* Triggers when DateTimePicker is created.
|
|
557
|
-
*
|
|
558
|
-
* @event created
|
|
559
|
-
*/
|
|
560
|
-
@Event()
|
|
561
|
-
public created: EmitType<Object>;
|
|
562
|
-
/**
|
|
563
|
-
* Triggers when DateTimePicker is destroyed.
|
|
564
|
-
*
|
|
565
|
-
* @event destroyed
|
|
566
|
-
*/
|
|
567
|
-
@Event()
|
|
568
|
-
public destroyed: EmitType<Object>;
|
|
569
|
-
/**
|
|
570
|
-
* Constructor for creating the widget
|
|
571
|
-
*
|
|
572
|
-
* @param {DateTimePickerModel} options - Specifies the DateTimePicker model.
|
|
573
|
-
* @param {string | HTMLInputElement} element - Specifies the element to render as component.
|
|
574
|
-
* @private
|
|
575
|
-
*/
|
|
576
|
-
public constructor(options?: DateTimePickerModel, element?: string | HTMLInputElement) {
|
|
577
|
-
super(options, element);
|
|
578
|
-
this.dateTimeOptions = options;
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
private focusHandler(): void {
|
|
582
|
-
if (!this.enabled) {
|
|
583
|
-
return;
|
|
584
|
-
}
|
|
585
|
-
addClass([this.inputWrapper.container], INPUTFOCUS);
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
/**
|
|
589
|
-
* Sets the focus to widget for interaction.
|
|
590
|
-
*
|
|
591
|
-
* @returns {void}
|
|
592
|
-
*/
|
|
593
|
-
public focusIn(): void {
|
|
594
|
-
super.focusIn();
|
|
595
|
-
}
|
|
596
|
-
/**
|
|
597
|
-
* Remove the focus from widget, if the widget is in focus state.
|
|
598
|
-
*
|
|
599
|
-
* @returns {void}
|
|
600
|
-
*/
|
|
601
|
-
public focusOut(): void {
|
|
602
|
-
if (document.activeElement === this.inputElement) {
|
|
603
|
-
this.inputElement.blur();
|
|
604
|
-
removeClass([this.inputWrapper.container], [INPUTFOCUS]);
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
protected blurHandler(e: MouseEvent): void {
|
|
610
|
-
if (!this.enabled) {
|
|
611
|
-
return;
|
|
612
|
-
}
|
|
613
|
-
// IE popup closing issue when click over the scrollbar
|
|
614
|
-
if (this.isTimePopupOpen() && this.isPreventBlur) {
|
|
615
|
-
this.inputElement.focus();
|
|
616
|
-
return;
|
|
617
|
-
}
|
|
618
|
-
removeClass([this.inputWrapper.container], INPUTFOCUS);
|
|
619
|
-
const blurArguments: BlurEventArgs = {
|
|
620
|
-
model: this
|
|
621
|
-
};
|
|
622
|
-
if (this.isTimePopupOpen()) {
|
|
623
|
-
this.hide(e);
|
|
624
|
-
}
|
|
625
|
-
this.trigger('blur', blurArguments);
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
/**
|
|
629
|
-
* To destroy the widget.
|
|
630
|
-
*
|
|
631
|
-
* @returns {void}
|
|
632
|
-
*/
|
|
633
|
-
public destroy(): void {
|
|
634
|
-
if (this.showClearButton) {
|
|
635
|
-
this.clearButton = document.getElementsByClassName('e-clear-icon')[0] as HTMLElement;
|
|
636
|
-
}
|
|
637
|
-
if (this.popupObject && this.popupObject.element.classList.contains(POPUP)) {
|
|
638
|
-
this.popupObject.destroy();
|
|
639
|
-
detach(this.dateTimeWrapper);
|
|
640
|
-
this.dateTimeWrapper = undefined;
|
|
641
|
-
this.liCollections = this.timeCollections = [];
|
|
642
|
-
if (!isNullOrUndefined(this.rippleFn)) {
|
|
643
|
-
this.rippleFn();
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
const ariaAttribute: object = {
|
|
647
|
-
'aria-live': 'assertive', 'aria-atomic': 'true', 'aria-invalid': 'false',
|
|
648
|
-
'autocorrect': 'off', 'autocapitalize': 'off', 'spellcheck': 'false',
|
|
649
|
-
'aria-expanded': 'false', 'role': 'combobox', 'autocomplete': 'off'
|
|
650
|
-
};
|
|
651
|
-
if (this.inputElement) {
|
|
652
|
-
Input.removeAttributes(<{ [key: string]: string }>ariaAttribute, this.inputElement);
|
|
653
|
-
}
|
|
654
|
-
if (this.isCalendar()) {
|
|
655
|
-
if (this.popupWrapper) {
|
|
656
|
-
detach(this.popupWrapper);
|
|
657
|
-
}
|
|
658
|
-
this.popupObject = this.popupWrapper = null;
|
|
659
|
-
this.keyboardHandler.destroy();
|
|
660
|
-
}
|
|
661
|
-
this.unBindInputEvents();
|
|
662
|
-
this.liCollections = null;
|
|
663
|
-
this.rippleFn = null;
|
|
664
|
-
this.selectedElement = null;
|
|
665
|
-
this.listTag = null;
|
|
666
|
-
this.timeIcon = null;
|
|
667
|
-
this.popupObject = null;
|
|
668
|
-
this.preventArgs = null;
|
|
669
|
-
this.keyboardModule = null;
|
|
670
|
-
Input.destroy({
|
|
671
|
-
element: this.inputElement,
|
|
672
|
-
floatLabelType: this.floatLabelType,
|
|
673
|
-
properties: this.properties
|
|
674
|
-
}, this.clearButton);
|
|
675
|
-
super.destroy();
|
|
676
|
-
}
|
|
677
|
-
/**
|
|
678
|
-
* To Initialize the control rendering.
|
|
679
|
-
*
|
|
680
|
-
* @returns {void}
|
|
681
|
-
* @private
|
|
682
|
-
*/
|
|
683
|
-
public render(): void {
|
|
684
|
-
this.timekeyConfigure = {
|
|
685
|
-
enter: 'enter',
|
|
686
|
-
escape: 'escape',
|
|
687
|
-
end: 'end',
|
|
688
|
-
tab: 'tab',
|
|
689
|
-
home: 'home',
|
|
690
|
-
down: 'downarrow',
|
|
691
|
-
up: 'uparrow',
|
|
692
|
-
left: 'leftarrow',
|
|
693
|
-
right: 'rightarrow',
|
|
694
|
-
open: 'alt+downarrow',
|
|
695
|
-
close: 'alt+uparrow'
|
|
696
|
-
};
|
|
697
|
-
this.valueWithMinutes = null;
|
|
698
|
-
this.previousDateTime = null;
|
|
699
|
-
this.isPreventBlur = false;
|
|
700
|
-
this.cloneElement = <HTMLElement>this.element.cloneNode(true);
|
|
701
|
-
this.dateTimeFormat = this.cldrDateTimeFormat();
|
|
702
|
-
this.initValue = this.value;
|
|
703
|
-
if (typeof (this.min) === 'string')
|
|
704
|
-
{
|
|
705
|
-
this.min = this.checkDateValue(new Date((this as any).min));
|
|
706
|
-
}
|
|
707
|
-
if (typeof (this.max) === 'string')
|
|
708
|
-
{
|
|
709
|
-
this.max = this.checkDateValue(new Date((this as any).max));
|
|
710
|
-
}
|
|
711
|
-
if (typeof (this.minTime) === 'string')
|
|
712
|
-
{
|
|
713
|
-
this.minTime = this.checkDateValue(new Date((this as any).minTime));
|
|
714
|
-
}
|
|
715
|
-
if (typeof (this.maxTime) === 'string')
|
|
716
|
-
{
|
|
717
|
-
this.maxTime = this.checkDateValue(new Date((this as any).maxTime));
|
|
718
|
-
}
|
|
719
|
-
if (!isNullOrUndefined(closest(this.element, 'fieldset') as HTMLFieldSetElement) && (closest(this.element, 'fieldset') as HTMLFieldSetElement).disabled) {
|
|
720
|
-
this.enabled = false;
|
|
721
|
-
}
|
|
722
|
-
super.updateHtmlAttributeToElement();
|
|
723
|
-
this.checkAttributes(false);
|
|
724
|
-
const localeText: { placeholder: string } = { placeholder: this.placeholder };
|
|
725
|
-
this.l10n = new L10n('datetimepicker', localeText, this.locale);
|
|
726
|
-
this.setProperties({ placeholder: this.placeholder || this.l10n.getConstant('placeholder') }, true);
|
|
727
|
-
super.render();
|
|
728
|
-
this.createInputElement();
|
|
729
|
-
super.updateHtmlAttributeToWrapper();
|
|
730
|
-
this.bindInputEvents();
|
|
731
|
-
if (this.enableMask) {
|
|
732
|
-
this.notify('createMask', {
|
|
733
|
-
module: 'MaskedDateTime'
|
|
734
|
-
});
|
|
735
|
-
}
|
|
736
|
-
this.setValue(true);
|
|
737
|
-
if (this.enableMask && !this.value && this.maskedDateValue && (this.floatLabelType === 'Always' || !this.floatLabelType || !this.placeholder)){
|
|
738
|
-
Input.setValue(this.maskedDateValue, this.inputElement, this.floatLabelType, this.showClearButton);
|
|
739
|
-
}
|
|
740
|
-
this.setProperties({ scrollTo: this.checkDateValue(new Date(this.checkValue(this.scrollTo))) }, true);
|
|
741
|
-
this.previousDateTime = this.value && new Date(+this.value);
|
|
742
|
-
if (this.element.tagName === 'EJS-DATETIMEPICKER') {
|
|
743
|
-
this.tabIndex = this.element.hasAttribute('tabindex') ? this.element.getAttribute('tabindex') : '0';
|
|
744
|
-
this.element.removeAttribute('tabindex');
|
|
745
|
-
if (!this.enabled) {
|
|
746
|
-
this.inputElement.tabIndex = -1;
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
if (this.floatLabelType !== 'Never') {
|
|
750
|
-
Input.calculateWidth(this.inputElement, this.inputWrapper.container);
|
|
751
|
-
}
|
|
752
|
-
if (!isNullOrUndefined(this.inputWrapper.buttons[0]) && !isNullOrUndefined(this.inputWrapper.container.getElementsByClassName('e-float-text-overflow')[0]) && this.floatLabelType !== 'Never') {
|
|
753
|
-
this.inputWrapper.container.getElementsByClassName('e-float-text-overflow')[0].classList.add('e-date-time-icon');
|
|
754
|
-
}
|
|
755
|
-
this.renderComplete();
|
|
756
|
-
}
|
|
757
|
-
private setValue(isDynamic : boolean = false): void {
|
|
758
|
-
this.initValue = this.validateMinMaxRange(this.value);
|
|
759
|
-
if (!this.strictMode && this.isDateObject(this.initValue)) {
|
|
760
|
-
const value: Date = this.validateMinMaxRange(this.initValue);
|
|
761
|
-
Input.setValue(this.getFormattedValue(value), this.inputElement, this.floatLabelType, this.showClearButton);
|
|
762
|
-
this.setProperties({ value: value }, true);
|
|
763
|
-
} else {
|
|
764
|
-
if (isNullOrUndefined(this.value)) {
|
|
765
|
-
this.initValue = null;
|
|
766
|
-
this.setProperties({ value: null }, true);
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
this.valueWithMinutes = this.value;
|
|
770
|
-
super.updateInput(isDynamic);
|
|
771
|
-
}
|
|
772
|
-
private validateMinMaxRange(value: Date): Date {
|
|
773
|
-
let result: Date = value;
|
|
774
|
-
if (this.isDateObject(value)) {
|
|
775
|
-
result = this.validateValue(value);
|
|
776
|
-
} else {
|
|
777
|
-
if (+this.min > +this.max) {
|
|
778
|
-
this.disablePopupButton(true);
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
this.checkValidState(result);
|
|
782
|
-
return result;
|
|
783
|
-
}
|
|
784
|
-
private checkValidState(value: Date): void {
|
|
785
|
-
this.isValidState = true;
|
|
786
|
-
if (!this.strictMode) {
|
|
787
|
-
if ((+(value) > +(this.max)) || (+(value) < +(this.min)) || !this.isValidTime(value)) {
|
|
788
|
-
this.isValidState = false;
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
this.checkErrorState();
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
private checkErrorState(): void {
|
|
795
|
-
if (this.isValidState) {
|
|
796
|
-
removeClass([this.inputWrapper.container], ERROR);
|
|
797
|
-
} else {
|
|
798
|
-
addClass([this.inputWrapper.container], ERROR);
|
|
799
|
-
}
|
|
800
|
-
attributes(this.inputElement, { 'aria-invalid': this.isValidState ? 'false' : 'true' });
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
protected isValidTime(value: Date): boolean {
|
|
804
|
-
if (value != null && (this.minTime || this.maxTime)) {
|
|
805
|
-
let minTimeValue: number;
|
|
806
|
-
let maxTimeValue: number;
|
|
807
|
-
let maxValue: number;
|
|
808
|
-
let minValue: number;
|
|
809
|
-
|
|
810
|
-
const valueTime: number = value.getHours() * 3600000 + value.getMinutes() * 60000 +
|
|
811
|
-
value.getSeconds() * 1000 + value.getMilliseconds();
|
|
812
|
-
|
|
813
|
-
if (this.minTime) {
|
|
814
|
-
minTimeValue = this.minTime.getHours() * 3600000 + this.minTime.getMinutes() * 60000 +
|
|
815
|
-
this.minTime.getSeconds() * 1000 + this.minTime.getMilliseconds();
|
|
816
|
-
}
|
|
817
|
-
if (this.maxTime) {
|
|
818
|
-
maxTimeValue = this.maxTime.getHours() * 3600000 + this.maxTime.getMinutes() * 60000 +
|
|
819
|
-
this.maxTime.getSeconds() * 1000 + this.maxTime.getMilliseconds();
|
|
820
|
-
}
|
|
821
|
-
if (this.min && (+value.getDate() === +this.min.getDate() && +value.getMonth() === +this.min.getMonth() &&
|
|
822
|
-
+value.getFullYear() === +this.min.getFullYear())) {
|
|
823
|
-
minValue = this.min.getHours() * 3600000 + this.min.getMinutes() * 60000 +
|
|
824
|
-
this.min.getSeconds() * 1000 + this.min.getMilliseconds();
|
|
825
|
-
minTimeValue = minTimeValue < minValue ? minValue : minTimeValue;
|
|
826
|
-
}
|
|
827
|
-
if (this.max && (+value.getDate() === +this.max.getDate() && +value.getMonth() === +this.max.getMonth() &&
|
|
828
|
-
+this.max.getFullYear() === +this.max.getFullYear())) {
|
|
829
|
-
maxValue = this.max.getHours() * 3600000 + this.max.getMinutes() * 60000 +
|
|
830
|
-
this.max.getSeconds() * 1000 + this.max.getMilliseconds();
|
|
831
|
-
maxTimeValue = maxTimeValue > maxValue ? maxValue : maxTimeValue;
|
|
832
|
-
}
|
|
833
|
-
if (this.strictMode) {
|
|
834
|
-
let newValue: Date;
|
|
835
|
-
if (minTimeValue && valueTime < minTimeValue) {
|
|
836
|
-
newValue = new Date(
|
|
837
|
-
value.getFullYear(),
|
|
838
|
-
value.getMonth(),
|
|
839
|
-
value.getDate(),
|
|
840
|
-
this.minTime.getHours(),
|
|
841
|
-
this.minTime.getMinutes(),
|
|
842
|
-
this.minTime.getSeconds(),
|
|
843
|
-
this.minTime.getMilliseconds()
|
|
844
|
-
);
|
|
845
|
-
this.setProperties({ value: newValue }, true);
|
|
846
|
-
this.changedArgs = { value: this.value };
|
|
847
|
-
}
|
|
848
|
-
else if (maxTimeValue && valueTime > maxTimeValue) {
|
|
849
|
-
newValue = new Date(
|
|
850
|
-
value.getFullYear(),
|
|
851
|
-
value.getMonth(),
|
|
852
|
-
value.getDate(),
|
|
853
|
-
this.maxTime.getHours(),
|
|
854
|
-
this.maxTime.getMinutes(),
|
|
855
|
-
this.maxTime.getSeconds(),
|
|
856
|
-
this.maxTime.getMilliseconds()
|
|
857
|
-
);
|
|
858
|
-
this.setProperties({ value: newValue }, true);
|
|
859
|
-
this.changedArgs = { value: this.value };
|
|
860
|
-
}
|
|
861
|
-
return true;
|
|
862
|
-
}
|
|
863
|
-
else {
|
|
864
|
-
return !((minTimeValue && valueTime < minTimeValue) || (maxTimeValue && valueTime > maxTimeValue));
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
return true;
|
|
868
|
-
}
|
|
869
|
-
|
|
870
|
-
private validateValue(value: Date): Date {
|
|
871
|
-
let dateVal: Date = value;
|
|
872
|
-
if (this.strictMode) {
|
|
873
|
-
if (+this.min > +this.max) {
|
|
874
|
-
this.disablePopupButton(true);
|
|
875
|
-
dateVal = this.max;
|
|
876
|
-
} else if (+value < +this.min) {
|
|
877
|
-
dateVal = this.min;
|
|
878
|
-
} else if (+value > +this.max) {
|
|
879
|
-
dateVal = this.max;
|
|
880
|
-
}
|
|
881
|
-
} else {
|
|
882
|
-
if (+this.min > +this.max) {
|
|
883
|
-
this.disablePopupButton(true);
|
|
884
|
-
dateVal = value;
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
return dateVal;
|
|
888
|
-
}
|
|
889
|
-
private disablePopupButton(isDisable: boolean): void {
|
|
890
|
-
if (isDisable) {
|
|
891
|
-
addClass([this.inputWrapper.buttons[0], this.timeIcon], DISABLED);
|
|
892
|
-
this.hide();
|
|
893
|
-
} else {
|
|
894
|
-
removeClass([this.inputWrapper.buttons[0], this.timeIcon], DISABLED);
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
private getFormattedValue(value: Date): string {
|
|
898
|
-
let dateOptions: object;
|
|
899
|
-
if (!isNullOrUndefined(value)) {
|
|
900
|
-
if (this.calendarMode === 'Gregorian') {
|
|
901
|
-
dateOptions = { format: this.cldrDateTimeFormat(), type: 'dateTime', skeleton: 'yMd' };
|
|
902
|
-
} else {
|
|
903
|
-
dateOptions = { format: this.cldrDateTimeFormat(), type: 'dateTime', skeleton: 'yMd', calendar: 'islamic' };
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
return this.globalize.formatDate(value, dateOptions);
|
|
907
|
-
} else {
|
|
908
|
-
return null;
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
|
-
private isDateObject(value: Date): boolean {
|
|
912
|
-
return (!isNullOrUndefined(value) && !isNaN(+value)) ? true : false;
|
|
913
|
-
}
|
|
914
|
-
private createInputElement(): void {
|
|
915
|
-
removeClass([this.inputElement], DATEPICKERROOT);
|
|
916
|
-
removeClass([this.inputWrapper.container], DATEWRAPPER);
|
|
917
|
-
addClass([this.inputWrapper.container], DATETIMEWRAPPER);
|
|
918
|
-
addClass([this.inputElement], ROOT);
|
|
919
|
-
this.renderTimeIcon();
|
|
920
|
-
}
|
|
921
|
-
private renderTimeIcon(): void {
|
|
922
|
-
this.timeIcon = Input.appendSpan(INPUTWRAPPER + ' ' + TIMEICON + ' ' + ICONS, this.inputWrapper.container);
|
|
923
|
-
}
|
|
924
|
-
private bindInputEvents(): void {
|
|
925
|
-
EventHandler.add(this.timeIcon, 'mousedown', this.timeHandler, this);
|
|
926
|
-
EventHandler.add(this.inputWrapper.buttons[0], 'mousedown', this.dateHandler, this);
|
|
927
|
-
EventHandler.add(this.inputElement, 'blur', this.blurHandler, this);
|
|
928
|
-
EventHandler.add(this.inputElement, 'focus', this.focusHandler, this);
|
|
929
|
-
this.defaultKeyConfigs = (extend(this.defaultKeyConfigs, this.keyConfigs) as { [key: string]: string });
|
|
930
|
-
this.keyboardHandler = new KeyboardEvents(
|
|
931
|
-
<HTMLElement>this.inputElement,
|
|
932
|
-
{
|
|
933
|
-
eventName: 'keydown',
|
|
934
|
-
keyAction: this.inputKeyAction.bind(this),
|
|
935
|
-
keyConfigs: this.defaultKeyConfigs
|
|
936
|
-
});
|
|
937
|
-
}
|
|
938
|
-
private unBindInputEvents(): void {
|
|
939
|
-
EventHandler.remove(this.timeIcon, 'mousedown touchstart', this.timeHandler);
|
|
940
|
-
EventHandler.remove(this.inputWrapper.buttons[0], 'mousedown touchstart', this.dateHandler);
|
|
941
|
-
if (this.inputElement) {
|
|
942
|
-
EventHandler.remove(this.inputElement, 'blur', this.blurHandler);
|
|
943
|
-
EventHandler.remove(this.inputElement, 'focus', this.focusHandler);
|
|
944
|
-
}
|
|
945
|
-
if (this.keyboardHandler) {
|
|
946
|
-
this.keyboardHandler.destroy();
|
|
947
|
-
}
|
|
948
|
-
}
|
|
949
|
-
private cldrTimeFormat(): string {
|
|
950
|
-
let cldrTime: string;
|
|
951
|
-
if (this.isNullOrEmpty(this.timeFormat)) {
|
|
952
|
-
if (this.locale === 'en' || this.locale === 'en-US') {
|
|
953
|
-
cldrTime = <string>(getValue('timeFormats.short', getDefaultDateObject()));
|
|
954
|
-
} else {
|
|
955
|
-
cldrTime = <string>(this.getCultureTimeObject(cldrData, '' + this.locale));
|
|
956
|
-
}
|
|
957
|
-
} else {
|
|
958
|
-
cldrTime = this.timeFormat;
|
|
959
|
-
}
|
|
960
|
-
return cldrTime;
|
|
961
|
-
}
|
|
962
|
-
private cldrDateTimeFormat(): string {
|
|
963
|
-
let cldrTime: string;
|
|
964
|
-
const culture: Internationalization = new Internationalization(this.locale);
|
|
965
|
-
const dateFormat: string = culture.getDatePattern({ skeleton: 'yMd' });
|
|
966
|
-
if (this.isNullOrEmpty(this.formatString)) {
|
|
967
|
-
cldrTime = dateFormat + ' ' + this.getCldrFormat('time');
|
|
968
|
-
} else {
|
|
969
|
-
cldrTime = this.formatString;
|
|
970
|
-
}
|
|
971
|
-
return cldrTime;
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
private getCldrFormat(type: string): string {
|
|
975
|
-
let cldrDateTime: string;
|
|
976
|
-
if (this.locale === 'en' || this.locale === 'en-US') {
|
|
977
|
-
cldrDateTime = <string>(getValue('timeFormats.short', getDefaultDateObject()));
|
|
978
|
-
} else {
|
|
979
|
-
cldrDateTime = <string>(this.getCultureTimeObject(cldrData, '' + this.locale));
|
|
980
|
-
}
|
|
981
|
-
return cldrDateTime;
|
|
982
|
-
}
|
|
983
|
-
private isNullOrEmpty(value: Date | string): boolean {
|
|
984
|
-
if (isNullOrUndefined(value) || (typeof value === 'string' && value.trim() === '')) {
|
|
985
|
-
return true;
|
|
986
|
-
} else {
|
|
987
|
-
return false;
|
|
988
|
-
}
|
|
989
|
-
}
|
|
990
|
-
|
|
991
|
-
protected getCultureTimeObject(ld: Object, c: string): Object {
|
|
992
|
-
if (this.calendarMode === 'Gregorian') {
|
|
993
|
-
return getValue('main.' + '' + this.locale + '.dates.calendars.gregorian.timeFormats.short', ld);
|
|
994
|
-
} else {
|
|
995
|
-
return getValue('main.' + '' + this.locale + '.dates.calendars.islamic.timeFormats.short', ld);
|
|
996
|
-
}
|
|
997
|
-
|
|
998
|
-
}
|
|
999
|
-
private timeHandler(e?: MouseEvent): void {
|
|
1000
|
-
if (!this.enabled) {
|
|
1001
|
-
return;
|
|
1002
|
-
}
|
|
1003
|
-
this.isIconClicked = true;
|
|
1004
|
-
if (Browser.isDevice) {
|
|
1005
|
-
this.inputElement.setAttribute('readonly', '');
|
|
1006
|
-
}
|
|
1007
|
-
if (e.currentTarget === this.timeIcon) {
|
|
1008
|
-
e.preventDefault();
|
|
1009
|
-
}
|
|
1010
|
-
if (this.enabled && !this.readonly) {
|
|
1011
|
-
if (this.isDatePopupOpen()) {
|
|
1012
|
-
super.hide(e);
|
|
1013
|
-
}
|
|
1014
|
-
if (this.isTimePopupOpen()) {
|
|
1015
|
-
this.closePopup(e);
|
|
1016
|
-
} else {
|
|
1017
|
-
this.inputElement.focus();
|
|
1018
|
-
this.popupCreation('time', e);
|
|
1019
|
-
addClass([this.inputWrapper.container], [INPUTFOCUS]);
|
|
1020
|
-
}
|
|
1021
|
-
}
|
|
1022
|
-
this.isIconClicked = false;
|
|
1023
|
-
}
|
|
1024
|
-
|
|
1025
|
-
private dateHandler(e?: MouseEvent): void {
|
|
1026
|
-
if (!this.enabled) {
|
|
1027
|
-
return;
|
|
1028
|
-
}
|
|
1029
|
-
if (e.currentTarget === this.inputWrapper.buttons[0]) {
|
|
1030
|
-
e.preventDefault();
|
|
1031
|
-
}
|
|
1032
|
-
if (this.enabled && !this.readonly) {
|
|
1033
|
-
if (this.isTimePopupOpen()) {
|
|
1034
|
-
this.closePopup(e);
|
|
1035
|
-
}
|
|
1036
|
-
if (!isNullOrUndefined(this.popupWrapper)) {
|
|
1037
|
-
this.popupCreation('date', e);
|
|
1038
|
-
}
|
|
1039
|
-
}
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
public show(type?: string, e?: MouseEvent | KeyboardEvent | KeyboardEventArgs): void {
|
|
1043
|
-
if ((this.enabled && this.readonly) || !this.enabled) {
|
|
1044
|
-
return;
|
|
1045
|
-
} else {
|
|
1046
|
-
if (type === 'time' && !this.dateTimeWrapper) {
|
|
1047
|
-
if (this.isDatePopupOpen()) {
|
|
1048
|
-
this.hide(e);
|
|
1049
|
-
}
|
|
1050
|
-
this.popupCreation('time', e);
|
|
1051
|
-
} else if (!this.popupObj) {
|
|
1052
|
-
if (this.isTimePopupOpen()) {
|
|
1053
|
-
this.hide(e);
|
|
1054
|
-
}
|
|
1055
|
-
super.show();
|
|
1056
|
-
this.popupCreation('date', e);
|
|
1057
|
-
}
|
|
1058
|
-
}
|
|
1059
|
-
}
|
|
1060
|
-
|
|
1061
|
-
public toggle(e?: KeyboardEventArgs): void {
|
|
1062
|
-
if (this.isDatePopupOpen()) {
|
|
1063
|
-
super.hide(e);
|
|
1064
|
-
this.show('time', null);
|
|
1065
|
-
} else if (this.isTimePopupOpen()) {
|
|
1066
|
-
this.hide(e);
|
|
1067
|
-
super.show(null, e);
|
|
1068
|
-
this.popupCreation('date', null);
|
|
1069
|
-
} else {
|
|
1070
|
-
this.show(null, e);
|
|
1071
|
-
}
|
|
1072
|
-
}
|
|
1073
|
-
|
|
1074
|
-
private listCreation(): void {
|
|
1075
|
-
let dateObject: Date;
|
|
1076
|
-
if (this.calendarMode === 'Gregorian') {
|
|
1077
|
-
this.cldrDateTimeFormat().replace(this.formatRegex, this.TimePopupFormat());
|
|
1078
|
-
if (this.dateFormatString === '') {
|
|
1079
|
-
this.dateFormatString = this.cldrDateTimeFormat();
|
|
1080
|
-
}
|
|
1081
|
-
dateObject = this.globalize.parseDate(this.getAmPmValue(this.inputElement.value), {
|
|
1082
|
-
format: this.dateFormatString, type: 'datetime'
|
|
1083
|
-
});
|
|
1084
|
-
} else {
|
|
1085
|
-
dateObject = this.globalize.parseDate(this.getAmPmValue(this.inputElement.value), {
|
|
1086
|
-
format: this.cldrDateTimeFormat(), type: 'datetime', calendar: 'islamic'
|
|
1087
|
-
});
|
|
1088
|
-
}
|
|
1089
|
-
const value: Date = isNullOrUndefined(this.value) ? this.inputElement.value !== '' ?
|
|
1090
|
-
dateObject : new Date() : this.value;
|
|
1091
|
-
this.valueWithMinutes = value;
|
|
1092
|
-
this.listWrapper = createElement('div', { className: CONTENT, attrs: { 'tabindex': '0' } });
|
|
1093
|
-
const min: Date = this.startTime(value);
|
|
1094
|
-
const max: Date = this.endTime(value);
|
|
1095
|
-
const listDetails: { collection: number[]; list: HTMLElement } =
|
|
1096
|
-
TimePickerBase.createListItems(this.createElement, min, max, this.globalize, this.cldrTimeFormat(), this.step);
|
|
1097
|
-
this.timeCollections = listDetails.collection;
|
|
1098
|
-
this.listTag = listDetails.list;
|
|
1099
|
-
attributes(this.listTag, { 'role': 'listbox', 'aria-hidden': 'false', 'id': this.element.id + '_options' });
|
|
1100
|
-
append([listDetails.list], this.listWrapper);
|
|
1101
|
-
this.wireTimeListEvents();
|
|
1102
|
-
const rippleModel: RippleOptions = { duration: 300, selector: '.' + LISTCLASS };
|
|
1103
|
-
this.rippleFn = rippleEffect(this.listWrapper, rippleModel);
|
|
1104
|
-
this.liCollections = <HTMLElement[] & NodeListOf<Element>>this.listWrapper.querySelectorAll('.' + LISTCLASS);
|
|
1105
|
-
}
|
|
1106
|
-
|
|
1107
|
-
private popupCreation(type: string, e?: KeyboardEvent | MouseEvent | Event): void {
|
|
1108
|
-
if (Browser.isDevice) {
|
|
1109
|
-
this.element.setAttribute('readonly', 'readonly');
|
|
1110
|
-
}
|
|
1111
|
-
if (type === 'date') {
|
|
1112
|
-
if (!this.readonly && this.popupWrapper) {
|
|
1113
|
-
addClass([this.popupWrapper], DATETIMEPOPUPWRAPPER);
|
|
1114
|
-
attributes(this.popupWrapper, { 'id': this.element.id + '_options' });
|
|
1115
|
-
}
|
|
1116
|
-
} else {
|
|
1117
|
-
if (!this.readonly) {
|
|
1118
|
-
const dateTimeWrapperElement: HTMLElement = createElement('div', {
|
|
1119
|
-
className: ROOT + ' ' + POPUP,
|
|
1120
|
-
attrs: { 'id': this.element.id + '_timepopup' }
|
|
1121
|
-
});
|
|
1122
|
-
dateTimeWrapperElement.style.cssText = 'visibility: hidden; display: block;';
|
|
1123
|
-
this.dateTimeWrapper = dateTimeWrapperElement;
|
|
1124
|
-
if (!isNullOrUndefined(this.cssClass)) {
|
|
1125
|
-
this.dateTimeWrapper.className += ' ' + this.cssClass;
|
|
1126
|
-
}
|
|
1127
|
-
if (!isNullOrUndefined(this.step) && this.step > 0) {
|
|
1128
|
-
this.listCreation();
|
|
1129
|
-
append([this.listWrapper], this.dateTimeWrapper);
|
|
1130
|
-
}
|
|
1131
|
-
document.body.appendChild(this.dateTimeWrapper);
|
|
1132
|
-
this.addTimeSelection();
|
|
1133
|
-
this.renderPopup();
|
|
1134
|
-
this.setTimeScrollPosition();
|
|
1135
|
-
this.openPopup(e);
|
|
1136
|
-
if (!Browser.isDevice || (Browser.isDevice && !this.fullScreenMode)) {
|
|
1137
|
-
this.popupObject.refreshPosition(this.inputElement);
|
|
1138
|
-
}
|
|
1139
|
-
if (Browser.isDevice) {
|
|
1140
|
-
this.modelWrapper.style.zIndex = (this.popupObject.zIndex - 1).toString();
|
|
1141
|
-
if (this.fullScreenMode) {
|
|
1142
|
-
this.dateTimeWrapper.style.left = '0px';
|
|
1143
|
-
}
|
|
1144
|
-
}
|
|
1145
|
-
|
|
1146
|
-
}
|
|
1147
|
-
}
|
|
1148
|
-
}
|
|
1149
|
-
private openPopup(e: KeyboardEvent | MouseEvent | Event): void {
|
|
1150
|
-
this.preventArgs = {
|
|
1151
|
-
cancel: false,
|
|
1152
|
-
popup: this.popupObject,
|
|
1153
|
-
event: e || null
|
|
1154
|
-
};
|
|
1155
|
-
const eventArgs: PopupObjectArgs = this.preventArgs;
|
|
1156
|
-
this.trigger('open', eventArgs, (eventArgs: PopupObjectArgs) => {
|
|
1157
|
-
this.preventArgs = eventArgs;
|
|
1158
|
-
if (!this.preventArgs.cancel && !this.readonly) {
|
|
1159
|
-
const openAnimation: AnimationModel = {
|
|
1160
|
-
name: 'FadeIn',
|
|
1161
|
-
duration: ANIMATIONDURATION
|
|
1162
|
-
};
|
|
1163
|
-
if (this.zIndex === 1000) {
|
|
1164
|
-
this.popupObject.show(new Animation(openAnimation), this.element);
|
|
1165
|
-
} else {
|
|
1166
|
-
this.popupObject.show(new Animation(openAnimation), null);
|
|
1167
|
-
}
|
|
1168
|
-
addClass([this.inputWrapper.container], [ICONANIMATION]);
|
|
1169
|
-
attributes(this.inputElement, { 'aria-expanded': 'true' });
|
|
1170
|
-
attributes(this.inputElement, { 'aria-owns': this.inputElement.id + '_options'});
|
|
1171
|
-
attributes(this.inputElement, { 'aria-controls': this.inputElement.id});
|
|
1172
|
-
EventHandler.add(document, 'mousedown touchstart', this.documentClickHandler, this);
|
|
1173
|
-
}
|
|
1174
|
-
});
|
|
1175
|
-
}
|
|
1176
|
-
private documentClickHandler(event: MouseEvent): void {
|
|
1177
|
-
const target: HTMLElement = <HTMLElement>event.target;
|
|
1178
|
-
if ((!isNullOrUndefined(this.popupObject) && (this.inputWrapper.container.contains(target) && event.type !== 'mousedown' ||
|
|
1179
|
-
(this.popupObject.element && this.popupObject.element.contains(target)))) && event.type !== 'touchstart') {
|
|
1180
|
-
event.preventDefault();
|
|
1181
|
-
}
|
|
1182
|
-
if (!(closest(target, '[id="' + (this.popupObject && this.popupObject.element.id + '"]'))) && target !== this.inputElement
|
|
1183
|
-
&& target !== this.timeIcon && !isNullOrUndefined(this.inputWrapper) && target !== this.inputWrapper.container) {
|
|
1184
|
-
if (this.isTimePopupOpen()) {
|
|
1185
|
-
this.hide(event);
|
|
1186
|
-
if (target.classList.contains('e-dlg-overlay')) {
|
|
1187
|
-
event.preventDefault();
|
|
1188
|
-
} else {
|
|
1189
|
-
this.focusOut();
|
|
1190
|
-
}
|
|
1191
|
-
}
|
|
1192
|
-
} else if (target !== this.inputElement) {
|
|
1193
|
-
if (!Browser.isDevice) {
|
|
1194
|
-
this.isPreventBlur = ((document.activeElement === this.inputElement) && (Browser.isIE || Browser.info.name === 'edge')
|
|
1195
|
-
&& target === this.popupObject.element);
|
|
1196
|
-
}
|
|
1197
|
-
}
|
|
1198
|
-
}
|
|
1199
|
-
private isTimePopupOpen(): boolean {
|
|
1200
|
-
return (this.dateTimeWrapper && this.dateTimeWrapper.classList.contains('' + ROOT)) ? true : false;
|
|
1201
|
-
}
|
|
1202
|
-
private isDatePopupOpen(): boolean {
|
|
1203
|
-
return (this.popupWrapper && this.popupWrapper.classList.contains('' + DATETIMEPOPUPWRAPPER)) ? true : false;
|
|
1204
|
-
}
|
|
1205
|
-
private renderPopup(): void {
|
|
1206
|
-
this.containerStyle = this.inputWrapper.container.getBoundingClientRect();
|
|
1207
|
-
if (Browser.isDevice) {
|
|
1208
|
-
this.timeModal = createElement('div');
|
|
1209
|
-
this.timeModal.className = '' + ROOT + ' e-time-modal';
|
|
1210
|
-
document.body.className += ' ' + OVERFLOW;
|
|
1211
|
-
this.timeModal.style.display = 'block';
|
|
1212
|
-
document.body.appendChild(this.timeModal);
|
|
1213
|
-
}
|
|
1214
|
-
if (Browser.isDevice){
|
|
1215
|
-
this.modelWrapper = createElement('div', { className: 'e-datetime-mob-popup-wrap' });
|
|
1216
|
-
this.modelWrapper.appendChild(this.dateTimeWrapper);
|
|
1217
|
-
const dlgOverlay: HTMLElement = createElement('div', { className: 'e-dlg-overlay'});
|
|
1218
|
-
dlgOverlay.style.zIndex = (this.zIndex - 1).toString();
|
|
1219
|
-
this.modelWrapper.appendChild(dlgOverlay);
|
|
1220
|
-
document.body.appendChild(this.modelWrapper);
|
|
1221
|
-
}
|
|
1222
|
-
const offset: number = 4;
|
|
1223
|
-
this.popupObject = new Popup(this.dateTimeWrapper as HTMLElement, {
|
|
1224
|
-
width: this.setPopupWidth(),
|
|
1225
|
-
zIndex: this.zIndex,
|
|
1226
|
-
targetType: 'container',
|
|
1227
|
-
collision: Browser.isDevice ? { X: 'fit', Y: 'fit' } : { X: 'flip', Y: 'flip' },
|
|
1228
|
-
relateTo: Browser.isDevice ? document.body : this.inputWrapper.container,
|
|
1229
|
-
position: Browser.isDevice ? { X: 'center', Y: 'center' } : { X: 'left', Y: 'bottom' },
|
|
1230
|
-
enableRtl: this.enableRtl,
|
|
1231
|
-
offsetY: offset,
|
|
1232
|
-
open: () => {
|
|
1233
|
-
this.dateTimeWrapper.style.visibility = 'visible';
|
|
1234
|
-
addClass([this.timeIcon], ACTIVE);
|
|
1235
|
-
if (!Browser.isDevice) {
|
|
1236
|
-
this.timekeyConfigure = (extend(this.timekeyConfigure, this.keyConfigs) as { [key: string]: string });
|
|
1237
|
-
this.inputEvent = new KeyboardEvents(
|
|
1238
|
-
this.inputWrapper.container, {
|
|
1239
|
-
keyAction: this.timeKeyActionHandle.bind(this),
|
|
1240
|
-
keyConfigs: this.timekeyConfigure,
|
|
1241
|
-
eventName: 'keydown'
|
|
1242
|
-
});
|
|
1243
|
-
}
|
|
1244
|
-
}, close: () => {
|
|
1245
|
-
removeClass([this.timeIcon], ACTIVE);
|
|
1246
|
-
this.unWireTimeListEvents();
|
|
1247
|
-
this.inputElement.removeAttribute('aria-activedescendant');
|
|
1248
|
-
remove(this.popupObject.element);
|
|
1249
|
-
this.popupObject.destroy();
|
|
1250
|
-
this.dateTimeWrapper.innerHTML = '';
|
|
1251
|
-
if (this.modelWrapper) {
|
|
1252
|
-
remove(this.modelWrapper);
|
|
1253
|
-
}
|
|
1254
|
-
this.listWrapper = this.dateTimeWrapper = undefined;
|
|
1255
|
-
if (this.inputEvent) {
|
|
1256
|
-
this.inputEvent.destroy();
|
|
1257
|
-
}
|
|
1258
|
-
}, targetExitViewport: () => {
|
|
1259
|
-
if (!Browser.isDevice) {
|
|
1260
|
-
this.hide();
|
|
1261
|
-
}
|
|
1262
|
-
}
|
|
1263
|
-
});
|
|
1264
|
-
if (Browser.isDevice && this.fullScreenMode){
|
|
1265
|
-
this.popupObject.element.style.maxHeight = '100%';
|
|
1266
|
-
this.popupObject.element.style.width = '100%';
|
|
1267
|
-
} else {
|
|
1268
|
-
this.popupObject.element.style.maxHeight = POPUPDIMENSION;
|
|
1269
|
-
}
|
|
1270
|
-
|
|
1271
|
-
if (Browser.isDevice && this.fullScreenMode) {
|
|
1272
|
-
const modelHeader: HTMLElement = this.createElement('div', { className: 'e-model-header' });
|
|
1273
|
-
const modelTitleSpan: HTMLElement = this.createElement('span', { className: 'e-model-title' });
|
|
1274
|
-
modelTitleSpan.textContent = 'Select time';
|
|
1275
|
-
const modelCloseIcon: HTMLElement = this.createElement('span', { className: 'e-popup-close' });
|
|
1276
|
-
EventHandler.add(modelCloseIcon, 'mousedown touchstart', this.dateTimeCloseHandler, this);
|
|
1277
|
-
modelHeader.appendChild(modelCloseIcon);
|
|
1278
|
-
modelHeader.appendChild(modelTitleSpan);
|
|
1279
|
-
this.dateTimeWrapper.insertBefore(modelHeader, this.dateTimeWrapper.firstElementChild);
|
|
1280
|
-
}
|
|
1281
|
-
}
|
|
1282
|
-
|
|
1283
|
-
private dateTimeCloseHandler(e: MouseEvent| TouchEvent): void {
|
|
1284
|
-
this.hide();
|
|
1285
|
-
}
|
|
1286
|
-
|
|
1287
|
-
private setDimension(width: number | string): string {
|
|
1288
|
-
if (typeof width === 'number') {
|
|
1289
|
-
width = formatUnit(width);
|
|
1290
|
-
} else if (typeof width === 'string') {
|
|
1291
|
-
// eslint-disable-next-line no-self-assign
|
|
1292
|
-
width = width;
|
|
1293
|
-
} else {
|
|
1294
|
-
width = '100%';
|
|
1295
|
-
}
|
|
1296
|
-
return width;
|
|
1297
|
-
}
|
|
1298
|
-
private setPopupWidth(): string {
|
|
1299
|
-
let width: string = this.setDimension(this.width);
|
|
1300
|
-
if (width.indexOf('%') > -1) {
|
|
1301
|
-
const inputWidth: number = this.containerStyle.width * parseFloat(width) / 100;
|
|
1302
|
-
width = inputWidth.toString() + 'px';
|
|
1303
|
-
}
|
|
1304
|
-
return width;
|
|
1305
|
-
}
|
|
1306
|
-
protected wireTimeListEvents(): void {
|
|
1307
|
-
EventHandler.add(this.listWrapper, 'click', this.onMouseClick, this);
|
|
1308
|
-
if (!Browser.isDevice) {
|
|
1309
|
-
EventHandler.add(this.listWrapper, 'mouseover', this.onMouseOver, this);
|
|
1310
|
-
EventHandler.add(this.listWrapper, 'mouseout', this.onMouseLeave, this);
|
|
1311
|
-
}
|
|
1312
|
-
}
|
|
1313
|
-
protected unWireTimeListEvents(): void {
|
|
1314
|
-
if (this.listWrapper) {
|
|
1315
|
-
EventHandler.remove(this.listWrapper, 'click', this.onMouseClick);
|
|
1316
|
-
EventHandler.remove(document, 'mousedown touchstart', this.documentClickHandler);
|
|
1317
|
-
if (!Browser.isDevice) {
|
|
1318
|
-
EventHandler.add(this.listWrapper, 'mouseover', this.onMouseOver, this);
|
|
1319
|
-
EventHandler.add(this.listWrapper, 'mouseout', this.onMouseLeave, this);
|
|
1320
|
-
}
|
|
1321
|
-
}
|
|
1322
|
-
}
|
|
1323
|
-
private onMouseOver(event: MouseEvent): void {
|
|
1324
|
-
const currentLi: HTMLElement = <HTMLElement>closest(<Element>event.target, '.' + LISTCLASS);
|
|
1325
|
-
this.setTimeHover(currentLi, HOVER);
|
|
1326
|
-
}
|
|
1327
|
-
private onMouseLeave(): void {
|
|
1328
|
-
this.removeTimeHover(HOVER);
|
|
1329
|
-
}
|
|
1330
|
-
private setTimeHover(li: HTMLElement, className: string): void {
|
|
1331
|
-
if (this.enabled && this.isValidLI(li) && !li.classList.contains(className)) {
|
|
1332
|
-
this.removeTimeHover(className);
|
|
1333
|
-
addClass([li], className);
|
|
1334
|
-
}
|
|
1335
|
-
}
|
|
1336
|
-
protected getPopupHeight(): number {
|
|
1337
|
-
const height: number = parseInt(<string>POPUPDIMENSION, 10);
|
|
1338
|
-
const popupHeight: number = this.dateTimeWrapper.getBoundingClientRect().height;
|
|
1339
|
-
if ( Browser.isDevice && this.fullScreenMode){
|
|
1340
|
-
return popupHeight;
|
|
1341
|
-
} else {
|
|
1342
|
-
return popupHeight > height ? height : popupHeight;
|
|
1343
|
-
}
|
|
1344
|
-
}
|
|
1345
|
-
protected changeEvent(e: Event): void {
|
|
1346
|
-
super.changeEvent(e);
|
|
1347
|
-
if ((this.value && this.value.valueOf()) !== (this.previousDateTime && +this.previousDateTime.valueOf())) {
|
|
1348
|
-
this.valueWithMinutes = this.value;
|
|
1349
|
-
this.setInputValue('date');
|
|
1350
|
-
this.previousDateTime = this.value && new Date(+this.value);
|
|
1351
|
-
}
|
|
1352
|
-
}
|
|
1353
|
-
private updateValue(e: KeyboardEvent | MouseEvent): void {
|
|
1354
|
-
this.setInputValue('time');
|
|
1355
|
-
if (+this.previousDateTime !== +this.value) {
|
|
1356
|
-
this.changedArgs = {
|
|
1357
|
-
value: this.value, event: e || null,
|
|
1358
|
-
isInteracted: !isNullOrUndefined(e),
|
|
1359
|
-
element: this.element
|
|
1360
|
-
};
|
|
1361
|
-
this.addTimeSelection();
|
|
1362
|
-
this.trigger('change', this.changedArgs);
|
|
1363
|
-
this.previousDateTime = this.previousDate = this.value;
|
|
1364
|
-
}
|
|
1365
|
-
}
|
|
1366
|
-
private setTimeScrollPosition(): void {
|
|
1367
|
-
const popupElement: HTMLElement = this.selectedElement;
|
|
1368
|
-
if (!isNullOrUndefined(popupElement)) {
|
|
1369
|
-
this.findScrollTop(popupElement);
|
|
1370
|
-
} else if (this.dateTimeWrapper && this.checkDateValue(this.scrollTo)) {
|
|
1371
|
-
this.setScrollTo();
|
|
1372
|
-
}
|
|
1373
|
-
}
|
|
1374
|
-
private findScrollTop(element: HTMLElement): void {
|
|
1375
|
-
const listHeight: number = this.getPopupHeight();
|
|
1376
|
-
const nextElement: Element = element.nextElementSibling;
|
|
1377
|
-
const height: number = nextElement ? (<HTMLElement>nextElement).offsetTop : element.offsetTop;
|
|
1378
|
-
const lineHeight: number = element.getBoundingClientRect().height;
|
|
1379
|
-
if ((height + element.offsetTop) > listHeight) {
|
|
1380
|
-
if (Browser.isDevice && this.fullScreenMode){
|
|
1381
|
-
const listContent: Element = this.dateTimeWrapper.querySelector('.e-content');
|
|
1382
|
-
listContent.scrollTop = nextElement ? (height - (listHeight / HALFPOSITION + lineHeight / HALFPOSITION)) : height;
|
|
1383
|
-
} else {
|
|
1384
|
-
this.dateTimeWrapper.scrollTop = nextElement ? (height - (listHeight / HALFPOSITION + lineHeight / HALFPOSITION)) : height;
|
|
1385
|
-
}
|
|
1386
|
-
} else {
|
|
1387
|
-
this.dateTimeWrapper.scrollTop = 0;
|
|
1388
|
-
}
|
|
1389
|
-
}
|
|
1390
|
-
private setScrollTo(): void {
|
|
1391
|
-
let element: HTMLElement;
|
|
1392
|
-
const items: HTMLElement[] = <NodeListOf<HTMLLIElement> & HTMLElement[]>this.dateTimeWrapper.querySelectorAll('.' + LISTCLASS);
|
|
1393
|
-
if (items.length >= 0) {
|
|
1394
|
-
this.scrollInvoked = true;
|
|
1395
|
-
const initialTime: number = this.timeCollections[0];
|
|
1396
|
-
const scrollTime: number = this.getDateObject(this.checkDateValue(this.scrollTo)).getTime();
|
|
1397
|
-
element = items[Math.round((scrollTime - initialTime) / (this.step * 60000))];
|
|
1398
|
-
} else {
|
|
1399
|
-
this.dateTimeWrapper.scrollTop = 0;
|
|
1400
|
-
}
|
|
1401
|
-
if (!isNullOrUndefined(element)) {
|
|
1402
|
-
this.findScrollTop(element);
|
|
1403
|
-
} else {
|
|
1404
|
-
this.dateTimeWrapper.scrollTop = 0;
|
|
1405
|
-
}
|
|
1406
|
-
}
|
|
1407
|
-
private setInputValue(type: string): void {
|
|
1408
|
-
if (type === 'date') {
|
|
1409
|
-
this.inputElement.value = this.previousElementValue = this.getFormattedValue(this.getFullDateTime());
|
|
1410
|
-
this.setProperties({ value: this.getFullDateTime() }, true);
|
|
1411
|
-
} else {
|
|
1412
|
-
const tempVal: string = this.getFormattedValue(new Date(this.timeCollections[this.activeIndex]));
|
|
1413
|
-
Input.setValue(tempVal, this.inputElement, this.floatLabelType, this.showClearButton);
|
|
1414
|
-
this.previousElementValue = this.inputElement.value;
|
|
1415
|
-
this.setProperties({ value: new Date(this.timeCollections[this.activeIndex]) }, true);
|
|
1416
|
-
if (this.enableMask)
|
|
1417
|
-
{
|
|
1418
|
-
this.createMask();
|
|
1419
|
-
}
|
|
1420
|
-
}
|
|
1421
|
-
this.updateIconState();
|
|
1422
|
-
}
|
|
1423
|
-
private getFullDateTime(): Date {
|
|
1424
|
-
let value: Date = null;
|
|
1425
|
-
if (this.isDateObject(this.valueWithMinutes)) {
|
|
1426
|
-
value = this.combineDateTime(this.valueWithMinutes);
|
|
1427
|
-
} else {
|
|
1428
|
-
value = this.previousDate;
|
|
1429
|
-
}
|
|
1430
|
-
return this.validateMinMaxRange(value);
|
|
1431
|
-
}
|
|
1432
|
-
private createMask(): void {
|
|
1433
|
-
this.notify('createMask', {
|
|
1434
|
-
module: 'MaskedDateTime'
|
|
1435
|
-
});
|
|
1436
|
-
}
|
|
1437
|
-
private combineDateTime(value: Date): Date {
|
|
1438
|
-
if (this.isDateObject(value)) {
|
|
1439
|
-
const day: number = this.previousDate.getDate();
|
|
1440
|
-
const month: number = this.previousDate.getMonth();
|
|
1441
|
-
const year: number = this.previousDate.getFullYear();
|
|
1442
|
-
const hour: number = value.getHours();
|
|
1443
|
-
const minutes: number = value.getMinutes();
|
|
1444
|
-
const seconds: number = value.getSeconds();
|
|
1445
|
-
return new Date(year, month, day, hour, minutes, seconds);
|
|
1446
|
-
} else {
|
|
1447
|
-
return this.previousDate;
|
|
1448
|
-
}
|
|
1449
|
-
}
|
|
1450
|
-
private onMouseClick(event: MouseEvent): void {
|
|
1451
|
-
const target: Element = <Element>event.target;
|
|
1452
|
-
const li: HTMLElement = this.selectedElement = <HTMLElement>closest(target, '.' + LISTCLASS);
|
|
1453
|
-
if (li && li.classList.contains(LISTCLASS)) {
|
|
1454
|
-
this.timeValue = li.getAttribute('data-value');
|
|
1455
|
-
this.hide(event);
|
|
1456
|
-
}
|
|
1457
|
-
this.setSelection(li, event);
|
|
1458
|
-
}
|
|
1459
|
-
private setSelection(li: HTMLElement, event: MouseEvent): void {
|
|
1460
|
-
if (this.isValidLI(li) && !li.classList.contains(ACTIVE)) {
|
|
1461
|
-
this.selectedElement = li;
|
|
1462
|
-
const index: number = Array.prototype.slice.call(this.liCollections).indexOf(li);
|
|
1463
|
-
this.activeIndex = index;
|
|
1464
|
-
this.valueWithMinutes = new Date(this.timeCollections[this.activeIndex]);
|
|
1465
|
-
addClass([this.selectedElement], ACTIVE);
|
|
1466
|
-
this.selectedElement.setAttribute('aria-selected', 'true');
|
|
1467
|
-
this.updateValue(event);
|
|
1468
|
-
}
|
|
1469
|
-
}
|
|
1470
|
-
private setTimeActiveClass(): void {
|
|
1471
|
-
const collections: HTMLElement = isNullOrUndefined(this.dateTimeWrapper) ? this.listWrapper : this.dateTimeWrapper;
|
|
1472
|
-
if (!isNullOrUndefined(collections)) {
|
|
1473
|
-
const items: HTMLElement[] = <NodeListOf<HTMLLIElement> & HTMLElement[]>collections.querySelectorAll('.' + LISTCLASS);
|
|
1474
|
-
if (items.length) {
|
|
1475
|
-
for (let i: number = 0; i < items.length; i++) {
|
|
1476
|
-
if (this.timeCollections[i as number] === +(this.valueWithMinutes)) {
|
|
1477
|
-
items[i as number].setAttribute('aria-selected', 'true');
|
|
1478
|
-
this.selectedElement = items[i as number];
|
|
1479
|
-
this.activeIndex = i;
|
|
1480
|
-
this.setTimeActiveDescendant();
|
|
1481
|
-
break;
|
|
1482
|
-
}
|
|
1483
|
-
}
|
|
1484
|
-
}
|
|
1485
|
-
}
|
|
1486
|
-
}
|
|
1487
|
-
private setTimeActiveDescendant(): void {
|
|
1488
|
-
if (!isNullOrUndefined(this.selectedElement) && this.value) {
|
|
1489
|
-
attributes(this.inputElement, { 'aria-activedescendant': this.selectedElement.getAttribute('id') });
|
|
1490
|
-
} else {
|
|
1491
|
-
this.inputElement.removeAttribute('aria-activedescendant');
|
|
1492
|
-
}
|
|
1493
|
-
}
|
|
1494
|
-
protected addTimeSelection(): void {
|
|
1495
|
-
this.selectedElement = null;
|
|
1496
|
-
this.removeTimeSelection();
|
|
1497
|
-
this.setTimeActiveClass();
|
|
1498
|
-
if (!isNullOrUndefined(this.selectedElement)) {
|
|
1499
|
-
addClass([this.selectedElement], ACTIVE);
|
|
1500
|
-
this.selectedElement.setAttribute('aria-selected', 'true');
|
|
1501
|
-
}
|
|
1502
|
-
}
|
|
1503
|
-
protected removeTimeSelection(): void {
|
|
1504
|
-
this.removeTimeHover(HOVER);
|
|
1505
|
-
if (!isNullOrUndefined(this.dateTimeWrapper)) {
|
|
1506
|
-
const items: Element[] = <NodeListOf<Element> & Element[]>this.dateTimeWrapper.querySelectorAll('.' + ACTIVE);
|
|
1507
|
-
if (items.length) {
|
|
1508
|
-
removeClass(items, ACTIVE);
|
|
1509
|
-
items[0].removeAttribute('aria-selected');
|
|
1510
|
-
}
|
|
1511
|
-
}
|
|
1512
|
-
}
|
|
1513
|
-
protected removeTimeHover(className: string): void {
|
|
1514
|
-
const hoveredItem: Element[] = this.getTimeHoverItem(className);
|
|
1515
|
-
if (hoveredItem && hoveredItem.length) {
|
|
1516
|
-
removeClass(hoveredItem, className);
|
|
1517
|
-
}
|
|
1518
|
-
}
|
|
1519
|
-
protected getTimeHoverItem(className: string): Element[] {
|
|
1520
|
-
const collections: HTMLElement = isNullOrUndefined(this.dateTimeWrapper) ? this.listWrapper : this.dateTimeWrapper;
|
|
1521
|
-
let hoveredItem: Element[];
|
|
1522
|
-
if (!isNullOrUndefined(collections)) {
|
|
1523
|
-
hoveredItem = <NodeListOf<HTMLLIElement> & Element[]>collections.querySelectorAll('.' + className);
|
|
1524
|
-
}
|
|
1525
|
-
return hoveredItem;
|
|
1526
|
-
}
|
|
1527
|
-
protected isValidLI(li: Element | HTMLElement): boolean {
|
|
1528
|
-
return (li && li.classList.contains(LISTCLASS) && !li.classList.contains(DISABLED));
|
|
1529
|
-
}
|
|
1530
|
-
private calculateStartEnd(value: Date, range: boolean, method: string): Date {
|
|
1531
|
-
const day: number = value.getDate();
|
|
1532
|
-
const month: number = value.getMonth();
|
|
1533
|
-
const year: number = value.getFullYear();
|
|
1534
|
-
const hours: number = value.getHours();
|
|
1535
|
-
const minutes: number = value.getMinutes();
|
|
1536
|
-
const seconds: number = value.getSeconds();
|
|
1537
|
-
const milliseconds: number = value.getMilliseconds();
|
|
1538
|
-
if (range) {
|
|
1539
|
-
if (method === 'starttime') {
|
|
1540
|
-
return new Date(year, month, day, 0, 0, 0);
|
|
1541
|
-
} else {
|
|
1542
|
-
return new Date(year, month, day, 23, 59, 59);
|
|
1543
|
-
}
|
|
1544
|
-
} else {
|
|
1545
|
-
return new Date(year, month, day, hours, minutes, seconds, milliseconds);
|
|
1546
|
-
}
|
|
1547
|
-
}
|
|
1548
|
-
private startTime(date: Date): Date {
|
|
1549
|
-
let tempStartValue: Date;
|
|
1550
|
-
let start: boolean;
|
|
1551
|
-
const tempMin: Date = this.min;
|
|
1552
|
-
const tempMax: Date = this.max;
|
|
1553
|
-
const value: Date = date === null ? new Date() : date;
|
|
1554
|
-
let isModified: boolean = false;
|
|
1555
|
-
let startValue: Date;
|
|
1556
|
-
if (this.minTime) {
|
|
1557
|
-
startValue = new Date(
|
|
1558
|
-
value.getFullYear(),
|
|
1559
|
-
value.getMonth(),
|
|
1560
|
-
value.getDate(),
|
|
1561
|
-
this.minTime.getHours(),
|
|
1562
|
-
this.minTime.getMinutes(),
|
|
1563
|
-
this.minTime.getSeconds(),
|
|
1564
|
-
this.minTime.getMilliseconds()
|
|
1565
|
-
);
|
|
1566
|
-
isModified = true;
|
|
1567
|
-
} else {
|
|
1568
|
-
startValue = value;
|
|
1569
|
-
}
|
|
1570
|
-
if ((+startValue.getDate() === +tempMin.getDate() && +startValue.getMonth() === +tempMin.getMonth() &&
|
|
1571
|
-
+startValue.getFullYear() === +tempMin.getFullYear()) ||
|
|
1572
|
-
((+new Date(startValue.getFullYear(), startValue.getMonth(), startValue.getDate())) <=
|
|
1573
|
-
+new Date(tempMin.getFullYear(), tempMin.getMonth(), tempMin.getDate()))) {
|
|
1574
|
-
start = false;
|
|
1575
|
-
tempStartValue = tempMin;
|
|
1576
|
-
if (isModified && ((+new Date(startValue.getFullYear(), startValue.getMonth(), startValue.getDate(), startValue.getHours(),
|
|
1577
|
-
startValue.getMinutes(), startValue.getSeconds(), startValue.getMilliseconds())) >=
|
|
1578
|
-
+new Date(tempMin.getFullYear(), tempMin.getMonth(), tempMin.getDate(), tempMin.getHours(),
|
|
1579
|
-
tempMin.getMinutes(), tempMin.getSeconds(), tempMin.getMilliseconds()))) {
|
|
1580
|
-
tempStartValue.setHours(startValue.getHours(), startValue.getMinutes(), startValue.getSeconds(),
|
|
1581
|
-
startValue.getMilliseconds());
|
|
1582
|
-
}
|
|
1583
|
-
} else if (+startValue < +tempMax && +startValue > +tempMin) {
|
|
1584
|
-
start = !isModified;
|
|
1585
|
-
tempStartValue = startValue;
|
|
1586
|
-
} else if (+startValue >= +tempMax) {
|
|
1587
|
-
start = true;
|
|
1588
|
-
tempStartValue = tempMax;
|
|
1589
|
-
}
|
|
1590
|
-
return this.calculateStartEnd(tempStartValue, start, 'starttime');
|
|
1591
|
-
}
|
|
1592
|
-
|
|
1593
|
-
private TimePopupFormat(): any {
|
|
1594
|
-
let format: string = '';
|
|
1595
|
-
let formatCount: number = 0;
|
|
1596
|
-
const proxy: DateTimePicker = null || this;
|
|
1597
|
-
|
|
1598
|
-
/**
|
|
1599
|
-
* Formats the value specifier.
|
|
1600
|
-
*
|
|
1601
|
-
* @param {string} formattext - The format text.
|
|
1602
|
-
* @returns {string} The formatted value specifier.
|
|
1603
|
-
*/
|
|
1604
|
-
function formatValueSpecifier(formattext: string): string {
|
|
1605
|
-
switch (formattext) {
|
|
1606
|
-
case 'd':
|
|
1607
|
-
case 'dd':
|
|
1608
|
-
case 'ddd':
|
|
1609
|
-
case 'dddd':
|
|
1610
|
-
case 'M':
|
|
1611
|
-
case 'MM':
|
|
1612
|
-
case 'MMM':
|
|
1613
|
-
case 'MMMM':
|
|
1614
|
-
case 'y':
|
|
1615
|
-
case 'yy':
|
|
1616
|
-
case 'yyy':
|
|
1617
|
-
case 'yyyy':
|
|
1618
|
-
if (format === '') {
|
|
1619
|
-
format = format + formattext;
|
|
1620
|
-
}
|
|
1621
|
-
else {
|
|
1622
|
-
format = format + '/' + formattext;
|
|
1623
|
-
}
|
|
1624
|
-
formatCount = formatCount + 1;
|
|
1625
|
-
break;
|
|
1626
|
-
}
|
|
1627
|
-
if (formatCount > 2) {
|
|
1628
|
-
proxy.dateFormatString = format;
|
|
1629
|
-
}
|
|
1630
|
-
return format;
|
|
1631
|
-
}
|
|
1632
|
-
return formatValueSpecifier;
|
|
1633
|
-
}
|
|
1634
|
-
|
|
1635
|
-
private endTime(date: Date): Date {
|
|
1636
|
-
let tempEndValue: Date;
|
|
1637
|
-
let end: boolean;
|
|
1638
|
-
const tempMax: Date = this.max;
|
|
1639
|
-
const value: Date = date === null ? new Date() : date;
|
|
1640
|
-
let isModified: boolean = false;
|
|
1641
|
-
let endValue: Date;
|
|
1642
|
-
if (this.maxTime) {
|
|
1643
|
-
endValue = new Date(
|
|
1644
|
-
value.getFullYear(),
|
|
1645
|
-
value.getMonth(),
|
|
1646
|
-
value.getDate(),
|
|
1647
|
-
this.maxTime.getHours(),
|
|
1648
|
-
this.maxTime.getMinutes(),
|
|
1649
|
-
this.maxTime.getSeconds(),
|
|
1650
|
-
this.maxTime.getMilliseconds()
|
|
1651
|
-
);
|
|
1652
|
-
isModified = true;
|
|
1653
|
-
} else {
|
|
1654
|
-
endValue = value;
|
|
1655
|
-
}
|
|
1656
|
-
if ((+endValue.getDate() === +tempMax.getDate() && +endValue.getMonth() === +tempMax.getMonth() &&
|
|
1657
|
-
+endValue.getFullYear() === +tempMax.getFullYear()) ||
|
|
1658
|
-
(+new Date(endValue.getUTCFullYear(), endValue.getMonth(), endValue.getDate()) >=
|
|
1659
|
-
+new Date(tempMax.getFullYear(), tempMax.getMonth(), tempMax.getDate()))) {
|
|
1660
|
-
end = false;
|
|
1661
|
-
tempEndValue = this.max;
|
|
1662
|
-
if (isModified && (+new Date(endValue.getUTCFullYear(), endValue.getMonth(), endValue.getDate(), endValue.getHours(),
|
|
1663
|
-
endValue.getMinutes(), endValue.getSeconds(), endValue.getMilliseconds()) <=
|
|
1664
|
-
+new Date(tempMax.getFullYear(), tempMax.getMonth(), tempMax.getDate(), tempMax.getHours(),
|
|
1665
|
-
tempMax.getMinutes(), tempMax.getSeconds(), tempMax.getMilliseconds()))) {
|
|
1666
|
-
tempEndValue.setHours(endValue.getHours(), endValue.getMinutes(), endValue.getSeconds(), endValue.getMilliseconds());
|
|
1667
|
-
}
|
|
1668
|
-
} else if (+endValue < +this.max && +endValue > +this.min) {
|
|
1669
|
-
end = !isModified;
|
|
1670
|
-
tempEndValue = endValue;
|
|
1671
|
-
} else if (+endValue <= +this.min) {
|
|
1672
|
-
end = true;
|
|
1673
|
-
tempEndValue = this.min;
|
|
1674
|
-
}
|
|
1675
|
-
return this.calculateStartEnd(tempEndValue, end, 'endtime');
|
|
1676
|
-
}
|
|
1677
|
-
public hide(e?: KeyboardEvent | MouseEvent | Event): void {
|
|
1678
|
-
if (this.popupObj || this.dateTimeWrapper) {
|
|
1679
|
-
this.preventArgs = {
|
|
1680
|
-
cancel: false,
|
|
1681
|
-
popup: this.popupObj || this.popupObject,
|
|
1682
|
-
event: e || null
|
|
1683
|
-
};
|
|
1684
|
-
const eventArgs: PopupObjectArgs = this.preventArgs;
|
|
1685
|
-
if (isNullOrUndefined(this.popupObj)) {
|
|
1686
|
-
this.trigger('close', eventArgs, (eventArgs: PopupObjectArgs) => {
|
|
1687
|
-
this.dateTimeCloseEventCallback(e, eventArgs);
|
|
1688
|
-
});
|
|
1689
|
-
} else {
|
|
1690
|
-
this.dateTimeCloseEventCallback(e, eventArgs);
|
|
1691
|
-
}
|
|
1692
|
-
} else {
|
|
1693
|
-
if (Browser.isDevice && this.allowEdit && !this.readonly) {
|
|
1694
|
-
this.inputElement.removeAttribute('readonly');
|
|
1695
|
-
}
|
|
1696
|
-
this.setAllowEdit();
|
|
1697
|
-
}
|
|
1698
|
-
}
|
|
1699
|
-
private dateTimeCloseEventCallback(e?: KeyboardEvent | MouseEvent | Event, eventArgs?: PopupObjectArgs): void {
|
|
1700
|
-
this.preventArgs = eventArgs;
|
|
1701
|
-
if (!this.preventArgs.cancel) {
|
|
1702
|
-
if (this.isDatePopupOpen()) {
|
|
1703
|
-
super.hide(e);
|
|
1704
|
-
} else if (this.isTimePopupOpen()) {
|
|
1705
|
-
this.closePopup(e);
|
|
1706
|
-
removeClass([document.body], OVERFLOW);
|
|
1707
|
-
if (Browser.isDevice && this.timeModal) {
|
|
1708
|
-
this.timeModal.style.display = 'none';
|
|
1709
|
-
this.timeModal.outerHTML = '';
|
|
1710
|
-
this.timeModal = null;
|
|
1711
|
-
}
|
|
1712
|
-
this.setTimeActiveDescendant();
|
|
1713
|
-
}
|
|
1714
|
-
}
|
|
1715
|
-
if (Browser.isDevice && this.allowEdit && !this.readonly) {
|
|
1716
|
-
this.inputElement.removeAttribute('readonly');
|
|
1717
|
-
}
|
|
1718
|
-
this.setAllowEdit();
|
|
1719
|
-
}
|
|
1720
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1721
|
-
private closePopup(e?: KeyboardEvent | MouseEvent | Event): void {
|
|
1722
|
-
if (this.isTimePopupOpen() && this.popupObject) {
|
|
1723
|
-
const animModel: AnimationModel = {
|
|
1724
|
-
name: 'FadeOut',
|
|
1725
|
-
duration: ANIMATIONDURATION,
|
|
1726
|
-
delay: 0
|
|
1727
|
-
};
|
|
1728
|
-
this.popupObject.hide(new Animation(animModel));
|
|
1729
|
-
this.inputWrapper.container.classList.remove(ICONANIMATION);
|
|
1730
|
-
attributes(this.inputElement, { 'aria-expanded': 'false' });
|
|
1731
|
-
this.inputElement.removeAttribute('aria-owns');
|
|
1732
|
-
this.inputElement.removeAttribute('aria-controls');
|
|
1733
|
-
EventHandler.remove(document, 'mousedown touchstart', this.documentClickHandler);
|
|
1734
|
-
}
|
|
1735
|
-
}
|
|
1736
|
-
protected preRender(): void {
|
|
1737
|
-
this.checkFormat();
|
|
1738
|
-
this.dateTimeFormat = this.cldrDateTimeFormat();
|
|
1739
|
-
super.preRender();
|
|
1740
|
-
removeClass([this.inputElementCopy], [ROOT]);
|
|
1741
|
-
}
|
|
1742
|
-
protected getProperty(date: DateTimePickerModel, val: string): void {
|
|
1743
|
-
if (val === 'min') {
|
|
1744
|
-
this.setProperties({ min: this.validateValue(date.min) }, true);
|
|
1745
|
-
} else {
|
|
1746
|
-
this.setProperties({ max: this.validateValue(date.max) }, true);
|
|
1747
|
-
}
|
|
1748
|
-
}
|
|
1749
|
-
|
|
1750
|
-
protected checkAttributes(isDynamic: boolean): void {
|
|
1751
|
-
const attributes: string[] = isDynamic ? isNullOrUndefined(this.htmlAttributes) ? [] : Object.keys(this.htmlAttributes) :
|
|
1752
|
-
['style', 'name', 'step', 'disabled', 'readonly', 'value', 'min', 'max', 'placeholder', 'type'];
|
|
1753
|
-
let value: Date;
|
|
1754
|
-
for (const prop of attributes) {
|
|
1755
|
-
if (!isNullOrUndefined(this.inputElement.getAttribute(prop))) {
|
|
1756
|
-
switch (prop) {
|
|
1757
|
-
case 'name':
|
|
1758
|
-
this.inputElement.setAttribute('name', this.inputElement.getAttribute(prop));
|
|
1759
|
-
break;
|
|
1760
|
-
case 'step':
|
|
1761
|
-
this.step = parseInt(this.inputElement.getAttribute(prop), 10);
|
|
1762
|
-
break;
|
|
1763
|
-
case 'readonly':
|
|
1764
|
-
if (( isNullOrUndefined(this.dateTimeOptions) || (this.dateTimeOptions['readonly'] === undefined)) || isDynamic) {
|
|
1765
|
-
const readonly: boolean = this.inputElement.getAttribute(prop) === 'disabled' ||
|
|
1766
|
-
this.inputElement.getAttribute(prop) === '' ||
|
|
1767
|
-
this.inputElement.getAttribute(prop) === 'true' ? true : false;
|
|
1768
|
-
this.setProperties({ readonly: readonly }, !isDynamic);
|
|
1769
|
-
}
|
|
1770
|
-
break;
|
|
1771
|
-
case 'placeholder':
|
|
1772
|
-
if (( isNullOrUndefined(this.dateTimeOptions) || (this.dateTimeOptions['placeholder'] === undefined)) || isDynamic) {
|
|
1773
|
-
this.setProperties({ placeholder: this.inputElement.getAttribute(prop) }, !isDynamic);
|
|
1774
|
-
}
|
|
1775
|
-
break;
|
|
1776
|
-
case 'min':
|
|
1777
|
-
if (( isNullOrUndefined(this.dateTimeOptions) || (this.dateTimeOptions['min'] === undefined)) || isDynamic) {
|
|
1778
|
-
value = new Date(this.inputElement.getAttribute(prop));
|
|
1779
|
-
if (!this.isNullOrEmpty(value) && !isNaN(+value)) {
|
|
1780
|
-
this.setProperties({ min: value }, !isDynamic);
|
|
1781
|
-
}
|
|
1782
|
-
}
|
|
1783
|
-
break;
|
|
1784
|
-
case 'disabled':
|
|
1785
|
-
if (( isNullOrUndefined(this.dateTimeOptions) || (this.dateTimeOptions['enabled'] === undefined)) || isDynamic) {
|
|
1786
|
-
const enabled: boolean = this.inputElement.getAttribute(prop) === 'disabled' ||
|
|
1787
|
-
this.inputElement.getAttribute(prop) === 'true' ||
|
|
1788
|
-
this.inputElement.getAttribute(prop) === '' ? false : true;
|
|
1789
|
-
this.setProperties({ enabled: enabled }, !isDynamic);
|
|
1790
|
-
}
|
|
1791
|
-
break;
|
|
1792
|
-
case 'value':
|
|
1793
|
-
if (( isNullOrUndefined(this.dateTimeOptions) || (this.dateTimeOptions['value'] === undefined)) || isDynamic) {
|
|
1794
|
-
value = new Date(this.inputElement.getAttribute(prop));
|
|
1795
|
-
if (!this.isNullOrEmpty(value) && !isNaN(+value)) {
|
|
1796
|
-
this.setProperties({ value: value }, !isDynamic);
|
|
1797
|
-
}
|
|
1798
|
-
}
|
|
1799
|
-
break;
|
|
1800
|
-
case 'max':
|
|
1801
|
-
if (( isNullOrUndefined(this.dateTimeOptions) || (this.dateTimeOptions['max'] === undefined)) || isDynamic) {
|
|
1802
|
-
value = new Date(this.inputElement.getAttribute(prop));
|
|
1803
|
-
if (!this.isNullOrEmpty(value) && !isNaN(+value)) {
|
|
1804
|
-
this.setProperties({ max: value }, !isDynamic);
|
|
1805
|
-
}
|
|
1806
|
-
}
|
|
1807
|
-
break;
|
|
1808
|
-
}
|
|
1809
|
-
}
|
|
1810
|
-
}
|
|
1811
|
-
}
|
|
1812
|
-
|
|
1813
|
-
public requiredModules(): ModuleDeclaration[] {
|
|
1814
|
-
const modules: ModuleDeclaration[] = [];
|
|
1815
|
-
if (this.calendarMode === 'Islamic') {
|
|
1816
|
-
modules.push({ args: [this], member: 'islamic', name: 'Islamic' });
|
|
1817
|
-
}
|
|
1818
|
-
if (this.enableMask)
|
|
1819
|
-
{
|
|
1820
|
-
modules.push(this.maskedDateModule());
|
|
1821
|
-
}
|
|
1822
|
-
|
|
1823
|
-
return modules;
|
|
1824
|
-
}
|
|
1825
|
-
|
|
1826
|
-
private maskedDateModule(): ModuleDeclaration
|
|
1827
|
-
{
|
|
1828
|
-
const modules: ModuleDeclaration = {args: [this], member: 'MaskedDateTime'};
|
|
1829
|
-
return modules;
|
|
1830
|
-
}
|
|
1831
|
-
|
|
1832
|
-
private getTimeActiveElement(): HTMLElement[] {
|
|
1833
|
-
if (!isNullOrUndefined(this.dateTimeWrapper)) {
|
|
1834
|
-
return <NodeListOf<HTMLElement> & HTMLElement[]>this.dateTimeWrapper.querySelectorAll('.' + ACTIVE);
|
|
1835
|
-
} else {
|
|
1836
|
-
return null;
|
|
1837
|
-
}
|
|
1838
|
-
}
|
|
1839
|
-
protected createDateObj(val: Date | string): Date {
|
|
1840
|
-
return val instanceof Date ? val : null;
|
|
1841
|
-
}
|
|
1842
|
-
private getDateObject(text: string | Date): Date {
|
|
1843
|
-
if (!this.isNullOrEmpty(text)) {
|
|
1844
|
-
const dateValue: Date = this.createDateObj(text);
|
|
1845
|
-
const value: Date = this.valueWithMinutes;
|
|
1846
|
-
const status: boolean = !isNullOrUndefined(value);
|
|
1847
|
-
if (this.checkDateValue(dateValue)) {
|
|
1848
|
-
const date: number = status ? value.getDate() : DAY;
|
|
1849
|
-
const month: number = status ? value.getMonth() : MONTH;
|
|
1850
|
-
const year: number = status ? value.getFullYear() : YEAR;
|
|
1851
|
-
const hour: number = status ? value.getHours() : HOUR;
|
|
1852
|
-
const minute: number = status ? value.getMinutes() : MINUTE;
|
|
1853
|
-
const second: number = status ? value.getSeconds() : SECOND;
|
|
1854
|
-
const millisecond: number = status ? value.getMilliseconds() : MILLISECOND;
|
|
1855
|
-
if (!this.scrollInvoked) {
|
|
1856
|
-
return new Date(year, month, date, hour, minute, second, millisecond);
|
|
1857
|
-
} else {
|
|
1858
|
-
this.scrollInvoked = false;
|
|
1859
|
-
return new Date(
|
|
1860
|
-
year, month, date, dateValue.getHours(), dateValue.getMinutes(), dateValue.getSeconds(), dateValue.getMilliseconds()
|
|
1861
|
-
);
|
|
1862
|
-
}
|
|
1863
|
-
}
|
|
1864
|
-
}
|
|
1865
|
-
return null;
|
|
1866
|
-
}
|
|
1867
|
-
protected findNextTimeElement(event: KeyboardEventArgs): void {
|
|
1868
|
-
const textVal: string = (this.inputElement).value;
|
|
1869
|
-
const value: Date = isNullOrUndefined(this.valueWithMinutes) ? this.createDateObj(textVal) :
|
|
1870
|
-
this.getDateObject(this.valueWithMinutes);
|
|
1871
|
-
let dateTimeVal: number = null;
|
|
1872
|
-
const listCount: number = this.liCollections.length;
|
|
1873
|
-
if (!isNullOrUndefined(this.activeIndex) || !isNullOrUndefined(this.checkDateValue(value))) {
|
|
1874
|
-
if (event.action === 'home') {
|
|
1875
|
-
dateTimeVal = +(this.createDateObj(new Date(this.timeCollections[0])));
|
|
1876
|
-
this.activeIndex = 0;
|
|
1877
|
-
} else if (event.action === 'end') {
|
|
1878
|
-
dateTimeVal = +(this.createDateObj(new Date(this.timeCollections[this.timeCollections.length - 1])));
|
|
1879
|
-
this.activeIndex = this.timeCollections.length - 1;
|
|
1880
|
-
} else {
|
|
1881
|
-
if (event.action === 'down') {
|
|
1882
|
-
for (let i: number = 0; i < listCount; i++) {
|
|
1883
|
-
if (+value < this.timeCollections[i as number]) {
|
|
1884
|
-
dateTimeVal = +(this.createDateObj(new Date(this.timeCollections[i as number])));
|
|
1885
|
-
this.activeIndex = i;
|
|
1886
|
-
break;
|
|
1887
|
-
}
|
|
1888
|
-
}
|
|
1889
|
-
} else {
|
|
1890
|
-
for (let i: number = listCount - 1; i >= 0; i--) {
|
|
1891
|
-
if (+value > this.timeCollections[i as number]) {
|
|
1892
|
-
dateTimeVal = +(this.createDateObj(new Date(this.timeCollections[i as number])));
|
|
1893
|
-
this.activeIndex = i;
|
|
1894
|
-
break;
|
|
1895
|
-
}
|
|
1896
|
-
}
|
|
1897
|
-
}
|
|
1898
|
-
}
|
|
1899
|
-
this.selectedElement = this.liCollections[this.activeIndex];
|
|
1900
|
-
this.timeElementValue(isNullOrUndefined(dateTimeVal) ? null : new Date(dateTimeVal));
|
|
1901
|
-
}
|
|
1902
|
-
}
|
|
1903
|
-
|
|
1904
|
-
protected setTimeValue(date: Date, value: Date): Date {
|
|
1905
|
-
let dateString: string;
|
|
1906
|
-
let time: Date;
|
|
1907
|
-
const val: string | Date = this.validateMinMaxRange(value);
|
|
1908
|
-
const newval: Date = this.createDateObj(val);
|
|
1909
|
-
if (this.getFormattedValue(newval) !== (!isNullOrUndefined(this.value) ? this.getFormattedValue(this.value) : null)) {
|
|
1910
|
-
this.valueWithMinutes = isNullOrUndefined(newval) ? null : newval;
|
|
1911
|
-
time = new Date(+this.valueWithMinutes);
|
|
1912
|
-
} else {
|
|
1913
|
-
if (this.strictMode) {
|
|
1914
|
-
//for strict mode case, when value not present within a range. Reset the nearest range value.
|
|
1915
|
-
date = newval;
|
|
1916
|
-
}
|
|
1917
|
-
this.valueWithMinutes = this.checkDateValue(date);
|
|
1918
|
-
time = new Date(+this.valueWithMinutes);
|
|
1919
|
-
}
|
|
1920
|
-
if (this.calendarMode === 'Gregorian') {
|
|
1921
|
-
dateString = this.globalize.formatDate(time, {
|
|
1922
|
-
format: !isNullOrUndefined(this.formatString) ? this.formatString : this.cldrDateTimeFormat(),
|
|
1923
|
-
type: 'dateTime', skeleton: 'yMd'
|
|
1924
|
-
});
|
|
1925
|
-
} else {
|
|
1926
|
-
dateString = this.globalize.formatDate(time, {
|
|
1927
|
-
format: !isNullOrUndefined(this.formatString) ? this.formatString : this.cldrDateTimeFormat(),
|
|
1928
|
-
type: 'dateTime', skeleton: 'yMd', calendar: 'islamic'
|
|
1929
|
-
});
|
|
1930
|
-
}
|
|
1931
|
-
|
|
1932
|
-
if (!this.strictMode && isNullOrUndefined(time)) {
|
|
1933
|
-
Input.setValue(dateString, this.inputElement, this.floatLabelType, this.showClearButton);
|
|
1934
|
-
} else {
|
|
1935
|
-
Input.setValue(dateString, this.inputElement, this.floatLabelType, this.showClearButton);
|
|
1936
|
-
}
|
|
1937
|
-
return time;
|
|
1938
|
-
}
|
|
1939
|
-
protected timeElementValue(value: Date): Date {
|
|
1940
|
-
if (!isNullOrUndefined(this.checkDateValue(value)) && !this.isNullOrEmpty(value)) {
|
|
1941
|
-
const date: Date = value instanceof Date ? value : this.getDateObject(value);
|
|
1942
|
-
return this.setTimeValue(date, value);
|
|
1943
|
-
}
|
|
1944
|
-
return null;
|
|
1945
|
-
}
|
|
1946
|
-
protected timeKeyHandler(event: KeyboardEventArgs): void {
|
|
1947
|
-
if (isNullOrUndefined(this.step) || this.step <= 0) {
|
|
1948
|
-
return;
|
|
1949
|
-
}
|
|
1950
|
-
const listCount: number = this.timeCollections.length;
|
|
1951
|
-
if (isNullOrUndefined(this.getTimeActiveElement()) || this.getTimeActiveElement().length === 0) {
|
|
1952
|
-
if (this.liCollections.length > 0) {
|
|
1953
|
-
if (isNullOrUndefined(this.value) && isNullOrUndefined(this.activeIndex)) {
|
|
1954
|
-
this.activeIndex = 0;
|
|
1955
|
-
this.selectedElement = this.liCollections[0];
|
|
1956
|
-
this.timeElementValue(new Date(this.timeCollections[0]));
|
|
1957
|
-
} else {
|
|
1958
|
-
this.findNextTimeElement(event);
|
|
1959
|
-
}
|
|
1960
|
-
}
|
|
1961
|
-
} else {
|
|
1962
|
-
let nextItemValue: number;
|
|
1963
|
-
if ((event.keyCode >= 37) && (event.keyCode <= 40)) {
|
|
1964
|
-
let index: number = (event.keyCode === 40 || event.keyCode === 39) ? ++this.activeIndex : --this.activeIndex;
|
|
1965
|
-
this.activeIndex = index = this.activeIndex === (listCount) ? 0 : this.activeIndex;
|
|
1966
|
-
this.activeIndex = index = this.activeIndex < 0 ? (listCount - 1) : this.activeIndex;
|
|
1967
|
-
nextItemValue = isNullOrUndefined(this.timeCollections[index as number]) ?
|
|
1968
|
-
this.timeCollections[0] : this.timeCollections[index as number];
|
|
1969
|
-
} else if (event.action === 'home') {
|
|
1970
|
-
this.activeIndex = 0;
|
|
1971
|
-
nextItemValue = this.timeCollections[0];
|
|
1972
|
-
} else if (event.action === 'end') {
|
|
1973
|
-
this.activeIndex = listCount - 1;
|
|
1974
|
-
nextItemValue = this.timeCollections[listCount - 1];
|
|
1975
|
-
}
|
|
1976
|
-
this.selectedElement = this.liCollections[this.activeIndex];
|
|
1977
|
-
this.timeElementValue(new Date(nextItemValue));
|
|
1978
|
-
}
|
|
1979
|
-
this.isNavigate = true;
|
|
1980
|
-
this.setTimeHover(this.selectedElement, NAVIGATION);
|
|
1981
|
-
this.setTimeActiveDescendant();
|
|
1982
|
-
if (this.isTimePopupOpen() && this.selectedElement !== null && (!event || event.type !== 'click')) {
|
|
1983
|
-
this.setTimeScrollPosition();
|
|
1984
|
-
}
|
|
1985
|
-
}
|
|
1986
|
-
protected timeKeyActionHandle(event: KeyboardEventArgs): void {
|
|
1987
|
-
if (this.enabled) {
|
|
1988
|
-
if (event.action !== 'right' && event.action !== 'left' && event.action !== 'tab') {
|
|
1989
|
-
event.preventDefault();
|
|
1990
|
-
}
|
|
1991
|
-
switch (event.action) {
|
|
1992
|
-
case 'up':
|
|
1993
|
-
case 'down':
|
|
1994
|
-
case 'home':
|
|
1995
|
-
case 'end':
|
|
1996
|
-
this.timeKeyHandler(event);
|
|
1997
|
-
break;
|
|
1998
|
-
case 'enter':
|
|
1999
|
-
if (this.isNavigate) {
|
|
2000
|
-
this.selectedElement = this.liCollections[this.activeIndex];
|
|
2001
|
-
this.valueWithMinutes = new Date(this.timeCollections[this.activeIndex]);
|
|
2002
|
-
this.setInputValue('time');
|
|
2003
|
-
if (+ this.previousDateTime !== +this.value) {
|
|
2004
|
-
this.changedArgs.value = this.value;
|
|
2005
|
-
this.addTimeSelection();
|
|
2006
|
-
this.previousDateTime = this.value;
|
|
2007
|
-
}
|
|
2008
|
-
} else {
|
|
2009
|
-
this.updateValue(event);
|
|
2010
|
-
}
|
|
2011
|
-
this.hide(event);
|
|
2012
|
-
addClass([this.inputWrapper.container], INPUTFOCUS);
|
|
2013
|
-
this.isNavigate = false;
|
|
2014
|
-
event.stopPropagation();
|
|
2015
|
-
break;
|
|
2016
|
-
case 'escape':
|
|
2017
|
-
this.hide(event);
|
|
2018
|
-
break;
|
|
2019
|
-
default:
|
|
2020
|
-
this.isNavigate = false;
|
|
2021
|
-
break;
|
|
2022
|
-
}
|
|
2023
|
-
}
|
|
2024
|
-
}
|
|
2025
|
-
protected inputKeyAction(event: KeyboardEventArgs): void {
|
|
2026
|
-
switch (event.action) {
|
|
2027
|
-
case 'altDownArrow':
|
|
2028
|
-
this.strictModeUpdate();
|
|
2029
|
-
this.updateInput();
|
|
2030
|
-
this.toggle(event);
|
|
2031
|
-
break;
|
|
2032
|
-
}
|
|
2033
|
-
}
|
|
2034
|
-
/**
|
|
2035
|
-
* Called internally if any of the property value changed.
|
|
2036
|
-
*
|
|
2037
|
-
* @param {DateTimePickerModel} newProp - Returns the dynamic property value of the component.
|
|
2038
|
-
* @param {DateTimePickerModel} oldProp - Returns the previous property value of the component.
|
|
2039
|
-
* @returns {void}
|
|
2040
|
-
* @deprecated
|
|
2041
|
-
*/
|
|
2042
|
-
public onPropertyChanged(newProp: DateTimePickerModel, oldProp: DateTimePickerModel): void {
|
|
2043
|
-
for (const prop of Object.keys(newProp)) {
|
|
2044
|
-
const openPopup: string[] = ['blur', 'change', 'cleared', 'close', 'created', 'destroyed', 'focus', 'navigated', 'open', 'renderDayCell'];
|
|
2045
|
-
if (openPopup.indexOf(prop) > 0 && this.isReact) {
|
|
2046
|
-
this.isDynamicValueChanged = true;
|
|
2047
|
-
}
|
|
2048
|
-
switch (prop) {
|
|
2049
|
-
case 'value':
|
|
2050
|
-
this.isDynamicValueChanged = true;
|
|
2051
|
-
this.invalidValueString = null;
|
|
2052
|
-
this.checkInvalidValue(newProp.value);
|
|
2053
|
-
newProp.value = this.value;
|
|
2054
|
-
newProp.value = this.validateValue(newProp.value);
|
|
2055
|
-
if (this.enableMask){
|
|
2056
|
-
Input.setValue(this.maskedDateValue, this.inputElement, this.floatLabelType, this.showClearButton);
|
|
2057
|
-
}
|
|
2058
|
-
else {
|
|
2059
|
-
Input.setValue(this.getFormattedValue(newProp.value), this.inputElement, this.floatLabelType, this.showClearButton);
|
|
2060
|
-
}
|
|
2061
|
-
this.valueWithMinutes = newProp.value;
|
|
2062
|
-
this.setProperties({ value: newProp.value }, true);
|
|
2063
|
-
if (this.popupObj) {
|
|
2064
|
-
this.popupUpdate();
|
|
2065
|
-
}
|
|
2066
|
-
this.previousDateTime = new Date(this.inputElement.value);
|
|
2067
|
-
this.updateInput();
|
|
2068
|
-
this.changeTrigger(null);
|
|
2069
|
-
this.preventChange = this.isAngular && this.preventChange ? !this.preventChange : this.preventChange;
|
|
2070
|
-
if (this.enableMask && this.value) {
|
|
2071
|
-
this.notify('createMask', {
|
|
2072
|
-
module: 'MaskedDateTime'
|
|
2073
|
-
});
|
|
2074
|
-
}
|
|
2075
|
-
break;
|
|
2076
|
-
case 'min':
|
|
2077
|
-
case 'max':
|
|
2078
|
-
this.getProperty(newProp, prop);
|
|
2079
|
-
this.updateInput();
|
|
2080
|
-
break;
|
|
2081
|
-
case 'enableRtl':
|
|
2082
|
-
Input.setEnableRtl(this.enableRtl, [this.inputWrapper.container]);
|
|
2083
|
-
break;
|
|
2084
|
-
case 'cssClass':
|
|
2085
|
-
if (!isNullOrUndefined(oldProp.cssClass)) {
|
|
2086
|
-
oldProp.cssClass = (oldProp.cssClass.replace(/\s+/g, ' ')).trim();
|
|
2087
|
-
}
|
|
2088
|
-
if (!isNullOrUndefined(newProp.cssClass)) {
|
|
2089
|
-
newProp.cssClass = (newProp.cssClass.replace(/\s+/g, ' ')).trim();
|
|
2090
|
-
}
|
|
2091
|
-
Input.setCssClass(newProp.cssClass, [this.inputWrapper.container], oldProp.cssClass);
|
|
2092
|
-
if (this.dateTimeWrapper) {
|
|
2093
|
-
Input.setCssClass(newProp.cssClass, [this.dateTimeWrapper], oldProp.cssClass);
|
|
2094
|
-
}
|
|
2095
|
-
break;
|
|
2096
|
-
case 'locale':
|
|
2097
|
-
this.globalize = new Internationalization(this.locale);
|
|
2098
|
-
this.l10n.setLocale(this.locale);
|
|
2099
|
-
if (this.dateTimeOptions && this.dateTimeOptions.placeholder == null) {
|
|
2100
|
-
this.setProperties({ placeholder: this.l10n.getConstant('placeholder') }, true);
|
|
2101
|
-
Input.setPlaceholder(this.l10n.getConstant('placeholder'), this.inputElement);
|
|
2102
|
-
}
|
|
2103
|
-
this.dateTimeFormat = this.cldrDateTimeFormat();
|
|
2104
|
-
super.updateInput();
|
|
2105
|
-
break;
|
|
2106
|
-
case 'htmlAttributes':
|
|
2107
|
-
this.updateHtmlAttributeToElement();
|
|
2108
|
-
this.updateHtmlAttributeToWrapper();
|
|
2109
|
-
this.checkAttributes(true);
|
|
2110
|
-
break;
|
|
2111
|
-
case 'format':
|
|
2112
|
-
this.setProperties({ format: newProp.format }, true);
|
|
2113
|
-
this.checkFormat();
|
|
2114
|
-
this.dateTimeFormat = this.formatString;
|
|
2115
|
-
this.setValue();
|
|
2116
|
-
if (this.enableMask) {
|
|
2117
|
-
this.notify('createMask', {
|
|
2118
|
-
module: 'MaskedDateTime'
|
|
2119
|
-
});
|
|
2120
|
-
if (!this.value)
|
|
2121
|
-
{
|
|
2122
|
-
Input.setValue(this.maskedDateValue, this.inputElement, this.floatLabelType, this.showClearButton);
|
|
2123
|
-
}
|
|
2124
|
-
}
|
|
2125
|
-
break;
|
|
2126
|
-
case 'placeholder':
|
|
2127
|
-
Input.setPlaceholder(newProp.placeholder, this.inputElement);
|
|
2128
|
-
break;
|
|
2129
|
-
case 'enabled':
|
|
2130
|
-
Input.setEnabled(this.enabled, this.inputElement);
|
|
2131
|
-
if (this.enabled) {
|
|
2132
|
-
this.inputElement.setAttribute('tabindex', this.tabIndex);
|
|
2133
|
-
} else {
|
|
2134
|
-
this.inputElement.tabIndex = -1;
|
|
2135
|
-
}
|
|
2136
|
-
break;
|
|
2137
|
-
case 'strictMode':
|
|
2138
|
-
this.invalidValueString = null;
|
|
2139
|
-
this.updateInput();
|
|
2140
|
-
break;
|
|
2141
|
-
case 'width':
|
|
2142
|
-
this.setWidth(newProp.width);
|
|
2143
|
-
Input.calculateWidth(this.inputElement, this.inputWrapper.container);
|
|
2144
|
-
if (!isNullOrUndefined(this.inputWrapper.buttons[0]) && !isNullOrUndefined(this.inputWrapper.container.getElementsByClassName('e-float-text-overflow')[0]) && this.floatLabelType !== 'Never') {
|
|
2145
|
-
this.inputWrapper.container.getElementsByClassName('e-float-text-overflow')[0].classList.add('e-date-time-icon');
|
|
2146
|
-
}
|
|
2147
|
-
break;
|
|
2148
|
-
case 'readonly':
|
|
2149
|
-
Input.setReadonly(this.readonly, this.inputElement);
|
|
2150
|
-
break;
|
|
2151
|
-
case 'floatLabelType':
|
|
2152
|
-
this.floatLabelType = newProp.floatLabelType;
|
|
2153
|
-
Input.removeFloating(this.inputWrapper);
|
|
2154
|
-
Input.addFloating(this.inputElement, this.floatLabelType, this.placeholder);
|
|
2155
|
-
if (!isNullOrUndefined(this.inputWrapper.buttons[0]) && !isNullOrUndefined(this.inputWrapper.container.getElementsByClassName('e-float-text-overflow')[0]) && this.floatLabelType !== 'Never') {
|
|
2156
|
-
this.inputWrapper.container.getElementsByClassName('e-float-text-overflow')[0].classList.add('e-date-time-icon');
|
|
2157
|
-
}
|
|
2158
|
-
break;
|
|
2159
|
-
case 'scrollTo':
|
|
2160
|
-
if (this.checkDateValue(new Date(this.checkValue(newProp.scrollTo)))) {
|
|
2161
|
-
if (this.dateTimeWrapper) {
|
|
2162
|
-
this.setScrollTo();
|
|
2163
|
-
}
|
|
2164
|
-
this.setProperties({ scrollTo: this.checkDateValue(new Date(this.checkValue(newProp.scrollTo))) }, true);
|
|
2165
|
-
} else {
|
|
2166
|
-
this.setProperties({ scrollTo: null }, true);
|
|
2167
|
-
}
|
|
2168
|
-
break;
|
|
2169
|
-
case 'enableMask':
|
|
2170
|
-
if (this.enableMask) {
|
|
2171
|
-
this.notify('createMask', {
|
|
2172
|
-
module: 'MaskedDateTime'
|
|
2173
|
-
});
|
|
2174
|
-
Input.setValue(this.maskedDateValue, this.inputElement, this.floatLabelType, this.showClearButton);
|
|
2175
|
-
}
|
|
2176
|
-
else
|
|
2177
|
-
{
|
|
2178
|
-
if (this.inputElement.value === this.maskedDateValue)
|
|
2179
|
-
{
|
|
2180
|
-
this.maskedDateValue = '';
|
|
2181
|
-
Input.setValue(this.maskedDateValue, this.inputElement, this.floatLabelType, this.showClearButton);
|
|
2182
|
-
}
|
|
2183
|
-
}
|
|
2184
|
-
break;
|
|
2185
|
-
default:
|
|
2186
|
-
super.onPropertyChanged(newProp, oldProp);
|
|
2187
|
-
break;
|
|
2188
|
-
}
|
|
2189
|
-
if (!this.isDynamicValueChanged) {
|
|
2190
|
-
this.hide(null);
|
|
2191
|
-
}
|
|
2192
|
-
this.isDynamicValueChanged = false;
|
|
2193
|
-
}
|
|
2194
|
-
}
|
|
2195
|
-
/**
|
|
2196
|
-
* To get component name.
|
|
2197
|
-
*
|
|
2198
|
-
* @returns {string} Returns the component name.
|
|
2199
|
-
* @private
|
|
2200
|
-
*/
|
|
2201
|
-
protected getModuleName(): string {
|
|
2202
|
-
return 'datetimepicker';
|
|
2203
|
-
}
|
|
2204
|
-
protected restoreValue(): void {
|
|
2205
|
-
this.previousDateTime = this.previousDate;
|
|
2206
|
-
this.currentDate = this.value ? this.value : new Date();
|
|
2207
|
-
this.valueWithMinutes = this.value;
|
|
2208
|
-
this.previousDate = this.value;
|
|
2209
|
-
this.previousElementValue = this.previousElementValue = (isNullOrUndefined(this.inputValueCopy)) ? '' :
|
|
2210
|
-
this.getFormattedValue(this.inputValueCopy);
|
|
2211
|
-
}
|
|
2212
|
-
}
|