@componyx/ui 0.0.0-stage → 1.0.3
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/AppSkin/AppSkin.css +1268 -0
- package/AppSkin/AppSkin.js +2748 -0
- package/AppSkin/Themes/Default.css +241 -0
- package/Base/Base.js +3407 -0
- package/Base/ComponentIcons.css +66 -0
- package/Base/Font/ComponentIcons.woff +0 -0
- package/Base/Font/UI.woff +0 -0
- package/Base/Library.js +8432 -0
- package/Base/NavigationManager.js +462 -0
- package/Base/ResponsiveTemplates.js +371 -0
- package/Base/Sanitizer.js +288 -0
- package/Base/Themes/Default.css +255 -0
- package/Base/UI.css +618 -0
- package/Base/UIResourcePath.js +6 -0
- package/Bindary/Bindary.js +2011 -0
- package/Bindary/Modules/Connection.js +216 -0
- package/Bindary/Modules/Core.js +854 -0
- package/Bindary/Modules/DataUpdater.js +351 -0
- package/Bindary/Modules/ExpressionEngine.js +347 -0
- package/Bindary/Modules/ProxyManager.js +482 -0
- package/Bindary/Modules/Renderer.js +605 -0
- package/Bindary/Modules/Router.js +291 -0
- package/Bindary/Modules/Scroller.js +89 -0
- package/Bindary/Modules/Template.js +1273 -0
- package/BookmarkSpy/BookmarkSpy.js +430 -0
- package/Box/Box.css +36 -0
- package/Box/Box.js +1685 -0
- package/Button/Button.css +470 -0
- package/Button/Button.js +1398 -0
- package/Button/Themes/Default.css +200 -0
- package/Carousel/Carousel.css +273 -0
- package/Carousel/Carousel.js +607 -0
- package/ColorButton/ColorButton.css +39 -0
- package/ColorButton/ColorButton.js +336 -0
- package/ColorPicker/ColorPicker.css +359 -0
- package/ColorPicker/ColorPicker.js +972 -0
- package/ComboBox/ComboBox.css +357 -0
- package/ComboBox/ComboBox.js +2342 -0
- package/ComboBox/Themes/Default.css +23 -0
- package/DataPager/DataPager.css +72 -0
- package/DataPager/DataPager.js +674 -0
- package/DatePicker/DatePicker.css +227 -0
- package/DatePicker/DatePicker.js +1531 -0
- package/DatePicker/Themes/Default.css +26 -0
- package/Dialog/Dialog.css +106 -0
- package/Dialog/Dialog.js +572 -0
- package/Dialog/Themes/Default.css +10 -0
- package/Editor/Data/Emoji.json +8285 -0
- package/Editor/Data/Special.json +1042 -0
- package/Editor/Editor.css +1562 -0
- package/Editor/Editor.js +4058 -0
- package/Editor/Font/Editor.woff +0 -0
- package/Editor/Modules/ComponentFactory.js +565 -0
- package/Editor/Modules/ContentManager.js +748 -0
- package/Editor/Modules/DialogManager.js +1234 -0
- package/Editor/Modules/EventManager.js +458 -0
- package/Editor/Modules/Format.js +950 -0
- package/Editor/Modules/History.js +191 -0
- package/Editor/Modules/LayoutState.js +379 -0
- package/Editor/Modules/ListManager.js +296 -0
- package/Editor/Modules/MenuManager.js +388 -0
- package/Editor/Modules/NodeManager.js +681 -0
- package/Editor/Modules/ParagraphButtons.js +122 -0
- package/Editor/Modules/Resizer.js +176 -0
- package/Editor/Modules/SelectionRange.js +564 -0
- package/Editor/Modules/SourceViewBuilder.js +212 -0
- package/Editor/Modules/SymbolPicker.js +208 -0
- package/Editor/Modules/Table.js +2327 -0
- package/Editor/Modules/TableDialog.js +757 -0
- package/Editor/Modules/Toolbar.js +375 -0
- package/Editor/Modules/TooltipMenu.js +125 -0
- package/Editor/Modules/Utility.js +131 -0
- package/Editor/Themes/Default.css +204 -0
- package/FileUpload/FileUpload.css +156 -0
- package/FileUpload/FileUpload.js +898 -0
- package/FileUpload/Themes/Default.css +17 -0
- package/Form/Form.css +1934 -0
- package/Form/Form.js +4943 -0
- package/Form/Modules/ActionManager.js +368 -0
- package/Form/Modules/BuildPanelManager.js +319 -0
- package/Form/Modules/ComponentFactory.js +468 -0
- package/Form/Modules/ComponentPanel.js +265 -0
- package/Form/Modules/ConfigPanelManager.js +685 -0
- package/Form/Modules/DataObserver.js +717 -0
- package/Form/Modules/Databinder.js +602 -0
- package/Form/Modules/Draggable.js +756 -0
- package/Form/Modules/OptionsPanel.js +342 -0
- package/Form/Modules/Renderer.js +1889 -0
- package/Form/Modules/RuleEngine.js +585 -0
- package/Form/Modules/RulesPanel.js +1158 -0
- package/Form/Modules/Types.js +1709 -0
- package/Form/Modules/ValidationManager.js +194 -0
- package/Form/Themes/Default.css +216 -0
- package/FormField/FormField.css +468 -0
- package/FormField/FormField.js +576 -0
- package/FormField/Themes/Default.css +99 -0
- package/Grid/Grid.css +544 -0
- package/Grid/Grid.js +3761 -0
- package/Grid/Themes/Default.css +43 -0
- package/LICENSE +126 -0
- package/MaskedTextBox/MaskedTextBox.css +28 -0
- package/MaskedTextBox/MaskedTextBox.js +642 -0
- package/MaskedTextBox/Themes/Default.css +6 -0
- package/Menu/Menu.css +328 -0
- package/Menu/Menu.js +2386 -0
- package/Menu/Themes/Default.css +24 -0
- package/NumericBox/NumericBox.css +120 -0
- package/NumericBox/NumericBox.js +984 -0
- package/PanelBar/PanelBar.css +123 -0
- package/PanelBar/PanelBar.js +505 -0
- package/PanelBar/Themes/Default.css +51 -0
- package/PieChart/PieChart.css +95 -0
- package/PieChart/PieChart.js +820 -0
- package/PieChart/Themes/Default.css +9 -0
- package/README.md +178 -3
- package/Slider/Slider.css +348 -0
- package/Slider/Slider.js +1306 -0
- package/Slider/Themes/Default.css +44 -0
- package/TabStrip/TabStrip.css +52 -0
- package/TabStrip/TabStrip.js +362 -0
- package/TabStrip/Themes/Default.css +35 -0
- package/TimePicker/Themes/Default.css +30 -0
- package/TimePicker/TimePicker.css +253 -0
- package/TimePicker/TimePicker.js +1485 -0
- package/TooltipManager/Themes/Default.css +21 -0
- package/TooltipManager/TooltipManager.css +227 -0
- package/TooltipManager/TooltipManager.js +791 -0
- package/Validator/Validator.css +54 -0
- package/Validator/Validator.js +2508 -0
- package/componyx.html-data.json +619 -0
- package/index.js +27 -0
- package/package.json +43 -4
- package/types/AppSkin.d.ts +842 -0
- package/types/Base.d.ts +1034 -0
- package/types/Bindary.d.ts +1196 -0
- package/types/BookmarkSpy.d.ts +112 -0
- package/types/Box.d.ts +374 -0
- package/types/Button.d.ts +455 -0
- package/types/Carousel.d.ts +136 -0
- package/types/ColorButton.d.ts +120 -0
- package/types/ColorPicker.d.ts +225 -0
- package/types/ComboBox.d.ts +507 -0
- package/types/DataPager.d.ts +152 -0
- package/types/DatePicker.d.ts +354 -0
- package/types/Dialog.d.ts +160 -0
- package/types/Editor.d.ts +1289 -0
- package/types/FileUpload.d.ts +206 -0
- package/types/Form.d.ts +3078 -0
- package/types/FormField.d.ts +204 -0
- package/types/Grid.d.ts +911 -0
- package/types/Library.d.ts +1899 -0
- package/types/MaskedTextBox.d.ts +91 -0
- package/types/Menu.d.ts +577 -0
- package/types/NumericBox.d.ts +310 -0
- package/types/PanelBar.d.ts +223 -0
- package/types/PieChart.d.ts +224 -0
- package/types/ResponsiveTemplates.d.ts +108 -0
- package/types/Slider.d.ts +227 -0
- package/types/TabStrip.d.ts +185 -0
- package/types/TimePicker.d.ts +265 -0
- package/types/TooltipManager.d.ts +178 -0
- package/types/UI.d.ts +29 -0
- package/types/Validator.d.ts +653 -0
- package/types/index.d.ts +59 -0
- package/ui.css +11783 -0
- package/ui.js +79477 -0
- package/ui.min.css +138 -0
- package/ui.min.js +264 -0
- package/ui.min.js.map +1 -0
|
@@ -0,0 +1,1485 @@
|
|
|
1
|
+
/*! Componyx.UI | (c) E.H. Daanen / Componyx | BUSL-1.1 | componyx.com/license */
|
|
2
|
+
import '../Base/Base.js';
|
|
3
|
+
import '../Base/Library.js';
|
|
4
|
+
import '../Dialog/Dialog.js';
|
|
5
|
+
import '../Button/Button.js';
|
|
6
|
+
import '../NumericBox/NumericBox.js';
|
|
7
|
+
|
|
8
|
+
(function (window)
|
|
9
|
+
{
|
|
10
|
+
/**
|
|
11
|
+
* TimePicker class.
|
|
12
|
+
* @class
|
|
13
|
+
* @memberof componyx.UI
|
|
14
|
+
* @augments componyx.UI.base.Component
|
|
15
|
+
* @mixes componyx.UI.base.methods
|
|
16
|
+
* @param {String} id The id of the component.
|
|
17
|
+
* @param {Object|HTMLElement} properties The properties used to initialize the component or the container element.
|
|
18
|
+
* @returns {Object} An instance of the component.
|
|
19
|
+
*/
|
|
20
|
+
componyx.UI.TimePicker = function TimePicker(id, properties)
|
|
21
|
+
{
|
|
22
|
+
// define private properties
|
|
23
|
+
var _instance = this,
|
|
24
|
+
_hidden,
|
|
25
|
+
_hourInput = null,
|
|
26
|
+
_minuteInput = null;
|
|
27
|
+
$base.static.ThemeOption;
|
|
28
|
+
var _viewModeOption = componyx.UI.TimePicker.ViewModeOption,
|
|
29
|
+
_clockDialog, _hourClockInput, _minuteClockInput, _hourClock, _minuteClock, _hourClockHand, _minuteClockHand, _hourClockValue, _minuteClockValue, _drag, _tabFocus,
|
|
30
|
+
_activeClock, _activeClockHand, _circle = {}, _clockHours = {}, _clockMinutes = {}, _minuteClockSelected, _hourClockSelected, _pickerButton,
|
|
31
|
+
_buttonPM, _buttonAM, _tabBlur,
|
|
32
|
+
_classOption =
|
|
33
|
+
{
|
|
34
|
+
NUMERICBOX: 'numeric-box',
|
|
35
|
+
HOUR: 'hour',
|
|
36
|
+
MINUTE: 'minute',
|
|
37
|
+
HOURCLOCK: 'clock hour',
|
|
38
|
+
MINUTECLOCK: 'clock minute',
|
|
39
|
+
CLOCKHAND: 'clock-hand',
|
|
40
|
+
CLOCKITEM: 'clock-item',
|
|
41
|
+
SELECTED: 'selected',
|
|
42
|
+
BETWEEN: 'between',
|
|
43
|
+
PICKER: 'button picker',
|
|
44
|
+
PM: 'button pm',
|
|
45
|
+
AM: 'button am',
|
|
46
|
+
TWENTYFOURCLOCK: 'clock-24',
|
|
47
|
+
TWENTYFOURHAND: 'hand-24',
|
|
48
|
+
SEPARATOR: 'separator',
|
|
49
|
+
INPUT: 'input',
|
|
50
|
+
BUTTONHOLDER: 'button-holder',
|
|
51
|
+
DISABLED: 'disabled'
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// define public properties
|
|
55
|
+
/**
|
|
56
|
+
* Gets or sets the css class of the numericbox.
|
|
57
|
+
* @type {String}
|
|
58
|
+
*/
|
|
59
|
+
this.cssClassNumericBox = '';
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Gets or sets the css class of the hour input.
|
|
63
|
+
* @type {String}
|
|
64
|
+
*/
|
|
65
|
+
this.cssClassHour = '';
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Gets or sets the css class of the minute input.
|
|
69
|
+
* @type {String}
|
|
70
|
+
*/
|
|
71
|
+
this.cssClassMinute = '';
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Gets or sets the placeholder which is visible when the hour input box has no value. Default: HH.
|
|
75
|
+
* @type {String}
|
|
76
|
+
*/
|
|
77
|
+
this.hourPlaceholder = 'HH';
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Gets or sets the placeholder which is visible when the minute input box has no value. Default: MM.
|
|
81
|
+
* @type {String}
|
|
82
|
+
*/
|
|
83
|
+
this.minutePlaceholder = 'MM';
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Gets or sets a value indicating whether the timepicker is readonly.
|
|
87
|
+
* @type {Boolean}
|
|
88
|
+
*/
|
|
89
|
+
this.readOnly = false;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Gets or sets a value indicating whether the timepicker is disabled.
|
|
93
|
+
* @type {Boolean}
|
|
94
|
+
*/
|
|
95
|
+
this.disabled = false;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Gets or sets a value indicating whether focus on an input field is automatically moved to the next field while typing.
|
|
99
|
+
* @type {Boolean}
|
|
100
|
+
*/
|
|
101
|
+
this.autoFocus = true;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Gets or sets a value indicating whether a leading zero is added to the hour input box if it is not provided. Default: true.
|
|
105
|
+
* @type {Boolean}
|
|
106
|
+
*/
|
|
107
|
+
this.hourLeadingZero = true;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Gets or sets a value indicating whether a 12 or 24 hour clock is used.
|
|
111
|
+
* @type {Boolean}
|
|
112
|
+
*/
|
|
113
|
+
this.is24HourClock = true;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Gets or sets the meridiem value if it’s not set to a 24 hour clock.
|
|
117
|
+
* @type {String}
|
|
118
|
+
*/
|
|
119
|
+
this.meridiemValue = 'AM';
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Gets or sets the hidden input field name which contains the selected time value.
|
|
123
|
+
* @type {String}
|
|
124
|
+
*/
|
|
125
|
+
this.name = '';
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Gets or sets the selected time value in format 'HH:MM'.
|
|
129
|
+
* @type {String|null}
|
|
130
|
+
*/
|
|
131
|
+
this.value = null;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Gets or sets the minimum allowed time in format 'HH:MM'. Minutes must be divisible by 5.
|
|
135
|
+
* @type {String|null}
|
|
136
|
+
*/
|
|
137
|
+
this.minValue = null;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Gets or sets the maximum allowed time in format 'HH:MM'. Minutes must be divisible by 5.
|
|
141
|
+
* @type {String|null}
|
|
142
|
+
*/
|
|
143
|
+
this.maxValue = null;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Gets or sets the incremental value in minutes. Minutes must be divisible by 5.
|
|
147
|
+
* @type {Number|null}
|
|
148
|
+
*/
|
|
149
|
+
this.incrementalValue = null;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Gets or sets a list of allowed clock times (format 'HH:MM'). Separate two date strings with a space to specify allowed range. When allowed times are set, date input fields are rendered in readonly mode.
|
|
153
|
+
* @type {String[]}
|
|
154
|
+
*/
|
|
155
|
+
this.allowedTimes = [];
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Gets or sets a value indicating if the times specified in the times property are disallowed instead of the default allowed.
|
|
159
|
+
* @type {Boolean}
|
|
160
|
+
*/
|
|
161
|
+
this.disallowTimes = false;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Gets or sets the view mode in which the time picker is rendered.
|
|
165
|
+
* @type {componyx.UI.TimePicker.ViewModeOption}
|
|
166
|
+
*/
|
|
167
|
+
this.viewMode = _viewModeOption.INPUT_CLOCK_POPUP;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Gets or sets the id of the hour numeric box from which the settings are cloned.
|
|
171
|
+
* @type {String|null}
|
|
172
|
+
*/
|
|
173
|
+
this.hourNumericBoxId = null;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Gets or sets the id of the minute numeric box from which the settings are cloned.
|
|
177
|
+
* @type {String|null}
|
|
178
|
+
*/
|
|
179
|
+
this.minuteNumericBoxId = null;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Gets or sets the id of the clock dialog from which the settings are cloned.
|
|
183
|
+
* @type {String|null}
|
|
184
|
+
*/
|
|
185
|
+
this.clockDialogId = null;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Gets or sets the id of the post meridiem (PM) button from which the settings are cloned.
|
|
189
|
+
* @type {String|null}
|
|
190
|
+
*/
|
|
191
|
+
this.pmButtonId = null;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Gets or sets the id of the ante meridiem (AM) button from which the settings are cloned.
|
|
195
|
+
* @type {String|null}
|
|
196
|
+
*/
|
|
197
|
+
this.amButtonId = null;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Gets or sets the id of the picker button from which the settings are cloned.
|
|
201
|
+
* @type {String|null}
|
|
202
|
+
*/
|
|
203
|
+
this.pickerButtonId = null;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Gets or sets the id of the hidden input from which the settings are cloned.
|
|
207
|
+
* @type {String|null}
|
|
208
|
+
*/
|
|
209
|
+
this.hiddenInputId = null;
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* @class
|
|
214
|
+
* @augments componyx.UI.base.Events
|
|
215
|
+
* @memberof componyx.UI.TimePicker
|
|
216
|
+
* @property {componyx.UI.base.Event} onFocus - Event which fires when the time picker is focused.
|
|
217
|
+
* @property {componyx.UI.base.Event} onBlur - Event which fires when the time picker is blurred.
|
|
218
|
+
* @property {componyx.UI.base.Event} onChanged - Event which fires when the value has changed. @see {@link componyx.UI.TimePicker.ChangedEventArgs}
|
|
219
|
+
* @see {@link componyx.UI.base.Events}
|
|
220
|
+
*/
|
|
221
|
+
function TimePickerEvents(events)
|
|
222
|
+
{
|
|
223
|
+
Object.assign(this, events);
|
|
224
|
+
this.onFocus = $base.static.createEvent('onFocus');
|
|
225
|
+
this.onBlur = $base.static.createEvent('onBlur');
|
|
226
|
+
this.onChanged = $base.static.createEvent('onChanged');
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* TimePicker events
|
|
230
|
+
* @type {componyx.UI.TimePicker.TimePickerEvents}
|
|
231
|
+
*/
|
|
232
|
+
this.events = new TimePickerEvents(this.events);
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* TimePicker changed event arguments.
|
|
236
|
+
* @typedef {Object} ChangedEventArgs
|
|
237
|
+
* @memberof componyx.UI.TimePicker
|
|
238
|
+
* @property {String} value - The time value in the format 'HH:MM'.
|
|
239
|
+
*/
|
|
240
|
+
|
|
241
|
+
// inherit base instance members
|
|
242
|
+
$base.Component.apply(this, [id, properties]);
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Resets the inputs to the initial value.
|
|
246
|
+
* @param {Boolean} [fireEvent=false] A value indicating if the onChanged event is fired.
|
|
247
|
+
*/
|
|
248
|
+
this.reset = function (fireEvent)
|
|
249
|
+
{
|
|
250
|
+
reset(($lib.isEmpty(fireEvent)) ? false : fireEvent);
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Clears the input values.
|
|
255
|
+
* @param {Boolean} [fireEvent=false] A value indicating if the onChanged event is fired.
|
|
256
|
+
*/
|
|
257
|
+
this.clear = function (fireEvent)
|
|
258
|
+
{
|
|
259
|
+
clear(($lib.isEmpty(fireEvent)) ? false : fireEvent);
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Selects the text of the first input field of the timepicker.
|
|
264
|
+
*/
|
|
265
|
+
this.select = function ()
|
|
266
|
+
{
|
|
267
|
+
select();
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Gets the hour value from the timepicker.
|
|
272
|
+
* @returns {Number} Hour value.
|
|
273
|
+
*/
|
|
274
|
+
this.getHour = function ()
|
|
275
|
+
{
|
|
276
|
+
return getHour();
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* @returns {Number} Minute value.
|
|
281
|
+
*/
|
|
282
|
+
this.getMinute = function ()
|
|
283
|
+
{
|
|
284
|
+
return getMinute();
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Gets the time value in string format.
|
|
289
|
+
* @returns {String} Time value in the format 'hour:minute'.
|
|
290
|
+
*/
|
|
291
|
+
this.getValue = function ()
|
|
292
|
+
{
|
|
293
|
+
return getValue();
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Sets the time value.
|
|
298
|
+
* @param {String} value The time value in the format hour:minute.
|
|
299
|
+
* @param {Boolean} [fireEvent=false] A value indicating if the onChanged event is fired.
|
|
300
|
+
*/
|
|
301
|
+
this.setValue = function (value, fireEvent)
|
|
302
|
+
{
|
|
303
|
+
setValue(value, ($lib.isEmpty(fireEvent)) ? false : fireEvent);
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Gets a value indicating if the time is before or after noon.
|
|
308
|
+
* @returns {String} PM or AM.
|
|
309
|
+
*/
|
|
310
|
+
this.getMeridiemValue = function ()
|
|
311
|
+
{
|
|
312
|
+
if (_instance.is24HourClock)
|
|
313
|
+
return '';
|
|
314
|
+
|
|
315
|
+
return getMeridiemValue();
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Sets a value indicating if the time is before or after noon.
|
|
320
|
+
* @param {String} PM or AM.
|
|
321
|
+
*/
|
|
322
|
+
this.setMeridiemValue = function (value)
|
|
323
|
+
{
|
|
324
|
+
if (_instance.is24HourClock)
|
|
325
|
+
return;
|
|
326
|
+
|
|
327
|
+
$UI.store[_instance.id + '_' + value.toUpperCase()].select();
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Shows the clock.
|
|
332
|
+
*/
|
|
333
|
+
this.showClock = function ()
|
|
334
|
+
{
|
|
335
|
+
showClock();
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Hides the clock.
|
|
340
|
+
*/
|
|
341
|
+
this.hideClock = function ()
|
|
342
|
+
{
|
|
343
|
+
hideClock();
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Selects the hour clock.
|
|
348
|
+
*/
|
|
349
|
+
this.selectHourClock = function ()
|
|
350
|
+
{
|
|
351
|
+
selectHourClock();
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Selects the minute clock.
|
|
356
|
+
*/
|
|
357
|
+
this.selectMinuteClock = function ()
|
|
358
|
+
{
|
|
359
|
+
selectMinuteClock();
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Renders the component
|
|
364
|
+
*/
|
|
365
|
+
this.render = function ()
|
|
366
|
+
{
|
|
367
|
+
if (_instance.renderState != $base.static.RenderState.RENDERING)
|
|
368
|
+
{
|
|
369
|
+
// call base render and return
|
|
370
|
+
$base.methods.render.call(_instance, preRender, 'time-picker');
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// render logic after loading resources
|
|
375
|
+
draw();
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Handles the post render procedure.
|
|
380
|
+
*/
|
|
381
|
+
this.postRender = function ()
|
|
382
|
+
{
|
|
383
|
+
if (_instance.renderState != $base.static.RenderState.RENDERING) // extra safety to never execute a postRender when the component state is incorrect
|
|
384
|
+
return;
|
|
385
|
+
|
|
386
|
+
if (_clockDialog)
|
|
387
|
+
{
|
|
388
|
+
var contentHolder = _clockDialog.getBox().contentElement.firstElementChild.firstElementChild;
|
|
389
|
+
$lib.on(contentHolder, 'mousedown', startDrag);
|
|
390
|
+
$lib.on(contentHolder, 'mousemove', drag);
|
|
391
|
+
$lib.on(contentHolder, 'mouseleave', endDrag);
|
|
392
|
+
$lib.on(contentHolder, 'wheel', navigate);
|
|
393
|
+
$lib.on(document, 'mouseup', endDrag);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
if (_instance.viewMode == _viewModeOption.INPUT_CLOCK_POPUP)
|
|
397
|
+
{
|
|
398
|
+
setInputEvent(_hourInput.getInput());
|
|
399
|
+
setInputEvent(_minuteInput.getInput());
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
if (!$base.methods.postRender.call(_instance)) // component got destroyed on postrender event
|
|
403
|
+
return;
|
|
404
|
+
|
|
405
|
+
setValue(_instance.value, false);
|
|
406
|
+
|
|
407
|
+
if (_instance.meridiemValue && !_instance.is24HourClock)
|
|
408
|
+
_instance.setMeridiemValue(_instance.meridiemValue);
|
|
409
|
+
|
|
410
|
+
selectHourClock();
|
|
411
|
+
};
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* Destroys the component.
|
|
415
|
+
* @see {@link componyx.UI.base.methods#destroy}
|
|
416
|
+
*/
|
|
417
|
+
this.destroy = function (...args)
|
|
418
|
+
{
|
|
419
|
+
dispose();
|
|
420
|
+
$base.methods.destroy.call(this, ...args);
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
function preRender()
|
|
424
|
+
{
|
|
425
|
+
// initialize script and css
|
|
426
|
+
var scripts = ['Button', 'NumericBox'];
|
|
427
|
+
|
|
428
|
+
if (_instance.viewMode != _viewModeOption.INPUT)
|
|
429
|
+
scripts.push('Dialog');
|
|
430
|
+
|
|
431
|
+
return ['TimePicker', scripts];
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
function draw()
|
|
435
|
+
{
|
|
436
|
+
_hidden = _instance.createSyncedInput(_instance.hiddenInputId, function ()
|
|
437
|
+
{
|
|
438
|
+
setValue(this.value);
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
_instance.value = _instance.value || _hidden.value;
|
|
442
|
+
|
|
443
|
+
if (_instance.viewMode < _viewModeOption.CLOCK)
|
|
444
|
+
{
|
|
445
|
+
if (($lib.touch && _instance.autoTouchConfig) || !$lib.isEmpty(_instance.allowedTimes))
|
|
446
|
+
_instance.readOnly = true;
|
|
447
|
+
|
|
448
|
+
initTimes();
|
|
449
|
+
|
|
450
|
+
createHourInput();
|
|
451
|
+
createSeparator(_instance.element);
|
|
452
|
+
createMinuteInput();
|
|
453
|
+
|
|
454
|
+
if (_instance.viewMode == _viewModeOption.INPUT_CLOCK_POPUP)
|
|
455
|
+
{
|
|
456
|
+
createPicker();
|
|
457
|
+
$lib.on(window, 'keyup', checkTabFocus);
|
|
458
|
+
$lib.on(window, 'keyup', checkTabBlur);
|
|
459
|
+
|
|
460
|
+
_instance.events.onFocus.priorityAdd(function ()
|
|
461
|
+
{
|
|
462
|
+
_tabBlur = false;
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
_instance.events.onBlur.priorityAdd(function ()
|
|
466
|
+
{
|
|
467
|
+
_tabBlur = true;
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
if (!_instance.is24HourClock)
|
|
472
|
+
createMeridiemButtons(_instance.element);
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
if (_instance.viewMode != _viewModeOption.INPUT)
|
|
476
|
+
createClockDialog();
|
|
477
|
+
|
|
478
|
+
_instance.renderChildren();
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
function initTimes()
|
|
482
|
+
{
|
|
483
|
+
var minValue = _instance.minValue,
|
|
484
|
+
maxValue = _instance.maxValue,
|
|
485
|
+
allowedTimes = _instance.allowedTimes;
|
|
486
|
+
|
|
487
|
+
_instance.incrementalValue = validateIncrement(_instance.incrementalValue);
|
|
488
|
+
|
|
489
|
+
if (minValue)
|
|
490
|
+
{
|
|
491
|
+
minValue = minValue.split(':');
|
|
492
|
+
_instance.minValue = minValue[0] + ':' + $lib.padLeft(floorToIncrement(minValue[1]), 2);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
if (maxValue)
|
|
496
|
+
{
|
|
497
|
+
maxValue = maxValue.split(':');
|
|
498
|
+
_instance.maxValue = maxValue[0] + ':' + $lib.padLeft(floorToIncrement(maxValue[1]), 2);
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
$lib.each(allowedTimes, function (time, index)
|
|
502
|
+
{
|
|
503
|
+
if (time.indexOf(' ') > -1) // min-max
|
|
504
|
+
allowedTimes[index] = [time.split(' ')[0], time.split(' ')[1]];
|
|
505
|
+
else
|
|
506
|
+
allowedTimes[index] = [time];
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
function validateIncrement(value)
|
|
511
|
+
{
|
|
512
|
+
if ($lib.isEmpty(value) || value == 0)
|
|
513
|
+
return 0;
|
|
514
|
+
|
|
515
|
+
value = parseInt(value, 10);
|
|
516
|
+
|
|
517
|
+
if (isNaN(value))
|
|
518
|
+
return 0;
|
|
519
|
+
|
|
520
|
+
if ((value !== 1 && 60 % value !== 0))
|
|
521
|
+
{
|
|
522
|
+
return 5; // fall back to 5 minutes
|
|
523
|
+
}
|
|
524
|
+
return value;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
function floorToIncrement(value)
|
|
528
|
+
{
|
|
529
|
+
value = parseInt(value, 10);
|
|
530
|
+
|
|
531
|
+
let incrementValue = parseInt(_instance.incrementalValue, 10);
|
|
532
|
+
|
|
533
|
+
if (incrementValue === 1) return value; // no rounding needed
|
|
534
|
+
|
|
535
|
+
return value - (value % incrementValue);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
function createHourInput()
|
|
539
|
+
{
|
|
540
|
+
var input,
|
|
541
|
+
minValue = (_instance.minValue) ? _instance.minValue.split(':')[0] : null,
|
|
542
|
+
maxValue = (_instance.maxValue) ? _instance.maxValue.split(':')[0] : null;
|
|
543
|
+
|
|
544
|
+
_hourInput = input = createInput(_instance.element, _instance.id + '_H', _instance.hourNumericBoxId);
|
|
545
|
+
input.cssClass += ' ' + (_instance.cssClassHour || _classOption.HOUR);
|
|
546
|
+
input.placeholder = _instance.hourPlaceholder;
|
|
547
|
+
input.maxLength = 2;
|
|
548
|
+
|
|
549
|
+
if ($lib.isEmpty(minValue))
|
|
550
|
+
input.minValue = (_instance.is24HourClock) ? 0 : 1;
|
|
551
|
+
else
|
|
552
|
+
input.minValue = null;
|
|
553
|
+
|
|
554
|
+
if ($lib.isEmpty(maxValue))
|
|
555
|
+
input.maxValue = (_instance.is24HourClock) ? 23 : 12;
|
|
556
|
+
else
|
|
557
|
+
input.maxValue = null;
|
|
558
|
+
|
|
559
|
+
input.selectOnFocus = (_instance.autoFocus) ? true : _hourInput.selectOnFocus;
|
|
560
|
+
input.showButtons = false;
|
|
561
|
+
input.digitPadLeftValue = (_instance.hourLeadingZero) ? "00" : null;
|
|
562
|
+
input.value = (_instance.value) ? _instance.value.split(':')[0] : '';
|
|
563
|
+
input.events.onChange.priorityAdd(moveFocus, null);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
function createMinuteInput()
|
|
567
|
+
{
|
|
568
|
+
var input;
|
|
569
|
+
|
|
570
|
+
_minuteInput = input = createInput(_instance.element, _instance.id + '_M', _instance.minuteNumericBoxId);
|
|
571
|
+
input.cssClass += ' ' + (_instance.cssClassMinute || _classOption.MINUTE);
|
|
572
|
+
input.placeholder = _instance.minutePlaceholder;
|
|
573
|
+
input.maxLength = 2;
|
|
574
|
+
input.maxValue = 59;
|
|
575
|
+
input.selectOnFocus = (_instance.autoFocus) ? true : _minuteInput.selectOnFocus;
|
|
576
|
+
input.showButtons = (input.readOnly && !$lib.isEmpty(_instance.allowedTimes)) ? false : true;
|
|
577
|
+
input.digitPadLeftValue = "00";
|
|
578
|
+
input.value = (_instance.value) ? _instance.value.split(':')[1] || '' : '';
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
function createInput(container, id, numericBoxId)
|
|
582
|
+
{
|
|
583
|
+
var input = $UI.createComponent(componyx.UI.NumericBox, { id: id, containerElement: container });
|
|
584
|
+
|
|
585
|
+
input.clone($UI.store[numericBoxId], _instance);
|
|
586
|
+
input.cssClass = input.cssClass || _instance.cssClassNumericBox || _classOption.NUMERICBOX;
|
|
587
|
+
input.focusGroupId = _instance.id;
|
|
588
|
+
input.readOnly = _instance.readOnly;
|
|
589
|
+
input.disabled = _instance.disabled;
|
|
590
|
+
input.focusableButtons = false;
|
|
591
|
+
input.leadingZeros = true;
|
|
592
|
+
input.minValue = 0;
|
|
593
|
+
input.incrementalValue = (_instance.incrementalValue) ? 0 : 1;
|
|
594
|
+
input.showing = true;
|
|
595
|
+
input.delegateFocusEvents(_instance);
|
|
596
|
+
input.events.onChanged.priorityAdd(valueChanged, null);
|
|
597
|
+
input.events.onIncrement.priorityAdd(increment);
|
|
598
|
+
input.events.onDecrement.priorityAdd(decrement);
|
|
599
|
+
input.events.onPostRender.priorityAdd(function () { _instance.isReady.apply(_instance); }, null);
|
|
600
|
+
|
|
601
|
+
if (_instance.viewMode == _viewModeOption.INPUT_CLOCK_POPUP)
|
|
602
|
+
{
|
|
603
|
+
if ($lib.endsWith(id, '_H'))
|
|
604
|
+
{
|
|
605
|
+
input.events.onClick.priorityAdd(function (input)
|
|
606
|
+
{
|
|
607
|
+
_tabFocus = false;
|
|
608
|
+
showClock();
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
input.events.onFocus.priorityAdd(function ()
|
|
612
|
+
{
|
|
613
|
+
selectHourClock();
|
|
614
|
+
showClock();
|
|
615
|
+
_tabFocus = true;
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
else
|
|
619
|
+
{
|
|
620
|
+
input.events.onClick.priorityAdd(function (input)
|
|
621
|
+
{
|
|
622
|
+
_tabFocus = false;
|
|
623
|
+
showClock();
|
|
624
|
+
});
|
|
625
|
+
|
|
626
|
+
input.events.onFocus.priorityAdd(function ()
|
|
627
|
+
{
|
|
628
|
+
selectMinuteClock();
|
|
629
|
+
showClock();
|
|
630
|
+
_tabFocus = true;
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
return input;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
function setInputEvent(input)
|
|
639
|
+
{
|
|
640
|
+
$lib.on(input, 'keyup', inputKeyUp);
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
function inputKeyUp(e)
|
|
644
|
+
{
|
|
645
|
+
var keyCode = e.key;
|
|
646
|
+
|
|
647
|
+
if (!$lib.isEmpty(_hidden.value) && (keyCode == 'Enter' || keyCode == ' ') && _clockDialog && _clockDialog.showing)
|
|
648
|
+
{
|
|
649
|
+
hideClock();
|
|
650
|
+
this.blur();
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
function checkTabFocus(e)
|
|
655
|
+
{
|
|
656
|
+
if (_tabFocus && e.key == 'Tab')
|
|
657
|
+
showClock();
|
|
658
|
+
|
|
659
|
+
_tabFocus = false;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
function checkTabBlur(e)
|
|
663
|
+
{
|
|
664
|
+
$lib.defer(function ()
|
|
665
|
+
{
|
|
666
|
+
if (_tabBlur && e.key == 'Tab')
|
|
667
|
+
hideClock();
|
|
668
|
+
|
|
669
|
+
_tabBlur = false;
|
|
670
|
+
}.bind(_instance, e));
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
function createSeparator(container)
|
|
674
|
+
{
|
|
675
|
+
$lib.element(container, '', 'span', ':', { "class": _classOption.SEPARATOR });
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
function createPicker()
|
|
679
|
+
{
|
|
680
|
+
var id = _instance.id + '_Picker';
|
|
681
|
+
_pickerButton = createButton(_instance.element, id, _instance.pickerButtonId);
|
|
682
|
+
|
|
683
|
+
_pickerButton.transparent = true;
|
|
684
|
+
_pickerButton.cssClass = _classOption.PICKER;
|
|
685
|
+
_pickerButton.hasIcon = true;
|
|
686
|
+
_pickerButton.type = componyx.UI.Button.TypeOption.CHECKBUTTON;
|
|
687
|
+
_pickerButton.command = function () { selectHourClock(); _clockDialog.toggle(); };
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
function createMeridiemButtons(container)
|
|
691
|
+
{
|
|
692
|
+
var id = _instance.id,
|
|
693
|
+
pm = 'PM', am = 'AM',
|
|
694
|
+
buttonHolder = $lib.element(container, '', '', '', { "class": _classOption.BUTTONHOLDER });
|
|
695
|
+
|
|
696
|
+
_buttonAM = createButton(buttonHolder, id + '_' + am, _instance.amButtonId, am);
|
|
697
|
+
_buttonAM.transparent = true;
|
|
698
|
+
_buttonAM.primary = (container !== _instance.element);
|
|
699
|
+
_buttonAM.cssClass = _classOption.AM;
|
|
700
|
+
|
|
701
|
+
_buttonPM = createButton(buttonHolder, id + '_' + pm, _instance.pmButtonId, pm);
|
|
702
|
+
_buttonPM.transparent = true;
|
|
703
|
+
_buttonPM.primary = (container !== _instance.element);
|
|
704
|
+
_buttonPM.cssClass = _classOption.PM;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
function createButton(container, id, cloneId, text)
|
|
708
|
+
{
|
|
709
|
+
var button = $UI.createComponent(componyx.UI.Button, { id: id, containerElement: container });
|
|
710
|
+
button.type = componyx.UI.Button.TypeOption.RADIOBUTTON;
|
|
711
|
+
button.radioGroupId = _instance.id;
|
|
712
|
+
button.text = text;
|
|
713
|
+
button.clone($UI.store[cloneId], _instance);
|
|
714
|
+
button.disabled = _instance.disabled;
|
|
715
|
+
button.delegateFocusEvents(_instance);
|
|
716
|
+
button.events.onPostRender.priorityAdd(function () { _instance.isReady.apply(_instance); }, null);
|
|
717
|
+
button.showing = true;
|
|
718
|
+
|
|
719
|
+
return button;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
function createClockDialog()
|
|
723
|
+
{
|
|
724
|
+
var id = _instance.id + '_Clock',
|
|
725
|
+
header = $lib.element(),
|
|
726
|
+
content = $lib.element();
|
|
727
|
+
|
|
728
|
+
_clockDialog = $UI.createComponent(componyx.UI.Dialog, { id: id, containerElement: _instance.element });
|
|
729
|
+
_clockDialog.clone($UI.store[_instance.dialogId], _instance);
|
|
730
|
+
_clockDialog.cssClass = _classOption.CLOCK;
|
|
731
|
+
_clockDialog.autoFit = _clockDialog.buttons.close = _clockDialog.buttons.deny = _clockDialog.buttons.confirm = _clockDialog.buttons.cancel = false;
|
|
732
|
+
_clockDialog.events.onPostRender.priorityAdd(function () { _instance.isReady.apply(_instance); }, null);
|
|
733
|
+
_clockDialog.setHeaderTemplate(header);
|
|
734
|
+
_clockDialog.setContentTemplate(content);
|
|
735
|
+
_clockDialog.expandDirection = componyx.UI.Box.ExpandDirectionOption.DOWN;
|
|
736
|
+
|
|
737
|
+
if (_instance.viewMode == _viewModeOption.INPUT_CLOCK_POPUP)
|
|
738
|
+
{
|
|
739
|
+
_clockDialog.expander = _instance.id;
|
|
740
|
+
_clockDialog.autoPosition = componyx.UI.Box.AutoPositionOption.EXPAND;
|
|
741
|
+
_clockDialog.autoInvertFit = _clockDialog.autoFit = true;
|
|
742
|
+
_clockDialog.events.onHideComplete.priorityAdd(function ()
|
|
743
|
+
{
|
|
744
|
+
_pickerButton.deselect();
|
|
745
|
+
|
|
746
|
+
if (!_instance.is24HourClock && _instance.viewMode == _viewModeOption.INPUT_CLOCK_POPUP)
|
|
747
|
+
_buttonAM.focus();
|
|
748
|
+
|
|
749
|
+
}, null);
|
|
750
|
+
_clockDialog.hideOnOutsideClick = true;
|
|
751
|
+
}
|
|
752
|
+
else
|
|
753
|
+
_clockDialog.showing = true;
|
|
754
|
+
|
|
755
|
+
createHeader();
|
|
756
|
+
createContent();
|
|
757
|
+
|
|
758
|
+
function createHeader()
|
|
759
|
+
{
|
|
760
|
+
_hourClockInput = $lib.element(header, '', '', '--', { "class": _classOption.INPUT + ' ' + _classOption.HOUR });
|
|
761
|
+
createSeparator(header);
|
|
762
|
+
_minuteClockInput = $lib.element(header, '', '', '--', { "class": _classOption.INPUT + ' ' + _classOption.MINUTE });
|
|
763
|
+
|
|
764
|
+
if (_instance.viewMode == _viewModeOption.CLOCK && !_instance.is24HourClock)
|
|
765
|
+
createMeridiemButtons(header);
|
|
766
|
+
|
|
767
|
+
$lib.on(_hourClockInput, 'click', selectHourClock);
|
|
768
|
+
$lib.on(_minuteClockInput, 'click', selectMinuteClock);
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
function createContent()
|
|
772
|
+
{
|
|
773
|
+
_hourClock = $lib.element(content, '', '', '', { "class": _classOption.HOURCLOCK });
|
|
774
|
+
_minuteClock = $lib.element(content, '', '', '', { "class": _classOption.MINUTECLOCK });
|
|
775
|
+
|
|
776
|
+
createHours($lib.element(_hourClock));
|
|
777
|
+
|
|
778
|
+
if (_instance.is24HourClock)
|
|
779
|
+
$lib.element(_hourClock, '', '', '', { "class": _classOption.TWENTYFOURCLOCK });
|
|
780
|
+
|
|
781
|
+
createMinutes($lib.element(_minuteClock));
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
function createHours(container)
|
|
785
|
+
{
|
|
786
|
+
_hourClockHand = $lib.element(container, '', '', '', { "class": _classOption.CLOCKHAND });
|
|
787
|
+
_hourClockHand.tabIndex = '0';
|
|
788
|
+
|
|
789
|
+
$lib.on(_hourClockHand, 'keydown', navigate);
|
|
790
|
+
$lib.on(_hourClockHand, 'blur', function () { _instance.onBlur.call(_instance); });
|
|
791
|
+
|
|
792
|
+
_clockHours = {};
|
|
793
|
+
createClock(container);
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
function createMinutes(container)
|
|
797
|
+
{
|
|
798
|
+
_minuteClockHand = $lib.element(container, '', '', '', { "class": _classOption.CLOCKHAND });
|
|
799
|
+
_minuteClockHand.tabIndex = '0';
|
|
800
|
+
|
|
801
|
+
$lib.on(_minuteClockHand, 'keydown', navigate);
|
|
802
|
+
$lib.on(_minuteClockHand, 'blur', function () { _instance.onBlur.call(_instance); });
|
|
803
|
+
|
|
804
|
+
_clockMinutes = [];
|
|
805
|
+
createClock(container, true);
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
function createClock(container, isMinutes)
|
|
809
|
+
{
|
|
810
|
+
var length = (!isMinutes && _instance.is24HourClock) ? 24: 12;
|
|
811
|
+
|
|
812
|
+
for (var index = 0; index < length; ++index)
|
|
813
|
+
{
|
|
814
|
+
var value = index,
|
|
815
|
+
label = (isMinutes) ? $lib.padLeft(value * 5, 2) : (!index) ? 12 : value;
|
|
816
|
+
|
|
817
|
+
var size = (!isMinutes && index > 11) ? 50 : 100, // 01-23 is inside container (50%)
|
|
818
|
+
top = ((100 - (size * (Math.sin((2 * Math.PI / 12) * (index + 3))))) / 2), // +3 because we start at top center
|
|
819
|
+
left = ((100 - (size * (Math.cos((2 * Math.PI / 12) * (index + 3))))) / 2),
|
|
820
|
+
el = $lib.element(container, '', '', '', { "class": _classOption.CLOCKITEM });
|
|
821
|
+
|
|
822
|
+
if (!isMinutes && value == 0 && length == 24)
|
|
823
|
+
label = '00';
|
|
824
|
+
|
|
825
|
+
el.style.top = top + '%';
|
|
826
|
+
el.style.left = left + '%';
|
|
827
|
+
el.innerHTML = '<span>' + label + '</span>';
|
|
828
|
+
|
|
829
|
+
if (isMinutes)
|
|
830
|
+
_clockMinutes[(value * 5).toString()] = el;
|
|
831
|
+
else
|
|
832
|
+
_clockHours[value.toString()] = el;
|
|
833
|
+
} }
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
function isInCircle(x, y, cx, cy, radius)
|
|
837
|
+
{
|
|
838
|
+
var distanceSquared = (x - cx) * (x - cx) + (y - cy) * (y - cy); // cx, cy = center point
|
|
839
|
+
return distanceSquared <= (radius * radius);
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
function navigate(e)
|
|
843
|
+
{
|
|
844
|
+
var keyCode = e.key,
|
|
845
|
+
wheelMove = e.deltaY != undefined && e.deltaY != 0,
|
|
846
|
+
up = (keyCode == 'ArrowUp'),
|
|
847
|
+
down = (keyCode == 'ArrowDown'),
|
|
848
|
+
left = (keyCode == 'ArrowLeft'),
|
|
849
|
+
right = (keyCode == 'ArrowRight');
|
|
850
|
+
|
|
851
|
+
if (!(up || down || left || right || wheelMove))
|
|
852
|
+
return;
|
|
853
|
+
|
|
854
|
+
var forwards = e.deltaY > 0 || right || down,
|
|
855
|
+
hand = ($lib.hasClass(_hourClock, _classOption.SELECTED)) ? _hourClockHand : _minuteClockHand;
|
|
856
|
+
|
|
857
|
+
var value = (hand === _hourClockHand) ? _hourClockValue : (_minuteClockValue || 0),
|
|
858
|
+
incrementValue = _instance.incrementalValue || 1;
|
|
859
|
+
|
|
860
|
+
if (hand === _hourClockHand)
|
|
861
|
+
value += (forwards) ? 1 : -1;
|
|
862
|
+
else
|
|
863
|
+
{
|
|
864
|
+
if (forwards)
|
|
865
|
+
value += incrementValue;
|
|
866
|
+
else
|
|
867
|
+
value = (value == 0) ? 60 - incrementValue : value - incrementValue;
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
if (hand === _hourClockHand)
|
|
871
|
+
setValue(mergeValues(value, _minuteClockValue));
|
|
872
|
+
else
|
|
873
|
+
setValue(mergeValues(_hourClockValue, value));
|
|
874
|
+
|
|
875
|
+
if (wheelMove)
|
|
876
|
+
e.preventDefault();
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
function showClock()
|
|
880
|
+
{
|
|
881
|
+
if (_pickerButton)
|
|
882
|
+
_pickerButton.select();
|
|
883
|
+
|
|
884
|
+
_clockDialog.show();
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
function hideClock()
|
|
888
|
+
{
|
|
889
|
+
_clockDialog.hide();
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
function startDrag(e)
|
|
893
|
+
{
|
|
894
|
+
_drag = true;
|
|
895
|
+
_activeClock = _hourClock;
|
|
896
|
+
_activeClockHand = _hourClockHand;
|
|
897
|
+
|
|
898
|
+
if ($lib.hasClass(_minuteClock, _classOption.SELECTED))
|
|
899
|
+
{
|
|
900
|
+
_activeClock = _minuteClock;
|
|
901
|
+
_activeClockHand = _minuteClockHand;
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
var pos = $lib.getPos(_activeClock, null, true);
|
|
905
|
+
_circle.radius = ((pos.bottom - pos.top) / 2);
|
|
906
|
+
_circle.innerRadius = (_circle.radius / 2);
|
|
907
|
+
_circle.cy = pos.top + _circle.radius;
|
|
908
|
+
_circle.cx = pos.left + _circle.radius;
|
|
909
|
+
drag(e);
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
function drag(e)
|
|
913
|
+
{
|
|
914
|
+
if (!_drag)
|
|
915
|
+
return;
|
|
916
|
+
|
|
917
|
+
var x = $lib.clientX(e),
|
|
918
|
+
y = $lib.clientY(e),
|
|
919
|
+
deltaY = _circle.cy - y,
|
|
920
|
+
deltaX = x - _circle.cx,
|
|
921
|
+
rad = Math.atan2(deltaY, deltaX), // in radians
|
|
922
|
+
deg = 90 - (rad * (180 / Math.PI)); // radians to degrees (90- because we start at top of circle and move clockwise instead of counter clockwise)
|
|
923
|
+
|
|
924
|
+
if (deg < 0)
|
|
925
|
+
deg = 360 + deg; // instead of minus degree values we use positive numbers only
|
|
926
|
+
|
|
927
|
+
if (_activeClock == _minuteClock)
|
|
928
|
+
setClockMinute(degreesToMinute(deg));
|
|
929
|
+
else
|
|
930
|
+
setClockHour(degreesToHour(deg, _instance.is24HourClock && isInCircle(x, y, _circle.cx, _circle.cy, _circle.innerRadius)));
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
function endDrag()
|
|
934
|
+
{
|
|
935
|
+
if (_drag)
|
|
936
|
+
{
|
|
937
|
+
_activeClockHand.focus();
|
|
938
|
+
|
|
939
|
+
if (_activeClockHand === _hourClockHand && !$lib.isEmpty(_hourClockValue))
|
|
940
|
+
selectMinuteClock();
|
|
941
|
+
else if (_activeClockHand === _minuteClockHand && !$lib.isEmpty(_hourClockValue) && !$lib.isEmpty(_minuteClockValue) && _instance.viewMode == _viewModeOption.INPUT_CLOCK_POPUP)
|
|
942
|
+
hideClock();
|
|
943
|
+
|
|
944
|
+
setValue(mergeValues(_hourClockValue, _minuteClockValue));
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
_drag = false;
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
function mergeValues(hourValue, minuteValue)
|
|
951
|
+
{
|
|
952
|
+
return validateValue(hourValue) + ':' + validateValue(minuteValue);
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
function validateValue(value)
|
|
956
|
+
{
|
|
957
|
+
return ($lib.isEmpty(value)) ? '' : value;
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
function selectHourClock()
|
|
961
|
+
{
|
|
962
|
+
if ($lib.hasClass(_hourClockInput, _classOption.SELECTED))
|
|
963
|
+
return;
|
|
964
|
+
|
|
965
|
+
toggleClock();
|
|
966
|
+
enableHourClockItems();
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
function selectMinuteClock()
|
|
970
|
+
{
|
|
971
|
+
if ($lib.hasClass(_minuteClockInput, _classOption.SELECTED))
|
|
972
|
+
return;
|
|
973
|
+
|
|
974
|
+
toggleClock(true);
|
|
975
|
+
enableMinuteClockItems();
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
function toggleClock(isMinute)
|
|
979
|
+
{
|
|
980
|
+
var activeInput = (isMinute) ? _minuteClockInput : _hourClockInput,
|
|
981
|
+
input = (isMinute) ? _hourClockInput : _minuteClockInput,
|
|
982
|
+
activeClock = (isMinute) ? _minuteClock : _hourClock,
|
|
983
|
+
clock = (isMinute) ? _hourClock : _minuteClock;
|
|
984
|
+
|
|
985
|
+
$lib.removeClass(input, _classOption.SELECTED);
|
|
986
|
+
$lib.removeClass(clock, _classOption.SELECTED);
|
|
987
|
+
$lib.addClass(activeInput, _classOption.SELECTED);
|
|
988
|
+
$lib.addClass(activeClock, _classOption.SELECTED);
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
function enableHourClockItems()
|
|
992
|
+
{
|
|
993
|
+
var incrementalValues = getIncrementalValues();
|
|
994
|
+
|
|
995
|
+
$lib.each(_clockHours, function (el, hour)
|
|
996
|
+
{
|
|
997
|
+
if ((!incrementalValues || incrementalValues.hours[hour]) && isAllowedHour(parseFloat(hour)))
|
|
998
|
+
$lib.removeClass(el, _classOption.DISABLED);
|
|
999
|
+
else
|
|
1000
|
+
$lib.addClass(el, _classOption.DISABLED);
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
function enableMinuteClockItems()
|
|
1005
|
+
{
|
|
1006
|
+
var incrementalValues = getIncrementalValues();
|
|
1007
|
+
|
|
1008
|
+
$lib.each(_clockMinutes, function (el, minute)
|
|
1009
|
+
{
|
|
1010
|
+
if ((!incrementalValues || incrementalValues.times[parseFloat(_hourClockValue).toString() + ':' + minute]) && isAllowedTime(parseFloat(_hourClockValue), parseFloat(minute)))
|
|
1011
|
+
$lib.removeClass(el, _classOption.DISABLED);
|
|
1012
|
+
else
|
|
1013
|
+
{
|
|
1014
|
+
if (_minuteClockValue == minute)
|
|
1015
|
+
_minuteClockValue = '';
|
|
1016
|
+
|
|
1017
|
+
$lib.addClass(el, _classOption.DISABLED);
|
|
1018
|
+
}
|
|
1019
|
+
});
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
function getIncrementalValues()
|
|
1023
|
+
{
|
|
1024
|
+
var incrementalValues,
|
|
1025
|
+
incrementalValue = _instance.incrementalValue || null,
|
|
1026
|
+
minValue = getMinValue(),
|
|
1027
|
+
maxValue = getMaxValue();
|
|
1028
|
+
|
|
1029
|
+
if (incrementalValue)
|
|
1030
|
+
{
|
|
1031
|
+
var dtMin = new Date(),
|
|
1032
|
+
dtMax = new Date();
|
|
1033
|
+
|
|
1034
|
+
incrementalValues = { times: {}, hours: {} };
|
|
1035
|
+
dtMin.setHours(minValue[0], minValue[1]);
|
|
1036
|
+
dtMax.setHours(maxValue[0], maxValue[1]);
|
|
1037
|
+
|
|
1038
|
+
while (dtMin < dtMax)
|
|
1039
|
+
{
|
|
1040
|
+
incrementalValues.hours[dtMin.getHours().toString()] = true;
|
|
1041
|
+
incrementalValues.times[dtMin.getHours().toString() + ':' + dtMin.getMinutes().toString()] = true;
|
|
1042
|
+
dtMin = addMinutes(dtMin, incrementalValue);
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
incrementalValues.hours[dtMin.getHours().toString()] = true;
|
|
1046
|
+
incrementalValues.times[dtMin.getHours().toString() + ':' + dtMin.getMinutes().toString()] = true;
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
return incrementalValues;
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
function isAllowedHour(hour)
|
|
1053
|
+
{
|
|
1054
|
+
var times = _instance.allowedTimes,
|
|
1055
|
+
minValue = getMinValue(),
|
|
1056
|
+
maxValue = getMaxValue();
|
|
1057
|
+
|
|
1058
|
+
if (hour < minValue[0] || (hour > maxValue[0])) // exceed min or max
|
|
1059
|
+
return false;
|
|
1060
|
+
else if (!$lib.isEmpty(times))
|
|
1061
|
+
{
|
|
1062
|
+
var val = times[$lib.indexOf(times, function (item)
|
|
1063
|
+
{
|
|
1064
|
+
return (item[0].split(':')[0] == hour || (item.length > 1 && item[1].split(':')[0] == hour));
|
|
1065
|
+
})];
|
|
1066
|
+
|
|
1067
|
+
if ((val && _instance.disallowDates) || (!val && !_instance.disallowDates))
|
|
1068
|
+
return false;
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
return true;
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
function isAllowedTime(hour, minute)
|
|
1075
|
+
{
|
|
1076
|
+
var times = _instance.allowedTimes,
|
|
1077
|
+
minValue = getMinValue(),
|
|
1078
|
+
maxValue = getMaxValue();
|
|
1079
|
+
|
|
1080
|
+
if ((hour == minValue[0] && minute < minValue[1]) || (hour == maxValue[0] && minute > maxValue[1])) // exceed min or max
|
|
1081
|
+
return false;
|
|
1082
|
+
else if (!$lib.isEmpty(times))
|
|
1083
|
+
{
|
|
1084
|
+
var val = times[$lib.indexOf(times, function (item)
|
|
1085
|
+
{
|
|
1086
|
+
if (item.length == 1)
|
|
1087
|
+
{
|
|
1088
|
+
item = item[0].split(':');
|
|
1089
|
+
return (item[0] == hour && item[1] == minute)
|
|
1090
|
+
}
|
|
1091
|
+
else
|
|
1092
|
+
{
|
|
1093
|
+
var min = parseFloat(item[0].split(':').join('')),
|
|
1094
|
+
max = parseFloat(item[1].split(':').join('')),
|
|
1095
|
+
check = parseFloat(hour.toString() + $lib.padLeft(minute.toString(), 2));
|
|
1096
|
+
|
|
1097
|
+
return (check >= min && check <= max);
|
|
1098
|
+
}
|
|
1099
|
+
})];
|
|
1100
|
+
|
|
1101
|
+
if ((val && _instance.disallowDates) || (!val && !_instance.disallowDates))
|
|
1102
|
+
return false;
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
return true;
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
function getMinValue()
|
|
1109
|
+
{
|
|
1110
|
+
return (_instance.minValue) ? _instance.minValue.split(':') : [0, 0];
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
function getMaxValue()
|
|
1114
|
+
{
|
|
1115
|
+
return (_instance.maxValue) ? _instance.maxValue.split(':') : [getMaxHours(), 59];
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
function getMaxHours()
|
|
1119
|
+
{
|
|
1120
|
+
return (_instance.is24HourClock) ? 23 : 11;
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
function moveFocus(input, args)
|
|
1124
|
+
{
|
|
1125
|
+
var keyCode = (args.event) ? args.event.key : null;
|
|
1126
|
+
|
|
1127
|
+
if (_instance.autoFocus && keyCode != null && keyCode != 'ArrowUp' && keyCode != 'ArrowDown' && !args.incremental && _hourInput.getValue().length == 2)
|
|
1128
|
+
_minuteInput.select();
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
function decrement(input)
|
|
1132
|
+
{
|
|
1133
|
+
increment(input, null, null, (_instance.incrementalValue) ? _instance.incrementalValue * -1 : input.incrementalValue * -1);
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
function increment(input, args, e, incrementalValue)
|
|
1137
|
+
{
|
|
1138
|
+
if (input.incrementalValue == 1)
|
|
1139
|
+
{
|
|
1140
|
+
valueChanged();
|
|
1141
|
+
return;
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
var hour = _hourInput.getValue() || 0,
|
|
1145
|
+
minute = _minuteInput.getValue() || 0;
|
|
1146
|
+
|
|
1147
|
+
if (incrementalValue == undefined)
|
|
1148
|
+
incrementalValue = _instance.incrementalValue;
|
|
1149
|
+
|
|
1150
|
+
var dt = new Date();
|
|
1151
|
+
dt.setHours(parseFloat(hour), parseFloat(minute));
|
|
1152
|
+
dt = addMinutes(dt, incrementalValue);
|
|
1153
|
+
|
|
1154
|
+
setValue(dt.getHours() + ':' + dt.getMinutes());
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
function addMinutes(date, minutes)
|
|
1158
|
+
{
|
|
1159
|
+
var dt = new Date(date.getTime() + minutes * 60000);
|
|
1160
|
+
return dt;
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
function valueChanged()
|
|
1164
|
+
{
|
|
1165
|
+
var value = _hourInput.getValue() + ':' + _minuteInput.getValue();
|
|
1166
|
+
setValue(value);
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
function reset()
|
|
1170
|
+
{
|
|
1171
|
+
setValue(_instance.value);
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
function clear()
|
|
1175
|
+
{
|
|
1176
|
+
setValue();
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
function select()
|
|
1180
|
+
{
|
|
1181
|
+
var input = $lib(null, _instance.element, 'input')[0];
|
|
1182
|
+
input.select();
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
function setValue(value, fireEvent)
|
|
1186
|
+
{
|
|
1187
|
+
value = value || '';
|
|
1188
|
+
|
|
1189
|
+
if (value == ':')
|
|
1190
|
+
value = '';
|
|
1191
|
+
|
|
1192
|
+
var is24HourClock = _instance.is24HourClock,
|
|
1193
|
+
arr = value.split(':'), number,
|
|
1194
|
+
hour = (arr[0]) ? $lib.padLeft(arr[0], 2) : '',
|
|
1195
|
+
minute = (arr[1]) ? $lib.padLeft(arr[1], 2) : '',
|
|
1196
|
+
minValue = (_instance.minValue) ? parseFloat(_instance.minValue.replace(':', '')) : null,
|
|
1197
|
+
maxValue = (_instance.maxValue) ? parseFloat(_instance.maxValue.replace(':', '')) : null;
|
|
1198
|
+
|
|
1199
|
+
if (hour)
|
|
1200
|
+
{
|
|
1201
|
+
number = parseFloat(hour);
|
|
1202
|
+
|
|
1203
|
+
if ((!is24HourClock && number > 11) || (is24HourClock && number > 23))
|
|
1204
|
+
hour = '00';
|
|
1205
|
+
else if (number < 0)
|
|
1206
|
+
hour = (is24HourClock) ? '23' : '11';
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
if (minute)
|
|
1210
|
+
{
|
|
1211
|
+
if (_instance.incrementalValue)
|
|
1212
|
+
minute = floorToIncrement(minute).toString();
|
|
1213
|
+
|
|
1214
|
+
number = parseFloat(minute);
|
|
1215
|
+
|
|
1216
|
+
if (number > 59)
|
|
1217
|
+
minute = '00';
|
|
1218
|
+
else if (number < 0)
|
|
1219
|
+
minute = '59';
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
if (!$lib.isEmpty(value))
|
|
1223
|
+
{
|
|
1224
|
+
var comparable = parseFloat($lib.format('{0}{1}', hour, minute || '00'));
|
|
1225
|
+
|
|
1226
|
+
if (minValue && comparable < minValue)
|
|
1227
|
+
{
|
|
1228
|
+
minValue = minValue.toString();
|
|
1229
|
+
minute = minValue.slice(-2);
|
|
1230
|
+
hour = $lib.padLeft(minValue.substr(0, minValue.length - minute.length), 2);
|
|
1231
|
+
}
|
|
1232
|
+
else if (maxValue && comparable > maxValue)
|
|
1233
|
+
{
|
|
1234
|
+
maxValue = maxValue.toString();
|
|
1235
|
+
minute = maxValue.slice(-2);
|
|
1236
|
+
hour = $lib.padLeft(maxValue.substr(0, maxValue.length - minute.length), 2);
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
value = $lib.padLeft(hour, 2) + ':' + $lib.padLeft(minute, 2);
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
if (!is24HourClock && hour == '00')
|
|
1243
|
+
hour = '12';
|
|
1244
|
+
|
|
1245
|
+
if (_instance.viewMode < _viewModeOption.CLOCK)
|
|
1246
|
+
{
|
|
1247
|
+
if (_hourInput.getValue() != hour)
|
|
1248
|
+
_hourInput.setValue(hour);
|
|
1249
|
+
|
|
1250
|
+
if (_minuteInput.getValue() != minute)
|
|
1251
|
+
_minuteInput.setValue(minute);
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
if (_clockDialog)
|
|
1255
|
+
{
|
|
1256
|
+
if (!_instance.is24HourClock && hour == '12')
|
|
1257
|
+
hour = 0;
|
|
1258
|
+
|
|
1259
|
+
setClockValue(($lib.isEmpty(hour)) ? null : parseFloat(hour), ($lib.isEmpty(minute)) ? null : parseFloat(minute));
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
var prevValue = _hidden.value;
|
|
1263
|
+
|
|
1264
|
+
if (!$lib.isEmpty(hour) && !$lib.isEmpty(minute))
|
|
1265
|
+
_hidden.__setValue(value);
|
|
1266
|
+
else
|
|
1267
|
+
_hidden.__setValue('');
|
|
1268
|
+
|
|
1269
|
+
if (fireEvent != false && prevValue != value)
|
|
1270
|
+
_instance.events.onChanged.fire(_instance, { value: value });
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
function setClockValue(hour, minute)
|
|
1274
|
+
{
|
|
1275
|
+
setClockHour(hour);
|
|
1276
|
+
setClockMinute(minute);
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
function setClockHour(value)
|
|
1280
|
+
{
|
|
1281
|
+
if (value === _hourClockValue)
|
|
1282
|
+
return;
|
|
1283
|
+
|
|
1284
|
+
_hourClockValue = value;
|
|
1285
|
+
clearSelected([_hourClockSelected, _hourClockHand]);
|
|
1286
|
+
|
|
1287
|
+
if ($lib.isEmpty(value))
|
|
1288
|
+
{
|
|
1289
|
+
_hourClockInput.textContent = '--';
|
|
1290
|
+
rotate(_hourClockHand, 0);
|
|
1291
|
+
return;
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
var el = _clockHours[value.toString()];
|
|
1295
|
+
selectHourClock();
|
|
1296
|
+
|
|
1297
|
+
if ($lib.hasClass(el, _classOption.DISABLED))
|
|
1298
|
+
{
|
|
1299
|
+
_hourClockValue = '';
|
|
1300
|
+
return;
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
setDisplayValue(_hourClockInput, value);
|
|
1304
|
+
$lib.addClass(el, _classOption.SELECTED);
|
|
1305
|
+
_hourClockSelected = el;
|
|
1306
|
+
|
|
1307
|
+
$lib.addClass(_hourClockHand, _classOption.SELECTED);
|
|
1308
|
+
rotate(_hourClockHand, hourToDegrees(value));
|
|
1309
|
+
|
|
1310
|
+
if (_instance.is24HourClock && value > 11)
|
|
1311
|
+
$lib.addClass(_hourClockHand, _classOption.TWENTYFOURHAND);
|
|
1312
|
+
else
|
|
1313
|
+
$lib.removeClass(_hourClockHand, _classOption.TWENTYFOURHAND);
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
function setClockMinute(value)
|
|
1317
|
+
{
|
|
1318
|
+
if (value === _minuteClockValue)
|
|
1319
|
+
return;
|
|
1320
|
+
|
|
1321
|
+
clearSelected([_minuteClockSelected, _minuteClockHand]);
|
|
1322
|
+
|
|
1323
|
+
if (_minuteClockHand.firstChild)
|
|
1324
|
+
{
|
|
1325
|
+
$lib.remove(_minuteClockHand.firstChild);
|
|
1326
|
+
$lib.removeClass(_minuteClockHand, _classOption.BETWEEN);
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
if ($lib.isEmpty(value))
|
|
1330
|
+
{
|
|
1331
|
+
_minuteClockInput.textContent = '--';
|
|
1332
|
+
_minuteClockValue = 0;
|
|
1333
|
+
rotate(_minuteClockHand, 0);
|
|
1334
|
+
return;
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
if (_instance.incrementalValue)
|
|
1338
|
+
value = floorToIncrement(value);
|
|
1339
|
+
|
|
1340
|
+
_minuteClockValue = value;
|
|
1341
|
+
|
|
1342
|
+
var el = _clockMinutes[value.toString()];
|
|
1343
|
+
selectMinuteClock();
|
|
1344
|
+
|
|
1345
|
+
if ($lib.hasClass(el, _classOption.DISABLED))
|
|
1346
|
+
{
|
|
1347
|
+
_minuteClockValue = '';
|
|
1348
|
+
_minuteClockValue = 0;
|
|
1349
|
+
return;
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1352
|
+
_minuteClockInput.textContent = $lib.padLeft(value.toString(), 2);
|
|
1353
|
+
|
|
1354
|
+
if (el)
|
|
1355
|
+
{
|
|
1356
|
+
$lib.addClass(el, _classOption.SELECTED);
|
|
1357
|
+
_minuteClockSelected = el;
|
|
1358
|
+
}
|
|
1359
|
+
else
|
|
1360
|
+
{
|
|
1361
|
+
var content = $lib.element(_minuteClockHand);
|
|
1362
|
+
$lib.element(content, '', 'span', $lib.padLeft(value, 2));
|
|
1363
|
+
rotate(content, minuteToDegrees(value) * -1);
|
|
1364
|
+
|
|
1365
|
+
$.addClass(_minuteClockHand, _classOption.BETWEEN);
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
$lib.addClass(_minuteClockHand, _classOption.SELECTED);
|
|
1369
|
+
rotate(_minuteClockHand, minuteToDegrees(value));
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
function setDisplayValue(input, value)
|
|
1373
|
+
{
|
|
1374
|
+
if (value == 0 && !_instance.is24HourClock)
|
|
1375
|
+
value = 12;
|
|
1376
|
+
|
|
1377
|
+
input.textContent = $lib.padLeft(value.toString(), 2);
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
function clearSelected(elements)
|
|
1381
|
+
{
|
|
1382
|
+
$lib.each(elements, function (el)
|
|
1383
|
+
{
|
|
1384
|
+
if (el)
|
|
1385
|
+
$lib.removeClass(el, _classOption.SELECTED);
|
|
1386
|
+
});
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
function rotate(hand, degrees)
|
|
1390
|
+
{
|
|
1391
|
+
hand.style.transform = 'rotate(' + degrees + 'deg)';
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
function degreesToHour(degrees, twentyFourClock)
|
|
1395
|
+
{
|
|
1396
|
+
var value = Math.round((12 / 360) * degrees);
|
|
1397
|
+
|
|
1398
|
+
if (twentyFourClock)
|
|
1399
|
+
{
|
|
1400
|
+
value = value + 12;
|
|
1401
|
+
|
|
1402
|
+
if (value > 23)
|
|
1403
|
+
value = 12;
|
|
1404
|
+
}
|
|
1405
|
+
else if (value > 11)
|
|
1406
|
+
value = 0;
|
|
1407
|
+
|
|
1408
|
+
return value;
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
function degreesToMinute(degrees)
|
|
1412
|
+
{
|
|
1413
|
+
var value = Math.round((60 / 360) * degrees);
|
|
1414
|
+
return (value > 59) ? 0 : value;
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
function hourToDegrees(hour)
|
|
1418
|
+
{
|
|
1419
|
+
hour = (_instance.is24HourClock && hour > 11) ? hour - 12 : hour;
|
|
1420
|
+
|
|
1421
|
+
var value = (360 / 12) * hour;
|
|
1422
|
+
return (value >= 360) ? 0 : value;
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
function minuteToDegrees(minute)
|
|
1426
|
+
{
|
|
1427
|
+
var value = (360 / 60) * minute;
|
|
1428
|
+
return (value >= 360) ? 0 : value;
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
function getMeridiemValue()
|
|
1432
|
+
{
|
|
1433
|
+
var button = componyx.UI.Button.getSelected(_instance.id);
|
|
1434
|
+
|
|
1435
|
+
return button.text;
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
function getValue()
|
|
1439
|
+
{
|
|
1440
|
+
return _hidden.value;
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
function getHour()
|
|
1444
|
+
{
|
|
1445
|
+
var value = _hidden.value.split(':')[0];
|
|
1446
|
+
return (value) ? parseInt(value, 10) : null;
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
function getMinute()
|
|
1450
|
+
{
|
|
1451
|
+
var value = _hidden.value.split(':')[1];
|
|
1452
|
+
return (value) ? parseInt(value, 10) : null;
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
function dispose()
|
|
1456
|
+
{
|
|
1457
|
+
_clockDialog = _buttonPM = _buttonAM = null;
|
|
1458
|
+
$lib.off(window, 'keyup', checkTabFocus);
|
|
1459
|
+
$lib.off(window, 'keyup', checkTabBlur);
|
|
1460
|
+
}
|
|
1461
|
+
};
|
|
1462
|
+
|
|
1463
|
+
/**
|
|
1464
|
+
* @see {@link componyx.UI.base.methods}
|
|
1465
|
+
*/
|
|
1466
|
+
componyx.UI.TimePicker.prototype = Object.create($base.methods);
|
|
1467
|
+
componyx.UI.TimePicker.prototype.constructor = componyx.UI.TimePicker;
|
|
1468
|
+
|
|
1469
|
+
/**
|
|
1470
|
+
* ViewModeOption
|
|
1471
|
+
* @readonly
|
|
1472
|
+
* @enum {number}
|
|
1473
|
+
*/
|
|
1474
|
+
componyx.UI.TimePicker.ViewModeOption =
|
|
1475
|
+
{
|
|
1476
|
+
INPUT_CLOCK_POPUP: 0,
|
|
1477
|
+
INPUT_CLOCK_STATIC: 1,
|
|
1478
|
+
INPUT: 2,
|
|
1479
|
+
CLOCK: 3
|
|
1480
|
+
};
|
|
1481
|
+
})(window);
|
|
1482
|
+
|
|
1483
|
+
const TimePicker = componyx.UI.TimePicker;
|
|
1484
|
+
|
|
1485
|
+
export { TimePicker };
|