@syncfusion/ej2-inputs 30.2.4 → 31.1.17

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.
Files changed (110) hide show
  1. package/dist/ej2-inputs.min.js +2 -2
  2. package/dist/ej2-inputs.umd.min.js +2 -2
  3. package/dist/ej2-inputs.umd.min.js.map +1 -1
  4. package/dist/es6/ej2-inputs.es2015.js +1 -1
  5. package/dist/es6/ej2-inputs.es2015.js.map +1 -1
  6. package/dist/es6/ej2-inputs.es5.js +1 -1
  7. package/dist/es6/ej2-inputs.es5.js.map +1 -1
  8. package/dist/global/ej2-inputs.min.js +2 -2
  9. package/dist/global/ej2-inputs.min.js.map +1 -1
  10. package/dist/global/index.d.ts +1 -1
  11. package/dist/ts/color-picker/color-picker-model.d.ts +186 -0
  12. package/dist/ts/color-picker/color-picker.d.ts +398 -0
  13. package/dist/ts/color-picker/color-picker.ts +2209 -0
  14. package/dist/ts/color-picker/index.d.ts +5 -0
  15. package/dist/ts/color-picker/index.ts +5 -0
  16. package/dist/ts/common/index.d.ts +4 -0
  17. package/dist/ts/common/index.ts +4 -0
  18. package/dist/ts/common/signature-base.d.ts +340 -0
  19. package/dist/ts/common/signature-base.ts +1170 -0
  20. package/dist/ts/form-validator/form-validator-model.d.ts +121 -0
  21. package/dist/ts/form-validator/form-validator.d.ts +312 -0
  22. package/dist/ts/form-validator/form-validator.ts +1068 -0
  23. package/dist/ts/form-validator/index.d.ts +5 -0
  24. package/dist/ts/form-validator/index.ts +5 -0
  25. package/dist/ts/index.d.ts +18 -0
  26. package/dist/ts/index.ts +18 -0
  27. package/dist/ts/input/index.d.ts +4 -0
  28. package/dist/ts/input/index.ts +4 -0
  29. package/dist/ts/input/input.d.ts +345 -0
  30. package/dist/ts/input/input.ts +1277 -0
  31. package/dist/ts/maskedtextbox/base/index.d.ts +4 -0
  32. package/dist/ts/maskedtextbox/base/index.ts +4 -0
  33. package/dist/ts/maskedtextbox/base/mask-base.d.ts +134 -0
  34. package/dist/ts/maskedtextbox/base/mask-base.ts +1207 -0
  35. package/dist/ts/maskedtextbox/index.d.ts +5 -0
  36. package/dist/ts/maskedtextbox/index.ts +5 -0
  37. package/dist/ts/maskedtextbox/maskedtextbox/index.d.ts +5 -0
  38. package/dist/ts/maskedtextbox/maskedtextbox/index.ts +5 -0
  39. package/dist/ts/maskedtextbox/maskedtextbox/maskedtextbox-model.d.ts +167 -0
  40. package/dist/ts/maskedtextbox/maskedtextbox/maskedtextbox.d.ts +307 -0
  41. package/dist/ts/maskedtextbox/maskedtextbox/maskedtextbox.ts +709 -0
  42. package/dist/ts/numerictextbox/index.d.ts +5 -0
  43. package/dist/ts/numerictextbox/index.ts +5 -0
  44. package/dist/ts/numerictextbox/numerictextbox-model.d.ts +228 -0
  45. package/dist/ts/numerictextbox/numerictextbox.d.ts +431 -0
  46. package/dist/ts/numerictextbox/numerictextbox.ts +1672 -0
  47. package/dist/ts/otp-input/index.d.ts +5 -0
  48. package/dist/ts/otp-input/index.ts +5 -0
  49. package/dist/ts/otp-input/otp-input-model.d.ts +165 -0
  50. package/dist/ts/otp-input/otp-input.d.ts +365 -0
  51. package/dist/ts/otp-input/otp-input.ts +924 -0
  52. package/dist/ts/rating/index.d.ts +5 -0
  53. package/dist/ts/rating/index.ts +5 -0
  54. package/dist/ts/rating/rating-model.d.ts +239 -0
  55. package/dist/ts/rating/rating.d.ts +416 -0
  56. package/dist/ts/rating/rating.ts +1101 -0
  57. package/dist/ts/signature/index.d.ts +5 -0
  58. package/dist/ts/signature/index.ts +5 -0
  59. package/dist/ts/signature/signature-model.d.ts +131 -0
  60. package/dist/ts/signature/signature.d.ts +167 -0
  61. package/dist/ts/signature/signature.ts +266 -0
  62. package/dist/ts/slider/index.d.ts +5 -0
  63. package/dist/ts/slider/index.ts +5 -0
  64. package/dist/ts/slider/slider-model.d.ts +401 -0
  65. package/dist/ts/slider/slider.d.ts +721 -0
  66. package/dist/ts/slider/slider.ts +3497 -0
  67. package/dist/ts/smart-textarea/caret-helper.d.ts +17 -0
  68. package/dist/ts/smart-textarea/caret-helper.ts +95 -0
  69. package/dist/ts/smart-textarea/index.d.ts +5 -0
  70. package/dist/ts/smart-textarea/index.ts +5 -0
  71. package/dist/ts/smart-textarea/smart-textarea-model.d.ts +44 -0
  72. package/dist/ts/smart-textarea/smart-textarea.d.ts +80 -0
  73. package/dist/ts/smart-textarea/smart-textarea.ts +518 -0
  74. package/dist/ts/speech-to-text/index.d.ts +5 -0
  75. package/dist/ts/speech-to-text/index.ts +5 -0
  76. package/dist/ts/speech-to-text/speech-to-text-model.d.ts +270 -0
  77. package/dist/ts/speech-to-text/speech-to-text.d.ts +487 -0
  78. package/dist/ts/speech-to-text/speech-to-text.ts +1008 -0
  79. package/dist/ts/textarea/index.d.ts +5 -0
  80. package/dist/ts/textarea/index.ts +5 -0
  81. package/dist/ts/textarea/textarea-model.d.ts +161 -0
  82. package/dist/ts/textarea/textarea.d.ts +237 -0
  83. package/dist/ts/textarea/textarea.ts +812 -0
  84. package/dist/ts/textbox/index.d.ts +5 -0
  85. package/dist/ts/textbox/index.ts +5 -0
  86. package/dist/ts/textbox/textbox-model.d.ts +155 -0
  87. package/dist/ts/textbox/textbox.d.ts +288 -0
  88. package/dist/ts/textbox/textbox.ts +872 -0
  89. package/dist/ts/uploader/index.d.ts +5 -0
  90. package/dist/ts/uploader/index.ts +5 -0
  91. package/dist/ts/uploader/uploader-model.d.ts +555 -0
  92. package/dist/ts/uploader/uploader.d.ts +1216 -0
  93. package/dist/ts/uploader/uploader.ts +4391 -0
  94. package/package.json +62 -12
  95. package/src/input/input.js +1 -1
  96. package/styles/bootstrap5.3-lite.css +3 -3
  97. package/styles/bootstrap5.3.css +5 -5
  98. package/styles/input/_layout.scss +0 -1
  99. package/styles/input/tailwind3.css +0 -1
  100. package/styles/tailwind-dark-lite.css +3 -3
  101. package/styles/tailwind-dark.css +5 -5
  102. package/styles/tailwind-lite.css +3 -3
  103. package/styles/tailwind.css +5 -5
  104. package/styles/tailwind3-lite.css +0 -1
  105. package/styles/tailwind3.css +0 -1
  106. package/styles/uploader/_bootstrap5.3-definition.scss +1 -1
  107. package/styles/uploader/_tailwind-definition.scss +1 -1
  108. package/styles/uploader/bootstrap5.3.css +5 -5
  109. package/styles/uploader/tailwind-dark.css +5 -5
  110. package/styles/uploader/tailwind.css +5 -5
@@ -0,0 +1,3497 @@
1
+ import { Component, EventHandler, Property, Event, EmitType, Complex, Collection } from '@syncfusion/ej2-base';
2
+ import { L10n, Internationalization, NumberFormatOptions } from '@syncfusion/ej2-base';
3
+ import { NotifyPropertyChanges, INotifyPropertyChanged, ChildProperty } from '@syncfusion/ej2-base';
4
+ import { attributes, addClass, removeClass, setStyleAttribute, detach, closest } from '@syncfusion/ej2-base';
5
+ import { isNullOrUndefined, formatUnit, Browser, SanitizeHtmlHelper, initializeCSPTemplate } from '@syncfusion/ej2-base';
6
+ import { Tooltip, Position, TooltipEventArgs, getZindexPartial } from '@syncfusion/ej2-popups';
7
+ import { SliderModel, TicksDataModel, TooltipDataModel, LimitDataModel, ColorRangeDataModel } from './slider-model';
8
+
9
+ /**
10
+ * Configures the ticks data of the Slider.
11
+ */
12
+ export class TicksData extends ChildProperty<TicksData> {
13
+ /**
14
+ * It is used to denote the position of the ticks in the Slider. The available options are:
15
+ *
16
+ * * before - Ticks are placed in the top of the horizontal slider bar or at the left of the vertical slider bar.
17
+ * * after - Ticks are placed in the bottom of the horizontal slider bar or at the right of the vertical slider bar.
18
+ * * both - Ticks are placed on the both side of the Slider bar.
19
+ * * none - Ticks are not shown.
20
+ * {% codeBlock src='slider/placement/index.md' %}{% endcodeBlock %}
21
+ *
22
+ * @default 'None'
23
+ */
24
+ @Property('None')
25
+ public placement: Placement;
26
+ /**
27
+ * It is used to denote the distance between two major (large) ticks from the scale of the Slider.
28
+ * {% codeBlock src='slider/largestep/index.md' %}{% endcodeBlock %}
29
+ *
30
+ * @default 10
31
+ */
32
+ @Property(10)
33
+ public largeStep: number;
34
+ /**
35
+ * It is used to denote the distance between two minor (small) ticks from the scale of the Slider.
36
+ * {% codeBlock src='slider/smallstep/index.md' %}{% endcodeBlock %}
37
+ *
38
+ * @default 1
39
+ */
40
+ @Property(1)
41
+ public smallStep: number;
42
+ /**
43
+ * We can show or hide the small ticks in the Slider, which will be appeared in between the largeTicks.
44
+ *
45
+ * @default false
46
+ */
47
+ @Property(false)
48
+ public showSmallTicks: boolean;
49
+
50
+ /**
51
+ * It is used to customize the Slider scale value to the desired format using Internationalization or events(custom formatting).
52
+ * {% codeBlock src='slider/format/index.md' %}{% endcodeBlock %}
53
+ */
54
+ @Property(null)
55
+ public format: string;
56
+ }
57
+
58
+ /**
59
+ * It is used to denote the TooltipChange Event arguments.
60
+ */
61
+ export interface SliderTooltipEventArgs {
62
+ /**
63
+ * It is used to get the value of the Slider.
64
+ *
65
+ * @isGenericType true
66
+ */
67
+ value: number | number[];
68
+ /**
69
+ * It is used to get the text shown in the Slider tooltip.
70
+ */
71
+ text: string;
72
+ }
73
+
74
+ /**
75
+ * It is used to denote the Slider Change/Changed Event arguments.
76
+ */
77
+ export interface SliderChangeEventArgs {
78
+ /**
79
+ * It is used to get the current value of the Slider.
80
+ *
81
+ * @isGenericType true
82
+ */
83
+ value: number | number[];
84
+ /**
85
+ * It is used to get the previous value of the Slider.
86
+ *
87
+ * @isGenericType true
88
+ */
89
+ previousValue: number | number[];
90
+ /**
91
+ * It is used to get the current text or formatted text of the Slider, which is placed in tooltip.
92
+ */
93
+ text?: string;
94
+ /**
95
+ * It is used to get the action applied on the Slider.
96
+ */
97
+ action: string;
98
+ /**
99
+ * It is used to check whether the event triggered is via user or programmatic way.
100
+ */
101
+ isInteracted: boolean;
102
+ }
103
+
104
+ /**
105
+ * It is used to denote the TicksRender Event arguments.
106
+ */
107
+ export interface SliderTickEventArgs {
108
+ /**
109
+ * It is used to get the value of the tick.
110
+ */
111
+ value: number;
112
+ /**
113
+ * It is used to get the label text of the tick.
114
+ */
115
+ text: string;
116
+ /**
117
+ * It is used to get the current tick element.
118
+ */
119
+ tickElement: Element;
120
+ }
121
+
122
+ /**
123
+ * It is used t denote the ticks rendered Event arguments.
124
+ */
125
+ export interface SliderTickRenderedEventArgs {
126
+ /**
127
+ * It returns the wrapper of the ticks element.
128
+ */
129
+ ticksWrapper: HTMLElement;
130
+ /**
131
+ * It returns the collection of tick elements.
132
+ */
133
+ tickElements: HTMLElement[];
134
+ }
135
+
136
+ /**
137
+ * It illustrates the color track data in slider.
138
+ * {% codeBlock src='slider/colorrange/index.md' %}{% endcodeBlock %}
139
+ */
140
+ export class ColorRangeData extends ChildProperty<ColorRangeData> {
141
+ /**
142
+ * It is used to set the color in the slider bar.
143
+ *
144
+ * @default ''
145
+ */
146
+ @Property(null)
147
+ public color: string;
148
+
149
+ /**
150
+ * It is used to get the starting value for applying color.
151
+ *
152
+ * @default null
153
+ */
154
+ @Property(null)
155
+ public start: number;
156
+
157
+ /**
158
+ * It is used to get the end value for applying color.
159
+ *
160
+ * @default null
161
+ */
162
+ @Property(null)
163
+ public end: number;
164
+ }
165
+
166
+ /**
167
+ * It illustrates the limit data in slider.
168
+ * {% codeBlock src='slider/limits/index.md' %}{% endcodeBlock %}
169
+ */
170
+ export class LimitData extends ChildProperty<LimitData> {
171
+ /**
172
+ * It is used to enable the limit in the slider.
173
+ *
174
+ * @default false
175
+ */
176
+ @Property(false)
177
+ public enabled: boolean;
178
+
179
+ /**
180
+ * It is used to set the minimum start limit value.
181
+ *
182
+ * @default null
183
+ */
184
+ @Property(null)
185
+ public minStart: number;
186
+
187
+ /**
188
+ * It is used to set the minimum end limit value.
189
+ *
190
+ * @default null
191
+ */
192
+ @Property(null)
193
+ public minEnd: number;
194
+
195
+ /**
196
+ * It is used to set the maximum start limit value.
197
+ *
198
+ * @default null
199
+ */
200
+ @Property(null)
201
+ public maxStart: number;
202
+
203
+ /**
204
+ * It is used to set the maximum end limit value.
205
+ *
206
+ * @default null
207
+ */
208
+ @Property(null)
209
+ public maxEnd: number;
210
+
211
+ /**
212
+ * It is used to lock the first handle.
213
+ * {% codeBlock src='slider/limitStartHandleFixed/index.md' %}{% endcodeBlock %}
214
+ *
215
+ * @default false
216
+ */
217
+ @Property(false)
218
+ public startHandleFixed: boolean;
219
+
220
+ /**
221
+ * It is used to lock the second handle.
222
+ * {% codeBlock src='slider/limitEndHandleFixed/index.md' %}{% endcodeBlock %}
223
+ *
224
+ * @default false
225
+ */
226
+ @Property(false)
227
+ public endHandleFixed: boolean;
228
+ }
229
+
230
+ /**
231
+ * It illustrates the tooltip data in slider.
232
+ */
233
+ export class TooltipData extends ChildProperty<TooltipData> {
234
+ /**
235
+ * It is used to customize the Tooltip which accepts custom CSS class names that define
236
+ * specific user-defined styles and themes to be applied on the Tooltip element.
237
+ *
238
+ * @default ''
239
+ */
240
+ @Property('')
241
+ public cssClass: string;
242
+ /**
243
+ * It is used to denote the position for the tooltip element in the Slider. The available options are:
244
+ * {% codeBlock src='slider/tooltipplacement/index.md' %}{% endcodeBlock %}
245
+ * * Before - Tooltip is shown in the top of the horizontal slider bar or at the left of the vertical slider bar.
246
+ * * After - Tooltip is shown in the bottom of the horizontal slider bar or at the right of the vertical slider bar.
247
+ */
248
+ @Property('Before')
249
+ public placement: TooltipPlacement;
250
+
251
+ /**
252
+ * It is used to determine the device mode to show the Tooltip.
253
+ * If it is in desktop, it will show the Tooltip content when hovering on the target element.
254
+ * If it is in touch device. It will show the Tooltip content when tap and holding on the target element.
255
+ * {% codeBlock src='slider/tooltipShowOn/index.md' %}{% endcodeBlock %}
256
+ *
257
+ * @default 'Auto'
258
+ */
259
+ @Property('Focus')
260
+ public showOn: TooltipShowOn;
261
+
262
+ /**
263
+ * It is used to show or hide the Tooltip of Slider Component.
264
+ * {% codeBlock src='slider/tooltipIsVisible/index.md' %}{% endcodeBlock %}
265
+ */
266
+ @Property(false)
267
+ public isVisible: boolean;
268
+
269
+ /**
270
+ * It is used to customize the Tooltip content to the desired format
271
+ * using internationalization or events (custom formatting).
272
+ */
273
+ @Property(null)
274
+ public format: string;
275
+ }
276
+
277
+
278
+ /**
279
+ * Ticks Placement.
280
+ * ```props
281
+ * Before :- Ticks are placed in the top of the horizontal slider bar or at the left of the vertical slider bar.
282
+ * After :- Ticks are placed in the bottom of the horizontal slider bar or at the right of the vertical slider bar.
283
+ * Both :- Ticks are placed on the both side of the slider bar.
284
+ * None :- Ticks are not shown.
285
+ * ```
286
+ */
287
+ export type Placement = 'Before' | 'After' | 'Both' | 'None';
288
+
289
+ /**
290
+ * Tooltip Placement.
291
+ * ```props
292
+ * Before :- Tooltip is shown in the top of the horizontal slider bar or at the left of the vertical slider bar.
293
+ * After :- Tooltip is shown in the bottom of the horizontal slider bar or at the right of the vertical slider bar.
294
+ * ```
295
+ */
296
+ export type TooltipPlacement = 'Before' | 'After';
297
+
298
+ /**
299
+ * Tooltip ShowOn.
300
+ * ```props
301
+ * Focus :- Tooltip is shown while focusing the Slider handle.
302
+ * Hover :- Tooltip is shown while hovering the Slider handle.
303
+ * Always :- Tooltip is shown always.
304
+ * Auto :- Tooltip is shown while hovering the Slider handle in desktop and tap and hold in touch devices.
305
+ * ```
306
+ */
307
+ export type TooltipShowOn = 'Focus' | 'Hover' | 'Always' | 'Auto';
308
+
309
+ /**
310
+ * Slider type.
311
+ * ```props
312
+ * Default :- Allows to select a single value in the Slider.
313
+ * MinRange :- Allows to select a single value in the Slider, it display’s a shadow from the start to the current value.
314
+ * Range :- Allows to select a range of values in the Slider.
315
+ * ```
316
+ */
317
+ export type SliderType = 'Default' | 'MinRange' | 'Range';
318
+
319
+ /**
320
+ * Slider orientation.
321
+ * ```props
322
+ * Horizontal :- Renders the slider in horizontal orientation.
323
+ * Vertical :- Renders the slider in vertical orientation.
324
+ * ```
325
+ */
326
+ export type SliderOrientation = 'Horizontal' | 'Vertical';
327
+
328
+ type SliderHandleNumber = 1 | 2;
329
+
330
+ const bootstrapTooltipOffset: number = 6;
331
+ const bootstrap4TooltipOffset: number = 3;
332
+ const tolerance: number = 1e-10;
333
+
334
+ const classNames: { [key: string]: string } = {
335
+ root: 'e-slider',
336
+ rtl: 'e-rtl',
337
+ sliderHiddenInput: 'e-slider-input',
338
+ controlWrapper: 'e-control-wrapper',
339
+ sliderHandle: 'e-handle',
340
+ rangeBar: 'e-range',
341
+ sliderButton: 'e-slider-button',
342
+ firstButton: 'e-first-button',
343
+ secondButton: 'e-second-button',
344
+ scale: 'e-scale',
345
+ tick: 'e-tick',
346
+ large: 'e-large',
347
+ tickValue: 'e-tick-value',
348
+ sliderTooltip: 'e-slider-tooltip',
349
+ sliderHover: 'e-slider-hover',
350
+ sliderFirstHandle: 'e-handle-first',
351
+ sliderSecondHandle: 'e-handle-second',
352
+ sliderDisabled: 'e-disabled',
353
+ sliderContainer: 'e-slider-container',
354
+ horizontalTooltipBefore: 'e-slider-horizontal-before',
355
+ horizontalTooltipAfter: 'e-slider-horizontal-after',
356
+ verticalTooltipBefore: 'e-slider-vertical-before',
357
+ verticalTooltipAfter: 'e-slider-vertical-after',
358
+ materialTooltip: 'e-material-tooltip',
359
+ materialTooltipOpen: 'e-material-tooltip-open',
360
+ materialTooltipActive: 'e-tooltip-active',
361
+ materialSlider: 'e-material-slider',
362
+ sliderTrack: 'e-slider-track',
363
+ sliderHorizantalColor: 'e-slider-horizantal-color',
364
+ sliderVerticalColor: 'e-slider-vertical-color',
365
+ sliderHandleFocused: 'e-handle-focused',
366
+ verticalSlider: 'e-vertical',
367
+ horizontalSlider: 'e-horizontal',
368
+ sliderHandleStart: 'e-handle-start',
369
+ sliderTooltipStart: 'e-material-tooltip-start',
370
+ sliderTabHandle: 'e-tab-handle',
371
+ sliderButtonIcon: 'e-button-icon',
372
+ sliderSmallSize: 'e-small-size',
373
+ sliderTickPosition: 'e-tick-pos',
374
+ sliderFirstTick: 'e-first-tick',
375
+ sliderLastTick: 'e-last-tick',
376
+ sliderButtonClass: 'e-slider-btn',
377
+ sliderTooltipWrapper: 'e-tooltip-wrap',
378
+ sliderTabTrack: 'e-tab-track',
379
+ sliderTabRange: 'e-tab-range',
380
+ sliderActiveHandle: 'e-handle-active',
381
+ sliderMaterialHandle: 'e-material-handle',
382
+ sliderMaterialRange: 'e-material-range',
383
+ sliderMaterialDefault: 'e-material-default',
384
+ materialTooltipShow: 'e-material-tooltip-show',
385
+ materialTooltipHide: 'e-material-tooltip-hide',
386
+ readonly: 'e-read-only',
387
+ limits: 'e-limits',
388
+ limitBarDefault: 'e-limit-bar',
389
+ limitBarFirst: 'e-limit-first',
390
+ limitBarSecond: 'e-limit-second',
391
+ dragHorizontal: 'e-drag-horizontal',
392
+ dragVertical: 'e-drag-vertical'
393
+ };
394
+
395
+
396
+ /**
397
+ * The Slider component allows the user to select a value or range
398
+ * of values in-between a min and max range, by dragging the handle over the slider bar.
399
+ * ```html
400
+ * <div id='slider'></div>
401
+ * ```
402
+ * ```typescript
403
+ * <script>
404
+ * var sliderObj = new Slider({ value: 10 });
405
+ * sliderObj.appendTo('#slider');
406
+ * </script>
407
+ * ```
408
+ */
409
+
410
+ @NotifyPropertyChanges
411
+ export class Slider extends Component<HTMLElement> implements INotifyPropertyChanged {
412
+ /* Internal variables */
413
+ private hiddenInput: HTMLInputElement;
414
+ private firstHandle: HTMLElement;
415
+ private sliderContainer: HTMLElement;
416
+ private secondHandle: HTMLElement;
417
+ private rangeBar: HTMLElement;
418
+ private onresize: EventListener;
419
+ private isElementFocused: boolean;
420
+ private handlePos1: number;
421
+ private handlePos2: number;
422
+ private rtl: boolean;
423
+ private preHandlePos1: number;
424
+ private preHandlePos2: number;
425
+ private handleVal1: number;
426
+ private handleVal2: number;
427
+ private val: number;
428
+ private activeHandle: number;
429
+ private sliderTrack: HTMLElement;
430
+ private materialHandle: HTMLElement;
431
+ private firstBtn: HTMLElement;
432
+ private tooltipObj: Tooltip;
433
+ private tooltipElement: HTMLElement;
434
+ private isMaterialTooltip: boolean;
435
+ private secondBtn: HTMLElement;
436
+ private ul: HTMLElement;
437
+ private firstChild: Element;
438
+ private tooltipCollidedPosition: string;
439
+ private tooltipTarget: HTMLElement;
440
+ private lastChild: Element;
441
+ private previousTooltipClass: string;
442
+ private horDir: string = 'left';
443
+ private verDir: string = 'bottom';
444
+ private transition: { [key: string]: string } = {
445
+ handle: 'left .4s cubic-bezier(.25, .8, .25, 1), right .4s cubic-bezier(.25, .8, .25, 1), ' +
446
+ 'top .4s cubic-bezier(.25, .8, .25, 1) , bottom .4s cubic-bezier(.25, .8, .25, 1)',
447
+ rangeBar: 'all .4s cubic-bezier(.25, .8, .25, 1)'
448
+ };
449
+ private transitionOnMaterialTooltip: { [key: string]: string } = {
450
+ handle: 'left 1ms ease-out, right 1ms ease-out, bottom 1ms ease-out, top 1ms ease-out',
451
+ rangeBar: 'left 1ms ease-out, right 1ms ease-out, bottom 1ms ease-out, width 1ms ease-out, height 1ms ease-out'
452
+ };
453
+ private scaleTransform: string = 'transform .4s cubic-bezier(.25, .8, .25, 1)';
454
+ private previousVal: number | number[];
455
+ private previousChanged: number | number[];
456
+ // eslint-disable-next-line
457
+ private repeatInterval: any;
458
+ private isMaterial: boolean;
459
+ private isMaterial3: boolean;
460
+ private isBootstrap: boolean;
461
+ private isBootstrap4: boolean;
462
+ private isTailwind: boolean;
463
+ private isTailwind3: boolean;
464
+ private isBootstrap5: boolean;
465
+ private isFluent: boolean;
466
+ private isFluent2: boolean;
467
+ private isBootstrap5Dot3: boolean;
468
+ private zIndex: number;
469
+ private l10n: L10n;
470
+ private internationalization: Internationalization;
471
+ private tooltipFormatInfo: NumberFormatOptions;
472
+ private ticksFormatInfo: NumberFormatOptions;
473
+ private customAriaText: string = null;
474
+ private tickElementCollection: HTMLElement[];
475
+ private limitBarFirst: HTMLElement;
476
+ private limitBarSecond: HTMLElement;
477
+ private firstPartRemain: number;
478
+ private secondPartRemain: number;
479
+ private minDiff: number;
480
+ private drag: boolean = true;
481
+ private isForm: boolean;
482
+ private formElement: HTMLFormElement;
483
+ private formResetValue: number | number[];
484
+ private rangeBarDragged: boolean;
485
+ private isDragComplete: boolean = false;
486
+ public initialTooltip: boolean = true;
487
+ /**
488
+ * It is used to denote the current value of the Slider.
489
+ * The value should be specified in array of number when render Slider type as range.
490
+ *
491
+ * {% codeBlock src="slider/value-api/index.ts" %}{% endcodeBlock %}
492
+ *
493
+ * @default null
494
+ * @isGenericType true
495
+ */
496
+ @Property(null)
497
+ public value: number | number[];
498
+
499
+ /**
500
+ * Specifies an array of slider values in number or string type.
501
+ * The min and max step values are not considered.
502
+ *
503
+ * @default null
504
+ */
505
+ @Property(null)
506
+ public customValues: string[] | number[];
507
+
508
+ /**
509
+ * Specifies the step value for each value change when the increase / decrease
510
+ * button is clicked or on arrow keys press or on dragging the thumb.
511
+ * Refer the documentation [here](../../slider/ticks#step)
512
+ * to know more about this property.
513
+ *
514
+ * {% codeBlock src="slider/step-api/index.ts" %}{% endcodeBlock %}
515
+ *
516
+ * @default 1
517
+ */
518
+ @Property(1)
519
+ public step: number;
520
+
521
+ /**
522
+ * Specifies the width of the Slider.
523
+ *
524
+ * @default null
525
+ */
526
+ @Property(null)
527
+ public width: number | string;
528
+
529
+ /**
530
+ * Gets/Sets the minimum value of the slider.
531
+ *
532
+ * {% codeBlock src="slider/min-max-api/index.ts" %}{% endcodeBlock %}
533
+ *
534
+ * @default 0
535
+ */
536
+ @Property(0)
537
+ public min: number;
538
+
539
+ /**
540
+ * Gets/Sets the maximum value of the slider.
541
+ *
542
+ * {% codeBlock src="slider/min-max-api/index.ts" %}{% endcodeBlock %}
543
+ *
544
+ * @default 100
545
+ */
546
+ @Property(100)
547
+ public max: number;
548
+
549
+ /**
550
+ * Specifies whether the render the slider in read-only mode to restrict any user interaction.
551
+ * The slider rendered with user defined values and can’t be interacted with user actions.
552
+ *
553
+ * @default false
554
+ */
555
+ @Property(false)
556
+ public readonly: boolean;
557
+
558
+ /**
559
+ * Defines the type of the Slider. The available options are:
560
+ * * default - Allows to a single value in the Slider.
561
+ * * minRange - Allows to select a single value in the Slider. It display’s a shadow from the start to the current value.
562
+ * * range - Allows to select a range of values in the Slider. It displays shadow in-between the selection range.
563
+ * {% codeBlock src='slider/types/index.md' %}{% endcodeBlock %}
564
+ *
565
+ * @default 'Default'
566
+ */
567
+ @Property('Default')
568
+ public type: SliderType;
569
+
570
+ /**
571
+ * Specifies the color to the slider based on given value.
572
+ */
573
+ @Collection<ColorRangeDataModel>([{}], ColorRangeData)
574
+ public colorRange: ColorRangeDataModel[];
575
+
576
+ /**
577
+ * It is used to render the slider ticks options such as placement and step values.
578
+ * Refer the documentation [here](../../slider/ticks)
579
+ * to know more about this property with demo.
580
+ * {% codeBlock src='slider/ticks/index.md' %}{% endcodeBlock %}
581
+ * {% codeBlock src="slider/ticks-api/index.ts" %}{% endcodeBlock %}
582
+ *
583
+ * @default { placement: 'before' }
584
+ */
585
+ @Complex<TicksDataModel>({}, TicksData)
586
+ public ticks: TicksDataModel;
587
+
588
+ /**
589
+ * Specified the limit within which the slider to be moved.
590
+ * Refer the documentation [here](../../slider/limits)
591
+ * to know more about this property.
592
+ *
593
+ * {% codeBlock src="slider/limits-api/index.ts" %}{% endcodeBlock %}
594
+ *
595
+ * @default { enabled: false }
596
+ */
597
+ @Complex<LimitDataModel>({}, LimitData)
598
+ public limits: LimitDataModel;
599
+
600
+ /**
601
+ * Enable or Disable the slider.
602
+ *
603
+ * @default true
604
+ */
605
+ @Property(true)
606
+ public enabled: boolean;
607
+
608
+ /**
609
+ * Specifies the visibility, position of the tooltip over the slider element.
610
+ *
611
+ * {% codeBlock src="slider/tooltip-api/index.ts" %}{% endcodeBlock %}
612
+ *
613
+ * @default { placement: 'Before', isVisible: false, showOn: 'Focus', format: null }
614
+ */
615
+ @Complex<TooltipDataModel>({}, TooltipData)
616
+ public tooltip: TooltipDataModel;
617
+
618
+ /**
619
+ * Specifies whether to show or hide the increase/decrease buttons
620
+ * of Slider to change the slider value.
621
+ * Refer the documentation [here](../../slider/getting-started#buttons)
622
+ * to know more about this property.
623
+ *
624
+ * {% codeBlock src="slider/showButtons-api/index.ts" %}{% endcodeBlock %}
625
+ *
626
+ * @default false
627
+ */
628
+ @Property(false)
629
+ public showButtons: boolean;
630
+
631
+ /**
632
+ * Enable or Disable the animation for slider movement.
633
+ *
634
+ * @default true
635
+ */
636
+ @Property(true)
637
+ public enableAnimation: boolean;
638
+
639
+ /**
640
+ * Specifies whether to render the slider in vertical or horizontal orientation.
641
+ * Refer the documentation [here](../../slider/orientation/)
642
+ * to know more about this property.
643
+ *
644
+ * @default 'Horizontal'
645
+ */
646
+ @Property('Horizontal')
647
+ public orientation: SliderOrientation;
648
+
649
+ /**
650
+ * Specifies the custom classes to be added to the element used to customize the slider.
651
+ * {% codeBlock src='slider/cssClass/index.md' %}{% endcodeBlock %}
652
+ *
653
+ * @default ''
654
+ */
655
+ @Property('')
656
+ public cssClass: string;
657
+ /**
658
+ * Specifies whether to display or remove the untrusted HTML values in the Slider component.
659
+ * If 'enableHtmlSanitizer' set to true, the component will sanitize any suspected untrusted strings and scripts before rendering them.
660
+ *
661
+ * @default true
662
+ */
663
+ @Property(true)
664
+ public enableHtmlSanitizer: boolean;
665
+ /**
666
+ * Triggers when the Slider is successfully created.
667
+ *
668
+ * @event created
669
+ */
670
+ @Event()
671
+ public created: EmitType<Object>;
672
+
673
+ /**
674
+ * We can trigger change event whenever Slider value is changed.
675
+ * In other term, this event will be triggered while drag the slider thumb.
676
+ * {% codeBlock src='slider/changeEvent/index.md' %}{% endcodeBlock %}
677
+ *
678
+ * @event change
679
+ */
680
+ @Event()
681
+ public change: EmitType<SliderChangeEventArgs>;
682
+
683
+ /**
684
+ * Fires whenever the Slider value is changed.
685
+ * In other term, this event will be triggered, while drag the slider thumb completed.
686
+ *
687
+ * @event changed
688
+ */
689
+ @Event()
690
+ public changed: EmitType<SliderChangeEventArgs>;
691
+
692
+ /**
693
+ * Triggers on rendering the ticks element in the Slider,
694
+ * which is used to customize the ticks labels dynamically.
695
+ * {% codeBlock src='slider/renderingticksEvent/index.md' %}{% endcodeBlock %}
696
+ *
697
+ * @event renderingTicks
698
+ */
699
+ @Event()
700
+ public renderingTicks: EmitType<SliderTickEventArgs>;
701
+
702
+ /**
703
+ * Triggers when the ticks are rendered on the Slider.
704
+ * {% codeBlock src='slider/renderedticksEvent/index.md' %}{% endcodeBlock %}
705
+ *
706
+ * @event renderedTicks
707
+ */
708
+ @Event()
709
+ public renderedTicks: EmitType<SliderTickRenderedEventArgs>;
710
+
711
+ /**
712
+ * Triggers when the Sider tooltip value is changed.
713
+ * {% codeBlock src='slider/tooltipChangeEvent/index.md' %}{% endcodeBlock %}
714
+ *
715
+ * @event tooltipChange
716
+ */
717
+ @Event()
718
+ public tooltipChange: EmitType<SliderTooltipEventArgs>;
719
+
720
+ constructor(options?: SliderModel, element?: string | HTMLElement) {
721
+ super(options, <HTMLElement | string>element);
722
+ }
723
+
724
+ protected preRender(): void {
725
+ const localeText: object = { incrementTitle: 'Increase', decrementTitle: 'Decrease' };
726
+ this.l10n = new L10n('slider', localeText, this.locale);
727
+ this.isElementFocused = false;
728
+ this.tickElementCollection = [];
729
+ this.tooltipFormatInfo = {};
730
+ this.ticksFormatInfo = {};
731
+ this.initCultureInfo();
732
+ this.initCultureFunc();
733
+ this.formChecker();
734
+ }
735
+
736
+ private formChecker(): void {
737
+ const formElement: Element = closest(this.element, 'form');
738
+ if (formElement) {
739
+ this.isForm = true;
740
+ // this condition needs to be checked, if the slider is going to be refreshed by `refresh()`
741
+ // then we need to revert the slider `value` back to `formResetValue` to preserve the initial value
742
+ if (!isNullOrUndefined(this.formResetValue)) {
743
+ this.setProperties({ 'value': this.formResetValue }, true);
744
+ }
745
+ this.formResetValue = this.value;
746
+ if (this.type === 'Range' &&
747
+ (isNullOrUndefined(this.formResetValue) || typeof (this.formResetValue) !== 'object')) {
748
+ this.formResetValue = [parseFloat(formatUnit(this.min)), parseFloat(formatUnit(this.max))];
749
+ } else if (isNullOrUndefined(this.formResetValue)) {
750
+ this.formResetValue = parseFloat(formatUnit(this.min));
751
+ }
752
+ this.formElement = formElement as HTMLFormElement;
753
+ } else {
754
+ this.isForm = false;
755
+ }
756
+ }
757
+
758
+ private initCultureFunc(): void {
759
+ this.internationalization = new Internationalization(this.locale);
760
+ }
761
+
762
+ private initCultureInfo(): void {
763
+ this.tooltipFormatInfo.format = (!isNullOrUndefined(this.tooltip.format)) ? this.tooltip.format : null;
764
+ this.ticksFormatInfo.format = (!isNullOrUndefined(this.ticks.format)) ? this.ticks.format : null;
765
+ }
766
+
767
+ private formatString(value: number, formatInfo: NumberFormatOptions): { elementVal: string, formatString: string } {
768
+ let formatValue: string = null;
769
+ let formatString: string = null;
770
+ if ((value || value === 0)) {
771
+ formatValue = this.formatNumber(value);
772
+ const numberOfDecimals: number = this.numberOfDecimals(value);
773
+ formatString = this.internationalization.getNumberFormat(formatInfo)(this.makeRoundNumber(value, numberOfDecimals));
774
+ }
775
+ return { elementVal: formatValue, formatString: formatString };
776
+ }
777
+
778
+ private formatNumber(value: number): string {
779
+ const numberOfDecimals: number = this.numberOfDecimals(value);
780
+ return this.internationalization.getNumberFormat({
781
+ maximumFractionDigits: numberOfDecimals,
782
+ minimumFractionDigits: numberOfDecimals, useGrouping: false
783
+ })(value);
784
+ }
785
+
786
+ private numberOfDecimals(value: number | string): number {
787
+ const decimalPart: string = value.toString().split('.')[1];
788
+ const numberOfDecimals: number = !decimalPart || !decimalPart.length ? 0 : decimalPart.length;
789
+ return numberOfDecimals;
790
+ }
791
+
792
+ private makeRoundNumber(value: number, precision: number): number {
793
+ const decimals: number = precision || 0;
794
+ return Number(value.toFixed(decimals));
795
+ }
796
+
797
+ /**
798
+ * To Initialize the control rendering
799
+ *
800
+ * @returns {void}
801
+ * @private
802
+ */
803
+ public render(): void {
804
+ this.initialize();
805
+ this.initRender();
806
+ this.wireEvents();
807
+ this.setZindex();
808
+ this.renderComplete();
809
+ if (this.element.tagName === 'EJS-SLIDER') {
810
+ if (this.getTheme(this.sliderContainer) === 'none') {
811
+ setTimeout(() => {
812
+ this.refresh();
813
+ }, 0);
814
+ }
815
+ }
816
+ }
817
+
818
+ private initialize(): void {
819
+ addClass([this.element], classNames.root);
820
+ this.setCSSClass();
821
+ }
822
+
823
+ private setElementWidth(width: number | string): void {
824
+ if (!isNullOrUndefined(width) && !isNullOrUndefined(this.sliderContainer)) {
825
+ if (typeof width === 'number') {
826
+ this.sliderContainer.style.width = formatUnit(width);
827
+ } else if (typeof width === 'string') {
828
+ this.sliderContainer.style.width = (width.match(/px|%|em/)) ? <string>(width) : <string>(formatUnit(width));
829
+ }
830
+ }
831
+ }
832
+
833
+ private setCSSClass(oldCSSClass?: string): void {
834
+ if (oldCSSClass) {
835
+ removeClass([this.element], oldCSSClass.split(' '));
836
+ }
837
+ if (this.cssClass) {
838
+ addClass([this.element], this.cssClass.split(' '));
839
+ }
840
+ }
841
+
842
+ private setEnabled(): void {
843
+ if (!this.enabled) {
844
+ addClass([this.sliderContainer], [classNames.sliderDisabled]);
845
+ if (this.tooltip.isVisible && this.tooltipElement && this.tooltip.showOn === 'Always') {
846
+ this.tooltipElement.classList.add(classNames.sliderDisabled);
847
+ }
848
+ this.unwireEvents();
849
+ } else {
850
+ removeClass([this.sliderContainer], [classNames.sliderDisabled]);
851
+ if (this.tooltip.isVisible && this.tooltipElement && this.tooltip.showOn === 'Always') {
852
+ this.tooltipElement.classList.remove(classNames.sliderDisabled);
853
+ }
854
+ this.wireEvents();
855
+ }
856
+ }
857
+
858
+ private getTheme(container: HTMLElement): string {
859
+ const theme: string = window.getComputedStyle(container as Element, ':after').getPropertyValue('content');
860
+ return theme.replace(/['"]+/g, '');
861
+ }
862
+
863
+ /**
864
+ * Initialize the rendering
865
+ *
866
+ * @returns {void}
867
+ * @private
868
+ */
869
+ private initRender(): void {
870
+ this.sliderContainer = this.createElement('div', { className: classNames.sliderContainer + ' ' + classNames.controlWrapper });
871
+ this.element.parentNode.insertBefore(this.sliderContainer, this.element);
872
+ this.sliderContainer.appendChild(this.element);
873
+ this.sliderTrack = this.createElement('div', { className: classNames.sliderTrack });
874
+ this.element.appendChild(this.sliderTrack);
875
+ this.setElementWidth(this.width);
876
+ this.element.tabIndex = -1;
877
+ this.getThemeInitialization();
878
+ this.setHandler();
879
+ this.createRangeBar();
880
+ if (this.limits.enabled) {
881
+ this.createLimitBar();
882
+ }
883
+ this.setOrientClass();
884
+ this.hiddenInput = <HTMLInputElement>(this.createElement('input', {
885
+ attrs: {
886
+ type: 'hidden', value: (isNullOrUndefined(this.value) ? (isNullOrUndefined(this.min) ? '0' : this.min.toString()) : this.value.toString()),
887
+ name: this.element.getAttribute('name') || this.element.getAttribute('id') ||
888
+ '_' + (Math.random() * 1000).toFixed(0) + 'slider', class: classNames.sliderHiddenInput
889
+ }
890
+ }));
891
+ this.hiddenInput.tabIndex = -1;
892
+ this.sliderContainer.appendChild(this.hiddenInput);
893
+ if (this.showButtons) { this.setButtons(); }
894
+ this.setEnableRTL();
895
+ if (this.type === 'Range') {
896
+ this.rangeValueUpdate();
897
+ } else {
898
+ this.value = isNullOrUndefined(this.value) ? (isNullOrUndefined(this.min) ? 0 :
899
+ parseFloat(formatUnit(this.min.toString()))) : this.value;
900
+ }
901
+ this.previousVal = this.type !== 'Range' ? this.checkHandleValue(parseFloat(formatUnit(this.value.toString()))) :
902
+ [this.checkHandleValue(parseFloat(formatUnit((this.value as number[])[0].toString()))),
903
+ this.checkHandleValue(parseFloat(formatUnit((this.value as number[])[1].toString())))];
904
+ this.previousChanged = this.previousVal;
905
+ if (!isNullOrUndefined(this.element.hasAttribute('name'))) {
906
+ this.element.removeAttribute('name');
907
+ }
908
+ this.setValue();
909
+ if (this.limits.enabled) {
910
+ this.setLimitBar();
911
+ }
912
+ if (this.ticks.placement !== 'None') {
913
+ this.renderScale();
914
+ }
915
+ if (this.tooltip.isVisible) {
916
+ this.renderTooltip();
917
+ }
918
+ if (!this.enabled) {
919
+ addClass([this.sliderContainer], [classNames.sliderDisabled]);
920
+ } else {
921
+ removeClass([this.sliderContainer], [classNames.sliderDisabled]);
922
+ }
923
+ if (this.readonly) {
924
+ addClass([this.sliderContainer], [classNames.readonly]);
925
+ } else {
926
+ removeClass([this.sliderContainer], [classNames.readonly]);
927
+ }
928
+ }
929
+
930
+ private getThemeInitialization(): void {
931
+ this.isMaterial = this.getTheme(this.sliderContainer) === 'material'
932
+ || this.getTheme(this.sliderContainer) === 'material-dark';
933
+ this.isMaterial3 = this.getTheme(this.sliderContainer) === 'Material3'
934
+ || this.getTheme(this.sliderContainer) === 'Material3-dark';
935
+ this.isBootstrap = this.getTheme(this.sliderContainer) === 'bootstrap'
936
+ || this.getTheme(this.sliderContainer) === 'bootstrap-dark';
937
+ this.isBootstrap4 = this.getTheme(this.sliderContainer) === 'bootstrap4';
938
+ this.isTailwind = this.getTheme(this.sliderContainer) === 'tailwind' || this.getTheme(this.sliderContainer) === 'tailwind-dark';
939
+ this.isTailwind3 = this.getTheme(this.sliderContainer) === 'tailwind3' || this.getTheme(this.sliderContainer) === 'tailwind3-dark';
940
+ this.isBootstrap5 = this.getTheme(this.sliderContainer) === 'bootstrap5';
941
+ this.isFluent = this.getTheme(this.sliderContainer) === 'FluentUI';
942
+ this.isFluent2 = this.getTheme(this.sliderContainer) === 'fluent2';
943
+ this.isBootstrap5Dot3 = this.getTheme(this.sliderContainer) === 'bootstrap5.3';
944
+ this.isMaterialTooltip = (this.isMaterial || this.isMaterial3) && this.type !== 'Range' && this.tooltip.isVisible;
945
+ }
946
+
947
+ private createRangeBar(): void {
948
+ if (this.type !== 'Default') {
949
+ this.rangeBar = <HTMLElement>(this.createElement('div', { attrs: { class: classNames.rangeBar } }));
950
+ this.element.appendChild(this.rangeBar);
951
+
952
+ if (this.drag && this.type === 'Range') {
953
+ if (this.orientation === 'Horizontal') {
954
+ this.rangeBar.classList.add(classNames.dragHorizontal);
955
+ } else {
956
+ this.rangeBar.classList.add(classNames.dragVertical);
957
+ }
958
+ }
959
+ }
960
+ }
961
+
962
+ private createLimitBar(): void {
963
+ let firstElementClassName: string = this.type !== 'Range' ? classNames.limitBarDefault :
964
+ classNames.limitBarFirst;
965
+ firstElementClassName += ' ' + classNames.limits;
966
+ this.limitBarFirst = <HTMLElement>(this.createElement('div', {
967
+ attrs: { class: firstElementClassName }
968
+ }));
969
+ this.element.appendChild(this.limitBarFirst);
970
+ if (this.type === 'Range') {
971
+ this.limitBarSecond = <HTMLElement>(this.createElement('div', {
972
+ attrs: {
973
+ class: classNames.limitBarSecond + ' ' + classNames.limits
974
+ }
975
+ }));
976
+ this.element.appendChild(this.limitBarSecond);
977
+ }
978
+ }
979
+
980
+ private setOrientClass(): void {
981
+ if (this.orientation !== 'Vertical') {
982
+ this.sliderContainer.classList.remove(classNames.verticalSlider);
983
+ this.sliderContainer.classList.add(classNames.horizontalSlider);
984
+ this.firstHandle.setAttribute('aria-orientation', 'horizontal');
985
+ if (this.type === 'Range') {
986
+ this.secondHandle.setAttribute('aria-orientation', 'horizontal');
987
+ }
988
+ } else {
989
+ this.sliderContainer.classList.remove(classNames.horizontalSlider);
990
+ this.sliderContainer.classList.add(classNames.verticalSlider);
991
+ this.firstHandle.setAttribute('aria-orientation', 'vertical');
992
+ if (this.type === 'Range') {
993
+ this.secondHandle.setAttribute('aria-orientation', 'vertical');
994
+ }
995
+ }
996
+ }
997
+
998
+ private setAriaAttributes(element: Element): void {
999
+ let min: string | number = this.min; let max: string | number = this.max;
1000
+ if (!isNullOrUndefined(this.customValues) && this.customValues.length > 0) {
1001
+ min = this.customValues[0];
1002
+ max = this.customValues[this.customValues.length - 1];
1003
+ }
1004
+ if (this.type !== 'Range') {
1005
+ attributes(element, {
1006
+ 'aria-valuemin': isNullOrUndefined(min) ? '0' : min.toString(), 'aria-valuemax': (isNullOrUndefined(max) ? '100' : max.toString())
1007
+ });
1008
+ } else {
1009
+ const range: string[][] = !isNullOrUndefined(this.customValues) && this.customValues.length > 0 ?
1010
+ [[!isNullOrUndefined(min) ? min.toString() : '', (this.value as number[]).length > 1 && !isNullOrUndefined(this.customValues[(this.value as number[])[1]]) ?
1011
+ (this.customValues[(this.value as number[])[1]]).toString() : ''], [(this.value as number[]).length > 0 && !isNullOrUndefined(this.customValues[(this.value as number[])[0]]) ?
1012
+ (this.customValues[(this.value as number[])[0]]).toString() : '', !isNullOrUndefined(max) ? max.toString() : '']] : [[
1013
+ !isNullOrUndefined(min) ? min.toString() : '', (this.value as number[]).length > 1 && !isNullOrUndefined((this.value as number[])[1]) ? (this.value as number[])[1].toString() : ''],
1014
+ [(this.value as number[]).length > 0 && !isNullOrUndefined((this.value as number[])[0]) ? (this.value as number[])[0].toString() : '',
1015
+ !isNullOrUndefined(max) ? max.toString() : '']];
1016
+ range.forEach((range: string[], index: number) => {
1017
+ const element: Element = index === 0 ? this.firstHandle : this.secondHandle;
1018
+ if (element) {
1019
+ attributes(element, {
1020
+ 'aria-valuemin': range[0], 'aria-valuemax': range[1]
1021
+ });
1022
+ }
1023
+ });
1024
+ }
1025
+ }
1026
+ private createSecondHandle(): void {
1027
+ this.secondHandle = this.createElement('div', {
1028
+ attrs: {
1029
+ class: classNames.sliderHandle, 'role': 'slider', tabIndex: '0', 'aria-label': 'slider'
1030
+ }
1031
+ });
1032
+ this.secondHandle.classList.add(classNames.sliderSecondHandle);
1033
+ this.element.appendChild(this.secondHandle);
1034
+ }
1035
+
1036
+ private createFirstHandle(): void {
1037
+ this.firstHandle = this.createElement('div', {
1038
+ attrs: {
1039
+ class: classNames.sliderHandle, 'role': 'slider', tabIndex: '0', 'aria-label': 'slider'
1040
+ }
1041
+ });
1042
+ this.firstHandle.classList.add(classNames.sliderFirstHandle);
1043
+ this.element.appendChild(this.firstHandle);
1044
+ if (this.isMaterialTooltip) {
1045
+ this.materialHandle = this.createElement('div', {
1046
+ attrs: {
1047
+ class: classNames.sliderHandle + ' ' +
1048
+ classNames.sliderMaterialHandle
1049
+ }
1050
+ });
1051
+ this.element.appendChild(this.materialHandle);
1052
+ }
1053
+ }
1054
+
1055
+ private wireFirstHandleEvt(destroy: boolean): void {
1056
+ if (!destroy) {
1057
+ EventHandler.add(this.firstHandle, 'mousedown touchstart', this.handleFocus, this);
1058
+ EventHandler.add(this.firstHandle, 'transitionend', this.transitionEnd, this);
1059
+ EventHandler.add(this.firstHandle, 'mouseenter touchenter', this.handleOver, this);
1060
+ EventHandler.add(this.firstHandle, 'mouseleave touchend', this.handleLeave, this);
1061
+ } else {
1062
+ EventHandler.remove(this.firstHandle, 'mousedown touchstart', this.handleFocus);
1063
+ EventHandler.remove(this.firstHandle, 'transitionend', this.transitionEnd);
1064
+ EventHandler.remove(this.firstHandle, 'mouseenter touchenter', this.handleOver);
1065
+ EventHandler.remove(this.firstHandle, 'mouseleave touchend', this.handleLeave);
1066
+ }
1067
+ }
1068
+
1069
+ private wireSecondHandleEvt(destroy: boolean): void {
1070
+ if (!destroy) {
1071
+ EventHandler.add(this.secondHandle, 'mousedown touchstart', this.handleFocus, this);
1072
+ EventHandler.add(this.secondHandle, 'transitionend', this.transitionEnd, this);
1073
+ EventHandler.add(this.secondHandle, 'mouseenter touchenter', this.handleOver, this);
1074
+ EventHandler.add(this.secondHandle, 'mouseleave touchend', this.handleLeave, this);
1075
+ } else {
1076
+ EventHandler.remove(this.secondHandle, 'mousedown touchstart', this.handleFocus);
1077
+ EventHandler.remove(this.secondHandle, 'transitionend', this.transitionEnd);
1078
+ EventHandler.remove(this.secondHandle, 'mouseenter touchenter', this.handleOver);
1079
+ EventHandler.remove(this.secondHandle, 'mouseleave touchend', this.handleLeave);
1080
+ }
1081
+ }
1082
+
1083
+ private handleStart(): void {
1084
+ if (this.type !== 'Range') {
1085
+ this.firstHandle.classList[this.handlePos1 === 0 ? 'add' : 'remove'](classNames.sliderHandleStart);
1086
+ if (this.isMaterialTooltip) {
1087
+ this.materialHandle.classList[this.handlePos1 === 0 ? 'add' : 'remove'](classNames.sliderHandleStart);
1088
+ if (this.tooltipElement) {
1089
+ this.tooltipElement.classList[this.handlePos1 === 0 ? 'add' : 'remove'](classNames.sliderTooltipStart);
1090
+ }
1091
+ }
1092
+ }
1093
+ }
1094
+
1095
+ private transitionEnd(e: TransitionEvent): void {
1096
+ if (e.propertyName !== 'transform') {
1097
+ this.handleStart();
1098
+ if (!this.enableAnimation) {
1099
+ this.getHandle().style.transition = 'none';
1100
+ }
1101
+ if (this.type !== 'Default') {
1102
+ this.rangeBar.style.transition = 'none';
1103
+ }
1104
+ if ((this.isMaterial || this.isMaterial3) && this.tooltip.isVisible && this.type === 'Default') {
1105
+ this.tooltipElement.style.transition = this.transition.handle;
1106
+ }
1107
+ this.tooltipToggle(this.getHandle());
1108
+ this.closeTooltip();
1109
+ }
1110
+ }
1111
+
1112
+ private handleFocusOut(): void {
1113
+ if (this.firstHandle.classList.contains(classNames.sliderHandleFocused)) {
1114
+ this.firstHandle.classList.remove(classNames.sliderHandleFocused);
1115
+ }
1116
+ if (this.type === 'Range') {
1117
+ if (this.secondHandle.classList.contains(classNames.sliderHandleFocused)) {
1118
+ this.secondHandle.classList.remove(classNames.sliderHandleFocused);
1119
+ }
1120
+ }
1121
+ }
1122
+ private handleFocus(e: MouseEvent & TouchEvent): void {
1123
+ this.focusSliderElement();
1124
+ this.sliderBarClick(e);
1125
+ if (e.currentTarget === this.firstHandle) {
1126
+ this.firstHandle.classList.add(classNames.sliderHandleFocused);
1127
+ this.firstHandle.classList.add(classNames.sliderTabHandle);
1128
+ } else {
1129
+ this.secondHandle.classList.add(classNames.sliderHandleFocused);
1130
+ this.secondHandle.classList.add(classNames.sliderTabHandle);
1131
+ }
1132
+ EventHandler.add(document, 'mousemove touchmove', this.sliderBarMove, this);
1133
+ EventHandler.add(document, 'mouseup touchend', this.sliderBarUp, this);
1134
+ }
1135
+ private handleOver(e: MouseEvent): void {
1136
+ if (this.tooltip.isVisible && this.tooltip.showOn === 'Hover') {
1137
+ this.tooltipToggle(e.currentTarget as HTMLElement);
1138
+ } if (this.type === 'Default') {
1139
+ this.tooltipToggle(this.getHandle());
1140
+ }
1141
+ }
1142
+ private handleLeave(e: MouseEvent): void {
1143
+ if (this.tooltip.isVisible && this.tooltip.showOn === 'Hover' &&
1144
+ !(e.currentTarget as HTMLElement).classList.contains(classNames.sliderHandleFocused) &&
1145
+ !(e.currentTarget as HTMLElement).classList.contains(classNames.sliderTabHandle)) {
1146
+ this.closeTooltip();
1147
+ }
1148
+
1149
+ }
1150
+ private setHandler(): void {
1151
+ this.createFirstHandle();
1152
+ if (this.type === 'Range') {
1153
+ this.createSecondHandle();
1154
+ }
1155
+ }
1156
+
1157
+ private setEnableRTL(): void {
1158
+ if (this.enableRtl && this.orientation !== 'Vertical') {
1159
+ addClass([this.sliderContainer], classNames.rtl);
1160
+ } else {
1161
+ removeClass([this.sliderContainer], classNames.rtl);
1162
+ }
1163
+ const preDir: string = (this.orientation !== 'Vertical') ? this.horDir : this.verDir;
1164
+ if (this.enableRtl) {
1165
+ this.horDir = 'right';
1166
+ this.verDir = 'bottom';
1167
+ } else {
1168
+ this.horDir = 'left';
1169
+ this.verDir = 'bottom';
1170
+ }
1171
+ const currDir: string = (this.orientation !== 'Vertical') ? this.horDir : this.verDir;
1172
+ if (preDir !== currDir) {
1173
+ if (this.orientation === 'Horizontal') {
1174
+ setStyleAttribute(this.firstHandle, { 'right': '', 'left': 'auto' });
1175
+ if (this.type === 'Range') {
1176
+ setStyleAttribute(this.secondHandle, { 'top': '', 'left': 'auto' });
1177
+ }
1178
+ }
1179
+ }
1180
+ this.setBarColor();
1181
+ }
1182
+
1183
+ private tooltipValue(): void {
1184
+ let text: string;
1185
+ const args: SliderTooltipEventArgs = {
1186
+ value: this.value,
1187
+ text: ''
1188
+ };
1189
+ if (this.initialTooltip) {
1190
+ this.initialTooltip = false;
1191
+ this.setTooltipContent();
1192
+ args.text = text = (typeof (this.tooltipObj.content) === 'function' ? this.tooltipObj.content() : this.tooltipObj.content) as string;
1193
+ this.trigger('tooltipChange', args, (observedArgs: SliderChangeEventArgs) => {
1194
+ this.addTooltipClass(observedArgs.text);
1195
+ if (text !== observedArgs.text) {
1196
+ this.customAriaText = observedArgs.text;
1197
+ if (this.enableHtmlSanitizer) {
1198
+ observedArgs.text = SanitizeHtmlHelper.sanitize(observedArgs.text.toString());
1199
+ } else {
1200
+ observedArgs.text = observedArgs.text.toString();
1201
+ }
1202
+ const contentTemp: Function = function (): string {
1203
+ return observedArgs.text;
1204
+ };
1205
+ this.tooltipObj.content = initializeCSPTemplate(contentTemp);
1206
+ this.setAriaAttrValue(this.firstHandle);
1207
+ if (this.type === 'Range') {
1208
+ this.setAriaAttrValue(this.secondHandle);
1209
+ }
1210
+ }
1211
+ });
1212
+ if (this.isMaterialTooltip) {
1213
+ this.setPreviousVal('change', this.value);
1214
+ }
1215
+ }
1216
+ }
1217
+
1218
+ private setTooltipContent(): void {
1219
+ const content: string = this.formatContent(this.tooltipFormatInfo, false);
1220
+ const contentTemp: Function = function (): string {
1221
+ return content;
1222
+ };
1223
+ this.tooltipObj.content = initializeCSPTemplate(contentTemp);
1224
+ }
1225
+
1226
+ private formatContent(formatInfo: NumberFormatOptions, ariaContent: boolean): string {
1227
+ let content: string = '';
1228
+ let handle1: number = this.handleVal1;
1229
+ let handle2: number = this.handleVal2;
1230
+ if (!isNullOrUndefined(this.customValues) && this.customValues.length > 0) {
1231
+ handle1 = <number>this.customValues[this.handleVal1];
1232
+ handle2 = <number>this.customValues[this.handleVal2];
1233
+ }
1234
+ if (!ariaContent) {
1235
+ if (this.type === 'Range') {
1236
+ if (this.enableRtl && this.orientation !== 'Vertical') {
1237
+ content = (!isNullOrUndefined(formatInfo.format)) ? (this.formatString(handle2, formatInfo)
1238
+ .formatString + ' - ' + this.formatString(handle1, formatInfo).formatString) :
1239
+ (handle2.toString() + ' - ' + handle1.toString());
1240
+ } else {
1241
+ content = (!isNullOrUndefined(formatInfo.format)) ? (this.formatString(handle1, formatInfo)
1242
+ .formatString + ' - ' + this.formatString(handle2, formatInfo).formatString) :
1243
+ (handle1.toString() + ' - ' + handle2.toString());
1244
+ }
1245
+ } else {
1246
+ if (!isNullOrUndefined(handle1)) {
1247
+ content = (!isNullOrUndefined(formatInfo.format)) ?
1248
+ this.formatString(handle1, formatInfo).formatString : handle1.toString();
1249
+ }
1250
+ }
1251
+ return content;
1252
+ } else {
1253
+ if (this.type === 'Range') {
1254
+ if (this.enableRtl && this.orientation !== 'Vertical') {
1255
+ content = (!isNullOrUndefined(this.tooltip) && !isNullOrUndefined(this.tooltip.format)) ?
1256
+ (this.formatString(handle2, formatInfo).elementVal + ' - ' +
1257
+ this.formatString(handle1, formatInfo).elementVal) :
1258
+ (handle2.toString() + ' - ' + handle1.toString());
1259
+ } else {
1260
+ content = (!isNullOrUndefined(this.tooltip) && !isNullOrUndefined(this.tooltip.format)) ?
1261
+ (this.formatString(handle1, formatInfo).elementVal + ' - ' +
1262
+ this.formatString(handle2, formatInfo).elementVal) :
1263
+ (handle1.toString() + ' - ' + handle2.toString());
1264
+ }
1265
+ } else {
1266
+ if (!isNullOrUndefined(handle1)) {
1267
+ content = (!isNullOrUndefined(this.tooltip) && !isNullOrUndefined(this.tooltip.format)) ?
1268
+ this.formatString(handle1, formatInfo).elementVal : handle1.toString();
1269
+ }
1270
+ }
1271
+ return content;
1272
+ }
1273
+ }
1274
+
1275
+ private addTooltipClass(content: string): void {
1276
+ if (this.isMaterialTooltip) {
1277
+ const count: number = content.toString().length;
1278
+ if (!this.tooltipElement) {
1279
+ const cssClass: string = count > 4 ? classNames.sliderMaterialRange : classNames.sliderMaterialDefault;
1280
+ this.tooltipObj.cssClass = classNames.sliderTooltip + ' ' + cssClass;
1281
+ } else {
1282
+ const cssClass: { [key: string]: string } = count > 4 ?
1283
+ { oldCss: classNames.sliderMaterialDefault, newCss: classNames.sliderMaterialRange } :
1284
+ { oldCss: classNames.sliderMaterialRange, newCss: classNames.sliderMaterialDefault };
1285
+ this.tooltipElement.classList.remove(cssClass.oldCss);
1286
+ if (!this.tooltipElement.classList.contains(cssClass.newCss)) {
1287
+ this.tooltipElement.classList.add(cssClass.newCss);
1288
+ this.tooltipElement.style.transform = count > 4 ? 'scale(1)' :
1289
+ this.getTooltipTransformProperties(this.previousTooltipClass).rotate;
1290
+ }
1291
+ }
1292
+ }
1293
+ }
1294
+
1295
+ private tooltipPlacement(): Position {
1296
+ return this.orientation === 'Horizontal' ? (this.tooltip.placement === 'Before' ? 'TopCenter' : 'BottomCenter') :
1297
+ (this.tooltip.placement === 'Before' ? 'LeftCenter' : 'RightCenter');
1298
+ }
1299
+
1300
+ private tooltipBeforeOpen(args: TooltipEventArgs): void {
1301
+ this.tooltipElement = args.element;
1302
+ if (this.tooltip.cssClass) {
1303
+ addClass([this.tooltipElement], this.tooltip.cssClass.split(' ').filter((css: string) => css));
1304
+ }
1305
+ args.target.removeAttribute('aria-describedby');
1306
+ if (this.isMaterialTooltip) {
1307
+ (this.tooltipElement.firstElementChild as HTMLElement).classList.add(classNames.materialTooltipHide);
1308
+ this.handleStart();
1309
+ this.setTooltipTransform();
1310
+ }
1311
+ }
1312
+
1313
+ private tooltipCollision(position: string): void {
1314
+ if (this.isBootstrap || this.isBootstrap4 || ((this.isMaterial || this.isMaterial3) && !this.isMaterialTooltip)) {
1315
+ const tooltipOffsetValue: number = this.isBootstrap4 ? bootstrap4TooltipOffset : bootstrapTooltipOffset;
1316
+ switch (position) {
1317
+ case 'TopCenter':
1318
+ this.tooltipObj.setProperties({ 'offsetY': -(tooltipOffsetValue) }, false);
1319
+ break;
1320
+
1321
+ case 'BottomCenter':
1322
+ this.tooltipObj.setProperties({ 'offsetY': tooltipOffsetValue }, false);
1323
+ break;
1324
+
1325
+ case 'LeftCenter':
1326
+ this.tooltipObj.setProperties({ 'offsetX': -(tooltipOffsetValue) }, false);
1327
+ break;
1328
+
1329
+ case 'RightCenter':
1330
+ this.tooltipObj.setProperties({ 'offsetX': tooltipOffsetValue }, false);
1331
+ break;
1332
+ }
1333
+ }
1334
+ }
1335
+
1336
+ private materialTooltipEventCallBack(event: MouseEvent & TouchEvent): void {
1337
+ this.sliderBarClick(event);
1338
+ EventHandler.add(document, 'mousemove touchmove', this.sliderBarMove, this);
1339
+ EventHandler.add(document, 'mouseup touchend', this.sliderBarUp, this);
1340
+ }
1341
+
1342
+ private wireMaterialTooltipEvent(destroy: boolean): void {
1343
+ if (this.isMaterialTooltip) {
1344
+ if (!destroy) {
1345
+ EventHandler.add(this.tooltipElement, 'mousedown touchstart', this.materialTooltipEventCallBack, this);
1346
+ } else {
1347
+ EventHandler.remove(this.tooltipElement, 'mousedown touchstart', this.materialTooltipEventCallBack);
1348
+ }
1349
+ }
1350
+ }
1351
+
1352
+ private tooltipPositionCalculation(position: string): string {
1353
+ let cssClass: string;
1354
+ switch (position) {
1355
+ case 'TopCenter':
1356
+ cssClass = classNames.horizontalTooltipBefore;
1357
+ break;
1358
+
1359
+ case 'BottomCenter':
1360
+ cssClass = classNames.horizontalTooltipAfter;
1361
+ break;
1362
+ case 'LeftCenter':
1363
+ cssClass = classNames.verticalTooltipBefore;
1364
+ break;
1365
+
1366
+ case 'RightCenter':
1367
+ cssClass = classNames.verticalTooltipAfter;
1368
+ break;
1369
+ }
1370
+ return cssClass;
1371
+ }
1372
+
1373
+ private getTooltipTransformProperties(className: string): { [key: string]: string } {
1374
+ let transformProperties: { [key: string]: string };
1375
+ if (this.tooltipElement) {
1376
+ const position: number = this.orientation === 'Horizontal' ?
1377
+ ((this.tooltipElement.clientHeight + 14) - (this.tooltipElement.clientHeight / 2)) :
1378
+ ((this.tooltipElement.clientWidth + 14) - (this.tooltipElement.clientWidth / 2));
1379
+ transformProperties = this.orientation === 'Horizontal' ?
1380
+ (className === classNames.horizontalTooltipBefore ? { rotate: 'rotate(45deg)', translate: `translateY(${position}px)` } :
1381
+ { rotate: 'rotate(225deg)', translate: `translateY(${-(position)}px)` }) :
1382
+ (className === classNames.verticalTooltipBefore ? { rotate: 'rotate(-45deg)', translate: `translateX(${position}px)` } :
1383
+ { rotate: 'rotate(-225deg)', translate: `translateX(${(-position)}px)` });
1384
+ }
1385
+ return transformProperties;
1386
+ }
1387
+
1388
+ private openMaterialTooltip(): void {
1389
+ if (this.isMaterialTooltip) {
1390
+ this.refreshTooltip(this.firstHandle);
1391
+ const tooltipContentElement: HTMLElement = this.tooltipElement.firstElementChild as HTMLElement;
1392
+ tooltipContentElement.classList.remove(classNames.materialTooltipHide);
1393
+ tooltipContentElement.classList.add(classNames.materialTooltipShow);
1394
+ this.firstHandle.style.cursor = 'default';
1395
+ this.tooltipElement.style.transition = this.scaleTransform;
1396
+ this.tooltipElement.classList.add(classNames.materialTooltipOpen);
1397
+ this.materialHandle.style.transform = 'scale(0)';
1398
+ if (tooltipContentElement.innerText.length > 4) {
1399
+ this.tooltipElement.style.transform = 'scale(1)';
1400
+ } else {
1401
+ this.tooltipElement.style.transform = this.getTooltipTransformProperties(this.previousTooltipClass).rotate;
1402
+ }
1403
+ if (this.type === 'Default') {
1404
+ setTimeout(() => { if (this.tooltipElement) {this.tooltipElement.style.transition = this.transition.handle; } }, 2500);
1405
+ } else {
1406
+ setTimeout(() => { if (this.tooltipElement) {this.tooltipElement.style.transition = 'none'; } }, 2500);
1407
+ }
1408
+
1409
+ }
1410
+ }
1411
+
1412
+ private closeMaterialTooltip(): void {
1413
+ if (this.isMaterialTooltip) {
1414
+ const tooltipContentElement: HTMLElement = this.tooltipElement.firstElementChild as HTMLElement;
1415
+ this.tooltipElement.style.transition = this.scaleTransform;
1416
+ tooltipContentElement.classList.remove(classNames.materialTooltipShow);
1417
+ tooltipContentElement.classList.add(classNames.materialTooltipHide);
1418
+ this.firstHandle.style.cursor = '-webkit-grab';
1419
+ this.firstHandle.style.cursor = 'grab';
1420
+ if (this.materialHandle) { this.materialHandle.style.transform = 'scale(1)'; }
1421
+ this.tooltipElement.classList.remove(classNames.materialTooltipOpen);
1422
+ this.setTooltipTransform();
1423
+ this.tooltipTarget = undefined;
1424
+ setTimeout(() => { if (this.tooltipElement) {this.tooltipElement.style.transition = 'none'; } }, 2500);
1425
+ }
1426
+ }
1427
+
1428
+ private checkTooltipPosition(args: TooltipEventArgs): void {
1429
+ const tooltipClass: string = this.tooltipPositionCalculation(args.collidedPosition);
1430
+ if (this.tooltipCollidedPosition === undefined ||
1431
+ this.tooltipCollidedPosition !== args.collidedPosition || !args.element.classList.contains(tooltipClass)) {
1432
+ if (this.isMaterialTooltip) {
1433
+ if (tooltipClass !== undefined) {
1434
+ args.element.classList.remove(this.previousTooltipClass);
1435
+ args.element.classList.add(tooltipClass);
1436
+ this.previousTooltipClass = tooltipClass;
1437
+ }
1438
+ if (args.element.style.transform && args.element.classList.contains(classNames.materialTooltipOpen) &&
1439
+ (args.element.firstElementChild as HTMLElement).innerText.length <= 4) {
1440
+ args.element.style.transform = this.getTooltipTransformProperties(this.previousTooltipClass).rotate;
1441
+ }
1442
+ }
1443
+ this.tooltipCollidedPosition = args.collidedPosition;
1444
+ }
1445
+ if (this.isMaterialTooltip && this.tooltipElement && this.tooltipElement.style.transform.indexOf('translate') !== -1) {
1446
+ this.setTooltipTransform();
1447
+ }
1448
+ }
1449
+
1450
+ private setTooltipTransform(): void {
1451
+ const transformProperties: { [key: string]: string } = this.getTooltipTransformProperties(this.previousTooltipClass);
1452
+ if (isNullOrUndefined(this.tooltipElement)) {return; }
1453
+ if ((this.tooltipElement.firstElementChild as HTMLElement).innerText.length > 4) {
1454
+ this.tooltipElement.style.transform = `${transformProperties.translate} scale(0.01)`;
1455
+ } else {
1456
+ this.tooltipElement.style.transform = `${transformProperties.translate} ${transformProperties.rotate} scale(0.01)`;
1457
+ }
1458
+ }
1459
+
1460
+ private renderTooltip(): void {
1461
+ this.tooltipObj = new Tooltip({
1462
+ showTipPointer: this.isBootstrap || this.isMaterial || this.isMaterial3 || this.isBootstrap4 || this.isTailwind
1463
+ || this.isTailwind3 || this.isBootstrap5 || this.isFluent || this.isFluent2 || this.isBootstrap5Dot3,
1464
+ cssClass: classNames.sliderTooltip,
1465
+ height: (this.isMaterial || this.isMaterial3) ? 30 : 'auto',
1466
+ animation: { open: { effect: 'None' }, close: { effect: 'FadeOut', duration: 500 } },
1467
+ opensOn: 'Custom',
1468
+ beforeOpen: this.tooltipBeforeOpen.bind(this),
1469
+ beforeCollision: this.checkTooltipPosition.bind(this),
1470
+ beforeClose: this.tooltipBeforeClose.bind(this),
1471
+ enableHtmlSanitizer: this.enableHtmlSanitizer
1472
+ });
1473
+ this.tooltipObj.appendTo(this.firstHandle);
1474
+ this.initializeTooltipProps();
1475
+ }
1476
+
1477
+ private initializeTooltipProps(): void {
1478
+ const tooltipShowOn: string = (this.tooltip.showOn === 'Auto' ? 'Hover' : this.tooltip.showOn);
1479
+ this.setProperties({ tooltip: { showOn: tooltipShowOn } }, true);
1480
+ this.tooltipObj.position = this.tooltipPlacement();
1481
+ this.tooltipCollision(this.tooltipObj.position);
1482
+ [this.firstHandle, this.rangeBar, this.secondHandle].forEach((handle: HTMLElement) => {
1483
+ if (!isNullOrUndefined(handle)) {
1484
+ handle.style.transition = 'none';
1485
+ }
1486
+ });
1487
+ if (this.isMaterialTooltip) {
1488
+ this.sliderContainer.classList.add(classNames.materialSlider);
1489
+ this.tooltipValue();
1490
+ this.tooltipObj.animation.close.effect = 'None';
1491
+ this.tooltipObj.open(this.firstHandle);
1492
+ }
1493
+ }
1494
+ private tooltipBeforeClose(): void {
1495
+ this.tooltipElement = undefined;
1496
+ this.tooltipCollidedPosition = undefined;
1497
+ }
1498
+
1499
+ private setButtons(): void {
1500
+ this.firstBtn = this.createElement('div', { className: classNames.sliderButton + ' ' + classNames.firstButton });
1501
+ this.firstBtn.appendChild(this.createElement('span', { className: classNames.sliderButtonIcon }));
1502
+ if (this.isTailwind || this.isTailwind3) {
1503
+ this.firstBtn.querySelector('span').classList.add('e-icons');
1504
+ }
1505
+ this.firstBtn.tabIndex = -1;
1506
+ this.secondBtn = this.createElement('div', { className: classNames.sliderButton + ' ' + classNames.secondButton });
1507
+ this.secondBtn.appendChild(this.createElement('span', { className: classNames.sliderButtonIcon }));
1508
+ if (this.isTailwind || this.isTailwind3) {
1509
+ this.secondBtn.querySelector('span').classList.add('e-icons');
1510
+ }
1511
+ this.secondBtn.tabIndex = -1;
1512
+ this.sliderContainer.classList.add(classNames.sliderButtonClass);
1513
+ this.sliderContainer.appendChild(this.firstBtn);
1514
+ this.sliderContainer.appendChild(this.secondBtn);
1515
+ this.sliderContainer.appendChild(this.element);
1516
+ this.buttonTitle();
1517
+ }
1518
+
1519
+ private buttonTitle(): void {
1520
+ const enabledRTL: boolean = this.enableRtl && this.orientation !== 'Vertical';
1521
+ this.l10n.setLocale(this.locale);
1522
+ const decrementTitle: string = this.l10n.getConstant('decrementTitle');
1523
+ const incrementTitle: string = this.l10n.getConstant('incrementTitle');
1524
+ attributes(enabledRTL ? this.secondBtn : this.firstBtn, { 'aria-label': decrementTitle, title: decrementTitle });
1525
+ attributes(enabledRTL ? this.firstBtn : this.secondBtn, { 'aria-label': incrementTitle, title: incrementTitle });
1526
+ }
1527
+
1528
+ private buttonFocusOut(): void {
1529
+ if (this.isMaterial || this.isMaterial3) {
1530
+ this.getHandle().classList.remove('e-large-thumb-size');
1531
+ }
1532
+ }
1533
+ private repeatButton(args: MouseEvent): void {
1534
+ const hVal: number = this.handleValueUpdate();
1535
+ const enabledRTL: boolean = this.enableRtl && this.orientation !== 'Vertical';
1536
+ let value: number;
1537
+ if ((<HTMLElement>args.target).parentElement.classList.contains(classNames.firstButton)
1538
+ || (<HTMLElement>args.target).classList.contains(classNames.firstButton)) {
1539
+ if (enabledRTL) {
1540
+ value = this.add(hVal, parseFloat(this.step.toString()), true);
1541
+ } else {
1542
+ value = this.add(hVal, parseFloat(this.step.toString()), false);
1543
+ }
1544
+ } else if ((<HTMLElement>args.target).parentElement.classList.contains(classNames.secondButton)
1545
+ || ((<HTMLElement>args.target).classList.contains(classNames.secondButton))) {
1546
+ if (enabledRTL) {
1547
+ value = this.add(hVal, parseFloat(this.step.toString()), false);
1548
+ } else {
1549
+ value = this.add(hVal, parseFloat(this.step.toString()), true);
1550
+ }
1551
+ }
1552
+ if (this.limits.enabled) {
1553
+ value = this.getLimitCorrectedValues(value);
1554
+ }
1555
+ if (value >= this.min && value <= this.max) {
1556
+ this.changeHandleValue(value);
1557
+ this.tooltipToggle(this.getHandle());
1558
+ }
1559
+ }
1560
+
1561
+ private repeatHandlerMouse(args: MouseEvent): void {
1562
+ args.preventDefault();
1563
+ if (args.type === ('mousedown') || args.type === ('touchstart')) {
1564
+ this.buttonClick(args);
1565
+ this.repeatInterval = setInterval(this.repeatButton.bind(this), 180, args);
1566
+ }
1567
+ }
1568
+
1569
+ private materialChange(): void {
1570
+ if (!this.getHandle().classList.contains('e-large-thumb-size')) {
1571
+ this.getHandle().classList.add('e-large-thumb-size');
1572
+ }
1573
+ }
1574
+
1575
+ private focusHandle(): void {
1576
+ if (!this.getHandle().classList.contains(classNames.sliderTabHandle)) {
1577
+ this.getHandle().classList.add(classNames.sliderTabHandle);
1578
+ }
1579
+ }
1580
+
1581
+ private repeatHandlerUp(e: MouseEvent): void {
1582
+ this.changeEvent('changed', e);
1583
+ this.closeTooltip();
1584
+ clearInterval(this.repeatInterval);
1585
+ this.getHandle().focus();
1586
+
1587
+ }
1588
+
1589
+ private customTickCounter(bigNum: number): number {
1590
+ let tickCount: number = 4;
1591
+ if (!isNullOrUndefined(this.customValues) && this.customValues.length > 0) {
1592
+ if (bigNum > 4) {
1593
+ tickCount = 3;
1594
+ }
1595
+ if (bigNum > 7) {
1596
+ tickCount = 2;
1597
+ }
1598
+ if (bigNum > 14) {
1599
+ tickCount = 1;
1600
+ }
1601
+ if (bigNum > 28) {
1602
+ tickCount = 0;
1603
+ }
1604
+ }
1605
+ return tickCount;
1606
+ }
1607
+
1608
+ private renderScale(): void {
1609
+ const orien: string = this.orientation === 'Vertical' ? 'v' : 'h';
1610
+ this.ul = this.createElement('ul', {
1611
+ className: classNames.scale + ' ' + 'e-' + orien + '-scale ' + classNames.tick + '-' + this.ticks.placement.toLowerCase(),
1612
+ attrs: { role: 'presentation', 'aria-hidden': 'true' }
1613
+ });
1614
+ this.ul.style.zIndex = '-1';
1615
+ if (Browser.isAndroid && orien === 'h') {
1616
+ this.ul.classList.add(classNames.sliderTickPosition);
1617
+ }
1618
+ let smallStep: number = this.ticks.smallStep;
1619
+ if (!this.ticks.showSmallTicks) {
1620
+ if (this.ticks.largeStep > 0) {
1621
+ smallStep = this.ticks.largeStep;
1622
+ } else {
1623
+ smallStep = (parseFloat(formatUnit(this.max))) - (parseFloat(formatUnit(this.min)));
1624
+ }
1625
+ } else if (smallStep <= 0) {
1626
+ smallStep = parseFloat(formatUnit(this.step));
1627
+ }
1628
+ const min: number = parseFloat(formatUnit(this.min));
1629
+ const max: number = parseFloat(formatUnit(this.max));
1630
+ const steps: number = parseFloat(formatUnit(smallStep));
1631
+ const bigNum: number = !isNullOrUndefined(this.customValues) && this.customValues.length > 0 && this.customValues.length - 1;
1632
+ const customStep: number = this.customTickCounter(bigNum);
1633
+ const count: number = !isNullOrUndefined(this.customValues) && this.customValues.length > 0 ?
1634
+ (bigNum * customStep) + bigNum : Math.abs((max - min) / steps);
1635
+ this.element.appendChild(this.ul);
1636
+ let li: HTMLElement; let start: number = parseFloat(this.min.toString());
1637
+ if (orien === 'v') { start = parseFloat(this.max.toString()); }
1638
+ let left: number = 0;
1639
+ let islargeTick: boolean;
1640
+ let tickWidth: number = 100 / count;
1641
+ if (tickWidth === Infinity) {
1642
+ tickWidth = 5;
1643
+ }
1644
+ for (let i: number = 0, y: number = !isNullOrUndefined(this.customValues) && this.customValues.length > 0 ?
1645
+ this.customValues.length - 1 : 0, k: number = 0; i <= count; i++) {
1646
+ li = (this.createElement('li', {
1647
+ attrs: {
1648
+ class: classNames.tick, role: 'presentation',
1649
+ 'aria-hidden': 'true'
1650
+ }
1651
+ }));
1652
+ if (!isNullOrUndefined(this.customValues) && this.customValues.length > 0) {
1653
+ islargeTick = i % (customStep + 1) === 0;
1654
+ if (islargeTick) {
1655
+ if (orien === 'h') {
1656
+ start = <number>this.customValues[k as number];
1657
+ k++;
1658
+ } else {
1659
+ start = <number>this.customValues[y as number];
1660
+ y--;
1661
+ }
1662
+ li.setAttribute('title', start.toString());
1663
+ }
1664
+ } else {
1665
+ li.setAttribute('title', start.toString());
1666
+ if (this.numberOfDecimals(this.max) === 0 && this.numberOfDecimals(this.min) === 0 &&
1667
+ this.numberOfDecimals(this.step) === 0) {
1668
+ if (orien === 'h') {
1669
+ const reminder: number = (start - parseFloat(this.min.toString())) % this.ticks.largeStep;
1670
+ islargeTick = (Math.abs(reminder) < tolerance || Math.abs(this.ticks.largeStep - reminder) < tolerance);
1671
+ } else {
1672
+ const reminder: number = Math.abs(start - parseFloat(this.max.toString())) % this.ticks.largeStep;
1673
+ islargeTick = (Math.abs(reminder) < tolerance || Math.abs(this.ticks.largeStep - reminder) < tolerance);
1674
+ }
1675
+ } else {
1676
+ const largestep: number = this.ticks.largeStep;
1677
+ const startValue: number = start;
1678
+ if (orien === 'h') {
1679
+ const reminder: number = ((startValue - min) % largestep);
1680
+ islargeTick = Math.abs(reminder) < tolerance || Math.abs(largestep - reminder) < tolerance;
1681
+ } else {
1682
+ const reminder: number = Math.abs(startValue - parseFloat(max.toString())) % largestep;
1683
+ islargeTick = Math.abs(reminder) < tolerance || Math.abs(largestep - reminder) < tolerance;
1684
+ }
1685
+ }
1686
+ }
1687
+ if (islargeTick) {
1688
+ li.classList.add(classNames.large);
1689
+ }
1690
+ if (orien === 'h') {
1691
+ li.style.width = tickWidth + '%';
1692
+ } else {
1693
+ li.style.height = tickWidth + '%';
1694
+ }
1695
+ const repeat: number = islargeTick ? (this.ticks.placement === 'Both' ? 2 : 1) : 0;
1696
+ if (islargeTick) {
1697
+ for (let j: number = 0; j < repeat; j++) {
1698
+ this.createTick(li, start);
1699
+ }
1700
+ } else if (isNullOrUndefined(this.customValues)) {
1701
+ this.formatTicksValue(li, start);
1702
+ }
1703
+ this.ul.appendChild(li);
1704
+ this.tickElementCollection.push(li);
1705
+ let decimalPoints: number;
1706
+ if (isNullOrUndefined(this.customValues)) {
1707
+ if (this.numberOfDecimals(smallStep) > this.numberOfDecimals(start)) {
1708
+ decimalPoints = this.numberOfDecimals(smallStep);
1709
+ } else {
1710
+ decimalPoints = this.numberOfDecimals(start);
1711
+ }
1712
+ if (orien === 'h') {
1713
+ start = this.makeRoundNumber(start + smallStep, decimalPoints);
1714
+ } else {
1715
+ if (this.min > this.max) {
1716
+ start = this.makeRoundNumber(start + smallStep, decimalPoints);
1717
+ }
1718
+ else {
1719
+ start = this.makeRoundNumber(start - smallStep, decimalPoints);
1720
+ }
1721
+ }
1722
+ left = this.makeRoundNumber(left + smallStep, decimalPoints);
1723
+ }
1724
+ }
1725
+ this.ticksAlignment(orien, tickWidth);
1726
+ }
1727
+
1728
+ private ticksAlignment(orien: string, tickWidth: number, triggerEvent: boolean = true): void {
1729
+ this.firstChild = this.ul.firstElementChild;
1730
+ this.lastChild = this.ul.lastElementChild;
1731
+ this.firstChild.classList.add(classNames.sliderFirstTick);
1732
+ this.lastChild.classList.add(classNames.sliderLastTick);
1733
+ this.sliderContainer.classList.add(classNames.scale + '-' + this.ticks.placement.toLowerCase());
1734
+ if (orien === 'h') {
1735
+ (this.firstChild as HTMLElement).style.width = tickWidth / 2 + '%';
1736
+ (this.lastChild as HTMLElement).style.width = tickWidth / 2 + '%';
1737
+ } else {
1738
+ (this.firstChild as HTMLElement).style.height = tickWidth / 2 + '%';
1739
+ (this.lastChild as HTMLElement).style.height = tickWidth / 2 + '%';
1740
+ }
1741
+ const eventArgs: SliderTickRenderedEventArgs = { ticksWrapper: this.ul, tickElements: this.tickElementCollection };
1742
+ if (triggerEvent) {
1743
+ this.trigger('renderedTicks', eventArgs);
1744
+ }
1745
+ this.scaleAlignment();
1746
+ }
1747
+
1748
+ private createTick(li: HTMLElement, start: number | string): void {
1749
+ const span: HTMLElement = this.createElement('span', {
1750
+ className: classNames.tickValue + ' ' + classNames.tick + '-' + this.ticks.placement.toLowerCase(),
1751
+ attrs: { role: 'presentation', 'aria-hidden': 'true' }
1752
+ });
1753
+ li.appendChild(span);
1754
+ if (isNullOrUndefined(this.customValues)) {
1755
+ this.formatTicksValue(li, <number>start, span);
1756
+ } else {
1757
+ if (this.enableHtmlSanitizer) {
1758
+ span.innerHTML = SanitizeHtmlHelper.sanitize(start.toString());
1759
+ } else {
1760
+ span.innerHTML = start.toString();
1761
+ }
1762
+ }
1763
+ }
1764
+
1765
+ private formatTicksValue(li: HTMLElement, start: number, spanElement?: HTMLElement): void {
1766
+ const tickText: string = this.formatNumber(start);
1767
+ const text: string = !isNullOrUndefined(this.ticks) && !isNullOrUndefined(this.ticks.format) ?
1768
+ this.formatString(start, this.ticksFormatInfo).formatString : tickText;
1769
+ const eventArgs: SliderTickEventArgs = { value: start, text: text, tickElement: li };
1770
+ this.trigger('renderingTicks', eventArgs, (observedArgs: SliderTickEventArgs) => {
1771
+ li.setAttribute('title', observedArgs.text.toString());
1772
+ if (spanElement) {
1773
+ if (this.enableHtmlSanitizer) {
1774
+ spanElement.innerHTML = SanitizeHtmlHelper.sanitize(observedArgs.text.toString());
1775
+ } else {
1776
+ spanElement.innerHTML = observedArgs.text.toString();
1777
+ }
1778
+ }
1779
+ });
1780
+ }
1781
+
1782
+ private scaleAlignment(): void {
1783
+ this.tickValuePosition();
1784
+ if (this.orientation === 'Vertical') {
1785
+ if (this.element.getBoundingClientRect().width <= 15) {
1786
+ this.sliderContainer.classList.add(classNames.sliderSmallSize);
1787
+ } else {
1788
+ this.sliderContainer.classList.remove(classNames.sliderSmallSize);
1789
+ }
1790
+ } else {
1791
+ if (this.element.getBoundingClientRect().height <= 15) {
1792
+ this.sliderContainer.classList.add(classNames.sliderSmallSize);
1793
+ } else {
1794
+ this.sliderContainer.classList.remove(classNames.sliderSmallSize);
1795
+ }
1796
+ }
1797
+ }
1798
+
1799
+ private tickValuePosition(): void {
1800
+ this.firstChild = this.element.querySelector('ul').children[0];
1801
+ const first: { width: number, height: number } = (this.firstChild as HTMLElement).getBoundingClientRect();
1802
+ let firstChild: { width: number, height: number };
1803
+ let otherChild: { width: number, height: number };
1804
+ const smallStep: number = this.ticks.smallStep;
1805
+ const count: number = Math.abs((parseFloat(formatUnit(this.max))) - (parseFloat(formatUnit(this.min)))) / smallStep;
1806
+ if (this.firstChild.children.length > 0) {
1807
+ firstChild = (this.firstChild.children[0] as HTMLElement).getBoundingClientRect();
1808
+ }
1809
+ const tickElements: NodeListOf<Element>[] = [this.sliderContainer.querySelectorAll('.' + classNames.tick + '.' +
1810
+ classNames.large + ' .' + classNames.tickValue)];
1811
+ let other: NodeListOf<Element>;
1812
+ if (this.ticks.placement === 'Both') {
1813
+ other = [].slice.call(tickElements[0], 2);
1814
+ } else {
1815
+ other = [].slice.call(tickElements[0], 1);
1816
+ }
1817
+ const tickWidth: number = this.orientation === 'Vertical' ?
1818
+ (first.height * 2) : (first.width * 2);
1819
+ for (let i: number = 0; i < this.firstChild.children.length; i++) {
1820
+ if (this.orientation === 'Vertical') {
1821
+ (this.firstChild.children[i as number] as HTMLElement).style.top = -(firstChild.height / 2) + 'px';
1822
+ } else {
1823
+ if (!this.enableRtl) {
1824
+ (this.firstChild.children[i as number] as HTMLElement).style.left = -(firstChild.width / 2) + 'px';
1825
+ } else {
1826
+ (this.firstChild.children[i as number] as HTMLElement).style.left = (tickWidth -
1827
+ this.firstChild.children[i as number].getBoundingClientRect().width) / 2 + 'px';
1828
+ }
1829
+ }
1830
+ }
1831
+ for (let i: number = 0; i < other.length; i++) {
1832
+ otherChild = (other[i as number] as HTMLElement).getBoundingClientRect();
1833
+ if (this.orientation === 'Vertical') {
1834
+ setStyleAttribute(other[i as number] as HTMLElement, { top: (tickWidth - otherChild.height) / 2 + 'px' });
1835
+ } else {
1836
+ setStyleAttribute(other[i as number] as HTMLElement, { left: (tickWidth - otherChild.width) / 2 + 'px' });
1837
+ }
1838
+ }
1839
+ if (this.enableRtl && this.lastChild.children.length && count !== 0) {
1840
+ (this.lastChild.children[0] as HTMLElement).style.left = -(this.lastChild.getBoundingClientRect().width / 2) + 'px';
1841
+ if (this.ticks.placement === 'Both') {
1842
+ (this.lastChild.children[1] as HTMLElement).style.left = -(this.lastChild.getBoundingClientRect().width / 2) + 'px';
1843
+ }
1844
+ }
1845
+ if (count === 0) {
1846
+ if (this.orientation === 'Horizontal') {
1847
+ if (!this.enableRtl) {
1848
+ (this.firstChild as HTMLElement).classList.remove(classNames.sliderLastTick);
1849
+ (this.firstChild as HTMLElement).style.left = this.firstHandle.style.left;
1850
+ } else {
1851
+ (this.firstChild as HTMLElement).classList.remove(classNames.sliderLastTick);
1852
+ (this.firstChild as HTMLElement).style.right = this.firstHandle.style.right;
1853
+ (this.firstChild.children[0] as HTMLElement).style.left =
1854
+ (this.firstChild.getBoundingClientRect().width / 2) + 2 + 'px';
1855
+ if (this.ticks.placement === 'Both') {
1856
+ (this.firstChild.children[1] as HTMLElement).style.left =
1857
+ (this.firstChild.getBoundingClientRect().width / 2) + 2 + 'px';
1858
+ }
1859
+ }
1860
+ }
1861
+ if (this.orientation === 'Vertical') {
1862
+ (this.firstChild as HTMLElement).classList.remove(classNames.sliderLastTick);
1863
+ }
1864
+ }
1865
+ }
1866
+
1867
+ private setAriaAttrValue(element: Element): void {
1868
+ let ariaValueText: string[];
1869
+ const isTickFormatted: boolean = ((!isNullOrUndefined(this.ticks) && !isNullOrUndefined(this.ticks.format))) ? true : false;
1870
+ let text: string = !isTickFormatted ?
1871
+ this.formatContent(this.ticksFormatInfo, false) : this.formatContent(this.tooltipFormatInfo, false);
1872
+ const valuenow: string = isTickFormatted ? this.formatContent(this.ticksFormatInfo, true) :
1873
+ this.formatContent(this.tooltipFormatInfo, true);
1874
+ text = (!this.customAriaText) ? (text) : (this.customAriaText);
1875
+ if (text.split(' - ').length === 2) {
1876
+ ariaValueText = text.split(' - ');
1877
+ } else {
1878
+ ariaValueText = [text, text];
1879
+ }
1880
+ this.setAriaAttributes(element);
1881
+ if (this.type !== 'Range') {
1882
+ attributes(element, { 'aria-valuenow': valuenow, 'aria-valuetext': text });
1883
+ } else {
1884
+ if (!this.enableRtl) {
1885
+ if (element === this.firstHandle) {
1886
+ attributes(element, { 'aria-valuenow': valuenow.split(' - ')[0], 'aria-valuetext': ariaValueText[0] });
1887
+ } else {
1888
+ attributes(element, { 'aria-valuenow': valuenow.split(' - ')[1], 'aria-valuetext': ariaValueText[1] });
1889
+ }
1890
+ } else {
1891
+ if (element === this.firstHandle) {
1892
+ attributes(element, { 'aria-valuenow': valuenow.split(' - ')[1], 'aria-valuetext': ariaValueText[1] });
1893
+ } else {
1894
+ attributes(element, { 'aria-valuenow': valuenow.split(' - ')[0], 'aria-valuetext': ariaValueText[0] });
1895
+ }
1896
+ }
1897
+ }
1898
+ }
1899
+
1900
+
1901
+ private handleValueUpdate(): number {
1902
+ let hVal: number;
1903
+ if (this.type === 'Range') {
1904
+ if (this.activeHandle === 1) {
1905
+ hVal = this.handleVal1;
1906
+ } else {
1907
+ hVal = this.handleVal2;
1908
+ }
1909
+ } else {
1910
+ hVal = this.handleVal1;
1911
+ }
1912
+ return hVal;
1913
+ }
1914
+
1915
+ private getLimitCorrectedValues(value: number): number {
1916
+ if (this.type === 'MinRange' || this.type === 'Default') {
1917
+ value = (this.getLimitValueAndPosition(value, this.limits.minStart, this.limits.minEnd))[0];
1918
+ } else {
1919
+ if (this.activeHandle === 1) {
1920
+ value = (this.getLimitValueAndPosition(value, this.limits.minStart, this.limits.minEnd))[0];
1921
+ } else {
1922
+ value = (this.getLimitValueAndPosition(value, this.limits.maxStart, this.limits.maxEnd))[0];
1923
+ }
1924
+ }
1925
+ return value;
1926
+ }
1927
+
1928
+ private focusSliderElement(): void {
1929
+ if (!this.isElementFocused) {
1930
+ this.element.focus();
1931
+ this.isElementFocused = true;
1932
+ }
1933
+ }
1934
+ private buttonClick(args: KeyboardEvent | MouseEvent): void {
1935
+ this.focusSliderElement();
1936
+ let value: number;
1937
+ const enabledRTL: boolean = this.enableRtl && this.orientation !== 'Vertical';
1938
+ const hVal: number = this.handleValueUpdate();
1939
+ if (((<KeyboardEvent>args).keyCode === 40) || ((<KeyboardEvent>args).keyCode === 37)
1940
+ || (args.currentTarget as HTMLElement).classList.contains(classNames.firstButton)) {
1941
+ if (enabledRTL) {
1942
+ value = this.add(hVal, parseFloat(this.step.toString()), true);
1943
+ } else {
1944
+ value = this.add(hVal, parseFloat(this.step.toString()), false);
1945
+ }
1946
+ } else if (((<KeyboardEvent>args).keyCode === 38) || ((<KeyboardEvent>args).keyCode === 39) ||
1947
+ (args.currentTarget as HTMLElement).classList.contains(classNames.secondButton)) {
1948
+ if (enabledRTL) {
1949
+ value = this.add(hVal, parseFloat(this.step.toString()), false);
1950
+ } else {
1951
+ value = this.add(hVal, parseFloat(this.step.toString()), true);
1952
+ }
1953
+ } else if (((<KeyboardEvent>args).keyCode === 33
1954
+ || (args.currentTarget as HTMLElement).classList.contains(classNames.firstButton))) {
1955
+ if (enabledRTL) {
1956
+ value = this.add(hVal, parseFloat(this.ticks.largeStep.toString()), false);
1957
+ } else {
1958
+ value = this.add(hVal, parseFloat(this.ticks.largeStep.toString()), true);
1959
+ }
1960
+ } else if (((<KeyboardEvent>args).keyCode === 34) ||
1961
+ (args.currentTarget as HTMLElement).classList.contains(classNames.secondButton)) {
1962
+ if (enabledRTL) {
1963
+ value = this.add(hVal, parseFloat(this.ticks.largeStep.toString()), true);
1964
+ } else {
1965
+ value = this.add(hVal, parseFloat(this.ticks.largeStep.toString()), false);
1966
+ }
1967
+ } else if (((<KeyboardEvent>args).keyCode === 36)) {
1968
+ value = parseFloat(this.min < this.max ? this.min.toString() : this.max.toString());
1969
+
1970
+ } else if (((<KeyboardEvent>args).keyCode === 35)) {
1971
+ value = parseFloat(this.min < this.max ? this.max.toString() : this.min.toString());
1972
+ }
1973
+ if (this.limits.enabled) {
1974
+ value = this.getLimitCorrectedValues(value);
1975
+ }
1976
+ this.changeHandleValue(value);
1977
+ if ((this.isMaterial || this.isMaterial3) && !this.tooltip.isVisible &&
1978
+ !(this.getHandle() as HTMLElement).classList.contains(classNames.sliderTabHandle)) {
1979
+ this.materialChange();
1980
+ }
1981
+ this.tooltipToggle(this.getHandle());
1982
+ this.getHandle().focus();
1983
+ this.focusHandle();
1984
+ if ((args.currentTarget as HTMLElement).classList.contains(classNames.firstButton)) {
1985
+ EventHandler.add(this.firstBtn, 'mouseup touchend', this.buttonUp, this);
1986
+ }
1987
+ if ((args.currentTarget as HTMLElement).classList.contains(classNames.secondButton)) {
1988
+ EventHandler.add(this.secondBtn, 'mouseup touchend', this.buttonUp, this);
1989
+ }
1990
+ }
1991
+
1992
+ private tooltipToggle(target?: HTMLElement): void {
1993
+ if (this.isMaterialTooltip) {
1994
+ if (!this.tooltipElement.classList.contains(classNames.materialTooltipOpen)) {
1995
+ this.openMaterialTooltip();
1996
+ } else {
1997
+ this.refreshTooltip(this.firstHandle);
1998
+ }
1999
+ } else {
2000
+ if (!this.tooltipElement) {
2001
+ this.openTooltip(target);
2002
+ } else {
2003
+ this.refreshTooltip(target);
2004
+ }
2005
+ }
2006
+
2007
+ }
2008
+
2009
+ private buttonUp(args: KeyboardEvent | MouseEvent): void {
2010
+ if ((args.currentTarget as HTMLElement).classList.contains(classNames.firstButton)) {
2011
+ EventHandler.remove(this.firstBtn, 'mouseup touchend', this.buttonUp);
2012
+ }
2013
+ if ((args.currentTarget as HTMLElement).classList.contains(classNames.secondButton)) {
2014
+ EventHandler.remove(this.secondBtn, 'mouseup touchend', this.buttonUp);
2015
+ }
2016
+ }
2017
+
2018
+ private setRangeBar(): void {
2019
+ if (this.orientation === 'Horizontal' && !isNullOrUndefined(this.rangeBar)) {
2020
+ if (this.type === 'MinRange') {
2021
+ if (this.enableRtl) {
2022
+ this.rangeBar.style.right = '0px';
2023
+ } else {
2024
+ this.rangeBar.style.left = '0px';
2025
+ }
2026
+ setStyleAttribute(this.rangeBar, { 'width': isNullOrUndefined(this.handlePos1) ? 0 : this.handlePos1 + 'px' });
2027
+ } else {
2028
+ if (this.enableRtl) {
2029
+ this.rangeBar.style.right = this.handlePos1 + 'px';
2030
+ } else {
2031
+ this.rangeBar.style.left = this.handlePos1 + 'px';
2032
+ }
2033
+ setStyleAttribute(this.rangeBar, { 'width': this.handlePos2 - this.handlePos1 + 'px' });
2034
+ }
2035
+ } else if (!isNullOrUndefined(this.rangeBar)) {
2036
+ if (this.type === 'MinRange') {
2037
+ this.rangeBar.style.bottom = this.min > this.max ? this.handlePos1 + 'px' : '0px';
2038
+ setStyleAttribute(this.rangeBar, { 'height': isNullOrUndefined(this.handlePos1) ? 0 : this.min > this.max ? this.element.clientHeight - this.handlePos1 + 'px' : this.handlePos1 + 'px' });
2039
+ } else {
2040
+ this.rangeBar.style.bottom = this.min > this.max ? this.handlePos2 + 'px' : this.handlePos1 + 'px';
2041
+ setStyleAttribute(this.rangeBar, { 'height': this.min > this.max ? this.handlePos1 - this.handlePos2 + 'px' : this.handlePos2 - this.handlePos1 + 'px' });
2042
+ }
2043
+ }
2044
+ }
2045
+
2046
+ private checkValidValueAndPos(value: number): number {
2047
+ value = this.checkHandleValue(value);
2048
+ value = this.checkHandlePosition(value);
2049
+ return value;
2050
+ }
2051
+
2052
+ private setLimitBarPositions(fromMinPostion: number, fromMaxpostion: number, toMinPostion?: number, toMaxpostion?: number): void {
2053
+ if (this.orientation === 'Horizontal') {
2054
+ if (!this.enableRtl) {
2055
+ this.limitBarFirst.style.left = fromMinPostion + 'px';
2056
+ this.limitBarFirst.style.width = (fromMaxpostion - fromMinPostion) + 'px';
2057
+ } else {
2058
+ this.limitBarFirst.style.right = fromMinPostion + 'px';
2059
+ this.limitBarFirst.style.width = (fromMaxpostion - fromMinPostion) + 'px';
2060
+ }
2061
+ } else {
2062
+ this.limitBarFirst.style.bottom = (this.min < this.max ? fromMinPostion : fromMaxpostion) + 'px';
2063
+ this.limitBarFirst.style.height = (this.min < this.max ? (fromMaxpostion - fromMinPostion) : (fromMinPostion - fromMaxpostion)) + 'px';
2064
+ }
2065
+ if (this.type === 'Range') {
2066
+ if (this.orientation === 'Horizontal') {
2067
+ if (!this.enableRtl) {
2068
+ this.limitBarSecond.style.left = toMinPostion + 'px';
2069
+ this.limitBarSecond.style.width = (toMaxpostion - toMinPostion) + 'px';
2070
+ } else {
2071
+ this.limitBarSecond.style.right = toMinPostion + 'px';
2072
+ this.limitBarSecond.style.width = (toMaxpostion - toMinPostion) + 'px';
2073
+ }
2074
+ } else {
2075
+ this.limitBarSecond.style.bottom = (this.min < this.max ? toMinPostion : toMaxpostion) + 'px';
2076
+ this.limitBarSecond.style.height = (this.min < this.max ? (toMaxpostion - toMinPostion) : (toMinPostion - toMaxpostion)) + 'px';
2077
+ }
2078
+ }
2079
+ }
2080
+
2081
+ private setLimitBar(): void {
2082
+ if (this.type === 'Default' || this.type === 'MinRange') {
2083
+ let fromPosition: number =
2084
+ (this.getLimitValueAndPosition(this.limits.minStart, this.limits.minStart, this.limits.minEnd, true))[0];
2085
+ fromPosition = this.checkValidValueAndPos(fromPosition);
2086
+ let toPosition: number = (this.getLimitValueAndPosition(this.limits.minEnd, this.limits.minStart, this.limits.minEnd, true))[0];
2087
+ toPosition = this.checkValidValueAndPos(toPosition);
2088
+ this.setLimitBarPositions(fromPosition, toPosition);
2089
+ } else if (this.type === 'Range') {
2090
+ let fromMinPostion: number =
2091
+ (this.getLimitValueAndPosition(this.limits.minStart, this.limits.minStart, this.limits.minEnd, true))[0];
2092
+ fromMinPostion = this.checkValidValueAndPos(fromMinPostion);
2093
+ let fromMaxpostion: number =
2094
+ (this.getLimitValueAndPosition(this.limits.minEnd, this.limits.minStart, this.limits.minEnd, true))[0];
2095
+ fromMaxpostion = this.checkValidValueAndPos(fromMaxpostion);
2096
+ let toMinPostion: number =
2097
+ (this.getLimitValueAndPosition(this.limits.maxStart, this.limits.maxStart, this.limits.maxEnd, true))[0];
2098
+ toMinPostion = this.checkValidValueAndPos(toMinPostion);
2099
+ let toMaxpostion: number =
2100
+ (this.getLimitValueAndPosition(this.limits.maxEnd, this.limits.maxStart, this.limits.maxEnd, true))[0];
2101
+ toMaxpostion = this.checkValidValueAndPos(toMaxpostion);
2102
+
2103
+ this.setLimitBarPositions(fromMinPostion, fromMaxpostion, toMinPostion, toMaxpostion);
2104
+ }
2105
+ }
2106
+
2107
+ private getLimitValueAndPosition(currentValue: number, minValue: number, maxValue: number, limitBar?: boolean): number[] {
2108
+ if (isNullOrUndefined(minValue)) {
2109
+ minValue = this.min < this.max ? this.min : this.max;
2110
+ if (isNullOrUndefined(currentValue) && limitBar) {
2111
+ currentValue = minValue;
2112
+ }
2113
+ }
2114
+ if (isNullOrUndefined(maxValue)) {
2115
+ maxValue = this.min < this.max ? this.max : this.min;
2116
+ if (isNullOrUndefined(currentValue) && limitBar) {
2117
+ currentValue = maxValue;
2118
+ }
2119
+ }
2120
+ if (currentValue < minValue) {
2121
+ currentValue = minValue;
2122
+ }
2123
+ if (currentValue > maxValue) {
2124
+ currentValue = maxValue;
2125
+ }
2126
+ return [currentValue, this.checkHandlePosition(currentValue)];
2127
+ }
2128
+
2129
+ private setValue(): void {
2130
+ if (!isNullOrUndefined(this.customValues) && this.customValues.length > 0) {
2131
+ this.min = 0;
2132
+ this.max = this.customValues.length - 1;
2133
+ this.setBarColor();
2134
+ }
2135
+ this.setAriaAttributes(this.firstHandle);
2136
+ this.handleVal1 = isNullOrUndefined(this.value) ? this.checkHandleValue(parseFloat(this.min.toString())) :
2137
+ this.checkHandleValue(parseFloat(this.value.toString()));
2138
+ this.handlePos1 = this.checkHandlePosition(this.handleVal1);
2139
+ this.preHandlePos1 = this.handlePos1;
2140
+ if (isNullOrUndefined(this.activeHandle)) {
2141
+ this.activeHandle = this.type === 'Range' ? 2 : 1;
2142
+ }
2143
+ if (this.type === 'Default' || this.type === 'MinRange') {
2144
+ if (this.limits.enabled) {
2145
+ const values: number[] = this.getLimitValueAndPosition(this.handleVal1, this.limits.minStart, this.limits.minEnd);
2146
+ this.handleVal1 = values[0];
2147
+ this.handlePos1 = values[1];
2148
+ this.preHandlePos1 = this.handlePos1;
2149
+ }
2150
+ this.setHandlePosition(null);
2151
+ this.handleStart();
2152
+ this.value = this.handleVal1;
2153
+ this.setAriaAttrValue(this.firstHandle);
2154
+ this.changeEvent('changed', null);
2155
+ } else {
2156
+ this.validateRangeValue();
2157
+ }
2158
+ if (this.type !== 'Default') {
2159
+ this.setRangeBar();
2160
+ }
2161
+ if (this.limits.enabled) {
2162
+ this.setLimitBar();
2163
+ }
2164
+ }
2165
+
2166
+ private rangeValueUpdate(): void {
2167
+ if (this.value === null || typeof (this.value) !== 'object') {
2168
+ this.value = [parseFloat(formatUnit(this.min)), parseFloat(formatUnit(this.max))];
2169
+ }
2170
+ }
2171
+
2172
+ private validateRangeValue(): void {
2173
+ this.rangeValueUpdate();
2174
+ this.setRangeValue();
2175
+ }
2176
+
2177
+ private modifyZindex(): void {
2178
+ if (this.type === 'Range' && !isNullOrUndefined(this.firstHandle) && !isNullOrUndefined(this.secondHandle)) {
2179
+ if (this.activeHandle === 1) {
2180
+ this.firstHandle.style.zIndex = (this.zIndex + 4) + '';
2181
+ this.secondHandle.style.zIndex = (this.zIndex + 3) + '';
2182
+ } else {
2183
+ this.firstHandle.style.zIndex = (this.zIndex + 3) + '';
2184
+ this.secondHandle.style.zIndex = (this.zIndex + 4) + '';
2185
+ }
2186
+ } else if (this.isMaterialTooltip && this.tooltipElement) {
2187
+ this.tooltipElement.style.zIndex = getZindexPartial(this.element) + '';
2188
+ }
2189
+ }
2190
+
2191
+ private setHandlePosition(event: MouseEvent | TouchEvent): void {
2192
+ let handle: HTMLElement[];
2193
+ const pos: number = (this.activeHandle === 1) ? this.handlePos1 : this.handlePos2;
2194
+ if (this.isMaterialTooltip) {
2195
+ handle = [this.firstHandle, this.materialHandle];
2196
+ } else {
2197
+ handle = [this.getHandle()];
2198
+ }
2199
+ this.handleStart();
2200
+ handle.forEach((handle: HTMLElement) => {
2201
+ if (isNullOrUndefined(handle)) { return; }
2202
+ if (this.orientation === 'Horizontal') {
2203
+ if (this.enableRtl) {
2204
+ handle.style.right = `${pos}px`;
2205
+ } else {
2206
+ handle.style.left = `${pos}px`;
2207
+ }
2208
+ } else {
2209
+ handle.style.bottom = `${pos}px`;
2210
+ }
2211
+ });
2212
+ this.changeEvent('change', event);
2213
+ }
2214
+
2215
+ private getHandle(): HTMLElement {
2216
+ return (this.activeHandle === 1) ? this.firstHandle : this.secondHandle;
2217
+ }
2218
+
2219
+ private setRangeValue(): void {
2220
+ this.updateRangeValue();
2221
+ this.activeHandle = 1;
2222
+ this.setHandlePosition(null);
2223
+ this.activeHandle = 2;
2224
+ this.setHandlePosition(null);
2225
+ this.activeHandle = 1;
2226
+ }
2227
+
2228
+ private changeEvent(eventName: string, e: MouseEvent | TouchEvent | KeyboardEvent): void {
2229
+ const previous: number | number[] = eventName === 'change' ? this.previousVal : this.previousChanged;
2230
+ if (this.type !== 'Range') {
2231
+ this.setProperties({ 'value': this.handleVal1 }, true);
2232
+ if (previous !== this.value && (!this.isMaterialTooltip || !this.initialTooltip)) {
2233
+ this.trigger(eventName, this.changeEventArgs(eventName, e));
2234
+ this.initialTooltip = true;
2235
+ this.setPreviousVal(eventName, this.value);
2236
+ }
2237
+ this.setAriaAttrValue(this.firstHandle);
2238
+ } else {
2239
+ const value: number | number[] = this.value = [this.handleVal1, this.handleVal2];
2240
+ this.setProperties({ 'value': value }, true);
2241
+ if ((<number[]>previous).length === (<number[]>this.value).length
2242
+ && (this.value as number[])[0] !== (<number[]>previous)[0] || (this.value as number[])[1] !== (<number[]>previous)[1]
2243
+ ) {
2244
+ this.initialTooltip = false;
2245
+ this.trigger(eventName, this.changeEventArgs(eventName, e));
2246
+ this.initialTooltip = true;
2247
+ this.setPreviousVal(eventName, this.value);
2248
+ }
2249
+ this.setAriaAttrValue(this.getHandle());
2250
+ }
2251
+ this.hiddenInput.value = this.value.toString();
2252
+ }
2253
+
2254
+ private changeEventArgs(eventName: string, e: MouseEvent | TouchEvent | KeyboardEvent): SliderChangeEventArgs {
2255
+ let eventArgs: SliderChangeEventArgs;
2256
+ if (this.tooltip.isVisible && this.tooltipObj && this.initialTooltip) {
2257
+ this.tooltipValue();
2258
+ eventArgs = {
2259
+ value: this.value,
2260
+ previousValue: eventName === 'change' ? this.previousVal : this.previousChanged,
2261
+ action: eventName, text: <string>(typeof (this.tooltipObj.content) === 'function' ? this.tooltipObj.content() : this.tooltipObj.content), isInteracted: isNullOrUndefined(e) ? false : true
2262
+ };
2263
+ } else {
2264
+ eventArgs = {
2265
+ value: this.value,
2266
+ previousValue: eventName === 'change' ? this.previousVal : this.previousChanged,
2267
+ action: eventName, text: isNullOrUndefined(this.ticksFormatInfo.format) ? this.value.toString() :
2268
+ (this.type !== 'Range' ? this.formatString(this.value as number, this.ticksFormatInfo).formatString :
2269
+ (this.formatString((this.value as number[])[0], this.ticksFormatInfo).formatString + ' - ' +
2270
+ this.formatString((this.value as number[])[1], this.ticksFormatInfo).formatString)),
2271
+ isInteracted: isNullOrUndefined(e) ? false : true
2272
+ };
2273
+ }
2274
+ return eventArgs;
2275
+ }
2276
+
2277
+ private setPreviousVal(eventName: string, value: number | number[]): void {
2278
+ if (eventName === 'change') {
2279
+ this.previousVal = value;
2280
+ } else {
2281
+ this.previousChanged = value;
2282
+ }
2283
+ }
2284
+
2285
+ private updateRangeValue(): void {
2286
+ const values: number[] = this.value.toString().split(',').map(Number);
2287
+ if ((this.enableRtl && this.orientation !== 'Vertical') || this.rtl) {
2288
+ this.value = [values[1], values[0]];
2289
+ } else {
2290
+ this.value = [values[0], values[1]];
2291
+ }
2292
+ if (this.enableRtl && this.orientation !== 'Vertical') {
2293
+ this.handleVal1 = this.checkHandleValue(this.value[1]);
2294
+ this.handleVal2 = this.checkHandleValue(this.value[0]);
2295
+ } else {
2296
+ this.handleVal1 = this.checkHandleValue(this.value[0]);
2297
+ this.handleVal2 = this.checkHandleValue(this.value[1]);
2298
+ }
2299
+ this.handlePos1 = this.checkHandlePosition(this.handleVal1);
2300
+ this.handlePos2 = this.checkHandlePosition(this.handleVal2);
2301
+
2302
+ if (this.min < this.max && this.handlePos1 > this.handlePos2) {
2303
+ this.handlePos1 = this.handlePos2;
2304
+ this.handleVal1 = this.handleVal2;
2305
+ }
2306
+ if (this.min > this.max && this.handlePos1 < this.handlePos2) {
2307
+ this.handlePos2 = this.handlePos1;
2308
+ this.handleVal2 = this.handleVal1;
2309
+ }
2310
+ this.preHandlePos1 = this.handlePos1;
2311
+ this.preHandlePos2 = this.handlePos2;
2312
+
2313
+ if (this.limits.enabled) {
2314
+ this.activeHandle = 1;
2315
+ let values: number[] = this.getLimitValueAndPosition(this.handleVal1, this.limits.minStart, this.limits.minEnd);
2316
+ this.handleVal1 = values[0];
2317
+ this.handlePos1 = values[1];
2318
+ this.preHandlePos1 = this.handlePos1;
2319
+
2320
+ this.activeHandle = 2;
2321
+ values = this.getLimitValueAndPosition(this.handleVal2, this.limits.maxStart, this.limits.maxEnd);
2322
+ this.handleVal2 = values[0];
2323
+ this.handlePos2 = values[1];
2324
+ this.preHandlePos2 = this.handlePos2;
2325
+ }
2326
+ }
2327
+
2328
+ private checkHandlePosition(value: number): number {
2329
+ let pos: number;
2330
+ value = (100 *
2331
+ (value - (parseFloat(formatUnit(this.min))))) / ((parseFloat(formatUnit(this.max))) - (parseFloat(formatUnit(this.min))));
2332
+
2333
+ if (this.orientation === 'Horizontal') {
2334
+ pos = this.element.getBoundingClientRect().width * (value / 100);
2335
+ } else {
2336
+ pos = this.element.getBoundingClientRect().height * (value / 100);
2337
+ }
2338
+ if (((parseFloat(formatUnit(this.max))) === (parseFloat(formatUnit(this.min))))) {
2339
+ if (this.orientation === 'Horizontal') {
2340
+ pos = this.element.getBoundingClientRect().width;
2341
+ } else {
2342
+ pos = this.element.getBoundingClientRect().height;
2343
+ }
2344
+ }
2345
+ return pos;
2346
+
2347
+ }
2348
+
2349
+ private checkHandleValue(value: number): number {
2350
+ if (this.min === this.max) {
2351
+ return (parseFloat(formatUnit(this.max)));
2352
+ }
2353
+ const handle: { [key: string]: Object } = this.tempStartEnd() as { [key: string]: Object };
2354
+ if (value < handle.start) {
2355
+ value = handle.start as number;
2356
+ } else if (value > handle.end) { value = handle.end as number; }
2357
+ return value;
2358
+ }
2359
+
2360
+ /**
2361
+ * It is used to reposition slider.
2362
+ *
2363
+ * @returns {void}
2364
+ */
2365
+ public reposition(): void {
2366
+ if (!isNullOrUndefined(this.firstHandle)) {this.firstHandle.style.transition = 'none'; }
2367
+ if (this.type !== 'Default' && !isNullOrUndefined(this.rangeBar)) {
2368
+ this.rangeBar.style.transition = 'none';
2369
+ }
2370
+ if (this.type === 'Range' && !isNullOrUndefined(this.secondHandle)) {
2371
+ this.secondHandle.style.transition = 'none';
2372
+ }
2373
+ this.handlePos1 = this.checkHandlePosition(this.handleVal1);
2374
+ if (this.handleVal2) {
2375
+ this.handlePos2 = this.checkHandlePosition(this.handleVal2);
2376
+ }
2377
+ if (this.orientation === 'Horizontal') {
2378
+ if (this.enableRtl) {
2379
+ this.firstHandle.style.right = `${this.handlePos1}px`;
2380
+ } else {
2381
+ this.firstHandle.style.left = `${this.handlePos1}px`;
2382
+ }
2383
+ if (this.isMaterialTooltip && !isNullOrUndefined(this.materialHandle)) {
2384
+ if (this.enableRtl) {
2385
+ this.materialHandle.style.right = `${this.handlePos1}px`;
2386
+ } else {
2387
+ this.materialHandle.style.left = `${this.handlePos1}px`;
2388
+ }
2389
+ }
2390
+ if (this.type === 'MinRange' && !isNullOrUndefined(this.rangeBar)) {
2391
+ if (this.enableRtl) {
2392
+ this.rangeBar.style.right = '0px';
2393
+ } else {
2394
+ this.rangeBar.style.left = '0px';
2395
+ }
2396
+ setStyleAttribute(this.rangeBar, { 'width': isNullOrUndefined(this.handlePos1) ? 0 : this.handlePos1 + 'px' });
2397
+ } else if (this.type === 'Range' && !isNullOrUndefined(this.secondHandle) && !isNullOrUndefined(this.rangeBar)) {
2398
+ if (this.enableRtl) {
2399
+ this.secondHandle.style.right = `${this.handlePos2}px`;
2400
+ this.rangeBar.style.right = this.handlePos1 + 'px';
2401
+ } else {
2402
+ this.secondHandle.style.left = `${this.handlePos2}px`;
2403
+ this.rangeBar.style.left = this.handlePos1 + 'px';
2404
+ }
2405
+ setStyleAttribute(this.rangeBar, { 'width': this.handlePos2 - this.handlePos1 + 'px' });
2406
+ }
2407
+ } else {
2408
+ this.firstHandle.style.bottom = `${this.handlePos1}px`;
2409
+ if (this.isMaterialTooltip) {
2410
+ this.materialHandle.style.bottom = `${this.handlePos1}px`;
2411
+ }
2412
+ if (this.type === 'MinRange') {
2413
+ this.rangeBar.style.bottom = this.min > this.max ? this.handlePos1 + 'px' : '0px';
2414
+ setStyleAttribute(this.rangeBar, { 'height': isNullOrUndefined(this.handlePos1) ? 0 : this.min > this.max ? this.element.clientHeight - this.handlePos1 + 'px' : this.handlePos1 + 'px' });
2415
+ } else if (this.type === 'Range') {
2416
+ this.secondHandle.style.bottom = `${this.handlePos2}px`;
2417
+ this.rangeBar.style.bottom = this.min > this.max ? this.handlePos2 + 'px' : this.handlePos1 + 'px';
2418
+ setStyleAttribute(this.rangeBar, { 'height': this.min > this.max ? this.handlePos1 - this.handlePos2 + 'px' : this.handlePos2 - this.handlePos1 + 'px' });
2419
+ }
2420
+ }
2421
+ if (this.limits.enabled) {
2422
+ this.setLimitBar();
2423
+ }
2424
+ if (this.ticks.placement !== 'None' && this.ul) {
2425
+ this.removeElement(this.ul);
2426
+ this.ul = undefined;
2427
+ this.renderScale();
2428
+ }
2429
+ this.handleStart();
2430
+ if (!this.tooltip.isVisible) {
2431
+ setTimeout(() => {
2432
+ if (!isNullOrUndefined(this.firstHandle)) {this.firstHandle.style.transition = this.scaleTransform; }
2433
+ if (this.type === 'Range' && !isNullOrUndefined(this.secondHandle)) {
2434
+ this.secondHandle.style.transition = this.scaleTransform;
2435
+ }
2436
+ });
2437
+ }
2438
+ this.refreshTooltip(this.tooltipTarget);
2439
+ this.setBarColor();
2440
+ }
2441
+
2442
+ private changeHandleValue(value: number): void {
2443
+ let position: number = null;
2444
+ if (this.activeHandle === 1) {
2445
+ if (!(this.limits.enabled && this.limits.startHandleFixed)) {
2446
+ this.handleVal1 = this.checkHandleValue(value);
2447
+ this.handlePos1 = this.checkHandlePosition(this.handleVal1);
2448
+
2449
+ if (this.type === 'Range' && ((this.handlePos1 > this.handlePos2 && this.min < this.max) || (this.handlePos1 < this.handlePos2 && this.min > this.max))) {
2450
+ this.handlePos1 = this.handlePos2;
2451
+ this.handleVal1 = this.handleVal2;
2452
+ }
2453
+ if (this.handlePos1 !== this.preHandlePos1) {
2454
+ position = this.preHandlePos1 = this.handlePos1;
2455
+ }
2456
+ }
2457
+ this.modifyZindex();
2458
+ } else {
2459
+ if (!(this.limits.enabled && this.limits.endHandleFixed)) {
2460
+ this.handleVal2 = this.checkHandleValue(value);
2461
+ this.handlePos2 = this.checkHandlePosition(this.handleVal2);
2462
+
2463
+ if (this.type === 'Range' && ((this.handlePos2 < this.handlePos1 && this.min < this.max) || (this.handlePos2 > this.handlePos1 && this.min > this.max))) {
2464
+ this.handlePos2 = this.handlePos1;
2465
+ this.handleVal2 = this.handleVal1;
2466
+ }
2467
+ if (this.handlePos2 !== this.preHandlePos2) {
2468
+ position = this.preHandlePos2 = this.handlePos2;
2469
+ }
2470
+ }
2471
+ this.modifyZindex();
2472
+ }
2473
+
2474
+ if (position !== null) {
2475
+ if (this.type !== 'Default') {
2476
+ this.setRangeBar();
2477
+ }
2478
+ this.setHandlePosition(null);
2479
+ }
2480
+ }
2481
+
2482
+ private tempStartEnd(): Object {
2483
+ if (this.min > this.max) {
2484
+ return {
2485
+ start: this.max,
2486
+ end: this.min
2487
+ };
2488
+ } else {
2489
+ return {
2490
+ start: this.min,
2491
+ end: this.max
2492
+ };
2493
+ }
2494
+ }
2495
+
2496
+ private xyToPosition(position: { [key: string]: Object }): number {
2497
+ let pos: number;
2498
+ if (this.min === this.max) {
2499
+ return 100;
2500
+ }
2501
+ if (this.orientation === 'Horizontal') {
2502
+ const left: number = position.x as number - this.element.getBoundingClientRect().left;
2503
+ const num: number = this.element.offsetWidth / 100;
2504
+ this.val = (left / num);
2505
+ } else {
2506
+ const top: number = position.y as number - this.element.getBoundingClientRect().top;
2507
+ const num: number = this.element.offsetHeight / 100;
2508
+ this.val = 100 - (top / num);
2509
+ }
2510
+ let val: number = this.stepValueCalculation(this.val);
2511
+ if (val < 0) {
2512
+ val = 0;
2513
+ } else if (val > 100) {
2514
+ val = 100;
2515
+ }
2516
+ if (this.enableRtl && this.orientation !== 'Vertical') {
2517
+ val = 100 - val;
2518
+ }
2519
+ if (this.orientation === 'Horizontal') {
2520
+ pos = this.element.getBoundingClientRect().width * (val / 100);
2521
+ } else {
2522
+ pos = this.element.getBoundingClientRect().height * (val / 100);
2523
+ }
2524
+ return pos;
2525
+ }
2526
+
2527
+ private stepValueCalculation(value: number): number {
2528
+ if (this.step === 0) {
2529
+ this.step = 1;
2530
+ }
2531
+ const percentStep: number =
2532
+ (parseFloat(formatUnit(this.step))) / ((parseFloat(formatUnit(this.max)) - parseFloat(formatUnit(this.min))) / 100);
2533
+ const remain: number = value % Math.abs(percentStep);
2534
+ if (remain !== 0) {
2535
+ if ((percentStep / 2) > remain) {
2536
+ value -= remain;
2537
+ } else {
2538
+ value += Math.abs(percentStep) - remain;
2539
+ }
2540
+ }
2541
+ return value;
2542
+ }
2543
+
2544
+ private add(a: number, b: number, addition: boolean): number {
2545
+ let precision: number;
2546
+ const x: number = Math.pow(10, precision || 3);
2547
+ let val: number;
2548
+ if (addition) {
2549
+ val = (Math.round(a * x) + Math.round(b * x)) / x;
2550
+ } else {
2551
+ val = (Math.round(a * x) - Math.round(b * x)) / x;
2552
+ }
2553
+ return val;
2554
+ }
2555
+
2556
+ private positionToValue(pos: number): number {
2557
+ let val: number;
2558
+ const diff: number = parseFloat(formatUnit(this.max)) - parseFloat(formatUnit(this.min));
2559
+ if (this.orientation === 'Horizontal') {
2560
+ val = (pos / this.element.getBoundingClientRect().width) * diff;
2561
+ } else {
2562
+ val = (pos / this.element.getBoundingClientRect().height) * diff;
2563
+ }
2564
+ const total: number = this.add(val, parseFloat(this.min.toString()), true);
2565
+ return (total);
2566
+ }
2567
+
2568
+ private sliderBarClick(evt: MouseEvent & TouchEvent): void {
2569
+ evt.preventDefault();
2570
+ let pos: { [key: string]: Object };
2571
+ if (evt.type === 'mousedown' || evt.type === 'mouseup' || evt.type === 'click') {
2572
+ pos = { x: evt.clientX, y: evt.clientY };
2573
+ } else if (evt.type === 'touchend' || evt.type === 'touchstart') {
2574
+ pos = { x: evt.changedTouches[0].clientX, y: evt.changedTouches[0].clientY };
2575
+ }
2576
+ let handlepos: number = this.xyToPosition(pos);
2577
+ let handleVal: number = this.positionToValue(handlepos);
2578
+ if (this.type === 'Range' && (this.min < (this.max) && (this.handlePos2 - handlepos) < (handlepos - this.handlePos1) || (this.min > this.max) && (this.handlePos1 - handlepos) > (handlepos - this.handlePos2))) {
2579
+ this.activeHandle = 2;
2580
+ if (!(this.limits.enabled && this.limits.endHandleFixed)) {
2581
+ if (this.limits.enabled) {
2582
+ const value: number[] = this.getLimitValueAndPosition(handleVal, this.limits.maxStart, this.limits.maxEnd);
2583
+ handleVal = value[0];
2584
+ handlepos = value[1];
2585
+ }
2586
+ this.secondHandle.classList.add(classNames.sliderActiveHandle);
2587
+ this.handlePos2 = this.preHandlePos2 = handlepos;
2588
+ this.handleVal2 = handleVal;
2589
+ }
2590
+ this.modifyZindex();
2591
+ this.secondHandle.focus();
2592
+ } else {
2593
+ this.activeHandle = 1;
2594
+ if (!(this.limits.enabled && this.limits.startHandleFixed)) {
2595
+ if (this.limits.enabled) {
2596
+ const value: number[] = this.getLimitValueAndPosition(handleVal, this.limits.minStart, this.limits.minEnd);
2597
+ handleVal = value[0];
2598
+ handlepos = value[1];
2599
+ }
2600
+ this.firstHandle.classList.add(classNames.sliderActiveHandle);
2601
+ this.handlePos1 = this.preHandlePos1 = handlepos;
2602
+ this.handleVal1 = handleVal;
2603
+ }
2604
+ this.modifyZindex();
2605
+ this.firstHandle.focus();
2606
+ }
2607
+ if (this.isMaterialTooltip) {
2608
+ this.tooltipElement.classList.add(classNames.materialTooltipActive);
2609
+ }
2610
+ const focusedElement: Element = this.element.querySelector('.' + classNames.sliderTabHandle);
2611
+ if (focusedElement && this.getHandle() !== focusedElement) {
2612
+ focusedElement.classList.remove(classNames.sliderTabHandle);
2613
+ }
2614
+ const handle: HTMLElement = this.activeHandle === 1 ? this.firstHandle : this.secondHandle;
2615
+ let behindElement: Element;
2616
+ if ((evt.type === 'click' || evt.type === 'mousedown') && evt.target === handle) {
2617
+ const { clientX: eventX, clientY: eventY } = evt;
2618
+ behindElement = document.elementFromPoint(eventX, eventY);
2619
+ }
2620
+ if (!this.checkRepeatedValue(handleVal)) {
2621
+ return;
2622
+ }
2623
+ const transition: { [key: string]: string } = (this.isMaterial || this.isMaterial3) && this.tooltip.isVisible ?
2624
+ this.transitionOnMaterialTooltip : this.transition;
2625
+ this.getHandle().style.transition = transition.handle;
2626
+ if (this.type !== 'Default') {
2627
+ this.rangeBar.style.transition = transition.rangeBar;
2628
+ }
2629
+ this.setHandlePosition(evt);
2630
+ if (this.isMaterialTooltip) {
2631
+ this.initialTooltip = false;
2632
+ }
2633
+ if (evt.target !== handle) {
2634
+ this.changeEvent('changed', evt);
2635
+ }
2636
+ if (this.type !== 'Default') {
2637
+ this.setRangeBar();
2638
+ }
2639
+ }
2640
+
2641
+ private handleValueAdjust(handleValue: number, assignValue: number, handleNumber: SliderHandleNumber): void {
2642
+ if (handleNumber === 1) {
2643
+ this.handleVal1 = assignValue;
2644
+ this.handleVal2 = this.handleVal1 + this.minDiff;
2645
+ } else if (handleNumber === 2) {
2646
+ this.handleVal2 = assignValue;
2647
+ this.handleVal1 = this.handleVal2 - this.minDiff;
2648
+ }
2649
+ this.handlePos1 = this.checkHandlePosition(this.handleVal1);
2650
+ this.handlePos2 = this.checkHandlePosition(this.handleVal2);
2651
+ }
2652
+
2653
+ private dragRangeBarMove(event: MouseEvent & TouchEvent): void {
2654
+ if (event.type !== 'touchmove') {
2655
+ event.preventDefault();
2656
+ }
2657
+ this.rangeBarDragged = true;
2658
+ let pos: { [key: string]: number };
2659
+ this.rangeBar.style.transition = 'none';
2660
+ this.firstHandle.style.transition = 'none';
2661
+ this.secondHandle.style.transition = 'none';
2662
+ let xPostion: number; let yPostion: number;
2663
+ if (event.type === 'mousemove') {
2664
+ [xPostion, yPostion] = [event.clientX, event.clientY];
2665
+ } else {
2666
+ [xPostion, yPostion] = [event.changedTouches[0].clientX, event.changedTouches[0].clientY];
2667
+ }
2668
+ if (!(this.limits.enabled && this.limits.startHandleFixed) && !(this.limits.enabled && this.limits.endHandleFixed)) {
2669
+ if (!this.enableRtl) {
2670
+ pos = { x: xPostion - this.firstPartRemain, y: yPostion + this.secondPartRemain };
2671
+ } else {
2672
+ pos = { x: xPostion + this.secondPartRemain, y: yPostion + this.secondPartRemain };
2673
+ }
2674
+ if (this.min > this.max) {
2675
+ this.handlePos2 = this.xyToPosition(pos);
2676
+ this.handleVal2 = this.positionToValue(this.handlePos2);
2677
+ }
2678
+ else {
2679
+ this.handlePos1 = this.xyToPosition(pos);
2680
+ this.handleVal1 = this.positionToValue(this.handlePos1);
2681
+ }
2682
+ if (!this.enableRtl) {
2683
+ pos = { x: xPostion + this.secondPartRemain, y: yPostion - this.firstPartRemain };
2684
+ } else {
2685
+ pos = { x: xPostion - this.firstPartRemain, y: yPostion - this.firstPartRemain };
2686
+ }
2687
+ if (this.min > this.max) {
2688
+ this.handlePos1 = this.xyToPosition(pos);
2689
+ this.handleVal1 = this.positionToValue(this.handlePos1);
2690
+ }
2691
+ else {
2692
+ this.handlePos2 = this.xyToPosition(pos);
2693
+ this.handleVal2 = this.positionToValue(this.handlePos2);
2694
+ }
2695
+ if (this.limits.enabled) {
2696
+ let value: number[] = this.getLimitValueAndPosition(this.handleVal1, this.limits.minStart, this.limits.minEnd);
2697
+ this.handleVal1 = value[0];
2698
+ this.handlePos1 = value[1];
2699
+ if (this.handleVal1 === this.limits.minEnd) {
2700
+ this.handleValueAdjust(this.handleVal1, this.limits.minEnd, 1);
2701
+ }
2702
+ if (this.handleVal1 === this.limits.minStart) {
2703
+ this.handleValueAdjust(this.handleVal1, this.limits.minStart, 1);
2704
+ }
2705
+ value = this.getLimitValueAndPosition(this.handleVal2, this.limits.maxStart, this.limits.maxEnd);
2706
+ this.handleVal2 = value[0];
2707
+ this.handlePos2 = value[1];
2708
+ if (this.handleVal2 === this.limits.maxStart) {
2709
+ this.handleValueAdjust(this.handleVal2, this.limits.maxStart, 2);
2710
+ }
2711
+ if (this.handleVal2 === this.limits.maxEnd) {
2712
+ this.handleValueAdjust(this.handleVal2, this.limits.maxEnd, 2);
2713
+ }
2714
+ }
2715
+ if (this.handleVal2 === (this.min > this.max ? this.min : this.max)) {
2716
+ this.handleValueAdjust(this.handleVal2, (this.min > this.max ? this.min : this.max), 2);
2717
+ }
2718
+ if (this.handleVal1 === (this.min > this.max ? this.max : this.min)) {
2719
+ this.handleValueAdjust(this.handleVal1, (this.min > this.max ? this.max : this.min), 1);
2720
+ }
2721
+ }
2722
+ this.activeHandle = 1;
2723
+ this.setHandlePosition(event);
2724
+ this.activeHandle = 2;
2725
+ this.setHandlePosition(event);
2726
+ this.tooltipToggle(this.rangeBar);
2727
+ this.setRangeBar();
2728
+ }
2729
+
2730
+ private sliderBarUp(event: MouseEvent): void {
2731
+ this.changeEvent('changed', event);
2732
+ this.handleFocusOut();
2733
+ this.firstHandle.classList.remove(classNames.sliderActiveHandle);
2734
+ if (this.type === 'Range') {
2735
+ this.initialTooltip = false;
2736
+ this.secondHandle.classList.remove(classNames.sliderActiveHandle);
2737
+ }
2738
+ this.closeTooltip();
2739
+ if (this.isMaterial || this.isMaterial3) {
2740
+ this.getHandle().classList.remove('e-large-thumb-size');
2741
+ if (this.isMaterialTooltip) {
2742
+ this.tooltipElement.classList.remove(classNames.materialTooltipActive);
2743
+ }
2744
+ }
2745
+ EventHandler.remove(document, 'mousemove touchmove', this.sliderBarMove);
2746
+ EventHandler.remove(document, 'mouseup touchend', this.sliderBarUp);
2747
+ }
2748
+
2749
+ private sliderBarMove(evt: MouseEvent & TouchEvent): void {
2750
+ if (evt.type !== 'touchmove') {
2751
+ evt.preventDefault();
2752
+ }
2753
+ let pos: { [key: string]: Object };
2754
+ if (evt.type === 'mousemove') {
2755
+ pos = { x: evt.clientX, y: evt.clientY };
2756
+ } else {
2757
+ pos = { x: evt.changedTouches[0].clientX, y: evt.changedTouches[0].clientY };
2758
+ }
2759
+ let handlepos: number = this.xyToPosition(pos);
2760
+ let handleVal: number = this.positionToValue(handlepos);
2761
+ handlepos = Math.round(handlepos);
2762
+ if (this.type !== 'Range' && this.activeHandle === 1) {
2763
+ if (!(this.limits.enabled && this.limits.startHandleFixed)) {
2764
+ if (this.limits.enabled) {
2765
+ const valueAndPostion: number[] = this.getLimitValueAndPosition(handleVal, this.limits.minStart, this.limits.minEnd);
2766
+ handlepos = valueAndPostion[1];
2767
+ handleVal = valueAndPostion[0];
2768
+ }
2769
+ this.handlePos1 = handlepos;
2770
+ this.handleVal1 = handleVal;
2771
+ }
2772
+ this.firstHandle.classList.add(classNames.sliderActiveHandle);
2773
+ }
2774
+ if (this.type === 'Range') {
2775
+ if (this.activeHandle === 1) {
2776
+ this.firstHandle.classList.add(classNames.sliderActiveHandle);
2777
+ if (!(this.limits.enabled && this.limits.startHandleFixed)) {
2778
+ if ((this.min < this.max && handlepos > this.handlePos2 || (this.min > this.max && handlepos < this.handlePos2))) {
2779
+ handlepos = this.handlePos2;
2780
+ handleVal = this.handleVal2;
2781
+ }
2782
+ if (handlepos !== this.preHandlePos1) {
2783
+ if (this.limits.enabled) {
2784
+ const value: number[] = this.getLimitValueAndPosition(handleVal, this.limits.minStart, this.limits.minEnd);
2785
+ handleVal = value[0];
2786
+ handlepos = value[1];
2787
+ }
2788
+ this.handlePos1 = this.preHandlePos1 = handlepos;
2789
+ this.handleVal1 = handleVal;
2790
+ this.activeHandle = 1;
2791
+ }
2792
+ }
2793
+ } else if (this.activeHandle === 2) {
2794
+ this.secondHandle.classList.add(classNames.sliderActiveHandle);
2795
+ if (!(this.limits.enabled && this.limits.endHandleFixed)) {
2796
+ if ((this.min < this.max && handlepos < this.handlePos1) || (this.min > this.max && handlepos > this.handlePos1)) {
2797
+ handlepos = this.handlePos1;
2798
+ handleVal = this.handleVal1;
2799
+ }
2800
+ if (handlepos !== this.preHandlePos2) {
2801
+ if (this.limits.enabled) {
2802
+ const value: number[] = this.getLimitValueAndPosition(handleVal, this.limits.maxStart, this.limits.maxEnd);
2803
+ handleVal = value[0];
2804
+ handlepos = value[1];
2805
+ }
2806
+ this.handlePos2 = this.preHandlePos2 = handlepos;
2807
+ this.handleVal2 = handleVal;
2808
+ this.activeHandle = 2;
2809
+ }
2810
+ }
2811
+ }
2812
+ }
2813
+ if (!this.checkRepeatedValue(handleVal)) {
2814
+ return;
2815
+ }
2816
+ this.getHandle().style.transition = this.scaleTransform;
2817
+ if (this.type !== 'Default') {
2818
+ this.rangeBar.style.transition = 'none';
2819
+ }
2820
+ this.setHandlePosition(evt);
2821
+ if ((this.isMaterial || this.isMaterial3) && !this.tooltip.isVisible &&
2822
+ !(this.getHandle() as HTMLElement).classList.contains(classNames.sliderTabHandle)) {
2823
+ this.materialChange();
2824
+ }
2825
+ this.tooltipToggle(this.getHandle());
2826
+ if (this.type !== 'Default') {
2827
+ this.setRangeBar();
2828
+ }
2829
+ }
2830
+
2831
+ private dragRangeBarUp(event: MouseEvent & TouchEvent): void {
2832
+ if (!this.rangeBarDragged) {
2833
+ this.focusSliderElement();
2834
+ this.sliderBarClick(event);
2835
+ } else {
2836
+ this.isDragComplete = true;
2837
+ }
2838
+ this.changeEvent('changed', event);
2839
+ this.closeTooltip();
2840
+ EventHandler.remove(document, 'mousemove touchmove', this.dragRangeBarMove);
2841
+ EventHandler.remove(document, 'mouseup touchend', this.dragRangeBarUp);
2842
+ this.rangeBarDragged = false;
2843
+ }
2844
+
2845
+ private checkRepeatedValue(currentValue: number): number {
2846
+ if (this.type === 'Range') {
2847
+ const previousVal: number = this.enableRtl && this.orientation !== 'Vertical' ? (this.activeHandle === 1 ?
2848
+ (this.previousVal as number[])[1] : (this.previousVal as number[])[0]) :
2849
+ (this.activeHandle === 1 ? (this.previousVal as number[])[0] : (this.previousVal as number[])[1]);
2850
+ if (currentValue === previousVal) {
2851
+ return 0;
2852
+ }
2853
+ } else {
2854
+ if (currentValue === this.previousVal) {
2855
+ return 0;
2856
+ }
2857
+ }
2858
+ return 1;
2859
+ }
2860
+ private refreshTooltip(target: HTMLElement): void {
2861
+ if (this.tooltip.isVisible && this.tooltipObj) {
2862
+ this.tooltipValue();
2863
+ if (target) {
2864
+ this.tooltipObj.refresh(target);
2865
+ this.tooltipTarget = target;
2866
+ }
2867
+ }
2868
+ }
2869
+
2870
+ private openTooltip(target?: HTMLElement): void {
2871
+ if (this.tooltip.isVisible && this.tooltipObj && !this.isMaterialTooltip) {
2872
+ this.tooltipValue();
2873
+ this.tooltipObj.open(target);
2874
+ this.tooltipTarget = target;
2875
+ }
2876
+ }
2877
+
2878
+ private closeTooltip(): void {
2879
+ if (this.tooltip.isVisible && this.tooltipObj && this.tooltip.showOn !== 'Always' && !this.isMaterialTooltip) {
2880
+ this.tooltipValue();
2881
+ this.tooltipObj.close();
2882
+ this.tooltipTarget = undefined;
2883
+ }
2884
+ }
2885
+
2886
+ private keyDown(event: KeyboardEvent): void {
2887
+ switch (event.keyCode) {
2888
+ case 37:
2889
+ case 38:
2890
+ case 39:
2891
+ case 40:
2892
+ case 33:
2893
+ case 34:
2894
+ case 36:
2895
+ case 35:
2896
+ event.preventDefault();
2897
+ this.buttonClick(event);
2898
+ break;
2899
+ }
2900
+
2901
+ }
2902
+
2903
+ private wireButtonEvt(destroy: boolean): void {
2904
+ if (!destroy) {
2905
+ EventHandler.add(this.firstBtn, 'mouseleave touchleave', this.buttonFocusOut, this);
2906
+ EventHandler.add(this.secondBtn, 'mouseleave touchleave', this.buttonFocusOut, this);
2907
+ EventHandler.add(this.firstBtn, 'mousedown touchstart', this.repeatHandlerMouse, this);
2908
+ EventHandler.add(this.firstBtn, 'mouseup mouseleave touchup touchend', this.repeatHandlerUp, this);
2909
+ EventHandler.add(this.secondBtn, 'mousedown touchstart', this.repeatHandlerMouse, this);
2910
+ EventHandler.add(this.secondBtn, 'mouseup mouseleave touchup touchend', this.repeatHandlerUp, this);
2911
+ EventHandler.add(this.firstBtn, 'focusout', this.sliderFocusOut, this);
2912
+ EventHandler.add(this.secondBtn, 'focusout', this.sliderFocusOut, this);
2913
+
2914
+ } else {
2915
+ EventHandler.remove(this.firstBtn, 'mouseleave touchleave', this.buttonFocusOut);
2916
+ EventHandler.remove(this.secondBtn, 'mouseleave touchleave', this.buttonFocusOut);
2917
+ EventHandler.remove(this.firstBtn, 'mousedown touchstart', this.repeatHandlerMouse);
2918
+ EventHandler.remove(this.firstBtn, 'mouseup mouseleave touchup touchend', this.repeatHandlerUp);
2919
+ EventHandler.remove(this.secondBtn, 'mousedown touchstart', this.repeatHandlerMouse);
2920
+ EventHandler.remove(this.secondBtn, 'mouseup mouseleave touchup touchend', this.repeatHandlerUp);
2921
+ EventHandler.remove(this.firstBtn, 'focusout', this.sliderFocusOut);
2922
+ EventHandler.remove(this.secondBtn, 'focusout', this.sliderFocusOut);
2923
+ }
2924
+ }
2925
+
2926
+ private rangeBarMousedown(event: MouseEvent & TouchEvent): void {
2927
+ event.preventDefault();
2928
+ this.focusSliderElement();
2929
+ if (this.type === 'Range' && this.drag && event.target === this.rangeBar) {
2930
+ let xPostion: number; let yPostion: number;
2931
+ if (event.type === 'mousedown') {
2932
+ [xPostion, yPostion] = [event.clientX, event.clientY];
2933
+ } else if (event.type === 'touchstart') {
2934
+ [xPostion, yPostion] = [event.changedTouches[0].clientX, event.changedTouches[0].clientY];
2935
+ }
2936
+ if (this.orientation === 'Horizontal') {
2937
+ this.firstPartRemain = xPostion - this.rangeBar.getBoundingClientRect().left;
2938
+ this.secondPartRemain = this.rangeBar.getBoundingClientRect().right - xPostion;
2939
+ } else {
2940
+ this.firstPartRemain = yPostion - this.rangeBar.getBoundingClientRect().top;
2941
+ this.secondPartRemain = this.rangeBar.getBoundingClientRect().bottom - yPostion;
2942
+ }
2943
+ this.minDiff = this.handleVal2 - this.handleVal1;
2944
+ this.tooltipToggle(this.rangeBar);
2945
+ const focusedElement: Element = this.element.querySelector('.' + classNames.sliderTabHandle);
2946
+ if (focusedElement) {
2947
+ focusedElement.classList.remove(classNames.sliderTabHandle);
2948
+ }
2949
+ EventHandler.add(document, 'mousemove touchmove', this.dragRangeBarMove, this);
2950
+ EventHandler.add(document, 'mouseup touchend', this.dragRangeBarUp, this);
2951
+ }
2952
+ }
2953
+
2954
+ private elementClick(event: MouseEvent & TouchEvent): void {
2955
+ if (this.isDragComplete) {
2956
+ this.isDragComplete = false;
2957
+ return;
2958
+ }
2959
+ event.preventDefault();
2960
+ this.focusSliderElement();
2961
+ this.sliderBarClick(event);
2962
+ this.focusHandle();
2963
+ }
2964
+
2965
+ private wireEvents(): void {
2966
+ this.onresize = this.reposition.bind(this);
2967
+ window.addEventListener('resize', this.onresize);
2968
+ if (this.enabled && !this.readonly) {
2969
+ EventHandler.add(this.element, 'click', this.elementClick, this);
2970
+ if (this.type === 'Range' && this.drag) {
2971
+ EventHandler.add(this.rangeBar, 'mousedown touchstart', this.rangeBarMousedown, this);
2972
+ }
2973
+ EventHandler.add(this.sliderContainer, 'keydown', this.keyDown, this);
2974
+ EventHandler.add(this.sliderContainer, 'keyup', this.keyUp, this);
2975
+ EventHandler.add(this.element, 'focusout', this.sliderFocusOut, this);
2976
+ EventHandler.add(this.sliderContainer, 'mouseover mouseout touchstart touchend', this.hover, this);
2977
+ this.wireFirstHandleEvt(false);
2978
+ if (this.type === 'Range') {
2979
+ this.wireSecondHandleEvt(false);
2980
+ }
2981
+ if (this.showButtons) {
2982
+ this.wireButtonEvt(false);
2983
+ }
2984
+ this.wireMaterialTooltipEvent(false);
2985
+ if (this.isForm) {
2986
+ EventHandler.add(this.formElement, 'reset', this.formResetHandler, this);
2987
+ }
2988
+ }
2989
+ }
2990
+
2991
+ private unwireEvents(): void {
2992
+ EventHandler.remove(this.element, 'click', this.elementClick);
2993
+ if (this.type === 'Range' && this.drag) {
2994
+ EventHandler.remove(this.rangeBar, 'mousedown touchstart', this.rangeBarMousedown);
2995
+ }
2996
+ EventHandler.remove(this.sliderContainer, 'keydown', this.keyDown);
2997
+ EventHandler.remove(this.sliderContainer, 'keyup', this.keyUp);
2998
+ EventHandler.remove(this.element, 'focusout', this.sliderFocusOut);
2999
+ EventHandler.remove(this.sliderContainer, 'mouseover mouseout touchstart touchend', this.hover);
3000
+ this.wireFirstHandleEvt(true);
3001
+ if (this.type === 'Range') {
3002
+ this.wireSecondHandleEvt(true);
3003
+ }
3004
+ if (this.showButtons) {
3005
+ this.wireButtonEvt(true);
3006
+ }
3007
+ this.wireMaterialTooltipEvent(true);
3008
+ EventHandler.remove(this.element, 'reset', this.formResetHandler);
3009
+ }
3010
+
3011
+ private formResetHandler(): void {
3012
+ this.setProperties({ 'value': this.formResetValue }, true);
3013
+ this.setValue();
3014
+ }
3015
+
3016
+ private keyUp(event: KeyboardEvent): void {
3017
+ if (event.keyCode === 9 && (event.target as HTMLElement).classList.contains(classNames.sliderHandle)) {
3018
+ this.focusSliderElement();
3019
+ if (!(event.target as HTMLElement).classList.contains(classNames.sliderTabHandle)) {
3020
+ if (this.element.querySelector('.' + classNames.sliderTabHandle)) {
3021
+ this.element.querySelector('.' + classNames.sliderTabHandle).classList.remove(classNames.sliderTabHandle);
3022
+ }
3023
+ (event.target as HTMLElement).classList.add(classNames.sliderTabHandle);
3024
+ const parentElement: HTMLElement = (event.target as HTMLElement).parentElement;
3025
+ if (parentElement === this.element) {
3026
+ (parentElement.querySelector('.' + classNames.sliderTrack) as HTMLElement).classList.add(classNames.sliderTabTrack);
3027
+ if (this.type === 'Range' || this.type === 'MinRange') {
3028
+ (parentElement.querySelector('.' + classNames.rangeBar) as HTMLElement).classList.add(classNames.sliderTabRange);
3029
+ }
3030
+ }
3031
+ if (this.type === 'Range') {
3032
+ const previousSibling: Element = (event.target as Element).previousSibling as Element;
3033
+ if (previousSibling && previousSibling.classList.contains(classNames.sliderHandle)) {
3034
+ this.activeHandle = 2;
3035
+ } else {
3036
+ this.activeHandle = 1;
3037
+ }
3038
+ }
3039
+ this.getHandle().focus();
3040
+ this.tooltipToggle(this.getHandle());
3041
+ }
3042
+ }
3043
+ this.closeTooltip();
3044
+ this.changeEvent('changed', event);
3045
+ }
3046
+
3047
+ private hover(event: MouseEvent): void {
3048
+ if (!isNullOrUndefined(event)) {
3049
+ if (event.type === 'mouseover' || event.type === 'touchmove' || event.type === 'mousemove' ||
3050
+ event.type === 'pointermove' || event.type === 'touchstart') {
3051
+ this.sliderContainer.classList.add(classNames.sliderHover);
3052
+ } else {
3053
+ this.sliderContainer.classList.remove(classNames.sliderHover);
3054
+ const curTarget: HTMLElement = event.currentTarget as HTMLElement;
3055
+ if (this.tooltip.isVisible && this.tooltip.showOn !== 'Always' && this.tooltipObj && this.isMaterialTooltip &&
3056
+ !curTarget.classList.contains(classNames.sliderHandleFocused) &&
3057
+ !curTarget.classList.contains(classNames.sliderTabHandle)) {
3058
+ this.closeMaterialTooltip();
3059
+ }
3060
+ }
3061
+ }
3062
+ }
3063
+
3064
+ private sliderFocusOut(event: MouseEvent): void {
3065
+ if (event.relatedTarget !== this.secondHandle && event.relatedTarget !== this.firstHandle &&
3066
+ event.relatedTarget !== this.element && event.relatedTarget !== this.firstBtn && event.relatedTarget !== this.secondBtn) {
3067
+ this.closeMaterialTooltip();
3068
+ this.closeTooltip();
3069
+ if (this.element.querySelector('.' + classNames.sliderTabHandle)) {
3070
+ this.element.querySelector('.' + classNames.sliderTabHandle).classList.remove(classNames.sliderTabHandle);
3071
+ }
3072
+ if (this.element.querySelector('.' + classNames.sliderTabTrack)) {
3073
+ this.element.querySelector('.' + classNames.sliderTabTrack).classList.remove(classNames.sliderTabTrack);
3074
+ if ((this.type === 'Range' || this.type === 'MinRange') &&
3075
+ this.element.querySelector('.' + classNames.sliderTabRange)) {
3076
+ this.element.querySelector('.' + classNames.sliderTabRange).classList.remove(classNames.sliderTabRange);
3077
+ }
3078
+ }
3079
+ this.hiddenInput.focus();
3080
+ this.hiddenInput.blur();
3081
+ this.isElementFocused = false;
3082
+ }
3083
+ }
3084
+
3085
+ private removeElement(element: Element): void {
3086
+ if (element.parentNode) {
3087
+ element.parentNode.removeChild(element);
3088
+ }
3089
+ }
3090
+ private changeSliderType(type: SliderType, args: string): void {
3091
+ if (this.isMaterialTooltip && this.materialHandle) {
3092
+ this.sliderContainer.classList.remove(classNames.materialSlider);
3093
+ this.removeElement(this.materialHandle);
3094
+ this.materialHandle = undefined;
3095
+ }
3096
+ this.removeElement(this.firstHandle);
3097
+ this.firstHandle = undefined;
3098
+ if (type !== 'Default') {
3099
+ if (type === 'Range') {
3100
+ this.removeElement(this.secondHandle);
3101
+ this.secondHandle = undefined;
3102
+ }
3103
+ this.removeElement(this.rangeBar);
3104
+ this.rangeBar = undefined;
3105
+ }
3106
+ if (this.tooltip.isVisible && !isNullOrUndefined(this.tooltipObj)) {
3107
+ this.tooltipObj.destroy();
3108
+ this.tooltipElement = undefined;
3109
+ this.tooltipCollidedPosition = undefined;
3110
+ }
3111
+ if (this.limits.enabled) {
3112
+ if (type === 'MinRange' || type === 'Default') {
3113
+ if (!isNullOrUndefined(this.limitBarFirst)) {
3114
+ this.removeElement(this.limitBarFirst);
3115
+ this.limitBarFirst = undefined;
3116
+ }
3117
+ } else {
3118
+ if (!isNullOrUndefined(this.limitBarSecond)) {
3119
+ this.removeElement(this.limitBarSecond);
3120
+ this.limitBarSecond = undefined;
3121
+ }
3122
+ }
3123
+ }
3124
+ this.activeHandle = 1;
3125
+ this.getThemeInitialization();
3126
+ if (this.type === 'Range') {
3127
+ this.rangeValueUpdate();
3128
+ }
3129
+ this.createRangeBar();
3130
+ if (this.limits.enabled) {
3131
+ this.createLimitBar();
3132
+ }
3133
+ this.setHandler();
3134
+ this.setOrientClass();
3135
+ this.wireFirstHandleEvt(!this.enabled);
3136
+ if (this.type === 'Range') {
3137
+ this.wireSecondHandleEvt(!this.enabled);
3138
+ }
3139
+ this.setValue();
3140
+ if (this.tooltip.isVisible) {
3141
+ this.renderTooltip();
3142
+ this.wireMaterialTooltipEvent(false);
3143
+ }
3144
+ this.setBarColor();
3145
+ if (args !== 'tooltip') {
3146
+ this.updateConfig();
3147
+ }
3148
+ if (this.readonly) {
3149
+ this.sliderContainer.classList.remove(classNames.readonly);
3150
+ this.setReadOnly();
3151
+ }
3152
+ }
3153
+
3154
+ private changeRtl(): void {
3155
+ if (!this.enableRtl && this.type === 'Range') {
3156
+ this.value = [this.handleVal2, this.handleVal1];
3157
+ }
3158
+ this.updateConfig();
3159
+ if (this.tooltip.isVisible) {
3160
+ this.tooltipObj.refresh(this.firstHandle);
3161
+ }
3162
+ if (this.showButtons) {
3163
+ const enabledRTL: boolean = this.enableRtl && this.orientation !== 'Vertical';
3164
+ attributes(enabledRTL ? this.secondBtn : this.firstBtn, { 'aria-label': 'Decrease', title: 'Decrease' });
3165
+ attributes(enabledRTL ? this.firstBtn : this.secondBtn, { 'aria-label': 'Increase', title: 'Increase' });
3166
+ }
3167
+ }
3168
+
3169
+ private changeOrientation(): void {
3170
+ this.changeSliderType(this.type, 'null');
3171
+ }
3172
+
3173
+ private updateConfig(): void {
3174
+ this.setEnableRTL();
3175
+ this.setValue();
3176
+ if (this.tooltip.isVisible) {
3177
+ this.refreshTooltip(this.tooltipTarget);
3178
+ }
3179
+ if (this.ticks.placement !== 'None') {
3180
+ if (this.ul) {
3181
+ this.removeElement(this.ul);
3182
+ this.ul = undefined;
3183
+ this.renderScale();
3184
+ }
3185
+ }
3186
+ this.limitsPropertyChange();
3187
+ }
3188
+
3189
+ private limitsPropertyChange(): void {
3190
+ if (this.limits.enabled) {
3191
+ if (isNullOrUndefined(this.limitBarFirst) && this.type !== 'Range') {
3192
+ this.createLimitBar();
3193
+ }
3194
+ if (isNullOrUndefined(this.limitBarFirst) && isNullOrUndefined(this.limitBarSecond) && this.type === 'Range') {
3195
+ this.createLimitBar();
3196
+ }
3197
+ this.setLimitBar();
3198
+ this.setValue();
3199
+ } else {
3200
+ if (!isNullOrUndefined(this.limitBarFirst)) {
3201
+ detach(this.limitBarFirst);
3202
+ }
3203
+ if (!isNullOrUndefined(this.limitBarSecond)) {
3204
+ detach(this.limitBarSecond);
3205
+ }
3206
+ }
3207
+ }
3208
+
3209
+ /**
3210
+ * Get the properties to be maintained in the persisted state.
3211
+ *
3212
+ * @returns {string} - Returns the string
3213
+ * @private
3214
+ */
3215
+ protected getPersistData(): string {
3216
+ const keyEntity: string[] = ['value'];
3217
+ return this.addOnPersist(keyEntity);
3218
+ }
3219
+
3220
+ /**
3221
+ * Removes the component from the DOM and detaches all its related event handlers.
3222
+ * Also it removes the attributes and classes.
3223
+ *
3224
+ * @method destroy
3225
+ * @returns {void}
3226
+ */
3227
+ public destroy(): void {
3228
+ super.destroy();
3229
+ this.unwireEvents();
3230
+ window.removeEventListener('resize', this.onresize);
3231
+ removeClass([this.sliderContainer], [classNames.sliderDisabled]);
3232
+ this.firstHandle.removeAttribute('aria-orientation');
3233
+ if (this.type === 'Range') {
3234
+ this.secondHandle.removeAttribute('aria-orientation');
3235
+ }
3236
+ if (this.sliderContainer.parentNode) {
3237
+ this.sliderContainer.parentNode.insertBefore(this.element, this.sliderContainer);
3238
+ }
3239
+ detach(this.sliderContainer);
3240
+ if (this.tooltip.isVisible) {
3241
+ this.tooltipObj.destroy();
3242
+ }
3243
+ this.element.innerHTML = '';
3244
+ this.hiddenInput = null;
3245
+ this.sliderContainer = null;
3246
+ this.sliderTrack = null;
3247
+ this.rangeBar = null;
3248
+ this.firstHandle = null;
3249
+ this.secondHandle = null;
3250
+ this.tickElementCollection = null;
3251
+ this.ul = null;
3252
+ this.firstBtn = null;
3253
+ this.secondBtn = null;
3254
+ this.materialHandle = null;
3255
+ this.tooltipObj = null;
3256
+ this.tooltipTarget = null;
3257
+ this.limitBarFirst = null;
3258
+ this.limitBarSecond = null;
3259
+ this.firstChild = null;
3260
+ this.lastChild = null;
3261
+ this.tooltipElement = null;
3262
+ }
3263
+
3264
+ /**
3265
+ * Calls internally if any of the property value is changed.
3266
+ *
3267
+ * @param {SliderModel} newProp - Specifies the new properties
3268
+ * @param {SliderModel} oldProp - Specifies the old properties
3269
+ * @returns {void}
3270
+ * @private
3271
+ */
3272
+ public onPropertyChanged(newProp: SliderModel, oldProp: SliderModel): void {
3273
+ for (const prop of Object.keys(newProp)) {
3274
+ switch (prop) {
3275
+ case 'cssClass':
3276
+ this.setCSSClass(oldProp.cssClass);
3277
+ break;
3278
+ case 'value':
3279
+ if (newProp && oldProp) {
3280
+ const value: number | number[] = isNullOrUndefined(newProp.value) ?
3281
+ (this.type === 'Range' ? [this.min, this.max] : this.min) : newProp.value;
3282
+ this.setProperties({ 'value': value }, true);
3283
+ if (!isNullOrUndefined(oldProp.value) && oldProp.value.toString() !== value.toString()) {
3284
+ this.setValue();
3285
+ this.refreshTooltip(this.tooltipTarget);
3286
+ if (this.type === 'Range') {
3287
+ if (isNullOrUndefined(newProp.value) || (oldProp.value as number[])[1] === (value as number[])[1]) {
3288
+ this.activeHandle = 1;
3289
+ } else {
3290
+ this.activeHandle = 2;
3291
+ }
3292
+ }
3293
+ }
3294
+ }
3295
+ break;
3296
+ case 'min':
3297
+ case 'step':
3298
+ case 'max':
3299
+ this.setMinMaxValue();
3300
+ break;
3301
+ case 'tooltip':
3302
+ if (!isNullOrUndefined(newProp.tooltip) && !isNullOrUndefined(oldProp.tooltip)) {
3303
+ this.initialTooltip = true;
3304
+ this.setTooltip(prop);
3305
+ if (!this.showButtons) {
3306
+ this.wireEvents();
3307
+ }
3308
+ }
3309
+ break;
3310
+ case 'type':
3311
+ if (!isNullOrUndefined(oldProp) && Object.keys(oldProp).length
3312
+ && !isNullOrUndefined(oldProp.type)) {
3313
+ this.changeSliderType(oldProp.type, prop);
3314
+ this.setZindex();
3315
+ }
3316
+ break;
3317
+ case 'enableRtl':
3318
+ if (oldProp.enableRtl !== newProp.enableRtl && this.orientation !== 'Vertical') {
3319
+ this.rtl = oldProp.enableRtl;
3320
+ this.changeRtl();
3321
+ }
3322
+ break;
3323
+ case 'limits':
3324
+ this.limitsPropertyChange();
3325
+ break;
3326
+ case 'orientation':
3327
+ this.changeOrientation();
3328
+ break;
3329
+ case 'ticks':
3330
+
3331
+ if (!isNullOrUndefined(this.sliderContainer.querySelector('.' + classNames.scale))) {
3332
+ detach(this.ul);
3333
+ Array.prototype.forEach.call(this.sliderContainer.classList, (className: string) => {
3334
+ if (className.match(/e-scale-/)) {
3335
+ this.sliderContainer.classList.remove(className);
3336
+ }
3337
+ });
3338
+ }
3339
+ if (this.ticks.placement !== 'None') {
3340
+ this.renderScale();
3341
+ this.setZindex();
3342
+ }
3343
+ break;
3344
+ case 'locale':
3345
+ if (this.showButtons) {
3346
+ this.buttonTitle();
3347
+ }
3348
+ break;
3349
+ case 'showButtons':
3350
+ if (newProp.showButtons) {
3351
+ this.setButtons();
3352
+ this.reposition();
3353
+ if (this.enabled && !this.readonly) {
3354
+ this.wireButtonEvt(false);
3355
+ }
3356
+ } else {
3357
+ if (this.firstBtn && this.secondBtn) {
3358
+ this.sliderContainer.removeChild(this.firstBtn);
3359
+ this.sliderContainer.removeChild(this.secondBtn);
3360
+ this.sliderContainer.classList.remove(classNames.sliderButtonClass);
3361
+ this.firstBtn = undefined;
3362
+ this.secondBtn = undefined;
3363
+ this.reposition();
3364
+ }
3365
+ }
3366
+ break;
3367
+ case 'enabled':
3368
+ this.setEnabled();
3369
+ break;
3370
+ case 'readonly':
3371
+ this.setReadOnly();
3372
+ break;
3373
+ case 'customValues':
3374
+ this.setValue();
3375
+ this.reposition();
3376
+ break;
3377
+ case 'colorRange':
3378
+ this.reposition();
3379
+ break;
3380
+ case 'width':
3381
+ this.setElementWidth(newProp.width);
3382
+ this.setMinMaxValue();
3383
+ if (this.limits) {
3384
+ this.limitsPropertyChange();
3385
+ }
3386
+ break;
3387
+ }
3388
+ }
3389
+ }
3390
+
3391
+ private setReadOnly(): void {
3392
+ if (this.readonly) {
3393
+ this.unwireEvents();
3394
+ this.sliderContainer.classList.add(classNames.readonly);
3395
+ } else {
3396
+ this.wireEvents();
3397
+ this.sliderContainer.classList.remove(classNames.readonly);
3398
+ }
3399
+ }
3400
+
3401
+ private setMinMaxValue(): void {
3402
+ this.setValue();
3403
+ this.refreshTooltip(this.tooltipTarget);
3404
+ if (!isNullOrUndefined(this.sliderContainer.querySelector('.' + classNames.scale))) {
3405
+ if (this.ul) {
3406
+ detach(this.ul);
3407
+ Array.prototype.forEach.call(this.sliderContainer.classList, (className: string) => {
3408
+ if (className.match(/e-scale-/)) {
3409
+ this.sliderContainer.classList.remove(className);
3410
+ }
3411
+ });
3412
+ }
3413
+ }
3414
+ if (this.ticks.placement !== 'None') {
3415
+ this.renderScale();
3416
+ this.setZindex();
3417
+ }
3418
+ }
3419
+
3420
+ private setZindex(): void {
3421
+ this.zIndex = 6;
3422
+ if (!isNullOrUndefined(this.ticks) && this.ticks.placement !== 'None' && !isNullOrUndefined(this.ul) && !isNullOrUndefined(this.element)) {
3423
+ this.ul.style.zIndex = (this.zIndex + -7) + '';
3424
+ this.element.style.zIndex = (this.zIndex + 2) + '';
3425
+ }
3426
+ if (!this.isMaterial && !this.isMaterial3 && !isNullOrUndefined(this.ticks) && this.ticks.placement === 'Both') {
3427
+ this.element.style.zIndex = (this.zIndex + 2) + '';
3428
+ }
3429
+ if (!isNullOrUndefined(this.firstHandle)) {this.firstHandle.style.zIndex = (this.zIndex + 3) + ''; }
3430
+ if (this.type === 'Range' && !isNullOrUndefined(this.secondHandle)) {
3431
+ this.secondHandle.style.zIndex = (this.zIndex + 4) + '';
3432
+ }
3433
+ }
3434
+
3435
+ public setTooltip(args?: string): void {
3436
+ this.changeSliderType(this.type, args);
3437
+ }
3438
+ private setBarColor(): void {
3439
+ let trackPosition: number;
3440
+ let trackClassName: string;
3441
+ let child: Element = this.sliderTrack.lastElementChild;
3442
+ while (child) {
3443
+ this.sliderTrack.removeChild(child);
3444
+ child = this.sliderTrack.lastElementChild;
3445
+ }
3446
+ for (let i: number = 0; i < this.colorRange.length; i++) {
3447
+
3448
+ if (!isNullOrUndefined(this.colorRange[i as number].start) && !isNullOrUndefined(this.colorRange[i as number].end)) {
3449
+ if (this.colorRange[i as number].end > this.colorRange[i as number].start) {
3450
+ if (this.colorRange[i as number].start < this.min) {
3451
+ this.colorRange[i as number].start = this.min;
3452
+ }
3453
+ if (this.colorRange[i as number].end > this.max) {
3454
+ this.colorRange[i as number].end = this.max;
3455
+ }
3456
+ const startingPosition: number = this.checkHandlePosition(this.colorRange[i as number].start);
3457
+ const endPosition: number = this.checkHandlePosition(this.colorRange[i as number].end);
3458
+ const trackContainer: HTMLElement = this.createElement('div');
3459
+ trackContainer.style.backgroundColor = this.colorRange[i as number].color;
3460
+ trackContainer.style.border = '1px solid ' + this.colorRange[i as number].color;
3461
+ if (this.orientation === 'Horizontal') {
3462
+ trackClassName = classNames.sliderHorizantalColor;
3463
+ if (this.enableRtl) {
3464
+ if (isNullOrUndefined(this.customValues)) {
3465
+ trackPosition =
3466
+ this.checkHandlePosition(this.max) - this.checkHandlePosition(this.colorRange[i as number].end);
3467
+ } else {
3468
+ trackPosition = this.checkHandlePosition(this.customValues.length - this.colorRange[i as number].end - 1);
3469
+ }
3470
+ } else {
3471
+ trackPosition = this.checkHandlePosition(this.colorRange[i as number].start);
3472
+ }
3473
+ trackContainer.style.width = endPosition - startingPosition + 'px';
3474
+ trackContainer.style.left = trackPosition + 'px';
3475
+
3476
+ } else {
3477
+ trackClassName = classNames.sliderVerticalColor;
3478
+ trackPosition = this.checkHandlePosition(this.colorRange[i as number].start);
3479
+ trackContainer.style.height = endPosition - startingPosition + 'px';
3480
+ trackContainer.style.bottom = trackPosition + 'px';
3481
+ }
3482
+ trackContainer.classList.add(trackClassName);
3483
+ this.sliderTrack.appendChild(trackContainer);
3484
+ }
3485
+ }
3486
+ }
3487
+ }
3488
+ /**
3489
+ * Gets the component name
3490
+ *
3491
+ * @returns {string} - Returns the string
3492
+ * @private
3493
+ */
3494
+ public getModuleName(): string {
3495
+ return 'slider';
3496
+ }
3497
+ }