@materializecss/materialize 2.1.1 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -14
- package/dist/css/materialize.css +213 -103
- package/dist/css/materialize.min.css +2 -2
- package/dist/css/materialize.min.css.map +1 -1
- package/dist/js/materialize.cjs.js +1399 -1066
- package/dist/js/materialize.d.ts +738 -580
- package/dist/js/materialize.js +1399 -1066
- package/dist/js/materialize.min.js +2 -2
- package/dist/js/materialize.mjs +1400 -1065
- package/package.json +11 -8
- package/sass/components/_badges.scss +5 -0
- package/sass/components/_buttons.scss +44 -12
- package/sass/components/_cards.scss +18 -6
- package/sass/components/_chips.scss +9 -3
- package/sass/components/_collapsible.scss +12 -6
- package/sass/components/_datepicker.scss +6 -0
- package/sass/components/_modal.scss +32 -65
- package/sass/components/_tabs.scss +31 -5
- package/sass/components/_timepicker.scss +95 -23
- package/sass/components/forms/_input-fields.scss +53 -23
- package/dist/materialize-src-v2.1.1.zip +0 -0
- package/dist/materialize-v2.1.1.zip +0 -0
package/dist/js/materialize.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Materialize v2.
|
|
2
|
+
* Materialize v2.2.1 (https://materializeweb.com)
|
|
3
3
|
* Copyright 2014-2024 Materialize
|
|
4
4
|
* MIT License (https://raw.githubusercontent.com/materializecss/materialize/master/LICENSE)
|
|
5
5
|
*/
|
|
@@ -26,7 +26,7 @@ var M = (function (exports) {
|
|
|
26
26
|
ARROW_DOWN: ['ArrowDown', 'Down'],
|
|
27
27
|
ARROW_LEFT: ['ArrowLeft', 'Left'],
|
|
28
28
|
ARROW_RIGHT: ['ArrowRight', 'Right'],
|
|
29
|
-
DELETE: ['Delete', 'Del']
|
|
29
|
+
DELETE: ['Delete', 'Del']
|
|
30
30
|
};
|
|
31
31
|
/**
|
|
32
32
|
* Detects when a key is pressed.
|
|
@@ -52,6 +52,8 @@ var M = (function (exports) {
|
|
|
52
52
|
* Detects when document is focused.
|
|
53
53
|
* @param e Event instance.
|
|
54
54
|
*/
|
|
55
|
+
/* eslint-disabled as of required event type condition check */
|
|
56
|
+
/* eslint-disable-next-line */
|
|
55
57
|
static docHandleFocus(e) {
|
|
56
58
|
if (Utils.keyDown) {
|
|
57
59
|
document.body.classList.add('keyboard-focused');
|
|
@@ -61,6 +63,8 @@ var M = (function (exports) {
|
|
|
61
63
|
* Detects when document is not focused.
|
|
62
64
|
* @param e Event instance.
|
|
63
65
|
*/
|
|
66
|
+
/* eslint-disabled as of required event type condition check */
|
|
67
|
+
/* eslint-disable-next-line */
|
|
64
68
|
static docHandleBlur(e) {
|
|
65
69
|
document.body.classList.remove('keyboard-focused');
|
|
66
70
|
}
|
|
@@ -82,21 +86,21 @@ var M = (function (exports) {
|
|
|
82
86
|
* @param offset Element offset.
|
|
83
87
|
*/
|
|
84
88
|
static checkWithinContainer(container, bounding, offset) {
|
|
85
|
-
|
|
89
|
+
const edges = {
|
|
86
90
|
top: false,
|
|
87
91
|
right: false,
|
|
88
92
|
bottom: false,
|
|
89
93
|
left: false
|
|
90
94
|
};
|
|
91
|
-
|
|
95
|
+
const containerRect = container.getBoundingClientRect();
|
|
92
96
|
// If body element is smaller than viewport, use viewport height instead.
|
|
93
|
-
|
|
97
|
+
const containerBottom = container === document.body
|
|
94
98
|
? Math.max(containerRect.bottom, window.innerHeight)
|
|
95
99
|
: containerRect.bottom;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
+
const scrollLeft = container.scrollLeft;
|
|
101
|
+
const scrollTop = container.scrollTop;
|
|
102
|
+
const scrolledX = bounding.left - scrollLeft;
|
|
103
|
+
const scrolledY = bounding.top - scrollTop;
|
|
100
104
|
// Check for container and viewport for each edge
|
|
101
105
|
if (scrolledX < containerRect.left + offset || scrolledX < offset) {
|
|
102
106
|
edges.left = true;
|
|
@@ -122,7 +126,7 @@ var M = (function (exports) {
|
|
|
122
126
|
* @param offset Element offset.
|
|
123
127
|
*/
|
|
124
128
|
static checkPossibleAlignments(el, container, bounding, offset) {
|
|
125
|
-
|
|
129
|
+
const canAlign = {
|
|
126
130
|
top: true,
|
|
127
131
|
right: true,
|
|
128
132
|
bottom: true,
|
|
@@ -132,16 +136,16 @@ var M = (function (exports) {
|
|
|
132
136
|
spaceOnBottom: null,
|
|
133
137
|
spaceOnLeft: null
|
|
134
138
|
};
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
139
|
+
const containerAllowsOverflow = getComputedStyle(container).overflow === 'visible';
|
|
140
|
+
const containerRect = container.getBoundingClientRect();
|
|
141
|
+
const containerHeight = Math.min(containerRect.height, window.innerHeight);
|
|
142
|
+
const containerWidth = Math.min(containerRect.width, window.innerWidth);
|
|
143
|
+
const elOffsetRect = el.getBoundingClientRect();
|
|
144
|
+
const scrollLeft = container.scrollLeft;
|
|
145
|
+
const scrollTop = container.scrollTop;
|
|
146
|
+
const scrolledX = bounding.left - scrollLeft;
|
|
147
|
+
const scrolledYTopEdge = bounding.top - scrollTop;
|
|
148
|
+
const scrolledYBottomEdge = bounding.top + elOffsetRect.height - scrollTop;
|
|
145
149
|
// Check for container and viewport for left
|
|
146
150
|
canAlign.spaceOnRight = !containerAllowsOverflow
|
|
147
151
|
? containerWidth - (scrolledX + bounding.width)
|
|
@@ -190,7 +194,6 @@ var M = (function (exports) {
|
|
|
190
194
|
static getDocumentScrollTop() {
|
|
191
195
|
return window.scrollY || document.documentElement.scrollTop || document.body.scrollTop || 0;
|
|
192
196
|
}
|
|
193
|
-
;
|
|
194
197
|
/**
|
|
195
198
|
* Retrieves document scroll postion from left.
|
|
196
199
|
*/
|
|
@@ -203,24 +206,20 @@ var M = (function (exports) {
|
|
|
203
206
|
* @param wait Wait time.
|
|
204
207
|
* @param options Additional options.
|
|
205
208
|
*/
|
|
206
|
-
static throttle(func, wait, options =
|
|
207
|
-
let context, args, result;
|
|
208
|
-
|
|
209
|
-
let previous = 0;
|
|
210
|
-
options || (options = {});
|
|
211
|
-
let later = function () {
|
|
209
|
+
static throttle(func, wait, options = {}) {
|
|
210
|
+
let context, args, result, timeout = null, previous = 0;
|
|
211
|
+
const later = () => {
|
|
212
212
|
previous = options.leading === false ? 0 : new Date().getTime();
|
|
213
213
|
timeout = null;
|
|
214
214
|
result = func.apply(context, args);
|
|
215
215
|
context = args = null;
|
|
216
216
|
};
|
|
217
|
-
return
|
|
218
|
-
|
|
217
|
+
return (...args) => {
|
|
218
|
+
const now = new Date().getTime();
|
|
219
219
|
if (!previous && options.leading === false)
|
|
220
220
|
previous = now;
|
|
221
|
-
|
|
221
|
+
const remaining = wait - (now - previous);
|
|
222
222
|
context = this;
|
|
223
|
-
args = arguments;
|
|
224
223
|
if (remaining <= 0) {
|
|
225
224
|
clearTimeout(timeout);
|
|
226
225
|
timeout = null;
|
|
@@ -257,7 +256,7 @@ var M = (function (exports) {
|
|
|
257
256
|
console.error(Error(el + ' is not an HTML Element'));
|
|
258
257
|
}
|
|
259
258
|
// If exists, destroy and reinitialize in child
|
|
260
|
-
|
|
259
|
+
const ins = classDef.getInstance(el);
|
|
261
260
|
if (!!ins) {
|
|
262
261
|
ins.destroy();
|
|
263
262
|
}
|
|
@@ -285,21 +284,26 @@ var M = (function (exports) {
|
|
|
285
284
|
/**
|
|
286
285
|
* @returns default options for component instance.
|
|
287
286
|
*/
|
|
288
|
-
static get defaults() {
|
|
287
|
+
static get defaults() {
|
|
288
|
+
return {};
|
|
289
|
+
}
|
|
289
290
|
/**
|
|
290
291
|
* Retrieves component instance for the given element.
|
|
291
292
|
* @param el Associated HTML Element.
|
|
292
293
|
*/
|
|
294
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
293
295
|
static getInstance(el) {
|
|
294
|
-
throw new Error(
|
|
296
|
+
throw new Error('This method must be implemented.');
|
|
295
297
|
}
|
|
296
298
|
/**
|
|
297
299
|
* Destroy plugin instance and teardown.
|
|
298
300
|
*/
|
|
299
|
-
destroy() {
|
|
301
|
+
destroy() {
|
|
302
|
+
throw new Error('This method must be implemented.');
|
|
303
|
+
}
|
|
300
304
|
}
|
|
301
305
|
|
|
302
|
-
const _defaults$
|
|
306
|
+
const _defaults$m = {
|
|
303
307
|
alignment: 'left',
|
|
304
308
|
autoFocus: true,
|
|
305
309
|
constrainWidth: true,
|
|
@@ -332,7 +336,7 @@ var M = (function (exports) {
|
|
|
332
336
|
filterTimeout;
|
|
333
337
|
constructor(el, options) {
|
|
334
338
|
super(el, options, Dropdown);
|
|
335
|
-
this.el
|
|
339
|
+
this.el['M_Dropdown'] = this;
|
|
336
340
|
Dropdown._dropdowns.push(this);
|
|
337
341
|
this.id = Utils.getIdFromTrigger(el);
|
|
338
342
|
this.dropdownEl = document.getElementById(this.id);
|
|
@@ -345,13 +349,14 @@ var M = (function (exports) {
|
|
|
345
349
|
this.isTouchMoving = false;
|
|
346
350
|
this.focusedIndex = -1;
|
|
347
351
|
this.filterQuery = [];
|
|
352
|
+
this.el.ariaExpanded = 'false';
|
|
348
353
|
// Move dropdown-content after dropdown-trigger
|
|
349
354
|
this._moveDropdown();
|
|
350
355
|
this._makeDropdownFocusable();
|
|
351
356
|
this._setupEventHandlers();
|
|
352
357
|
}
|
|
353
358
|
static get defaults() {
|
|
354
|
-
return _defaults$
|
|
359
|
+
return _defaults$m;
|
|
355
360
|
}
|
|
356
361
|
/**
|
|
357
362
|
* Initializes instances of Dropdown.
|
|
@@ -362,13 +367,13 @@ var M = (function (exports) {
|
|
|
362
367
|
return super.init(els, options, Dropdown);
|
|
363
368
|
}
|
|
364
369
|
static getInstance(el) {
|
|
365
|
-
return el
|
|
370
|
+
return el['M_Dropdown'];
|
|
366
371
|
}
|
|
367
372
|
destroy() {
|
|
368
373
|
this._resetDropdownStyles();
|
|
369
374
|
this._removeEventHandlers();
|
|
370
375
|
Dropdown._dropdowns.splice(Dropdown._dropdowns.indexOf(this), 1);
|
|
371
|
-
this.el
|
|
376
|
+
this.el['M_Dropdown'] = undefined;
|
|
372
377
|
}
|
|
373
378
|
_setupEventHandlers() {
|
|
374
379
|
// Trigger keydown handler
|
|
@@ -412,6 +417,7 @@ var M = (function (exports) {
|
|
|
412
417
|
}
|
|
413
418
|
_handleClick = (e) => {
|
|
414
419
|
e.preventDefault();
|
|
420
|
+
this._moveDropdown(e.target.closest('li'));
|
|
415
421
|
if (this.isOpen) {
|
|
416
422
|
this.close();
|
|
417
423
|
}
|
|
@@ -419,7 +425,8 @@ var M = (function (exports) {
|
|
|
419
425
|
this.open();
|
|
420
426
|
}
|
|
421
427
|
};
|
|
422
|
-
_handleMouseEnter = () => {
|
|
428
|
+
_handleMouseEnter = (e) => {
|
|
429
|
+
this._moveDropdown(e.target.closest('li'));
|
|
423
430
|
this.open();
|
|
424
431
|
};
|
|
425
432
|
_handleMouseLeave = (e) => {
|
|
@@ -427,9 +434,7 @@ var M = (function (exports) {
|
|
|
427
434
|
const leaveToDropdownContent = !!toEl.closest('.dropdown-content');
|
|
428
435
|
let leaveToActiveDropdownTrigger = false;
|
|
429
436
|
const closestTrigger = toEl.closest('.dropdown-trigger');
|
|
430
|
-
if (closestTrigger &&
|
|
431
|
-
!!closestTrigger.M_Dropdown &&
|
|
432
|
-
closestTrigger.M_Dropdown.isOpen) {
|
|
437
|
+
if (closestTrigger && !!closestTrigger['M_Dropdown'] && closestTrigger['M_Dropdown'].isOpen) {
|
|
433
438
|
leaveToActiveDropdownTrigger = true;
|
|
434
439
|
}
|
|
435
440
|
// Close hover dropdown if mouse did not leave to either active dropdown-trigger or dropdown-content
|
|
@@ -439,9 +444,7 @@ var M = (function (exports) {
|
|
|
439
444
|
};
|
|
440
445
|
_handleDocumentClick = (e) => {
|
|
441
446
|
const target = e.target;
|
|
442
|
-
if (this.options.closeOnClick &&
|
|
443
|
-
target.closest('.dropdown-content') &&
|
|
444
|
-
!this.isTouchMoving) {
|
|
447
|
+
if (this.options.closeOnClick && target.closest('.dropdown-content') && !this.isTouchMoving) {
|
|
445
448
|
// isTouchMoving to check if scrolling on mobile.
|
|
446
449
|
this.close();
|
|
447
450
|
}
|
|
@@ -528,12 +531,17 @@ var M = (function (exports) {
|
|
|
528
531
|
// CASE WHEN USER TYPE LTTERS
|
|
529
532
|
const keyText = e.key.toLowerCase();
|
|
530
533
|
const isLetter = /[a-zA-Z0-9-_]/.test(keyText);
|
|
531
|
-
const specialKeys = [
|
|
534
|
+
const specialKeys = [
|
|
535
|
+
...Utils.keys.ARROW_DOWN,
|
|
536
|
+
...Utils.keys.ARROW_UP,
|
|
537
|
+
...Utils.keys.ENTER,
|
|
538
|
+
...Utils.keys.ESC,
|
|
539
|
+
...Utils.keys.TAB
|
|
540
|
+
];
|
|
532
541
|
if (isLetter && !specialKeys.includes(e.key)) {
|
|
533
542
|
this.filterQuery.push(keyText);
|
|
534
543
|
const string = this.filterQuery.join('');
|
|
535
|
-
const newOptionEl = Array.from(this.dropdownEl.querySelectorAll('li'))
|
|
536
|
-
.find((el) => el.innerText.toLowerCase().indexOf(string) === 0);
|
|
544
|
+
const newOptionEl = Array.from(this.dropdownEl.querySelectorAll('li')).find((el) => el.innerText.toLowerCase().indexOf(string) === 0);
|
|
537
545
|
if (newOptionEl) {
|
|
538
546
|
this.focusedIndex = [...newOptionEl.parentNode.children].indexOf(newOptionEl);
|
|
539
547
|
this._focusFocusedItem();
|
|
@@ -541,7 +549,7 @@ var M = (function (exports) {
|
|
|
541
549
|
}
|
|
542
550
|
this.filterTimeout = setTimeout(this._resetFilterQuery, 1000);
|
|
543
551
|
};
|
|
544
|
-
_handleWindowResize = (
|
|
552
|
+
_handleWindowResize = () => {
|
|
545
553
|
// Only re-place the dropdown if it's still visible
|
|
546
554
|
// Accounts for elements hiding via media queries
|
|
547
555
|
if (this.el.offsetParent) {
|
|
@@ -553,13 +561,16 @@ var M = (function (exports) {
|
|
|
553
561
|
};
|
|
554
562
|
_resetDropdownStyles() {
|
|
555
563
|
this.dropdownEl.style.display = '';
|
|
564
|
+
this._resetDropdownPositioningStyles();
|
|
565
|
+
this.dropdownEl.style.transform = '';
|
|
566
|
+
this.dropdownEl.style.opacity = '';
|
|
567
|
+
}
|
|
568
|
+
_resetDropdownPositioningStyles() {
|
|
556
569
|
this.dropdownEl.style.width = '';
|
|
557
570
|
this.dropdownEl.style.height = '';
|
|
558
571
|
this.dropdownEl.style.left = '';
|
|
559
572
|
this.dropdownEl.style.top = '';
|
|
560
573
|
this.dropdownEl.style.transformOrigin = '';
|
|
561
|
-
this.dropdownEl.style.transform = '';
|
|
562
|
-
this.dropdownEl.style.opacity = '';
|
|
563
574
|
}
|
|
564
575
|
// Move dropdown after container or trigger
|
|
565
576
|
_moveDropdown(containerEl = null) {
|
|
@@ -578,7 +589,7 @@ var M = (function (exports) {
|
|
|
578
589
|
_makeDropdownFocusable() {
|
|
579
590
|
if (!this.dropdownEl)
|
|
580
591
|
return;
|
|
581
|
-
this.dropdownEl.popover =
|
|
592
|
+
this.dropdownEl.popover = '';
|
|
582
593
|
// Needed for arrow key navigation
|
|
583
594
|
this.dropdownEl.tabIndex = 0;
|
|
584
595
|
// Only set tabindex if it hasn't been set by user
|
|
@@ -602,7 +613,7 @@ var M = (function (exports) {
|
|
|
602
613
|
}
|
|
603
614
|
}
|
|
604
615
|
_getDropdownPosition(closestOverflowParent) {
|
|
605
|
-
this.el.offsetParent.getBoundingClientRect();
|
|
616
|
+
// const offsetParentBRect = this.el.offsetParent.getBoundingClientRect();
|
|
606
617
|
const triggerBRect = this.el.getBoundingClientRect();
|
|
607
618
|
const dropdownBRect = this.dropdownEl.getBoundingClientRect();
|
|
608
619
|
let idealHeight = dropdownBRect.height;
|
|
@@ -686,7 +697,7 @@ var M = (function (exports) {
|
|
|
686
697
|
this.dropdownEl.style.opacity = '0';
|
|
687
698
|
this.dropdownEl.style.transform = 'scale(0.3, 0.3)';
|
|
688
699
|
setTimeout(() => {
|
|
689
|
-
// easeOutQuad (opacity) & easeOutQuint
|
|
700
|
+
// easeOutQuad (opacity) & easeOutQuint
|
|
690
701
|
this.dropdownEl.style.transition = `opacity ${duration}ms ease, transform ${duration}ms ease`;
|
|
691
702
|
// to
|
|
692
703
|
this.dropdownEl.style.opacity = '1';
|
|
@@ -701,7 +712,7 @@ var M = (function (exports) {
|
|
|
701
712
|
}
|
|
702
713
|
_animateOut() {
|
|
703
714
|
const duration = this.options.outDuration;
|
|
704
|
-
// easeOutQuad (opacity) & easeOutQuint
|
|
715
|
+
// easeOutQuad (opacity) & easeOutQuint
|
|
705
716
|
this.dropdownEl.style.transition = `opacity ${duration}ms ease, transform ${duration}ms ease`;
|
|
706
717
|
// to
|
|
707
718
|
this.dropdownEl.style.opacity = '0';
|
|
@@ -722,17 +733,15 @@ var M = (function (exports) {
|
|
|
722
733
|
}
|
|
723
734
|
return null;
|
|
724
735
|
}
|
|
725
|
-
;
|
|
726
736
|
_placeDropdown() {
|
|
727
737
|
// Container here will be closest ancestor with overflow: hidden
|
|
728
738
|
let closestOverflowParent = this._getClosestAncestor(this.dropdownEl, (ancestor) => {
|
|
729
|
-
return !['HTML', 'BODY'].includes(ancestor.tagName) &&
|
|
739
|
+
return (!['HTML', 'BODY'].includes(ancestor.tagName) &&
|
|
740
|
+
getComputedStyle(ancestor).overflow !== 'visible');
|
|
730
741
|
});
|
|
731
742
|
// Fallback
|
|
732
743
|
if (!closestOverflowParent) {
|
|
733
|
-
closestOverflowParent = (!!this.dropdownEl.offsetParent
|
|
734
|
-
? this.dropdownEl.offsetParent
|
|
735
|
-
: this.dropdownEl.parentNode);
|
|
744
|
+
closestOverflowParent = ((!!this.dropdownEl.offsetParent ? this.dropdownEl.offsetParent : this.dropdownEl.parentNode));
|
|
736
745
|
}
|
|
737
746
|
if (getComputedStyle(closestOverflowParent).position === 'static')
|
|
738
747
|
closestOverflowParent.style.position = 'relative';
|
|
@@ -768,6 +777,7 @@ var M = (function (exports) {
|
|
|
768
777
|
// Do this one frame later so that we don't bind an event handler that's immediately
|
|
769
778
|
// called when the event bubbles up to the document and closes the dropdown
|
|
770
779
|
setTimeout(() => this._setupTemporaryEventHandlers(), 0);
|
|
780
|
+
this.el.ariaExpanded = 'true';
|
|
771
781
|
};
|
|
772
782
|
/**
|
|
773
783
|
* Close dropdown.
|
|
@@ -786,23 +796,20 @@ var M = (function (exports) {
|
|
|
786
796
|
if (this.options.autoFocus) {
|
|
787
797
|
this.el.focus();
|
|
788
798
|
}
|
|
799
|
+
this.el.ariaExpanded = 'false';
|
|
789
800
|
};
|
|
790
801
|
/**
|
|
791
802
|
* While dropdown is open, you can recalculate its dimensions if its contents have changed.
|
|
792
803
|
*/
|
|
793
804
|
recalculateDimensions = () => {
|
|
794
805
|
if (this.isOpen) {
|
|
795
|
-
this.
|
|
796
|
-
this.dropdownEl.style.height = '';
|
|
797
|
-
this.dropdownEl.style.left = '';
|
|
798
|
-
this.dropdownEl.style.top = '';
|
|
799
|
-
this.dropdownEl.style.transformOrigin = '';
|
|
806
|
+
this._resetDropdownPositioningStyles();
|
|
800
807
|
this._placeDropdown();
|
|
801
808
|
}
|
|
802
809
|
};
|
|
803
810
|
}
|
|
804
811
|
|
|
805
|
-
|
|
812
|
+
const _defaults$l = {
|
|
806
813
|
data: [], // Autocomplete data set
|
|
807
814
|
onAutocomplete: null, // Callback for when autocompleted
|
|
808
815
|
dropdownOptions: {
|
|
@@ -815,8 +822,8 @@ var M = (function (exports) {
|
|
|
815
822
|
isMultiSelect: false,
|
|
816
823
|
onSearch: (text, autocomplete) => {
|
|
817
824
|
const normSearch = text.toLocaleLowerCase();
|
|
818
|
-
autocomplete.setMenuItems(autocomplete.options.data.filter((option) => option.id.toString().toLocaleLowerCase().includes(normSearch)
|
|
819
|
-
|
|
825
|
+
autocomplete.setMenuItems(autocomplete.options.data.filter((option) => option.id.toString().toLocaleLowerCase().includes(normSearch) ||
|
|
826
|
+
option.text?.toLocaleLowerCase().includes(normSearch)));
|
|
820
827
|
},
|
|
821
828
|
maxDropDownHeight: '300px',
|
|
822
829
|
allowUnsafeHTML: false
|
|
@@ -839,7 +846,7 @@ var M = (function (exports) {
|
|
|
839
846
|
menuItems;
|
|
840
847
|
constructor(el, options) {
|
|
841
848
|
super(el, options, Autocomplete);
|
|
842
|
-
this.el
|
|
849
|
+
this.el['M_Autocomplete'] = this;
|
|
843
850
|
this.options = {
|
|
844
851
|
...Autocomplete.defaults,
|
|
845
852
|
...options
|
|
@@ -847,7 +854,7 @@ var M = (function (exports) {
|
|
|
847
854
|
this.isOpen = false;
|
|
848
855
|
this.count = 0;
|
|
849
856
|
this.activeIndex = -1;
|
|
850
|
-
this.oldVal =
|
|
857
|
+
this.oldVal = '';
|
|
851
858
|
this.selectedValues = [];
|
|
852
859
|
this.menuItems = this.options.data || [];
|
|
853
860
|
this.$active = null;
|
|
@@ -856,7 +863,7 @@ var M = (function (exports) {
|
|
|
856
863
|
this._setupEventHandlers();
|
|
857
864
|
}
|
|
858
865
|
static get defaults() {
|
|
859
|
-
return _defaults$
|
|
866
|
+
return _defaults$l;
|
|
860
867
|
}
|
|
861
868
|
/**
|
|
862
869
|
* Initializes instances of Autocomplete.
|
|
@@ -867,17 +874,17 @@ var M = (function (exports) {
|
|
|
867
874
|
return super.init(els, options, Autocomplete);
|
|
868
875
|
}
|
|
869
876
|
static getInstance(el) {
|
|
870
|
-
return el
|
|
877
|
+
return el['M_Autocomplete'];
|
|
871
878
|
}
|
|
872
879
|
destroy() {
|
|
873
880
|
this._removeEventHandlers();
|
|
874
881
|
this._removeDropdown();
|
|
875
|
-
this.el
|
|
882
|
+
this.el['M_Autocomplete'] = undefined;
|
|
876
883
|
}
|
|
877
884
|
_setupEventHandlers() {
|
|
878
885
|
this.el.addEventListener('blur', this._handleInputBlur);
|
|
879
|
-
this.el.addEventListener('keyup', this.
|
|
880
|
-
this.el.addEventListener('focus', this.
|
|
886
|
+
this.el.addEventListener('keyup', this._handleInputKeyup);
|
|
887
|
+
this.el.addEventListener('focus', this._handleInputFocus);
|
|
881
888
|
this.el.addEventListener('keydown', this._handleInputKeydown);
|
|
882
889
|
this.el.addEventListener('click', this._handleInputClick);
|
|
883
890
|
this.container.addEventListener('mousedown', this._handleContainerMousedownAndTouchstart);
|
|
@@ -889,8 +896,8 @@ var M = (function (exports) {
|
|
|
889
896
|
}
|
|
890
897
|
_removeEventHandlers() {
|
|
891
898
|
this.el.removeEventListener('blur', this._handleInputBlur);
|
|
892
|
-
this.el.removeEventListener('keyup', this.
|
|
893
|
-
this.el.removeEventListener('focus', this.
|
|
899
|
+
this.el.removeEventListener('keyup', this._handleInputKeyup);
|
|
900
|
+
this.el.removeEventListener('focus', this._handleInputFocus);
|
|
894
901
|
this.el.removeEventListener('keydown', this._handleInputKeydown);
|
|
895
902
|
this.el.removeEventListener('click', this._handleInputClick);
|
|
896
903
|
this.container.removeEventListener('mousedown', this._handleContainerMousedownAndTouchstart);
|
|
@@ -906,18 +913,19 @@ var M = (function (exports) {
|
|
|
906
913
|
this.container.id = `autocomplete-options-${Utils.guid()}`;
|
|
907
914
|
this.container.classList.add('autocomplete-content', 'dropdown-content');
|
|
908
915
|
this.el.setAttribute('data-target', this.container.id);
|
|
909
|
-
this.menuItems.forEach(menuItem => {
|
|
916
|
+
this.menuItems.forEach((menuItem) => {
|
|
910
917
|
const itemElement = this._createDropdownItem(menuItem);
|
|
911
918
|
this.container.append(itemElement);
|
|
912
919
|
});
|
|
913
920
|
// ! Issue in Component Dropdown: _placeDropdown moves dom-position
|
|
914
921
|
this.el.parentElement.appendChild(this.container);
|
|
915
922
|
// Initialize dropdown
|
|
916
|
-
|
|
923
|
+
const dropdownOptions = {
|
|
917
924
|
...Autocomplete.defaults.dropdownOptions,
|
|
918
925
|
...this.options.dropdownOptions
|
|
919
926
|
};
|
|
920
|
-
|
|
927
|
+
// @todo shouldn't we conditionally check if dropdownOptions.onItemClick is set in first place?
|
|
928
|
+
const userOnItemClick = dropdownOptions.onItemClick;
|
|
921
929
|
// Ensuring the select Option call when user passes custom onItemClick function to dropdown
|
|
922
930
|
dropdownOptions.onItemClick = (li) => {
|
|
923
931
|
if (!li)
|
|
@@ -955,21 +963,31 @@ var M = (function (exports) {
|
|
|
955
963
|
this._resetAutocomplete();
|
|
956
964
|
}
|
|
957
965
|
};
|
|
958
|
-
|
|
966
|
+
_handleInputKeyup = (e) => {
|
|
959
967
|
if (e.type === 'keyup')
|
|
960
968
|
Autocomplete._keydown = false;
|
|
961
969
|
this.count = 0;
|
|
962
970
|
const actualValue = this.el.value.toLocaleLowerCase();
|
|
963
971
|
// Don't capture enter or arrow key usage.
|
|
964
|
-
if (Utils.keys.ENTER.includes(e.key) ||
|
|
972
|
+
if (Utils.keys.ENTER.includes(e.key) ||
|
|
973
|
+
Utils.keys.ARROW_UP.includes(e.key) ||
|
|
974
|
+
Utils.keys.ARROW_DOWN.includes(e.key))
|
|
965
975
|
return;
|
|
966
976
|
// Check if the input isn't empty
|
|
967
977
|
// Check if focus triggered by tab
|
|
968
|
-
if (this.oldVal !== actualValue &&
|
|
978
|
+
if (this.oldVal !== actualValue && Utils.tabPressed) {
|
|
969
979
|
this.open();
|
|
970
980
|
}
|
|
981
|
+
this._inputChangeDetection(actualValue);
|
|
982
|
+
};
|
|
983
|
+
_handleInputFocus = () => {
|
|
984
|
+
this.count = 0;
|
|
985
|
+
const actualValue = this.el.value.toLocaleLowerCase();
|
|
986
|
+
this._inputChangeDetection(actualValue);
|
|
987
|
+
};
|
|
988
|
+
_inputChangeDetection = (value) => {
|
|
971
989
|
// Value has changed!
|
|
972
|
-
if (this.oldVal !==
|
|
990
|
+
if (this.oldVal !== value) {
|
|
973
991
|
this._setStatusLoading();
|
|
974
992
|
this.options.onSearch(this.el.value, this);
|
|
975
993
|
}
|
|
@@ -978,7 +996,7 @@ var M = (function (exports) {
|
|
|
978
996
|
this.selectedValues = [];
|
|
979
997
|
this._triggerChanged();
|
|
980
998
|
}
|
|
981
|
-
this.oldVal =
|
|
999
|
+
this.oldVal = value;
|
|
982
1000
|
};
|
|
983
1001
|
_handleInputKeydown = (e) => {
|
|
984
1002
|
Autocomplete._keydown = true;
|
|
@@ -1084,7 +1102,8 @@ var M = (function (exports) {
|
|
|
1084
1102
|
item.appendChild(itemText);
|
|
1085
1103
|
item.querySelector('.item-text').appendChild(div);
|
|
1086
1104
|
// Description
|
|
1087
|
-
if (typeof entry.description === 'string' ||
|
|
1105
|
+
if (typeof entry.description === 'string' ||
|
|
1106
|
+
(typeof entry.description === 'number' && !isNaN(entry.description))) {
|
|
1088
1107
|
const description = document.createElement('small');
|
|
1089
1108
|
description.setAttribute('style', 'line-height:1.3;color:grey;white-space:nowrap;text-overflow:ellipsis;display:block;width:90%;overflow:hidden;');
|
|
1090
1109
|
description.innerText = entry.description;
|
|
@@ -1116,7 +1135,8 @@ var M = (function (exports) {
|
|
|
1116
1135
|
}
|
|
1117
1136
|
}
|
|
1118
1137
|
_setStatusLoading() {
|
|
1119
|
-
this.el.parentElement.querySelector('.status-info').innerHTML =
|
|
1138
|
+
this.el.parentElement.querySelector('.status-info').innerHTML =
|
|
1139
|
+
`<div style="height:100%;width:50px;"><svg version="1.1" id="L4" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 100 100" enable-background="new 0 0 0 0" xml:space="preserve">
|
|
1120
1140
|
<circle fill="#888c" stroke="none" cx="6" cy="50" r="6"><animate attributeName="opacity" dur="1s" values="0;1;0" repeatCount="indefinite" begin="0.1"/></circle>
|
|
1121
1141
|
<circle fill="#888c" stroke="none" cx="26" cy="50" r="6"><animate attributeName="opacity" dur="1s" values="0;1;0" repeatCount="indefinite" begin="0.2"/></circle>
|
|
1122
1142
|
<circle fill="#888c" stroke="none" cx="46" cy="50" r="6"><animate attributeName="opacity" dur="1s" values="0;1;0" repeatCount="indefinite" begin="0.3"/></circle>
|
|
@@ -1222,7 +1242,7 @@ var M = (function (exports) {
|
|
|
1222
1242
|
}
|
|
1223
1243
|
}
|
|
1224
1244
|
|
|
1225
|
-
|
|
1245
|
+
const _defaults$k = {
|
|
1226
1246
|
direction: 'top',
|
|
1227
1247
|
hoverEnabled: true,
|
|
1228
1248
|
toolbarEnabled: false
|
|
@@ -1243,7 +1263,7 @@ var M = (function (exports) {
|
|
|
1243
1263
|
btnWidth;
|
|
1244
1264
|
constructor(el, options) {
|
|
1245
1265
|
super(el, options, FloatingActionButton);
|
|
1246
|
-
this.el
|
|
1266
|
+
this.el['M_FloatingActionButton'] = this;
|
|
1247
1267
|
this.options = {
|
|
1248
1268
|
...FloatingActionButton.defaults,
|
|
1249
1269
|
...options
|
|
@@ -1267,7 +1287,7 @@ var M = (function (exports) {
|
|
|
1267
1287
|
this._setupEventHandlers();
|
|
1268
1288
|
}
|
|
1269
1289
|
static get defaults() {
|
|
1270
|
-
return _defaults$
|
|
1290
|
+
return _defaults$k;
|
|
1271
1291
|
}
|
|
1272
1292
|
/**
|
|
1273
1293
|
* Initializes instances of FloatingActionButton.
|
|
@@ -1278,11 +1298,11 @@ var M = (function (exports) {
|
|
|
1278
1298
|
return super.init(els, options, FloatingActionButton);
|
|
1279
1299
|
}
|
|
1280
1300
|
static getInstance(el) {
|
|
1281
|
-
return el
|
|
1301
|
+
return el['M_FloatingActionButton'];
|
|
1282
1302
|
}
|
|
1283
1303
|
destroy() {
|
|
1284
1304
|
this._removeEventHandlers();
|
|
1285
|
-
this.el
|
|
1305
|
+
this.el['M_FloatingActionButton'] = undefined;
|
|
1286
1306
|
}
|
|
1287
1307
|
_setupEventHandlers() {
|
|
1288
1308
|
if (this.options.hoverEnabled && !this.options.toolbarEnabled) {
|
|
@@ -1313,7 +1333,7 @@ var M = (function (exports) {
|
|
|
1313
1333
|
_handleDocumentClick = (e) => {
|
|
1314
1334
|
const elem = e.target;
|
|
1315
1335
|
if (elem !== this._menu)
|
|
1316
|
-
this.close;
|
|
1336
|
+
this.close();
|
|
1317
1337
|
};
|
|
1318
1338
|
/**
|
|
1319
1339
|
* Open FAB.
|
|
@@ -1375,17 +1395,15 @@ var M = (function (exports) {
|
|
|
1375
1395
|
});
|
|
1376
1396
|
}
|
|
1377
1397
|
_animateInToolbar() {
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
const backdrop = document.createElement('div');
|
|
1398
|
+
const windowWidth = window.innerWidth;
|
|
1399
|
+
const windowHeight = window.innerHeight;
|
|
1400
|
+
const btnRect = this.el.getBoundingClientRect();
|
|
1401
|
+
const backdrop = document.createElement('div'), scaleFactor = windowWidth / backdrop[0].clientWidth, fabColor = getComputedStyle(this._anchor).backgroundColor; // css('background-color');
|
|
1383
1402
|
backdrop.classList.add('fab-backdrop'); // $('<div class="fab-backdrop"></div>');
|
|
1384
|
-
|
|
1403
|
+
backdrop.style.backgroundColor = fabColor;
|
|
1385
1404
|
this._anchor.append(backdrop);
|
|
1386
1405
|
this.offsetX = btnRect.left - windowWidth / 2 + btnRect.width / 2;
|
|
1387
1406
|
this.offsetY = windowHeight - btnRect.bottom;
|
|
1388
|
-
scaleFactor = windowWidth / backdrop[0].clientWidth;
|
|
1389
1407
|
this.btnBottom = btnRect.bottom;
|
|
1390
1408
|
this.btnLeft = btnRect.left;
|
|
1391
1409
|
this.btnWidth = btnRect.width;
|
|
@@ -1399,10 +1417,10 @@ var M = (function (exports) {
|
|
|
1399
1417
|
this.el.style.transition = 'none';
|
|
1400
1418
|
this._anchor.style.transform = `translateY(${this.offsetY}px`;
|
|
1401
1419
|
this._anchor.style.transition = 'none';
|
|
1402
|
-
backdrop.style.backgroundColor = fabColor;
|
|
1403
1420
|
setTimeout(() => {
|
|
1404
1421
|
this.el.style.transform = '';
|
|
1405
|
-
this.el.style.transition =
|
|
1422
|
+
this.el.style.transition =
|
|
1423
|
+
'transform .2s cubic-bezier(0.550, 0.085, 0.680, 0.530), background-color 0s linear .2s';
|
|
1406
1424
|
this._anchor.style.overflow = 'visible';
|
|
1407
1425
|
this._anchor.style.transform = '';
|
|
1408
1426
|
this._anchor.style.transition = 'transform .2s';
|
|
@@ -1411,7 +1429,9 @@ var M = (function (exports) {
|
|
|
1411
1429
|
this.el.style.backgroundColor = fabColor;
|
|
1412
1430
|
backdrop.style.transform = 'scale(' + scaleFactor + ')';
|
|
1413
1431
|
backdrop.style.transition = 'transform .2s cubic-bezier(0.550, 0.055, 0.675, 0.190)';
|
|
1414
|
-
this._menu
|
|
1432
|
+
this._menu
|
|
1433
|
+
.querySelectorAll('li > a')
|
|
1434
|
+
.forEach((a) => (a.style.opacity = '1'));
|
|
1415
1435
|
// Scroll to close.
|
|
1416
1436
|
window.addEventListener('scroll', this.close, true);
|
|
1417
1437
|
document.body.addEventListener('click', this._handleDocumentClick, true);
|
|
@@ -1420,49 +1440,143 @@ var M = (function (exports) {
|
|
|
1420
1440
|
}
|
|
1421
1441
|
}
|
|
1422
1442
|
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
activators.forEach(activator => {
|
|
1450
|
-
if (trigger === activator || activator.contains(trigger)) {
|
|
1451
|
-
card.style.overflow = 'hidden';
|
|
1452
|
-
cardReveal.style.display = 'block';
|
|
1453
|
-
setTimeout(() => {
|
|
1454
|
-
const duration = 300;
|
|
1455
|
-
cardReveal.style.transition = `transform ${duration}ms ease`; //easeInOutQuad
|
|
1456
|
-
cardReveal.style.transform = 'translateY(-100%)';
|
|
1457
|
-
}, 1);
|
|
1458
|
-
}
|
|
1459
|
-
});
|
|
1460
|
-
});
|
|
1443
|
+
const _defaults$j = {
|
|
1444
|
+
onOpen: null,
|
|
1445
|
+
onClose: null,
|
|
1446
|
+
inDuration: 225,
|
|
1447
|
+
outDuration: 300
|
|
1448
|
+
};
|
|
1449
|
+
class Cards extends Component {
|
|
1450
|
+
isOpen = false;
|
|
1451
|
+
cardReveal;
|
|
1452
|
+
initialOverflow;
|
|
1453
|
+
_activators;
|
|
1454
|
+
cardRevealClose;
|
|
1455
|
+
constructor(el, options) {
|
|
1456
|
+
super(el, options, Cards);
|
|
1457
|
+
this.el['M_Cards'] = this;
|
|
1458
|
+
this.options = {
|
|
1459
|
+
...Cards.defaults,
|
|
1460
|
+
...options
|
|
1461
|
+
};
|
|
1462
|
+
this.cardReveal = this.el.querySelector('.card-reveal');
|
|
1463
|
+
if (this.cardReveal) {
|
|
1464
|
+
this.initialOverflow = getComputedStyle(this.el).overflow;
|
|
1465
|
+
this._activators = Array.from(this.el.querySelectorAll('.activator'));
|
|
1466
|
+
this._activators.forEach((el) => {
|
|
1467
|
+
if (el)
|
|
1468
|
+
el.tabIndex = 0;
|
|
1461
1469
|
});
|
|
1470
|
+
this.cardRevealClose = this.cardReveal?.querySelector('.card-title');
|
|
1471
|
+
if (this.cardRevealClose)
|
|
1472
|
+
this.cardRevealClose.tabIndex = -1;
|
|
1473
|
+
this.cardReveal.ariaExpanded = 'false';
|
|
1474
|
+
this._setupEventHandlers();
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
static get defaults() {
|
|
1478
|
+
return _defaults$j;
|
|
1479
|
+
}
|
|
1480
|
+
/**
|
|
1481
|
+
* Initializes instances of Cards.
|
|
1482
|
+
* @param els HTML elements.
|
|
1483
|
+
* @param options Component options.
|
|
1484
|
+
*/
|
|
1485
|
+
static init(els, options) {
|
|
1486
|
+
return super.init(els, options, Cards);
|
|
1487
|
+
}
|
|
1488
|
+
static getInstance(el) {
|
|
1489
|
+
return el['M_Cards'];
|
|
1462
1490
|
}
|
|
1491
|
+
/**
|
|
1492
|
+
* {@inheritDoc}
|
|
1493
|
+
*/
|
|
1494
|
+
destroy() {
|
|
1495
|
+
this._removeEventHandlers();
|
|
1496
|
+
this._activators = [];
|
|
1497
|
+
}
|
|
1498
|
+
_setupEventHandlers = () => {
|
|
1499
|
+
this._activators.forEach((el) => {
|
|
1500
|
+
el.addEventListener('click', this._handleClickInteraction);
|
|
1501
|
+
el.addEventListener('keypress', this._handleKeypressEvent);
|
|
1502
|
+
});
|
|
1503
|
+
};
|
|
1504
|
+
_removeEventHandlers = () => {
|
|
1505
|
+
this._activators.forEach((el) => {
|
|
1506
|
+
el.removeEventListener('click', this._handleClickInteraction);
|
|
1507
|
+
el.removeEventListener('keypress', this._handleKeypressEvent);
|
|
1508
|
+
});
|
|
1509
|
+
};
|
|
1510
|
+
_handleClickInteraction = () => {
|
|
1511
|
+
this._handleRevealEvent();
|
|
1512
|
+
};
|
|
1513
|
+
_handleKeypressEvent = (e) => {
|
|
1514
|
+
if (Utils.keys.ENTER.includes(e.key)) {
|
|
1515
|
+
this._handleRevealEvent();
|
|
1516
|
+
}
|
|
1517
|
+
};
|
|
1518
|
+
_handleRevealEvent = () => {
|
|
1519
|
+
// Reveal Card
|
|
1520
|
+
this._activators.forEach((el) => (el.tabIndex = -1));
|
|
1521
|
+
this.open();
|
|
1522
|
+
};
|
|
1523
|
+
_setupRevealCloseEventHandlers = () => {
|
|
1524
|
+
this.cardRevealClose.addEventListener('click', this.close);
|
|
1525
|
+
this.cardRevealClose.addEventListener('keypress', this._handleKeypressCloseEvent);
|
|
1526
|
+
};
|
|
1527
|
+
_removeRevealCloseEventHandlers = () => {
|
|
1528
|
+
this.cardRevealClose.addEventListener('click', this.close);
|
|
1529
|
+
this.cardRevealClose.addEventListener('keypress', this._handleKeypressCloseEvent);
|
|
1530
|
+
};
|
|
1531
|
+
_handleKeypressCloseEvent = (e) => {
|
|
1532
|
+
if (Utils.keys.ENTER.includes(e.key)) {
|
|
1533
|
+
this.close();
|
|
1534
|
+
}
|
|
1535
|
+
};
|
|
1536
|
+
/**
|
|
1537
|
+
* Show card reveal.
|
|
1538
|
+
*/
|
|
1539
|
+
open = () => {
|
|
1540
|
+
if (this.isOpen)
|
|
1541
|
+
return;
|
|
1542
|
+
this.isOpen = true;
|
|
1543
|
+
this.el.style.overflow = 'hidden';
|
|
1544
|
+
this.cardReveal.style.display = 'block';
|
|
1545
|
+
this.cardReveal.ariaExpanded = 'true';
|
|
1546
|
+
this.cardRevealClose.tabIndex = 0;
|
|
1547
|
+
setTimeout(() => {
|
|
1548
|
+
this.cardReveal.style.transition = `transform ${this.options.outDuration}ms ease`; //easeInOutQuad
|
|
1549
|
+
this.cardReveal.style.transform = 'translateY(-100%)';
|
|
1550
|
+
}, 1);
|
|
1551
|
+
if (typeof this.options.onOpen === 'function') {
|
|
1552
|
+
this.options.onOpen.call(this);
|
|
1553
|
+
}
|
|
1554
|
+
this._setupRevealCloseEventHandlers();
|
|
1555
|
+
};
|
|
1556
|
+
/**
|
|
1557
|
+
* Hide card reveal.
|
|
1558
|
+
*/
|
|
1559
|
+
close = () => {
|
|
1560
|
+
if (!this.isOpen)
|
|
1561
|
+
return;
|
|
1562
|
+
this.isOpen = false;
|
|
1563
|
+
this.cardReveal.style.transition = `transform ${this.options.inDuration}ms ease`; //easeInOutQuad
|
|
1564
|
+
this.cardReveal.style.transform = 'translateY(0)';
|
|
1565
|
+
setTimeout(() => {
|
|
1566
|
+
this.cardReveal.style.display = 'none';
|
|
1567
|
+
this.cardReveal.ariaExpanded = 'false';
|
|
1568
|
+
this._activators.forEach((el) => (el.tabIndex = 0));
|
|
1569
|
+
this.cardRevealClose.tabIndex = -1;
|
|
1570
|
+
this.el.style.overflow = this.initialOverflow;
|
|
1571
|
+
}, this.options.inDuration);
|
|
1572
|
+
if (typeof this.options.onClose === 'function') {
|
|
1573
|
+
this.options.onClose.call(this);
|
|
1574
|
+
}
|
|
1575
|
+
this._removeRevealCloseEventHandlers();
|
|
1576
|
+
};
|
|
1463
1577
|
}
|
|
1464
1578
|
|
|
1465
|
-
|
|
1579
|
+
const _defaults$i = {
|
|
1466
1580
|
duration: 200, // ms
|
|
1467
1581
|
dist: -100, // zoom scale TODO: make this more intuitive as an option
|
|
1468
1582
|
shift: 0, // spacing for center image
|
|
@@ -1505,7 +1619,7 @@ var M = (function (exports) {
|
|
|
1505
1619
|
oneTimeCallback;
|
|
1506
1620
|
constructor(el, options) {
|
|
1507
1621
|
super(el, options, Carousel);
|
|
1508
|
-
this.el
|
|
1622
|
+
this.el['M_Carousel'] = this;
|
|
1509
1623
|
this.options = {
|
|
1510
1624
|
...Carousel.defaults,
|
|
1511
1625
|
...options
|
|
@@ -1538,6 +1652,7 @@ var M = (function (exports) {
|
|
|
1538
1652
|
if (this.showIndicators) {
|
|
1539
1653
|
const indicator = document.createElement('li');
|
|
1540
1654
|
indicator.classList.add('indicator-item');
|
|
1655
|
+
indicator.tabIndex = 0;
|
|
1541
1656
|
if (i === 0) {
|
|
1542
1657
|
indicator.classList.add('active');
|
|
1543
1658
|
}
|
|
@@ -1552,7 +1667,7 @@ var M = (function (exports) {
|
|
|
1552
1667
|
// Setup cross browser string
|
|
1553
1668
|
this.xform = 'transform';
|
|
1554
1669
|
['webkit', 'Moz', 'O', 'ms'].every((prefix) => {
|
|
1555
|
-
|
|
1670
|
+
const e = prefix + 'Transform';
|
|
1556
1671
|
if (typeof document.body.style[e] !== 'undefined') {
|
|
1557
1672
|
this.xform = e;
|
|
1558
1673
|
return false;
|
|
@@ -1574,11 +1689,11 @@ var M = (function (exports) {
|
|
|
1574
1689
|
return super.init(els, options, Carousel);
|
|
1575
1690
|
}
|
|
1576
1691
|
static getInstance(el) {
|
|
1577
|
-
return el
|
|
1692
|
+
return el['M_Carousel'];
|
|
1578
1693
|
}
|
|
1579
1694
|
destroy() {
|
|
1580
1695
|
this._removeEventHandlers();
|
|
1581
|
-
this.el
|
|
1696
|
+
this.el['M_Carousel'] = undefined;
|
|
1582
1697
|
}
|
|
1583
1698
|
_setupEventHandlers() {
|
|
1584
1699
|
if (typeof window.ontouchstart !== 'undefined') {
|
|
@@ -1594,6 +1709,7 @@ var M = (function (exports) {
|
|
|
1594
1709
|
if (this.showIndicators && this._indicators) {
|
|
1595
1710
|
this._indicators.querySelectorAll('.indicator-item').forEach((el) => {
|
|
1596
1711
|
el.addEventListener('click', this._handleIndicatorClick);
|
|
1712
|
+
el.addEventListener('keypress', this._handleIndicatorKeyPress);
|
|
1597
1713
|
});
|
|
1598
1714
|
}
|
|
1599
1715
|
// Resize
|
|
@@ -1617,7 +1733,9 @@ var M = (function (exports) {
|
|
|
1617
1733
|
}
|
|
1618
1734
|
window.removeEventListener('resize', this._handleThrottledResize);
|
|
1619
1735
|
}
|
|
1620
|
-
_handleThrottledResize = Utils.throttle(function () {
|
|
1736
|
+
_handleThrottledResize = Utils.throttle(function () {
|
|
1737
|
+
this._handleResize();
|
|
1738
|
+
}, 200, null).bind(this);
|
|
1621
1739
|
_handleCarouselTap = (e) => {
|
|
1622
1740
|
// Fixes firefox draggable image bug
|
|
1623
1741
|
if (e.type === 'mousedown' && e.target.tagName === 'IMG') {
|
|
@@ -1720,7 +1838,8 @@ var M = (function (exports) {
|
|
|
1720
1838
|
// fixes https://github.com/materializecss/materialize/issues/180
|
|
1721
1839
|
if (clickedIndex < 0) {
|
|
1722
1840
|
// relative X position > center of carousel = clicked at the right part of the carousel
|
|
1723
|
-
if (e.clientX - e.target.getBoundingClientRect().left >
|
|
1841
|
+
if (e.clientX - e.target.getBoundingClientRect().left >
|
|
1842
|
+
this.el.clientWidth / 2) {
|
|
1724
1843
|
this.next();
|
|
1725
1844
|
}
|
|
1726
1845
|
else {
|
|
@@ -1734,6 +1853,15 @@ var M = (function (exports) {
|
|
|
1734
1853
|
};
|
|
1735
1854
|
_handleIndicatorClick = (e) => {
|
|
1736
1855
|
e.stopPropagation();
|
|
1856
|
+
this._handleIndicatorInteraction(e);
|
|
1857
|
+
};
|
|
1858
|
+
_handleIndicatorKeyPress = (e) => {
|
|
1859
|
+
e.stopPropagation();
|
|
1860
|
+
if (Utils.keys.ENTER.includes(e.key)) {
|
|
1861
|
+
this._handleIndicatorInteraction(e);
|
|
1862
|
+
}
|
|
1863
|
+
};
|
|
1864
|
+
_handleIndicatorInteraction = (e) => {
|
|
1737
1865
|
const indicator = e.target.closest('.indicator-item');
|
|
1738
1866
|
if (indicator) {
|
|
1739
1867
|
const index = [...indicator.parentNode.children].indexOf(indicator);
|
|
@@ -1787,7 +1915,7 @@ var M = (function (exports) {
|
|
|
1787
1915
|
}
|
|
1788
1916
|
_xpos(e) {
|
|
1789
1917
|
// touch event
|
|
1790
|
-
if (e.type.startsWith(
|
|
1918
|
+
if (e.type.startsWith('touch') && e.targetTouches.length >= 1) {
|
|
1791
1919
|
return e.targetTouches[0].clientX;
|
|
1792
1920
|
}
|
|
1793
1921
|
// mouse event
|
|
@@ -1795,27 +1923,23 @@ var M = (function (exports) {
|
|
|
1795
1923
|
}
|
|
1796
1924
|
_ypos(e) {
|
|
1797
1925
|
// touch event
|
|
1798
|
-
if (e.type.startsWith(
|
|
1926
|
+
if (e.type.startsWith('touch') && e.targetTouches.length >= 1) {
|
|
1799
1927
|
return e.targetTouches[0].clientY;
|
|
1800
1928
|
}
|
|
1801
1929
|
// mouse event
|
|
1802
1930
|
return e.clientY;
|
|
1803
1931
|
}
|
|
1804
1932
|
_wrap(x) {
|
|
1805
|
-
return x >= this.count
|
|
1806
|
-
? x % this.count
|
|
1807
|
-
: x < 0
|
|
1808
|
-
? this._wrap(this.count + (x % this.count))
|
|
1809
|
-
: x;
|
|
1933
|
+
return x >= this.count ? x % this.count : x < 0 ? this._wrap(this.count + (x % this.count)) : x;
|
|
1810
1934
|
}
|
|
1811
1935
|
_track = () => {
|
|
1812
|
-
|
|
1813
|
-
now = Date.now();
|
|
1814
|
-
elapsed = now - this.timestamp;
|
|
1936
|
+
const now = Date.now(), elapsed = now - this.timestamp, delta = this.offset - this.frame, v = (1000 * delta) / (1 + elapsed);
|
|
1937
|
+
// now = Date.now();
|
|
1938
|
+
// elapsed = now - this.timestamp;
|
|
1815
1939
|
this.timestamp = now;
|
|
1816
|
-
delta = this.offset - this.frame;
|
|
1940
|
+
// delta = this.offset - this.frame;
|
|
1817
1941
|
this.frame = this.offset;
|
|
1818
|
-
v = (1000 * delta) / (1 + elapsed);
|
|
1942
|
+
// v = (1000 * delta) / (1 + elapsed);
|
|
1819
1943
|
this.velocity = 0.8 * v + 0.2 * this.velocity;
|
|
1820
1944
|
};
|
|
1821
1945
|
_autoScroll = () => {
|
|
@@ -1838,21 +1962,22 @@ var M = (function (exports) {
|
|
|
1838
1962
|
this.el.classList.add('scrolling');
|
|
1839
1963
|
}
|
|
1840
1964
|
if (this.scrollingTimeout != null) {
|
|
1841
|
-
|
|
1965
|
+
clearTimeout(this.scrollingTimeout);
|
|
1842
1966
|
}
|
|
1843
|
-
this.scrollingTimeout =
|
|
1967
|
+
this.scrollingTimeout = setTimeout(() => {
|
|
1844
1968
|
this.el.classList.remove('scrolling');
|
|
1845
1969
|
}, this.options.duration);
|
|
1846
1970
|
// Start actual scroll
|
|
1847
|
-
let i, half, delta, dir, tween, el, alignment, zTranslation, tweenedOpacity, centerTweenedOpacity;
|
|
1848
|
-
let lastCenter = this.center;
|
|
1849
|
-
let numVisibleOffset = 1 / this.options.numVisible;
|
|
1850
1971
|
this.offset = typeof x === 'number' ? x : this.offset;
|
|
1851
1972
|
this.center = Math.floor((this.offset + this.dim / 2) / this.dim);
|
|
1852
|
-
delta = this.offset - this.center * this.dim;
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1973
|
+
const half = this.count >> 1, delta = this.offset - this.center * this.dim, dir = delta < 0 ? 1 : -1, tween = (-dir * delta * 2) / this.dim;
|
|
1974
|
+
let i, el, alignment, zTranslation, tweenedOpacity, centerTweenedOpacity;
|
|
1975
|
+
const lastCenter = this.center;
|
|
1976
|
+
const numVisibleOffset = 1 / this.options.numVisible;
|
|
1977
|
+
// delta = this.offset - this.center * this.dim;
|
|
1978
|
+
// dir = delta < 0 ? 1 : -1;
|
|
1979
|
+
// tween = (-dir * delta * 2) / this.dim;
|
|
1980
|
+
// half = this.count >> 1;
|
|
1856
1981
|
if (this.options.fullWidth) {
|
|
1857
1982
|
alignment = 'translateX(0)';
|
|
1858
1983
|
centerTweenedOpacity = 1;
|
|
@@ -1882,10 +2007,7 @@ var M = (function (exports) {
|
|
|
1882
2007
|
this.el.querySelector('.carousel-item').classList.remove('active');
|
|
1883
2008
|
el.classList.add('active');
|
|
1884
2009
|
}
|
|
1885
|
-
|
|
1886
|
-
this.options.shift *
|
|
1887
|
-
tween *
|
|
1888
|
-
i}px) translateZ(${this.options.dist * tween}px)`;
|
|
2010
|
+
const transformString = `${alignment} translateX(${-delta / 2}px) translateX(${dir * this.options.shift * tween * i}px) translateZ(${this.options.dist * tween}px)`;
|
|
1889
2011
|
this._updateItemStyle(el, centerTweenedOpacity, 0, transformString);
|
|
1890
2012
|
}
|
|
1891
2013
|
for (i = 1; i <= half; ++i) {
|
|
@@ -1901,8 +2023,7 @@ var M = (function (exports) {
|
|
|
1901
2023
|
// Don't show wrapped items.
|
|
1902
2024
|
if (!this.noWrap || this.center + i < this.count) {
|
|
1903
2025
|
el = this.images[this._wrap(this.center + i)];
|
|
1904
|
-
|
|
1905
|
-
(this.dim * i - delta) / 2}px) translateZ(${zTranslation}px)`;
|
|
2026
|
+
const transformString = `${alignment} translateX(${this.options.shift + (this.dim * i - delta) / 2}px) translateZ(${zTranslation}px)`;
|
|
1906
2027
|
this._updateItemStyle(el, tweenedOpacity, -i, transformString);
|
|
1907
2028
|
}
|
|
1908
2029
|
// left side
|
|
@@ -1917,8 +2038,7 @@ var M = (function (exports) {
|
|
|
1917
2038
|
// Don't show wrapped items.
|
|
1918
2039
|
if (!this.noWrap || this.center - i >= 0) {
|
|
1919
2040
|
el = this.images[this._wrap(this.center - i)];
|
|
1920
|
-
|
|
1921
|
-
(-this.dim * i - delta) / 2}px) translateZ(${zTranslation}px)`;
|
|
2041
|
+
const transformString = `${alignment} translateX(${-this.options.shift + (-this.dim * i - delta) / 2}px) translateZ(${zTranslation}px)`;
|
|
1922
2042
|
this._updateItemStyle(el, tweenedOpacity, -i, transformString);
|
|
1923
2043
|
}
|
|
1924
2044
|
}
|
|
@@ -1926,9 +2046,7 @@ var M = (function (exports) {
|
|
|
1926
2046
|
// Don't show wrapped items.
|
|
1927
2047
|
if (!this.noWrap || (this.center >= 0 && this.center < this.count)) {
|
|
1928
2048
|
el = this.images[this._wrap(this.center)];
|
|
1929
|
-
|
|
1930
|
-
this.options.shift *
|
|
1931
|
-
tween}px) translateZ(${this.options.dist * tween}px)`;
|
|
2049
|
+
const transformString = `${alignment} translateX(${-delta / 2}px) translateX(${dir * this.options.shift * tween}px) translateZ(${this.options.dist * tween}px)`;
|
|
1932
2050
|
this._updateItemStyle(el, centerTweenedOpacity, 0, transformString);
|
|
1933
2051
|
}
|
|
1934
2052
|
// onCycleTo callback
|
|
@@ -2032,7 +2150,7 @@ var M = (function (exports) {
|
|
|
2032
2150
|
}
|
|
2033
2151
|
}
|
|
2034
2152
|
|
|
2035
|
-
|
|
2153
|
+
const _defaults$h = {
|
|
2036
2154
|
data: [],
|
|
2037
2155
|
placeholder: '',
|
|
2038
2156
|
secondaryPlaceholder: '',
|
|
@@ -2040,6 +2158,7 @@ var M = (function (exports) {
|
|
|
2040
2158
|
autocompleteOptions: {},
|
|
2041
2159
|
autocompleteOnly: false,
|
|
2042
2160
|
limit: Infinity,
|
|
2161
|
+
allowUserInput: false,
|
|
2043
2162
|
onChipAdd: null,
|
|
2044
2163
|
onChipSelect: null,
|
|
2045
2164
|
onChipDelete: null
|
|
@@ -2061,30 +2180,28 @@ var M = (function (exports) {
|
|
|
2061
2180
|
_selectedChip;
|
|
2062
2181
|
constructor(el, options) {
|
|
2063
2182
|
super(el, options, Chips);
|
|
2064
|
-
this.el
|
|
2183
|
+
this.el['M_Chips'] = this;
|
|
2065
2184
|
this.options = {
|
|
2066
2185
|
...Chips.defaults,
|
|
2067
2186
|
...options
|
|
2068
2187
|
};
|
|
2069
|
-
this.el.classList.add('chips'
|
|
2188
|
+
this.el.classList.add('chips');
|
|
2070
2189
|
this.chipsData = [];
|
|
2071
2190
|
this._chips = [];
|
|
2072
|
-
this._setupInput();
|
|
2073
|
-
this.hasAutocomplete = Object.keys(this.options.autocompleteOptions).length > 0;
|
|
2074
|
-
// Set input id
|
|
2075
|
-
if (!this._input.getAttribute('id'))
|
|
2076
|
-
this._input.setAttribute('id', Utils.guid());
|
|
2077
2191
|
// Render initial chips
|
|
2078
2192
|
if (this.options.data.length) {
|
|
2079
2193
|
this.chipsData = this.options.data;
|
|
2080
2194
|
this._renderChips();
|
|
2081
2195
|
}
|
|
2082
|
-
// Setup autocomplete if needed
|
|
2083
|
-
if (this.hasAutocomplete)
|
|
2084
|
-
this._setupAutocomplete();
|
|
2085
|
-
this._setPlaceholder();
|
|
2086
2196
|
this._setupLabel();
|
|
2087
|
-
|
|
2197
|
+
// Render input element, setup event handlers
|
|
2198
|
+
if (this.options.allowUserInput) {
|
|
2199
|
+
this.el.classList.add('input-field');
|
|
2200
|
+
this._setupInput();
|
|
2201
|
+
this._setupEventHandlers();
|
|
2202
|
+
// move input to end
|
|
2203
|
+
this.el.append(this._input);
|
|
2204
|
+
}
|
|
2088
2205
|
}
|
|
2089
2206
|
static get defaults() {
|
|
2090
2207
|
return _defaults$h;
|
|
@@ -2098,19 +2215,22 @@ var M = (function (exports) {
|
|
|
2098
2215
|
return super.init(els, options, Chips);
|
|
2099
2216
|
}
|
|
2100
2217
|
static getInstance(el) {
|
|
2101
|
-
return el
|
|
2218
|
+
return el['M_Chips'];
|
|
2102
2219
|
}
|
|
2103
2220
|
getData() {
|
|
2104
2221
|
return this.chipsData;
|
|
2105
2222
|
}
|
|
2106
2223
|
destroy() {
|
|
2107
|
-
this.
|
|
2108
|
-
|
|
2224
|
+
if (this.options.allowUserInput) {
|
|
2225
|
+
this._removeEventHandlers();
|
|
2226
|
+
}
|
|
2227
|
+
this._chips.forEach((c) => c.remove());
|
|
2109
2228
|
this._chips = [];
|
|
2110
|
-
this.el
|
|
2229
|
+
this.el['M_Chips'] = undefined;
|
|
2111
2230
|
}
|
|
2112
2231
|
_setupEventHandlers() {
|
|
2113
2232
|
this.el.addEventListener('click', this._handleChipClick);
|
|
2233
|
+
// @todo why do we need this as document event listener, shouldn't we apply it to the element wrapper itself?
|
|
2114
2234
|
document.addEventListener('keydown', Chips._handleChipsKeydown);
|
|
2115
2235
|
document.addEventListener('keyup', Chips._handleChipsKeyup);
|
|
2116
2236
|
this.el.addEventListener('blur', Chips._handleChipsBlur, true);
|
|
@@ -2153,7 +2273,7 @@ var M = (function (exports) {
|
|
|
2153
2273
|
const tag = e.target.tagName;
|
|
2154
2274
|
if (tag === 'INPUT' || tag === 'TEXTAREA' || !chipsKeydown)
|
|
2155
2275
|
return;
|
|
2156
|
-
const currChips = chips
|
|
2276
|
+
const currChips = chips['M_Chips'];
|
|
2157
2277
|
if (Utils.keys.BACKSPACE.includes(e.key) || Utils.keys.DELETE.includes(e.key)) {
|
|
2158
2278
|
e.preventDefault();
|
|
2159
2279
|
let selectIndex = currChips.chipsData.length;
|
|
@@ -2187,13 +2307,13 @@ var M = (function (exports) {
|
|
|
2187
2307
|
}
|
|
2188
2308
|
}
|
|
2189
2309
|
}
|
|
2190
|
-
static _handleChipsKeyup(
|
|
2310
|
+
static _handleChipsKeyup() {
|
|
2191
2311
|
Chips._keydown = false;
|
|
2192
2312
|
}
|
|
2193
2313
|
static _handleChipsBlur(e) {
|
|
2194
2314
|
if (!Chips._keydown && document.hidden) {
|
|
2195
2315
|
const chips = e.target.closest('.chips');
|
|
2196
|
-
const currChips = chips
|
|
2316
|
+
const currChips = chips['M_Chips'];
|
|
2197
2317
|
currChips._selectedChip = null;
|
|
2198
2318
|
}
|
|
2199
2319
|
}
|
|
@@ -2229,17 +2349,19 @@ var M = (function (exports) {
|
|
|
2229
2349
|
const renderedChip = document.createElement('div');
|
|
2230
2350
|
renderedChip.classList.add('chip');
|
|
2231
2351
|
renderedChip.innerText = chip.text || chip.id;
|
|
2232
|
-
renderedChip.setAttribute('tabindex', "0");
|
|
2233
|
-
const closeIcon = document.createElement('i');
|
|
2234
|
-
closeIcon.classList.add(this.options.closeIconClass, 'close');
|
|
2235
|
-
closeIcon.innerText = 'close';
|
|
2236
2352
|
// attach image if needed
|
|
2237
2353
|
if (chip.image) {
|
|
2238
2354
|
const img = document.createElement('img');
|
|
2239
2355
|
img.setAttribute('src', chip.image);
|
|
2240
2356
|
renderedChip.insertBefore(img, renderedChip.firstChild);
|
|
2241
2357
|
}
|
|
2242
|
-
|
|
2358
|
+
if (this.options.allowUserInput) {
|
|
2359
|
+
renderedChip.setAttribute('tabindex', '0');
|
|
2360
|
+
const closeIcon = document.createElement('i');
|
|
2361
|
+
closeIcon.classList.add(this.options.closeIconClass, 'close');
|
|
2362
|
+
closeIcon.innerText = 'close';
|
|
2363
|
+
renderedChip.appendChild(closeIcon);
|
|
2364
|
+
}
|
|
2243
2365
|
return renderedChip;
|
|
2244
2366
|
}
|
|
2245
2367
|
_renderChips() {
|
|
@@ -2249,8 +2371,6 @@ var M = (function (exports) {
|
|
|
2249
2371
|
this.el.appendChild(chipElem);
|
|
2250
2372
|
this._chips.push(chipElem);
|
|
2251
2373
|
}
|
|
2252
|
-
// move input to end
|
|
2253
|
-
this.el.append(this._input);
|
|
2254
2374
|
}
|
|
2255
2375
|
_setupAutocomplete() {
|
|
2256
2376
|
this.options.autocompleteOptions.onAutocomplete = (items) => {
|
|
@@ -2272,6 +2392,14 @@ var M = (function (exports) {
|
|
|
2272
2392
|
this.el.append(this._input);
|
|
2273
2393
|
}
|
|
2274
2394
|
this._input.classList.add('input');
|
|
2395
|
+
this.hasAutocomplete = Object.keys(this.options.autocompleteOptions).length > 0;
|
|
2396
|
+
// Setup autocomplete if needed
|
|
2397
|
+
if (this.hasAutocomplete)
|
|
2398
|
+
this._setupAutocomplete();
|
|
2399
|
+
this._setPlaceholder();
|
|
2400
|
+
// Set input id
|
|
2401
|
+
if (!this._input.getAttribute('id'))
|
|
2402
|
+
this._input.setAttribute('id', Utils.guid());
|
|
2275
2403
|
}
|
|
2276
2404
|
_setupLabel() {
|
|
2277
2405
|
this._label = this.el.querySelector('label');
|
|
@@ -2289,7 +2417,7 @@ var M = (function (exports) {
|
|
|
2289
2417
|
}
|
|
2290
2418
|
_isValidAndNotExist(chip) {
|
|
2291
2419
|
const isValid = !!chip.id;
|
|
2292
|
-
const doesNotExist = !this.chipsData.some(item => item.id == chip.id);
|
|
2420
|
+
const doesNotExist = !this.chipsData.some((item) => item.id == chip.id);
|
|
2293
2421
|
return isValid && doesNotExist;
|
|
2294
2422
|
}
|
|
2295
2423
|
/**
|
|
@@ -2340,15 +2468,18 @@ var M = (function (exports) {
|
|
|
2340
2468
|
}
|
|
2341
2469
|
static Init() {
|
|
2342
2470
|
if (typeof document !== 'undefined')
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
document.
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2471
|
+
// Handle removal of static chips.
|
|
2472
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
2473
|
+
const chips = document.querySelectorAll('.chips');
|
|
2474
|
+
chips.forEach((el) => {
|
|
2475
|
+
// if (el && (el['M_Chips == undefined) return;
|
|
2476
|
+
el.addEventListener('click', (e) => {
|
|
2477
|
+
if (e.target.classList.contains('close')) {
|
|
2478
|
+
const chip = e.target.closest('.chip');
|
|
2479
|
+
if (chip)
|
|
2480
|
+
chip.remove();
|
|
2481
|
+
}
|
|
2482
|
+
});
|
|
2352
2483
|
});
|
|
2353
2484
|
});
|
|
2354
2485
|
}
|
|
@@ -2370,14 +2501,14 @@ var M = (function (exports) {
|
|
|
2370
2501
|
_headers;
|
|
2371
2502
|
constructor(el, options) {
|
|
2372
2503
|
super(el, options, Collapsible);
|
|
2373
|
-
this.el
|
|
2504
|
+
this.el['M_Collapsible'] = this;
|
|
2374
2505
|
this.options = {
|
|
2375
2506
|
...Collapsible.defaults,
|
|
2376
2507
|
...options
|
|
2377
2508
|
};
|
|
2378
2509
|
// Setup tab indices
|
|
2379
2510
|
this._headers = Array.from(this.el.querySelectorAll('li > .collapsible-header'));
|
|
2380
|
-
this._headers.forEach(el => el.tabIndex = 0);
|
|
2511
|
+
this._headers.forEach((el) => (el.tabIndex = 0));
|
|
2381
2512
|
this._setupEventHandlers();
|
|
2382
2513
|
// Open active
|
|
2383
2514
|
const activeBodies = Array.from(this.el.querySelectorAll('li.active > .collapsible-body'));
|
|
@@ -2389,7 +2520,7 @@ var M = (function (exports) {
|
|
|
2389
2520
|
}
|
|
2390
2521
|
else {
|
|
2391
2522
|
// Expandables => all active
|
|
2392
|
-
activeBodies.forEach(el => this._setExpanded(el));
|
|
2523
|
+
activeBodies.forEach((el) => this._setExpanded(el));
|
|
2393
2524
|
}
|
|
2394
2525
|
}
|
|
2395
2526
|
static get defaults() {
|
|
@@ -2404,19 +2535,19 @@ var M = (function (exports) {
|
|
|
2404
2535
|
return super.init(els, options, Collapsible);
|
|
2405
2536
|
}
|
|
2406
2537
|
static getInstance(el) {
|
|
2407
|
-
return el
|
|
2538
|
+
return el['M_Collapsible'];
|
|
2408
2539
|
}
|
|
2409
2540
|
destroy() {
|
|
2410
2541
|
this._removeEventHandlers();
|
|
2411
|
-
this.el
|
|
2542
|
+
this.el['M_Collapsible'] = undefined;
|
|
2412
2543
|
}
|
|
2413
2544
|
_setupEventHandlers() {
|
|
2414
2545
|
this.el.addEventListener('click', this._handleCollapsibleClick);
|
|
2415
|
-
this._headers.forEach(header => header.addEventListener('keydown', this._handleCollapsibleKeydown));
|
|
2546
|
+
this._headers.forEach((header) => header.addEventListener('keydown', this._handleCollapsibleKeydown));
|
|
2416
2547
|
}
|
|
2417
2548
|
_removeEventHandlers() {
|
|
2418
2549
|
this.el.removeEventListener('click', this._handleCollapsibleClick);
|
|
2419
|
-
this._headers.forEach(header => header.removeEventListener('keydown', this._handleCollapsibleKeydown));
|
|
2550
|
+
this._headers.forEach((header) => header.removeEventListener('keydown', this._handleCollapsibleKeydown));
|
|
2420
2551
|
}
|
|
2421
2552
|
_handleCollapsibleClick = (e) => {
|
|
2422
2553
|
const header = e.target.closest('.collapsible-header');
|
|
@@ -2439,7 +2570,7 @@ var M = (function (exports) {
|
|
|
2439
2570
|
}
|
|
2440
2571
|
};
|
|
2441
2572
|
_setExpanded(li) {
|
|
2442
|
-
li.style.maxHeight = li.scrollHeight +
|
|
2573
|
+
li.style.maxHeight = li.scrollHeight + 'px';
|
|
2443
2574
|
}
|
|
2444
2575
|
_animateIn(index) {
|
|
2445
2576
|
const li = this.el.children[index];
|
|
@@ -2462,7 +2593,7 @@ var M = (function (exports) {
|
|
|
2462
2593
|
const body = li.querySelector('.collapsible-body');
|
|
2463
2594
|
const duration = this.options.outDuration; // easeInOutCubic
|
|
2464
2595
|
body.style.transition = `max-height ${duration}ms ease-out`;
|
|
2465
|
-
body.style.maxHeight =
|
|
2596
|
+
body.style.maxHeight = '0';
|
|
2466
2597
|
setTimeout(() => {
|
|
2467
2598
|
if (typeof this.options.onCloseEnd === 'function') {
|
|
2468
2599
|
this.options.onCloseEnd.call(this, li);
|
|
@@ -2474,7 +2605,7 @@ var M = (function (exports) {
|
|
|
2474
2605
|
* @param n Nth section to open.
|
|
2475
2606
|
*/
|
|
2476
2607
|
open = (index) => {
|
|
2477
|
-
const listItems = Array.from(this.el.children).filter(c => c.tagName === 'LI');
|
|
2608
|
+
const listItems = Array.from(this.el.children).filter((c) => c.tagName === 'LI');
|
|
2478
2609
|
const li = listItems[index];
|
|
2479
2610
|
if (li && !li.classList.contains('active')) {
|
|
2480
2611
|
// onOpenStart callback
|
|
@@ -2483,8 +2614,8 @@ var M = (function (exports) {
|
|
|
2483
2614
|
}
|
|
2484
2615
|
// Handle accordion behavior
|
|
2485
2616
|
if (this.options.accordion) {
|
|
2486
|
-
const activeLis = listItems.filter(li => li.classList.contains('active'));
|
|
2487
|
-
activeLis.forEach(activeLi => {
|
|
2617
|
+
const activeLis = listItems.filter((li) => li.classList.contains('active'));
|
|
2618
|
+
activeLis.forEach((activeLi) => {
|
|
2488
2619
|
const index = listItems.indexOf(activeLi);
|
|
2489
2620
|
this.close(index);
|
|
2490
2621
|
});
|
|
@@ -2499,7 +2630,7 @@ var M = (function (exports) {
|
|
|
2499
2630
|
* @param n Nth section to close.
|
|
2500
2631
|
*/
|
|
2501
2632
|
close = (index) => {
|
|
2502
|
-
const li = Array.from(this.el.children).filter(c => c.tagName === 'LI')[index];
|
|
2633
|
+
const li = Array.from(this.el.children).filter((c) => c.tagName === 'LI')[index];
|
|
2503
2634
|
if (li && li.classList.contains('active')) {
|
|
2504
2635
|
// onCloseStart callback
|
|
2505
2636
|
if (typeof this.options.onCloseStart === 'function') {
|
|
@@ -2513,271 +2644,6 @@ var M = (function (exports) {
|
|
|
2513
2644
|
}
|
|
2514
2645
|
|
|
2515
2646
|
const _defaults$f = {
|
|
2516
|
-
opacity: 0.5,
|
|
2517
|
-
inDuration: 250,
|
|
2518
|
-
outDuration: 250,
|
|
2519
|
-
onOpenStart: null,
|
|
2520
|
-
onOpenEnd: null,
|
|
2521
|
-
onCloseStart: null,
|
|
2522
|
-
onCloseEnd: null,
|
|
2523
|
-
preventScrolling: true,
|
|
2524
|
-
dismissible: true,
|
|
2525
|
-
startingTop: '4%',
|
|
2526
|
-
endingTop: '10%'
|
|
2527
|
-
};
|
|
2528
|
-
class Modal extends Component {
|
|
2529
|
-
static _modalsOpen;
|
|
2530
|
-
static _count;
|
|
2531
|
-
/**
|
|
2532
|
-
* ID of the modal element.
|
|
2533
|
-
*/
|
|
2534
|
-
id;
|
|
2535
|
-
/**
|
|
2536
|
-
* If the modal is open.
|
|
2537
|
-
*/
|
|
2538
|
-
isOpen;
|
|
2539
|
-
_openingTrigger;
|
|
2540
|
-
_overlay;
|
|
2541
|
-
_nthModalOpened;
|
|
2542
|
-
constructor(el, options) {
|
|
2543
|
-
super(el, options, Modal);
|
|
2544
|
-
this.el.M_Modal = this;
|
|
2545
|
-
this.options = {
|
|
2546
|
-
...Modal.defaults,
|
|
2547
|
-
...options
|
|
2548
|
-
};
|
|
2549
|
-
this.isOpen = false;
|
|
2550
|
-
this.id = this.el.id;
|
|
2551
|
-
this._openingTrigger = undefined;
|
|
2552
|
-
this._overlay = document.createElement('div');
|
|
2553
|
-
this._overlay.classList.add('modal-overlay');
|
|
2554
|
-
this.el.tabIndex = 0;
|
|
2555
|
-
this._nthModalOpened = 0;
|
|
2556
|
-
Modal._count++;
|
|
2557
|
-
this._setupEventHandlers();
|
|
2558
|
-
}
|
|
2559
|
-
static get defaults() {
|
|
2560
|
-
return _defaults$f;
|
|
2561
|
-
}
|
|
2562
|
-
/**
|
|
2563
|
-
* Initializes instances of Modal.
|
|
2564
|
-
* @param els HTML elements.
|
|
2565
|
-
* @param options Component options.
|
|
2566
|
-
* @returns {Modal | Modal[]}
|
|
2567
|
-
*/
|
|
2568
|
-
static init(els, options = {}) {
|
|
2569
|
-
return super.init(els, options, Modal);
|
|
2570
|
-
}
|
|
2571
|
-
static getInstance(el) {
|
|
2572
|
-
return el.M_Modal;
|
|
2573
|
-
}
|
|
2574
|
-
destroy() {
|
|
2575
|
-
Modal._count--;
|
|
2576
|
-
this._removeEventHandlers();
|
|
2577
|
-
this.el.removeAttribute('style');
|
|
2578
|
-
this._overlay.remove();
|
|
2579
|
-
this.el.M_Modal = undefined;
|
|
2580
|
-
}
|
|
2581
|
-
_setupEventHandlers() {
|
|
2582
|
-
if (Modal._count === 1) {
|
|
2583
|
-
document.body.addEventListener('click', this._handleTriggerClick);
|
|
2584
|
-
}
|
|
2585
|
-
this._overlay.addEventListener('click', this._handleOverlayClick);
|
|
2586
|
-
this.el.addEventListener('click', this._handleModalCloseClick);
|
|
2587
|
-
}
|
|
2588
|
-
_removeEventHandlers() {
|
|
2589
|
-
if (Modal._count === 0) {
|
|
2590
|
-
document.body.removeEventListener('click', this._handleTriggerClick);
|
|
2591
|
-
}
|
|
2592
|
-
this._overlay.removeEventListener('click', this._handleOverlayClick);
|
|
2593
|
-
this.el.removeEventListener('click', this._handleModalCloseClick);
|
|
2594
|
-
}
|
|
2595
|
-
_handleTriggerClick = (e) => {
|
|
2596
|
-
const trigger = e.target.closest('.modal-trigger');
|
|
2597
|
-
if (!trigger)
|
|
2598
|
-
return;
|
|
2599
|
-
const modalId = Utils.getIdFromTrigger(trigger);
|
|
2600
|
-
const modalInstance = document.getElementById(modalId).M_Modal;
|
|
2601
|
-
if (modalInstance)
|
|
2602
|
-
modalInstance.open(trigger);
|
|
2603
|
-
e.preventDefault();
|
|
2604
|
-
};
|
|
2605
|
-
_handleOverlayClick = () => {
|
|
2606
|
-
if (this.options.dismissible)
|
|
2607
|
-
this.close();
|
|
2608
|
-
};
|
|
2609
|
-
_handleModalCloseClick = (e) => {
|
|
2610
|
-
const closeTrigger = e.target.closest('.modal-close');
|
|
2611
|
-
if (closeTrigger)
|
|
2612
|
-
this.close();
|
|
2613
|
-
};
|
|
2614
|
-
_handleKeydown = (e) => {
|
|
2615
|
-
if (Utils.keys.ESC.includes(e.key) && this.options.dismissible)
|
|
2616
|
-
this.close();
|
|
2617
|
-
};
|
|
2618
|
-
_handleFocus = (e) => {
|
|
2619
|
-
// Only trap focus if this modal is the last model opened (prevents loops in nested modals).
|
|
2620
|
-
if (!this.el.contains(e.target) && this._nthModalOpened === Modal._modalsOpen) {
|
|
2621
|
-
this.el.focus();
|
|
2622
|
-
}
|
|
2623
|
-
};
|
|
2624
|
-
_animateIn() {
|
|
2625
|
-
// Set initial styles
|
|
2626
|
-
this._overlay.style.display = 'block';
|
|
2627
|
-
this._overlay.style.opacity = '0';
|
|
2628
|
-
this.el.style.display = 'block';
|
|
2629
|
-
this.el.style.opacity = '0';
|
|
2630
|
-
const duration = this.options.inDuration;
|
|
2631
|
-
const isBottomSheet = this.el.classList.contains('bottom-sheet');
|
|
2632
|
-
if (!isBottomSheet) {
|
|
2633
|
-
this.el.style.top = this.options.startingTop;
|
|
2634
|
-
this.el.style.transform = 'scaleX(0.9) scaleY(0.9)';
|
|
2635
|
-
}
|
|
2636
|
-
// Overlay
|
|
2637
|
-
this._overlay.style.transition = `opacity ${duration}ms ease-out`; // v1: easeOutQuad
|
|
2638
|
-
// Modal
|
|
2639
|
-
this.el.style.transition = `
|
|
2640
|
-
top ${duration}ms ease-out,
|
|
2641
|
-
bottom ${duration}ms ease-out,
|
|
2642
|
-
opacity ${duration}ms ease-out,
|
|
2643
|
-
transform ${duration}ms ease-out
|
|
2644
|
-
`;
|
|
2645
|
-
setTimeout(() => {
|
|
2646
|
-
this._overlay.style.opacity = this.options.opacity.toString();
|
|
2647
|
-
this.el.style.opacity = '1';
|
|
2648
|
-
if (isBottomSheet) {
|
|
2649
|
-
this.el.style.bottom = '0';
|
|
2650
|
-
}
|
|
2651
|
-
else {
|
|
2652
|
-
this.el.style.top = this.options.endingTop;
|
|
2653
|
-
this.el.style.transform = 'scaleX(1) scaleY(1)';
|
|
2654
|
-
}
|
|
2655
|
-
setTimeout(() => {
|
|
2656
|
-
if (typeof this.options.onOpenEnd === 'function') {
|
|
2657
|
-
this.options.onOpenEnd.call(this, this.el, this._openingTrigger);
|
|
2658
|
-
}
|
|
2659
|
-
}, duration);
|
|
2660
|
-
}, 1);
|
|
2661
|
-
}
|
|
2662
|
-
_animateOut() {
|
|
2663
|
-
const duration = this.options.outDuration;
|
|
2664
|
-
const isBottomSheet = this.el.classList.contains('bottom-sheet');
|
|
2665
|
-
if (!isBottomSheet) {
|
|
2666
|
-
this.el.style.top = this.options.endingTop;
|
|
2667
|
-
}
|
|
2668
|
-
// Overlay
|
|
2669
|
-
this._overlay.style.transition = `opacity ${duration}ms ease-out`; // v1: easeOutQuart
|
|
2670
|
-
// Modal // easeOutCubic
|
|
2671
|
-
this.el.style.transition = `
|
|
2672
|
-
top ${duration}ms ease-out,
|
|
2673
|
-
bottom ${duration}ms ease-out,
|
|
2674
|
-
opacity ${duration}ms ease-out,
|
|
2675
|
-
transform ${duration}ms ease-out
|
|
2676
|
-
`;
|
|
2677
|
-
setTimeout(() => {
|
|
2678
|
-
this._overlay.style.opacity = '0';
|
|
2679
|
-
this.el.style.opacity = '0';
|
|
2680
|
-
if (isBottomSheet) {
|
|
2681
|
-
this.el.style.bottom = '-100%';
|
|
2682
|
-
}
|
|
2683
|
-
else {
|
|
2684
|
-
this.el.style.top = this.options.startingTop;
|
|
2685
|
-
this.el.style.transform = 'scaleX(0.9) scaleY(0.9)';
|
|
2686
|
-
}
|
|
2687
|
-
setTimeout(() => {
|
|
2688
|
-
this.el.style.display = 'none';
|
|
2689
|
-
this._overlay.remove();
|
|
2690
|
-
if (typeof this.options.onCloseEnd === 'function') {
|
|
2691
|
-
this.options.onCloseEnd.call(this, this.el);
|
|
2692
|
-
}
|
|
2693
|
-
}, duration);
|
|
2694
|
-
}, 1);
|
|
2695
|
-
}
|
|
2696
|
-
/**
|
|
2697
|
-
* Open modal.
|
|
2698
|
-
*/
|
|
2699
|
-
open = (trigger) => {
|
|
2700
|
-
if (this.isOpen)
|
|
2701
|
-
return;
|
|
2702
|
-
this.isOpen = true;
|
|
2703
|
-
Modal._modalsOpen++;
|
|
2704
|
-
this._nthModalOpened = Modal._modalsOpen;
|
|
2705
|
-
// Set Z-Index based on number of currently open modals
|
|
2706
|
-
this._overlay.style.zIndex = (1000 + Modal._modalsOpen * 2).toString();
|
|
2707
|
-
this.el.style.zIndex = (1000 + Modal._modalsOpen * 2 + 1).toString();
|
|
2708
|
-
// Set opening trigger, undefined indicates modal was opened by javascript
|
|
2709
|
-
this._openingTrigger = !!trigger ? trigger : undefined;
|
|
2710
|
-
// onOpenStart callback
|
|
2711
|
-
if (typeof this.options.onOpenStart === 'function') {
|
|
2712
|
-
this.options.onOpenStart.call(this, this.el, this._openingTrigger);
|
|
2713
|
-
}
|
|
2714
|
-
if (this.options.preventScrolling) {
|
|
2715
|
-
const hasVerticalScrollBar = document.documentElement.scrollHeight > document.documentElement.clientHeight;
|
|
2716
|
-
if (hasVerticalScrollBar) {
|
|
2717
|
-
const scrollTop = document.documentElement.scrollTop;
|
|
2718
|
-
document.documentElement.style.top = '-' + scrollTop + "px";
|
|
2719
|
-
document.documentElement.classList.add('noscroll');
|
|
2720
|
-
}
|
|
2721
|
-
}
|
|
2722
|
-
this.el.classList.add('open');
|
|
2723
|
-
this.el.insertAdjacentElement('afterend', this._overlay);
|
|
2724
|
-
if (this.options.dismissible) {
|
|
2725
|
-
document.addEventListener('keydown', this._handleKeydown);
|
|
2726
|
-
document.addEventListener('focus', this._handleFocus, true);
|
|
2727
|
-
}
|
|
2728
|
-
this._animateIn();
|
|
2729
|
-
// Focus modal
|
|
2730
|
-
this.el.focus();
|
|
2731
|
-
return this;
|
|
2732
|
-
};
|
|
2733
|
-
/**
|
|
2734
|
-
* Close modal.
|
|
2735
|
-
*/
|
|
2736
|
-
close = () => {
|
|
2737
|
-
if (!this.isOpen)
|
|
2738
|
-
return;
|
|
2739
|
-
this.isOpen = false;
|
|
2740
|
-
Modal._modalsOpen--;
|
|
2741
|
-
this._nthModalOpened = 0;
|
|
2742
|
-
// Call onCloseStart callback
|
|
2743
|
-
if (typeof this.options.onCloseStart === 'function') {
|
|
2744
|
-
this.options.onCloseStart.call(this, this.el);
|
|
2745
|
-
}
|
|
2746
|
-
this.el.classList.remove('open');
|
|
2747
|
-
// Enable body scrolling only if there are no more modals open.
|
|
2748
|
-
if (Modal._modalsOpen === 0) {
|
|
2749
|
-
const scrollTop = -parseInt(document.documentElement.style.top);
|
|
2750
|
-
document.documentElement.style.removeProperty("top");
|
|
2751
|
-
document.documentElement.classList.remove('noscroll');
|
|
2752
|
-
document.documentElement.scrollTop = scrollTop;
|
|
2753
|
-
}
|
|
2754
|
-
if (this.options.dismissible) {
|
|
2755
|
-
document.removeEventListener('keydown', this._handleKeydown);
|
|
2756
|
-
document.removeEventListener('focus', this._handleFocus, true);
|
|
2757
|
-
}
|
|
2758
|
-
this._animateOut();
|
|
2759
|
-
return this;
|
|
2760
|
-
};
|
|
2761
|
-
// Experimental!
|
|
2762
|
-
// also note: https://stackoverflow.com/a/35385518/8830502
|
|
2763
|
-
static create(children = '') {
|
|
2764
|
-
return `<dialog id="modal1" class="modal">
|
|
2765
|
-
<div class="modal-content">
|
|
2766
|
-
<h4>${children}</h4>
|
|
2767
|
-
<p>A bunch of text</p>
|
|
2768
|
-
</div>
|
|
2769
|
-
<div class="modal-footer">
|
|
2770
|
-
<a href="#!" class="modal-close waves-effect btn-flat">Agree</a>
|
|
2771
|
-
</div>
|
|
2772
|
-
</dialog>`;
|
|
2773
|
-
}
|
|
2774
|
-
static {
|
|
2775
|
-
Modal._modalsOpen = 0;
|
|
2776
|
-
Modal._count = 0;
|
|
2777
|
-
}
|
|
2778
|
-
}
|
|
2779
|
-
|
|
2780
|
-
let _defaults$e = {
|
|
2781
2647
|
classes: '',
|
|
2782
2648
|
dropdownOptions: {}
|
|
2783
2649
|
};
|
|
@@ -2803,7 +2669,7 @@ var M = (function (exports) {
|
|
|
2803
2669
|
super(el, options, FormSelect);
|
|
2804
2670
|
if (this.el.classList.contains('browser-default'))
|
|
2805
2671
|
return;
|
|
2806
|
-
this.el
|
|
2672
|
+
this.el['M_FormSelect'] = this;
|
|
2807
2673
|
this.options = {
|
|
2808
2674
|
...FormSelect.defaults,
|
|
2809
2675
|
...options
|
|
@@ -2815,7 +2681,7 @@ var M = (function (exports) {
|
|
|
2815
2681
|
this._setupEventHandlers();
|
|
2816
2682
|
}
|
|
2817
2683
|
static get defaults() {
|
|
2818
|
-
return _defaults$
|
|
2684
|
+
return _defaults$f;
|
|
2819
2685
|
}
|
|
2820
2686
|
/**
|
|
2821
2687
|
* Initializes instances of FormSelect.
|
|
@@ -2826,18 +2692,18 @@ var M = (function (exports) {
|
|
|
2826
2692
|
return super.init(els, options, FormSelect);
|
|
2827
2693
|
}
|
|
2828
2694
|
static getInstance(el) {
|
|
2829
|
-
return el
|
|
2695
|
+
return el['M_FormSelect'];
|
|
2830
2696
|
}
|
|
2831
2697
|
destroy() {
|
|
2832
2698
|
this._removeEventHandlers();
|
|
2833
2699
|
this._removeDropdown();
|
|
2834
|
-
this.el
|
|
2700
|
+
this.el['M_FormSelect'] = undefined;
|
|
2835
2701
|
}
|
|
2836
2702
|
_setupEventHandlers() {
|
|
2837
2703
|
this.dropdownOptions.querySelectorAll('li:not(.optgroup)').forEach((el) => {
|
|
2838
2704
|
el.addEventListener('click', this._handleOptionClick);
|
|
2839
2705
|
el.addEventListener('keydown', (e) => {
|
|
2840
|
-
if (e.key ===
|
|
2706
|
+
if (e.key === ' ' || e.key === 'Enter')
|
|
2841
2707
|
this._handleOptionClick(e);
|
|
2842
2708
|
});
|
|
2843
2709
|
});
|
|
@@ -2873,7 +2739,8 @@ var M = (function (exports) {
|
|
|
2873
2739
|
return true;
|
|
2874
2740
|
}
|
|
2875
2741
|
_selectOptionElement(virtualOption) {
|
|
2876
|
-
if (!virtualOption.classList.contains('disabled') &&
|
|
2742
|
+
if (!virtualOption.classList.contains('disabled') &&
|
|
2743
|
+
!virtualOption.classList.contains('optgroup')) {
|
|
2877
2744
|
const value = this._values.find((value) => value.optionEl === virtualOption);
|
|
2878
2745
|
const previousSelectedValues = this.getSelectedValues();
|
|
2879
2746
|
if (this.isMultiple) {
|
|
@@ -2919,7 +2786,7 @@ var M = (function (exports) {
|
|
|
2919
2786
|
hiddenDiv.appendChild(this.el);
|
|
2920
2787
|
if (this.el.disabled)
|
|
2921
2788
|
this.wrapper.classList.add('disabled');
|
|
2922
|
-
this.selectOptions = Array.from(this.el.children).filter(el => ['OPTION', 'OPTGROUP'].includes(el.tagName));
|
|
2789
|
+
this.selectOptions = (Array.from(this.el.children).filter((el) => ['OPTION', 'OPTGROUP'].includes(el.tagName)));
|
|
2923
2790
|
// Create dropdown
|
|
2924
2791
|
this.dropdownOptions = document.createElement('ul');
|
|
2925
2792
|
this.dropdownOptions.id = `select-options-${Utils.guid()}`;
|
|
@@ -2938,7 +2805,7 @@ var M = (function (exports) {
|
|
|
2938
2805
|
}
|
|
2939
2806
|
else if (realOption.tagName === 'OPTGROUP') {
|
|
2940
2807
|
// Optgroup
|
|
2941
|
-
const groupId =
|
|
2808
|
+
const groupId = 'opt-group-' + Utils.guid();
|
|
2942
2809
|
const groupParent = document.createElement('li');
|
|
2943
2810
|
groupParent.classList.add('optgroup');
|
|
2944
2811
|
groupParent.tabIndex = -1;
|
|
@@ -2947,42 +2814,42 @@ var M = (function (exports) {
|
|
|
2947
2814
|
groupParent.innerHTML = `<span id="${groupId}" role="presentation">${realOption.getAttribute('label')}</span>`;
|
|
2948
2815
|
this.dropdownOptions.append(groupParent);
|
|
2949
2816
|
const groupChildren = [];
|
|
2950
|
-
const selectOptions = Array.from(realOption.children).filter(el => el.tagName === 'OPTION');
|
|
2951
|
-
selectOptions.forEach(realOption => {
|
|
2817
|
+
const selectOptions = (Array.from(realOption.children).filter((el) => el.tagName === 'OPTION'));
|
|
2818
|
+
selectOptions.forEach((realOption) => {
|
|
2952
2819
|
const virtualOption = this._createAndAppendOptionWithIcon(realOption, 'optgroup-option');
|
|
2953
|
-
const childId =
|
|
2820
|
+
const childId = 'opt-child-' + Utils.guid();
|
|
2954
2821
|
virtualOption.id = childId;
|
|
2955
2822
|
groupChildren.push(childId);
|
|
2956
2823
|
this._addOptionToValues(realOption, virtualOption);
|
|
2957
2824
|
});
|
|
2958
|
-
groupParent.setAttribute(
|
|
2825
|
+
groupParent.setAttribute('aria-owns', groupChildren.join(' '));
|
|
2959
2826
|
}
|
|
2960
2827
|
});
|
|
2961
2828
|
}
|
|
2962
2829
|
this.wrapper.append(this.dropdownOptions);
|
|
2963
2830
|
// Add input dropdown
|
|
2964
2831
|
this.input = document.createElement('input');
|
|
2965
|
-
this.input.id =
|
|
2832
|
+
this.input.id = 'm_select-input-' + Utils.guid();
|
|
2966
2833
|
this.input.classList.add('select-dropdown', 'dropdown-trigger');
|
|
2967
2834
|
this.input.type = 'text';
|
|
2968
2835
|
this.input.readOnly = true;
|
|
2969
2836
|
this.input.setAttribute('data-target', this.dropdownOptions.id);
|
|
2970
2837
|
this.input.ariaReadOnly = 'true';
|
|
2971
|
-
this.input.ariaRequired = this.el.hasAttribute(
|
|
2838
|
+
this.input.ariaRequired = this.el.hasAttribute('required').toString(); //setAttribute("aria-required", this.el.hasAttribute("required"));
|
|
2972
2839
|
if (this.el.disabled)
|
|
2973
2840
|
this.input.disabled = true; // 'true');
|
|
2974
2841
|
const attrs = this.el.attributes;
|
|
2975
2842
|
for (let i = 0; i < attrs.length; ++i) {
|
|
2976
2843
|
const attr = attrs[i];
|
|
2977
|
-
if (attr.name.startsWith(
|
|
2844
|
+
if (attr.name.startsWith('aria-'))
|
|
2978
2845
|
this.input.setAttribute(attr.name, attr.value);
|
|
2979
2846
|
}
|
|
2980
2847
|
// Adds aria-attributes to input element
|
|
2981
2848
|
this.input.setAttribute('role', 'combobox');
|
|
2982
2849
|
this.input.ariaExpanded = 'false';
|
|
2983
|
-
this.input.setAttribute(
|
|
2984
|
-
this.input.setAttribute(
|
|
2985
|
-
this.input.placeholder =
|
|
2850
|
+
this.input.setAttribute('aria-owns', this.dropdownOptions.id);
|
|
2851
|
+
this.input.setAttribute('aria-controls', this.dropdownOptions.id);
|
|
2852
|
+
this.input.placeholder = ' ';
|
|
2986
2853
|
this.wrapper.prepend(this.input);
|
|
2987
2854
|
this._setValueToInput();
|
|
2988
2855
|
// Add caret
|
|
@@ -3001,7 +2868,7 @@ var M = (function (exports) {
|
|
|
3001
2868
|
const userOnOpenEnd = dropdownOptions.onOpenEnd;
|
|
3002
2869
|
const userOnCloseEnd = dropdownOptions.onCloseEnd;
|
|
3003
2870
|
// Add callback for centering selected option when dropdown content is scrollable
|
|
3004
|
-
dropdownOptions.onOpenEnd = (
|
|
2871
|
+
dropdownOptions.onOpenEnd = () => {
|
|
3005
2872
|
const selectedOption = this.dropdownOptions.querySelector('.selected');
|
|
3006
2873
|
if (selectedOption) {
|
|
3007
2874
|
// Focus selected option in dropdown
|
|
@@ -3023,7 +2890,7 @@ var M = (function (exports) {
|
|
|
3023
2890
|
userOnOpenEnd.call(this.dropdown, this.el);
|
|
3024
2891
|
};
|
|
3025
2892
|
// Add callback for reseting "expanded" state
|
|
3026
|
-
dropdownOptions.onCloseEnd = (
|
|
2893
|
+
dropdownOptions.onCloseEnd = () => {
|
|
3027
2894
|
this.input.ariaExpanded = 'false';
|
|
3028
2895
|
// Handle user declared onOpenEnd if needed
|
|
3029
2896
|
if (userOnCloseEnd && typeof userOnCloseEnd === 'function')
|
|
@@ -3101,7 +2968,7 @@ var M = (function (exports) {
|
|
|
3101
2968
|
checkbox.checked = false;
|
|
3102
2969
|
}
|
|
3103
2970
|
_deselectAll() {
|
|
3104
|
-
this._values.forEach(value => this._deselectValue(value));
|
|
2971
|
+
this._values.forEach((value) => this._deselectValue(value));
|
|
3105
2972
|
}
|
|
3106
2973
|
_isValueSelected(value) {
|
|
3107
2974
|
const realValues = this.getSelectedValues();
|
|
@@ -3121,7 +2988,7 @@ var M = (function (exports) {
|
|
|
3121
2988
|
const selectedRealOptions = this._getSelectedOptions();
|
|
3122
2989
|
const selectedOptionPairs = this._values.filter((value) => selectedRealOptions.indexOf(value.el) >= 0);
|
|
3123
2990
|
// Filter not disabled
|
|
3124
|
-
const notDisabledOptionPairs = selectedOptionPairs.filter(op => !op.el.disabled);
|
|
2991
|
+
const notDisabledOptionPairs = selectedOptionPairs.filter((op) => !op.el.disabled);
|
|
3125
2992
|
const texts = notDisabledOptionPairs.map((value) => value.optionEl.querySelector('span').innerText.trim());
|
|
3126
2993
|
// Set input-text to first Option with empty value which indicates a description like "choose your option"
|
|
3127
2994
|
if (texts.length === 0) {
|
|
@@ -3152,7 +3019,7 @@ var M = (function (exports) {
|
|
|
3152
3019
|
if (!li)
|
|
3153
3020
|
return;
|
|
3154
3021
|
if (!this.isMultiple)
|
|
3155
|
-
ul.querySelectorAll('li.selected').forEach(li => li.classList.remove('selected'));
|
|
3022
|
+
ul.querySelectorAll('li.selected').forEach((li) => li.classList.remove('selected'));
|
|
3156
3023
|
li.classList.add('selected');
|
|
3157
3024
|
li.ariaSelected = 'true';
|
|
3158
3025
|
}
|
|
@@ -3161,17 +3028,23 @@ var M = (function (exports) {
|
|
|
3161
3028
|
}
|
|
3162
3029
|
}
|
|
3163
3030
|
|
|
3164
|
-
|
|
3165
|
-
// Close when date is selected
|
|
3166
|
-
autoClose: false,
|
|
3031
|
+
const _defaults$e = {
|
|
3167
3032
|
// the default output format for the input field value
|
|
3168
3033
|
format: 'mmm dd, yyyy',
|
|
3169
3034
|
// Used to create date object from current input string
|
|
3170
3035
|
parse: null,
|
|
3036
|
+
// The initial condition if the datepicker is based on date range
|
|
3037
|
+
isDateRange: false,
|
|
3038
|
+
// The initial condition if the datepicker is based on multiple date selection
|
|
3039
|
+
isMultipleSelection: false,
|
|
3171
3040
|
// The initial date to view when first opened
|
|
3172
3041
|
defaultDate: null,
|
|
3042
|
+
// The initial end date to view when first opened
|
|
3043
|
+
defaultEndDate: null,
|
|
3173
3044
|
// Make the `defaultDate` the initial selected value
|
|
3174
3045
|
setDefaultDate: false,
|
|
3046
|
+
// Make the `defaultEndDate` the initial selected value
|
|
3047
|
+
setDefaultEndDate: false,
|
|
3175
3048
|
disableWeekends: false,
|
|
3176
3049
|
disableDayFn: null,
|
|
3177
3050
|
// First day of week (0: Sunday, 1: Monday etc)
|
|
@@ -3242,15 +3115,11 @@ var M = (function (exports) {
|
|
|
3242
3115
|
events: [],
|
|
3243
3116
|
// callback function
|
|
3244
3117
|
onSelect: null,
|
|
3245
|
-
onOpen: null,
|
|
3246
|
-
onClose: null,
|
|
3247
3118
|
onDraw: null
|
|
3248
3119
|
};
|
|
3249
3120
|
class Datepicker extends Component {
|
|
3250
3121
|
id;
|
|
3251
|
-
|
|
3252
|
-
isOpen;
|
|
3253
|
-
modal;
|
|
3122
|
+
multiple = false;
|
|
3254
3123
|
calendarEl;
|
|
3255
3124
|
/** CLEAR button instance. */
|
|
3256
3125
|
clearBtn;
|
|
@@ -3260,8 +3129,12 @@ var M = (function (exports) {
|
|
|
3260
3129
|
modalEl;
|
|
3261
3130
|
yearTextEl;
|
|
3262
3131
|
dateTextEl;
|
|
3132
|
+
endDateEl;
|
|
3133
|
+
dateEls;
|
|
3263
3134
|
/** The selected Date. */
|
|
3264
3135
|
date;
|
|
3136
|
+
endDate;
|
|
3137
|
+
dates;
|
|
3265
3138
|
formats;
|
|
3266
3139
|
calendars;
|
|
3267
3140
|
_y;
|
|
@@ -3269,7 +3142,7 @@ var M = (function (exports) {
|
|
|
3269
3142
|
static _template;
|
|
3270
3143
|
constructor(el, options) {
|
|
3271
3144
|
super(el, options, Datepicker);
|
|
3272
|
-
this.el
|
|
3145
|
+
this.el['M_Datepicker'] = this;
|
|
3273
3146
|
this.options = {
|
|
3274
3147
|
...Datepicker.defaults,
|
|
3275
3148
|
...options
|
|
@@ -3286,16 +3159,15 @@ var M = (function (exports) {
|
|
|
3286
3159
|
this.id = Utils.guid();
|
|
3287
3160
|
this._setupVariables();
|
|
3288
3161
|
this._insertHTMLIntoDOM();
|
|
3289
|
-
this._setupModal();
|
|
3290
3162
|
this._setupEventHandlers();
|
|
3291
3163
|
if (!this.options.defaultDate) {
|
|
3292
3164
|
this.options.defaultDate = new Date(Date.parse(this.el.value));
|
|
3293
3165
|
}
|
|
3294
|
-
|
|
3166
|
+
const defDate = this.options.defaultDate;
|
|
3295
3167
|
if (Datepicker._isDate(defDate)) {
|
|
3296
3168
|
if (this.options.setDefaultDate) {
|
|
3297
3169
|
this.setDate(defDate, true);
|
|
3298
|
-
this.setInputValue();
|
|
3170
|
+
this.setInputValue(this.el, defDate);
|
|
3299
3171
|
}
|
|
3300
3172
|
else {
|
|
3301
3173
|
this.gotoDate(defDate);
|
|
@@ -3304,10 +3176,25 @@ var M = (function (exports) {
|
|
|
3304
3176
|
else {
|
|
3305
3177
|
this.gotoDate(new Date());
|
|
3306
3178
|
}
|
|
3307
|
-
this.
|
|
3179
|
+
if (this.options.isDateRange) {
|
|
3180
|
+
this.multiple = true;
|
|
3181
|
+
const defEndDate = this.options.defaultEndDate;
|
|
3182
|
+
if (Datepicker._isDate(defEndDate)) {
|
|
3183
|
+
if (this.options.setDefaultEndDate) {
|
|
3184
|
+
this.setDate(defEndDate, true, true);
|
|
3185
|
+
this.setInputValue(this.endDateEl, defEndDate);
|
|
3186
|
+
}
|
|
3187
|
+
}
|
|
3188
|
+
}
|
|
3189
|
+
if (this.options.isMultipleSelection) {
|
|
3190
|
+
this.multiple = true;
|
|
3191
|
+
this.dates = [];
|
|
3192
|
+
this.dateEls = [];
|
|
3193
|
+
this.dateEls.push(el);
|
|
3194
|
+
}
|
|
3308
3195
|
}
|
|
3309
3196
|
static get defaults() {
|
|
3310
|
-
return _defaults$
|
|
3197
|
+
return _defaults$e;
|
|
3311
3198
|
}
|
|
3312
3199
|
/**
|
|
3313
3200
|
* Initializes instances of Datepicker.
|
|
@@ -3321,9 +3208,12 @@ var M = (function (exports) {
|
|
|
3321
3208
|
return /Date/.test(Object.prototype.toString.call(obj)) && !isNaN(obj.getTime());
|
|
3322
3209
|
}
|
|
3323
3210
|
static _isWeekend(date) {
|
|
3324
|
-
|
|
3211
|
+
const day = date.getDay();
|
|
3325
3212
|
return day === 0 || day === 6;
|
|
3326
3213
|
}
|
|
3214
|
+
/**
|
|
3215
|
+
* @deprecated as this function has no effect without any return statement or global parameter setter.
|
|
3216
|
+
*/
|
|
3327
3217
|
static _setToStartOfDay(date) {
|
|
3328
3218
|
if (Datepicker._isDate(date))
|
|
3329
3219
|
date.setHours(0, 0, 0, 0);
|
|
@@ -3339,27 +3229,40 @@ var M = (function (exports) {
|
|
|
3339
3229
|
// weak date comparison (use setToStartOfDay(date) to ensure correct result)
|
|
3340
3230
|
return a.getTime() === b.getTime();
|
|
3341
3231
|
}
|
|
3232
|
+
static _compareWithinRange(day, date, dateEnd) {
|
|
3233
|
+
return day.getTime() > date.getTime() && day.getTime() < dateEnd.getTime();
|
|
3234
|
+
}
|
|
3235
|
+
static _comparePastDate(a, b) {
|
|
3236
|
+
return a.getTime() < b.getTime();
|
|
3237
|
+
}
|
|
3342
3238
|
static getInstance(el) {
|
|
3343
|
-
return el
|
|
3239
|
+
return el['M_Datepicker'];
|
|
3344
3240
|
}
|
|
3345
3241
|
destroy() {
|
|
3346
3242
|
this._removeEventHandlers();
|
|
3347
|
-
this.modal.destroy();
|
|
3348
3243
|
this.modalEl.remove();
|
|
3349
3244
|
this.destroySelects();
|
|
3350
|
-
this.el
|
|
3245
|
+
this.el['M_Datepicker'] = undefined;
|
|
3351
3246
|
}
|
|
3352
3247
|
destroySelects() {
|
|
3353
|
-
|
|
3248
|
+
const oldYearSelect = this.calendarEl.querySelector('.orig-select-year');
|
|
3354
3249
|
if (oldYearSelect) {
|
|
3355
3250
|
FormSelect.getInstance(oldYearSelect).destroy();
|
|
3356
3251
|
}
|
|
3357
|
-
|
|
3252
|
+
const oldMonthSelect = this.calendarEl.querySelector('.orig-select-month');
|
|
3358
3253
|
if (oldMonthSelect) {
|
|
3359
3254
|
FormSelect.getInstance(oldMonthSelect).destroy();
|
|
3360
3255
|
}
|
|
3361
3256
|
}
|
|
3362
3257
|
_insertHTMLIntoDOM() {
|
|
3258
|
+
// HTML5 input date field support
|
|
3259
|
+
if (this.el.type == 'date') {
|
|
3260
|
+
this.el.classList.add('datepicker-date-input');
|
|
3261
|
+
}
|
|
3262
|
+
if (this.options.isDateRange) {
|
|
3263
|
+
this.endDateEl = this.createDateInput();
|
|
3264
|
+
this.endDateEl.classList.add('datepicker-end-date');
|
|
3265
|
+
}
|
|
3363
3266
|
if (this.options.showClearBtn) {
|
|
3364
3267
|
this.clearBtn.style.visibility = '';
|
|
3365
3268
|
this.clearBtn.innerText = this.options.i18n.clear;
|
|
@@ -3377,39 +3280,59 @@ var M = (function (exports) {
|
|
|
3377
3280
|
this.el.parentElement.appendChild(this.modalEl);
|
|
3378
3281
|
}
|
|
3379
3282
|
}
|
|
3380
|
-
_setupModal() {
|
|
3381
|
-
this.modalEl.id = 'modal-' + this.id;
|
|
3382
|
-
this.modal = Modal.init(this.modalEl, {
|
|
3383
|
-
onCloseEnd: () => {
|
|
3384
|
-
this.isOpen = false;
|
|
3385
|
-
}
|
|
3386
|
-
});
|
|
3387
|
-
}
|
|
3388
3283
|
/**
|
|
3389
|
-
* Gets a string representation of the
|
|
3284
|
+
* Gets a string representation of the given date.
|
|
3390
3285
|
*/
|
|
3391
|
-
toString(format = null) {
|
|
3286
|
+
toString(date = this.date, format = null) {
|
|
3392
3287
|
format = format || this.options.format;
|
|
3393
3288
|
if (typeof format === 'function')
|
|
3394
|
-
return format(
|
|
3395
|
-
if (!Datepicker._isDate(
|
|
3289
|
+
return format(date);
|
|
3290
|
+
if (!Datepicker._isDate(date))
|
|
3396
3291
|
return '';
|
|
3397
3292
|
// String Format
|
|
3293
|
+
return this.formatDate(date, format);
|
|
3294
|
+
}
|
|
3295
|
+
/**
|
|
3296
|
+
* Returns the formatted date.
|
|
3297
|
+
*/
|
|
3298
|
+
formatDate(date, format) {
|
|
3398
3299
|
const formatArray = format.split(/(d{1,4}|m{1,4}|y{4}|yy|!.)/g);
|
|
3399
|
-
|
|
3400
|
-
.map(label => this.formats[label] ? this.formats[label]() : label)
|
|
3300
|
+
return formatArray
|
|
3301
|
+
.map((label) => (this.formats[label] ? this.formats[label](date) : label))
|
|
3401
3302
|
.join('');
|
|
3402
|
-
|
|
3303
|
+
}
|
|
3304
|
+
/**
|
|
3305
|
+
* Sets date from input field.
|
|
3306
|
+
*/
|
|
3307
|
+
setDateFromInput(el) {
|
|
3308
|
+
const date = new Date(Date.parse(el.value));
|
|
3309
|
+
this.setDate(date, false, el == this.endDateEl, true);
|
|
3403
3310
|
}
|
|
3404
3311
|
/**
|
|
3405
3312
|
* Set a date on the datepicker.
|
|
3406
3313
|
* @param date Date to set on the datepicker.
|
|
3407
3314
|
* @param preventOnSelect Undocumented as of 5 March 2018.
|
|
3315
|
+
* @param isEndDate
|
|
3316
|
+
* @param fromUserInput
|
|
3408
3317
|
*/
|
|
3409
|
-
setDate(date = null, preventOnSelect = false) {
|
|
3318
|
+
setDate(date = null, preventOnSelect = false, isEndDate = false, fromUserInput = false) {
|
|
3319
|
+
const selectedDate = this.validateDate(date);
|
|
3320
|
+
if (!selectedDate) {
|
|
3321
|
+
return;
|
|
3322
|
+
}
|
|
3323
|
+
if (!this.options.isMultipleSelection)
|
|
3324
|
+
this.setSingleDate(selectedDate, isEndDate);
|
|
3325
|
+
else if (!fromUserInput)
|
|
3326
|
+
this.setMultiDate(selectedDate);
|
|
3327
|
+
Datepicker._setToStartOfDay(selectedDate);
|
|
3328
|
+
this.gotoDate(selectedDate);
|
|
3329
|
+
if (!preventOnSelect && typeof this.options.onSelect === 'function') {
|
|
3330
|
+
this.options.onSelect.call(this, selectedDate);
|
|
3331
|
+
}
|
|
3332
|
+
}
|
|
3333
|
+
validateDate(date) {
|
|
3410
3334
|
if (!date) {
|
|
3411
|
-
this.date
|
|
3412
|
-
this._renderDateDisplay();
|
|
3335
|
+
this._renderDateDisplay(date);
|
|
3413
3336
|
return this.draw();
|
|
3414
3337
|
}
|
|
3415
3338
|
if (typeof date === 'string') {
|
|
@@ -3418,36 +3341,114 @@ var M = (function (exports) {
|
|
|
3418
3341
|
if (!Datepicker._isDate(date)) {
|
|
3419
3342
|
return;
|
|
3420
3343
|
}
|
|
3421
|
-
|
|
3344
|
+
const min = this.options.minDate, max = this.options.maxDate;
|
|
3422
3345
|
if (Datepicker._isDate(min) && date < min) {
|
|
3423
3346
|
date = min;
|
|
3424
3347
|
}
|
|
3425
3348
|
else if (Datepicker._isDate(max) && date > max) {
|
|
3426
3349
|
date = max;
|
|
3427
3350
|
}
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3351
|
+
return new Date(date.getTime());
|
|
3352
|
+
}
|
|
3353
|
+
/**
|
|
3354
|
+
* Set a single date on the datepicker.
|
|
3355
|
+
* @param date Date to set on the datepicker.
|
|
3356
|
+
* @param isEndDate
|
|
3357
|
+
*/
|
|
3358
|
+
setSingleDate(date, isEndDate) {
|
|
3359
|
+
if (!isEndDate) {
|
|
3360
|
+
this.date = date;
|
|
3361
|
+
}
|
|
3362
|
+
else if (isEndDate) {
|
|
3363
|
+
this.endDate = date;
|
|
3364
|
+
}
|
|
3365
|
+
}
|
|
3366
|
+
/**
|
|
3367
|
+
* Set a multi date on the datepicker.
|
|
3368
|
+
* @param date Date to set on the datepicker.
|
|
3369
|
+
*/
|
|
3370
|
+
setMultiDate(date) {
|
|
3371
|
+
const selectedDate = this.dates?.find((item) => {
|
|
3372
|
+
return item.getTime() === date.getTime() ? item : false;
|
|
3373
|
+
});
|
|
3374
|
+
if (!selectedDate) {
|
|
3375
|
+
this.dates.push(date);
|
|
3376
|
+
}
|
|
3377
|
+
else {
|
|
3378
|
+
this.dates.splice(this.dates.indexOf(selectedDate), 1);
|
|
3379
|
+
}
|
|
3380
|
+
this.dates.sort((a, b) => (a.getTime() < b.getTime() ? -1 : 0));
|
|
3381
|
+
}
|
|
3382
|
+
/**
|
|
3383
|
+
* Sets the data-date attribute on the date input field
|
|
3384
|
+
*/
|
|
3385
|
+
setDataDate(el, date) {
|
|
3386
|
+
el.setAttribute('data-date', this.toString(date));
|
|
3387
|
+
}
|
|
3388
|
+
/**
|
|
3389
|
+
* Sets dates on the input values.
|
|
3390
|
+
*/
|
|
3391
|
+
setInputValues() {
|
|
3392
|
+
if (!this.options?.isMultipleSelection) {
|
|
3393
|
+
this.setInputValue(this.el, this.date);
|
|
3394
|
+
if (this.options?.isDateRange) {
|
|
3395
|
+
this.setInputValue(this.endDateEl, this.endDate);
|
|
3396
|
+
}
|
|
3397
|
+
return;
|
|
3434
3398
|
}
|
|
3399
|
+
this.setMultipleSelectionInputValues();
|
|
3400
|
+
}
|
|
3401
|
+
setMultipleSelectionInputValues() {
|
|
3402
|
+
const dateElsArr = Array.from(this.dateEls).filter((el, index) => {
|
|
3403
|
+
if (index > this.dates.length - 1)
|
|
3404
|
+
return el;
|
|
3405
|
+
});
|
|
3406
|
+
dateElsArr.forEach((el) => {
|
|
3407
|
+
el.remove();
|
|
3408
|
+
});
|
|
3409
|
+
this.dates.forEach((date, index) => {
|
|
3410
|
+
if (Array.from(this.dateEls)[index]) {
|
|
3411
|
+
this.setInputValue(this.dateEls[index], date);
|
|
3412
|
+
return;
|
|
3413
|
+
}
|
|
3414
|
+
const dateEl = this.createDateInput();
|
|
3415
|
+
this.setInputValue(dateEl, date);
|
|
3416
|
+
this.dateEls.push(dateEl);
|
|
3417
|
+
});
|
|
3435
3418
|
}
|
|
3436
3419
|
/**
|
|
3437
|
-
* Sets
|
|
3420
|
+
* Sets given date as the input value on the given element.
|
|
3438
3421
|
*/
|
|
3439
|
-
setInputValue() {
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3422
|
+
setInputValue(el, date) {
|
|
3423
|
+
console.log('setinputvalue');
|
|
3424
|
+
if (el.type == 'date') {
|
|
3425
|
+
this.setDataDate(el, date);
|
|
3426
|
+
el.value = this.formatDate(date, 'yyyy-mm-dd');
|
|
3427
|
+
}
|
|
3428
|
+
else {
|
|
3429
|
+
el.value = this.toString(date);
|
|
3430
|
+
}
|
|
3431
|
+
this.el.dispatchEvent(new CustomEvent('change', {
|
|
3432
|
+
bubbles: true,
|
|
3433
|
+
cancelable: true,
|
|
3434
|
+
composed: true,
|
|
3435
|
+
detail: { firedBy: this }
|
|
3436
|
+
}));
|
|
3437
|
+
}
|
|
3438
|
+
/**
|
|
3439
|
+
* Renders the date in the modal head section.
|
|
3440
|
+
*/
|
|
3441
|
+
_renderDateDisplay(date, endDate = null) {
|
|
3442
|
+
const displayDate = Datepicker._isDate(date) ? date : new Date();
|
|
3443
|
+
// this.yearTextEl.innerHTML = displayDate.getFullYear().toString();
|
|
3444
|
+
// @todo should we include an option for date formatting by component options?
|
|
3445
|
+
if (!this.options.isDateRange) {
|
|
3446
|
+
this.dateTextEl.innerHTML = this.formatDate(displayDate, 'ddd, mmm d');
|
|
3447
|
+
}
|
|
3448
|
+
else {
|
|
3449
|
+
const displayEndDate = Datepicker._isDate(endDate) ? endDate : new Date();
|
|
3450
|
+
this.dateTextEl.innerHTML = `${this.formatDate(displayDate, 'mmm d')} - ${this.formatDate(displayEndDate, 'mmm d')}`;
|
|
3451
|
+
}
|
|
3451
3452
|
}
|
|
3452
3453
|
/**
|
|
3453
3454
|
* Change date view to a specific date on the datepicker.
|
|
@@ -3459,7 +3460,7 @@ var M = (function (exports) {
|
|
|
3459
3460
|
return;
|
|
3460
3461
|
}
|
|
3461
3462
|
if (this.calendars) {
|
|
3462
|
-
|
|
3463
|
+
const firstVisibleDate = new Date(this.calendars[0].year, this.calendars[0].month, 1), lastVisibleDate = new Date(this.calendars[this.calendars.length - 1].year, this.calendars[this.calendars.length - 1].month, 1), visibleDate = date.getTime();
|
|
3463
3464
|
// get the end of the month
|
|
3464
3465
|
lastVisibleDate.setMonth(lastVisibleDate.getMonth() + 1);
|
|
3465
3466
|
lastVisibleDate.setDate(lastVisibleDate.getDate() - 1);
|
|
@@ -3500,15 +3501,16 @@ var M = (function (exports) {
|
|
|
3500
3501
|
this.adjustCalendars();
|
|
3501
3502
|
}
|
|
3502
3503
|
render(year, month, randId) {
|
|
3503
|
-
|
|
3504
|
+
const now = new Date(), days = Datepicker._getDaysInMonth(year, month), data = [];
|
|
3505
|
+
let before = new Date(year, month, 1).getDay(), row = [];
|
|
3504
3506
|
Datepicker._setToStartOfDay(now);
|
|
3505
|
-
if (
|
|
3506
|
-
before -=
|
|
3507
|
+
if (this.options.firstDay > 0) {
|
|
3508
|
+
before -= this.options.firstDay;
|
|
3507
3509
|
if (before < 0) {
|
|
3508
3510
|
before += 7;
|
|
3509
3511
|
}
|
|
3510
3512
|
}
|
|
3511
|
-
|
|
3513
|
+
const previousMonth = month === 0 ? 11 : month - 1, nextMonth = month === 11 ? 0 : month + 1, yearOfPreviousMonth = month === 0 ? year - 1 : year, yearOfNextMonth = month === 11 ? year + 1 : year, daysInPreviousMonth = Datepicker._getDaysInMonth(yearOfPreviousMonth, previousMonth);
|
|
3512
3514
|
let cells = days + before, after = cells;
|
|
3513
3515
|
while (after > 7) {
|
|
3514
3516
|
after -= 7;
|
|
@@ -3516,12 +3518,27 @@ var M = (function (exports) {
|
|
|
3516
3518
|
cells += 7 - after;
|
|
3517
3519
|
let isWeekSelected = false;
|
|
3518
3520
|
for (let i = 0, r = 0; i < cells; i++) {
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
(
|
|
3523
|
-
(
|
|
3524
|
-
(
|
|
3521
|
+
const day = new Date(year, month, 1 + (i - before)), isToday = Datepicker._compareDates(day, now), hasEvent = this.options.events.indexOf(day.toDateString()) !== -1, isEmpty = i < before || i >= days + before, isStartRange = this.options.startRange && Datepicker._compareDates(this.options.startRange, day), isEndRange = this.options.endRange && Datepicker._compareDates(this.options.endRange, day), isInRange = this.options.startRange &&
|
|
3522
|
+
this.options.endRange &&
|
|
3523
|
+
this.options.startRange < day &&
|
|
3524
|
+
day < this.options.endRange, isDisabled = (this.options.minDate && day < this.options.minDate) ||
|
|
3525
|
+
(this.options.maxDate && day > this.options.maxDate) ||
|
|
3526
|
+
(this.options.disableWeekends && Datepicker._isWeekend(day)) ||
|
|
3527
|
+
(this.options.disableDayFn && this.options.disableDayFn(day)), isDateRange = this.options.isDateRange &&
|
|
3528
|
+
Datepicker._isDate(this.endDate) &&
|
|
3529
|
+
Datepicker._compareWithinRange(day, this.date, this.endDate);
|
|
3530
|
+
let dayNumber = 1 + (i - before), monthNumber = month, yearNumber = year;
|
|
3531
|
+
let isSelected = false;
|
|
3532
|
+
if (Datepicker._isDate(this.date)) {
|
|
3533
|
+
isSelected = Datepicker._compareDates(day, this.date);
|
|
3534
|
+
}
|
|
3535
|
+
if (!isSelected && Datepicker._isDate(this.endDate)) {
|
|
3536
|
+
isSelected = Datepicker._compareDates(day, this.endDate);
|
|
3537
|
+
}
|
|
3538
|
+
if (this.options.isMultipleSelection &&
|
|
3539
|
+
this.dates?.some((item) => item.getTime() === day.getTime())) {
|
|
3540
|
+
isSelected = true;
|
|
3541
|
+
}
|
|
3525
3542
|
if (isEmpty) {
|
|
3526
3543
|
if (i < before) {
|
|
3527
3544
|
dayNumber = daysInPreviousMonth + dayNumber;
|
|
@@ -3534,7 +3551,7 @@ var M = (function (exports) {
|
|
|
3534
3551
|
yearNumber = yearOfNextMonth;
|
|
3535
3552
|
}
|
|
3536
3553
|
}
|
|
3537
|
-
|
|
3554
|
+
const dayConfig = {
|
|
3538
3555
|
day: dayNumber,
|
|
3539
3556
|
month: monthNumber,
|
|
3540
3557
|
year: yearNumber,
|
|
@@ -3546,20 +3563,21 @@ var M = (function (exports) {
|
|
|
3546
3563
|
isStartRange: isStartRange,
|
|
3547
3564
|
isEndRange: isEndRange,
|
|
3548
3565
|
isInRange: isInRange,
|
|
3549
|
-
showDaysInNextAndPreviousMonths:
|
|
3566
|
+
showDaysInNextAndPreviousMonths: this.options.showDaysInNextAndPreviousMonths,
|
|
3567
|
+
isDateRange: isDateRange
|
|
3550
3568
|
};
|
|
3551
3569
|
row.push(this.renderDay(dayConfig));
|
|
3552
3570
|
if (++r === 7) {
|
|
3553
|
-
data.push(this.renderRow(row,
|
|
3571
|
+
data.push(this.renderRow(row, this.options.isRTL, isWeekSelected));
|
|
3554
3572
|
row = [];
|
|
3555
3573
|
r = 0;
|
|
3556
3574
|
isWeekSelected = false;
|
|
3557
3575
|
}
|
|
3558
3576
|
}
|
|
3559
|
-
return this.renderTable(
|
|
3577
|
+
return this.renderTable(this.options, data, randId);
|
|
3560
3578
|
}
|
|
3561
3579
|
renderDay(opts) {
|
|
3562
|
-
|
|
3580
|
+
const arr = [];
|
|
3563
3581
|
let ariaSelected = 'false';
|
|
3564
3582
|
if (opts.isEmpty) {
|
|
3565
3583
|
if (opts.showDaysInNextAndPreviousMonths) {
|
|
@@ -3570,6 +3588,7 @@ var M = (function (exports) {
|
|
|
3570
3588
|
return '<td class="is-empty"></td>';
|
|
3571
3589
|
}
|
|
3572
3590
|
}
|
|
3591
|
+
// @todo wouldn't it be better defining opts class mapping and looping trough opts?
|
|
3573
3592
|
if (opts.isDisabled) {
|
|
3574
3593
|
arr.push('is-disabled');
|
|
3575
3594
|
}
|
|
@@ -3580,18 +3599,26 @@ var M = (function (exports) {
|
|
|
3580
3599
|
arr.push('is-selected');
|
|
3581
3600
|
ariaSelected = 'true';
|
|
3582
3601
|
}
|
|
3602
|
+
// @todo should we create this additional css class?
|
|
3583
3603
|
if (opts.hasEvent) {
|
|
3584
3604
|
arr.push('has-event');
|
|
3585
3605
|
}
|
|
3606
|
+
// @todo should we create this additional css class?
|
|
3586
3607
|
if (opts.isInRange) {
|
|
3587
3608
|
arr.push('is-inrange');
|
|
3588
3609
|
}
|
|
3610
|
+
// @todo should we create this additional css class?
|
|
3589
3611
|
if (opts.isStartRange) {
|
|
3590
3612
|
arr.push('is-startrange');
|
|
3591
3613
|
}
|
|
3614
|
+
// @todo should we create this additional css class?
|
|
3592
3615
|
if (opts.isEndRange) {
|
|
3593
3616
|
arr.push('is-endrange');
|
|
3594
3617
|
}
|
|
3618
|
+
// @todo create additional css class
|
|
3619
|
+
if (opts.isDateRange) {
|
|
3620
|
+
arr.push('is-daterange');
|
|
3621
|
+
}
|
|
3595
3622
|
return (`<td data-day="${opts.day}" class="${arr.join(' ')}" aria-selected="${ariaSelected}">` +
|
|
3596
3623
|
`<button class="datepicker-day-button" type="button" data-year="${opts.year}" data-month="${opts.month}" data-day="${opts.day}">${opts.day}</button>` +
|
|
3597
3624
|
'</td>');
|
|
@@ -3612,7 +3639,8 @@ var M = (function (exports) {
|
|
|
3612
3639
|
'</table></div>');
|
|
3613
3640
|
}
|
|
3614
3641
|
renderHead(opts) {
|
|
3615
|
-
|
|
3642
|
+
const arr = [];
|
|
3643
|
+
let i;
|
|
3616
3644
|
for (i = 0; i < 7; i++) {
|
|
3617
3645
|
arr.push(`<th scope="col"><abbr title="${this.renderDayName(opts, i)}">${this.renderDayName(opts, i, true)}</abbr></th>`);
|
|
3618
3646
|
}
|
|
@@ -3622,10 +3650,11 @@ var M = (function (exports) {
|
|
|
3622
3650
|
return '<tbody>' + rows.join('') + '</tbody>';
|
|
3623
3651
|
}
|
|
3624
3652
|
renderTitle(instance, c, year, month, refYear, randId) {
|
|
3625
|
-
|
|
3653
|
+
const opts = this.options, isMinYear = year === opts.minYear, isMaxYear = year === opts.maxYear;
|
|
3654
|
+
let i, j, arr = [], html = '<div id="' +
|
|
3626
3655
|
randId +
|
|
3627
|
-
'" class="datepicker-controls" role="heading" aria-live="assertive">',
|
|
3628
|
-
for (
|
|
3656
|
+
'" class="datepicker-controls" role="heading" aria-live="assertive">', prev = true, next = true;
|
|
3657
|
+
for (i = 0; i < 12; i++) {
|
|
3629
3658
|
arr.push('<option value="' +
|
|
3630
3659
|
(year === refYear ? i - c : 12 + i - c) +
|
|
3631
3660
|
'"' +
|
|
@@ -3637,7 +3666,9 @@ var M = (function (exports) {
|
|
|
3637
3666
|
opts.i18n.months[i] +
|
|
3638
3667
|
'</option>');
|
|
3639
3668
|
}
|
|
3640
|
-
monthHtml = '<select class="datepicker-select orig-select-month" tabindex="-1">' +
|
|
3669
|
+
const monthHtml = '<select class="datepicker-select orig-select-month" tabindex="-1">' +
|
|
3670
|
+
arr.join('') +
|
|
3671
|
+
'</select>';
|
|
3641
3672
|
if (Array.isArray(opts.yearRange)) {
|
|
3642
3673
|
i = opts.yearRange[0];
|
|
3643
3674
|
j = opts.yearRange[1] + 1;
|
|
@@ -3653,8 +3684,8 @@ var M = (function (exports) {
|
|
|
3653
3684
|
}
|
|
3654
3685
|
if (opts.yearRangeReverse)
|
|
3655
3686
|
arr.reverse();
|
|
3656
|
-
yearHtml = `<select class="datepicker-select orig-select-year" tabindex="-1">${arr.join('')}</select>`;
|
|
3657
|
-
|
|
3687
|
+
const yearHtml = `<select class="datepicker-select orig-select-year" tabindex="-1">${arr.join('')}</select>`;
|
|
3688
|
+
const leftArrow = '<svg height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M15.41 16.09l-4.58-4.59 4.58-4.59L14 5.5l-6 6 6 6z"/><path d="M0-.5h24v24H0z" fill="none"/></svg>';
|
|
3658
3689
|
html += `<button class="month-prev${prev ? '' : ' is-disabled'} btn-flat" type="button">${leftArrow}</button>`;
|
|
3659
3690
|
html += '<div class="selects-container">';
|
|
3660
3691
|
if (opts.showMonthAfterYear) {
|
|
@@ -3670,15 +3701,14 @@ var M = (function (exports) {
|
|
|
3670
3701
|
if (isMaxYear && (month === 11 || opts.maxMonth <= month)) {
|
|
3671
3702
|
next = false;
|
|
3672
3703
|
}
|
|
3673
|
-
|
|
3704
|
+
const rightArrow = '<svg height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M8.59 16.34l4.58-4.59-4.58-4.59L10 5.75l6 6-6 6z"/><path d="M0-.25h24v24H0z" fill="none"/></svg>';
|
|
3674
3705
|
html += `<button class="month-next${next ? '' : ' is-disabled'} btn-flat" type="button">${rightArrow}</button>`;
|
|
3675
3706
|
return (html += '</div>');
|
|
3676
3707
|
}
|
|
3677
3708
|
// refresh HTML
|
|
3678
|
-
draw(
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
let opts = this.options, minYear = opts.minYear, maxYear = opts.maxYear, minMonth = opts.minMonth, maxMonth = opts.maxMonth, html = '', randId;
|
|
3709
|
+
draw() {
|
|
3710
|
+
const opts = this.options, minYear = opts.minYear, maxYear = opts.maxYear, minMonth = opts.minMonth, maxMonth = opts.maxMonth;
|
|
3711
|
+
let html = '';
|
|
3682
3712
|
if (this._y <= minYear) {
|
|
3683
3713
|
this._y = minYear;
|
|
3684
3714
|
if (!isNaN(minMonth) && this._m < minMonth) {
|
|
@@ -3691,22 +3721,26 @@ var M = (function (exports) {
|
|
|
3691
3721
|
this._m = maxMonth;
|
|
3692
3722
|
}
|
|
3693
3723
|
}
|
|
3694
|
-
randId =
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
.substr(0, 2);
|
|
3724
|
+
const randId = 'datepicker-title-' +
|
|
3725
|
+
Math.random()
|
|
3726
|
+
.toString(36)
|
|
3727
|
+
.replace(/[^a-z]+/g, '')
|
|
3728
|
+
.substr(0, 2);
|
|
3700
3729
|
for (let c = 0; c < 1; c++) {
|
|
3701
|
-
this.
|
|
3730
|
+
if (!this.options.isDateRange) {
|
|
3731
|
+
this._renderDateDisplay(this.date);
|
|
3732
|
+
}
|
|
3733
|
+
else {
|
|
3734
|
+
this._renderDateDisplay(this.date, this.endDate);
|
|
3735
|
+
}
|
|
3702
3736
|
html +=
|
|
3703
3737
|
this.renderTitle(this, c, this.calendars[c].year, this.calendars[c].month, this.calendars[0].year, randId) + this.render(this.calendars[c].year, this.calendars[c].month, randId);
|
|
3704
3738
|
}
|
|
3705
3739
|
this.destroySelects();
|
|
3706
3740
|
this.calendarEl.innerHTML = html;
|
|
3707
3741
|
// Init Materialize Select
|
|
3708
|
-
|
|
3709
|
-
|
|
3742
|
+
const yearSelect = this.calendarEl.querySelector('.orig-select-year');
|
|
3743
|
+
const monthSelect = this.calendarEl.querySelector('.orig-select-month');
|
|
3710
3744
|
FormSelect.init(yearSelect, {
|
|
3711
3745
|
classes: 'select-year',
|
|
3712
3746
|
dropdownOptions: { container: document.body, constrainWidth: false }
|
|
@@ -3727,7 +3761,7 @@ var M = (function (exports) {
|
|
|
3727
3761
|
this.el.addEventListener('keydown', this._handleInputKeydown);
|
|
3728
3762
|
this.el.addEventListener('change', this._handleInputChange);
|
|
3729
3763
|
this.calendarEl.addEventListener('click', this._handleCalendarClick);
|
|
3730
|
-
this.doneBtn.addEventListener('click', this.
|
|
3764
|
+
this.doneBtn.addEventListener('click', () => this.setInputValues());
|
|
3731
3765
|
this.cancelBtn.addEventListener('click', this.close);
|
|
3732
3766
|
if (this.options.showClearBtn) {
|
|
3733
3767
|
this.clearBtn.addEventListener('click', this._handleClearClick);
|
|
@@ -3743,40 +3777,41 @@ var M = (function (exports) {
|
|
|
3743
3777
|
if (this.options.showClearBtn) {
|
|
3744
3778
|
this.clearBtn = this.modalEl.querySelector('.datepicker-clear');
|
|
3745
3779
|
}
|
|
3780
|
+
// TODO: This should not be part of the datepicker
|
|
3746
3781
|
this.doneBtn = this.modalEl.querySelector('.datepicker-done');
|
|
3747
3782
|
this.cancelBtn = this.modalEl.querySelector('.datepicker-cancel');
|
|
3748
3783
|
this.formats = {
|
|
3749
|
-
d: () => {
|
|
3750
|
-
return
|
|
3784
|
+
d: (date) => {
|
|
3785
|
+
return date.getDate();
|
|
3751
3786
|
},
|
|
3752
|
-
dd: () => {
|
|
3753
|
-
|
|
3787
|
+
dd: (date) => {
|
|
3788
|
+
const d = date.getDate();
|
|
3754
3789
|
return (d < 10 ? '0' : '') + d;
|
|
3755
3790
|
},
|
|
3756
|
-
ddd: () => {
|
|
3757
|
-
return this.options.i18n.weekdaysShort[
|
|
3791
|
+
ddd: (date) => {
|
|
3792
|
+
return this.options.i18n.weekdaysShort[date.getDay()];
|
|
3758
3793
|
},
|
|
3759
|
-
dddd: () => {
|
|
3760
|
-
return this.options.i18n.weekdays[
|
|
3794
|
+
dddd: (date) => {
|
|
3795
|
+
return this.options.i18n.weekdays[date.getDay()];
|
|
3761
3796
|
},
|
|
3762
|
-
m: () => {
|
|
3763
|
-
return
|
|
3797
|
+
m: (date) => {
|
|
3798
|
+
return date.getMonth() + 1;
|
|
3764
3799
|
},
|
|
3765
|
-
mm: () => {
|
|
3766
|
-
|
|
3800
|
+
mm: (date) => {
|
|
3801
|
+
const m = date.getMonth() + 1;
|
|
3767
3802
|
return (m < 10 ? '0' : '') + m;
|
|
3768
3803
|
},
|
|
3769
|
-
mmm: () => {
|
|
3770
|
-
return this.options.i18n.monthsShort[
|
|
3804
|
+
mmm: (date) => {
|
|
3805
|
+
return this.options.i18n.monthsShort[date.getMonth()];
|
|
3771
3806
|
},
|
|
3772
|
-
mmmm: () => {
|
|
3773
|
-
return this.options.i18n.months[
|
|
3807
|
+
mmmm: (date) => {
|
|
3808
|
+
return this.options.i18n.months[date.getMonth()];
|
|
3774
3809
|
},
|
|
3775
|
-
yy: () => {
|
|
3776
|
-
return ('' +
|
|
3810
|
+
yy: (date) => {
|
|
3811
|
+
return ('' + date.getFullYear()).slice(2);
|
|
3777
3812
|
},
|
|
3778
|
-
yyyy: () => {
|
|
3779
|
-
return
|
|
3813
|
+
yyyy: (date) => {
|
|
3814
|
+
return date.getFullYear();
|
|
3780
3815
|
}
|
|
3781
3816
|
};
|
|
3782
3817
|
}
|
|
@@ -3785,28 +3820,42 @@ var M = (function (exports) {
|
|
|
3785
3820
|
this.el.removeEventListener('keydown', this._handleInputKeydown);
|
|
3786
3821
|
this.el.removeEventListener('change', this._handleInputChange);
|
|
3787
3822
|
this.calendarEl.removeEventListener('click', this._handleCalendarClick);
|
|
3823
|
+
if (this.options.isDateRange) {
|
|
3824
|
+
this.endDateEl.removeEventListener('click', this._handleInputClick);
|
|
3825
|
+
this.endDateEl.removeEventListener('keypress', this._handleInputKeydown);
|
|
3826
|
+
this.endDateEl.removeEventListener('change', this._handleInputChange);
|
|
3827
|
+
}
|
|
3788
3828
|
}
|
|
3789
|
-
_handleInputClick = () => {
|
|
3790
|
-
|
|
3829
|
+
_handleInputClick = (e) => {
|
|
3830
|
+
// Prevents default browser datepicker modal rendering
|
|
3831
|
+
if (e.type == 'date') {
|
|
3832
|
+
e.preventDefault();
|
|
3833
|
+
}
|
|
3834
|
+
this.setDateFromInput(e.target);
|
|
3835
|
+
this.draw();
|
|
3836
|
+
this.gotoDate(e.target === this.el ? this.date : this.endDate);
|
|
3791
3837
|
};
|
|
3792
3838
|
_handleInputKeydown = (e) => {
|
|
3793
3839
|
if (Utils.keys.ENTER.includes(e.key)) {
|
|
3794
3840
|
e.preventDefault();
|
|
3795
|
-
this.
|
|
3841
|
+
this.setDateFromInput(e.target);
|
|
3842
|
+
this.draw();
|
|
3796
3843
|
}
|
|
3797
3844
|
};
|
|
3798
3845
|
_handleCalendarClick = (e) => {
|
|
3799
|
-
|
|
3800
|
-
return;
|
|
3801
|
-
const target = (e.target);
|
|
3846
|
+
const target = e.target;
|
|
3802
3847
|
if (!target.classList.contains('is-disabled')) {
|
|
3803
3848
|
if (target.classList.contains('datepicker-day-button') &&
|
|
3804
3849
|
!target.classList.contains('is-empty') &&
|
|
3805
3850
|
!target.parentElement.classList.contains('is-disabled')) {
|
|
3806
|
-
|
|
3807
|
-
if (this.options.
|
|
3808
|
-
this.
|
|
3851
|
+
const selectedDate = new Date(e.target.getAttribute('data-year'), e.target.getAttribute('data-month'), e.target.getAttribute('data-day'));
|
|
3852
|
+
if (!this.multiple || (this.multiple && this.options.isMultipleSelection)) {
|
|
3853
|
+
this.setDate(selectedDate);
|
|
3809
3854
|
}
|
|
3855
|
+
if (this.options.isDateRange) {
|
|
3856
|
+
this._handleDateRangeCalendarClick(selectedDate);
|
|
3857
|
+
}
|
|
3858
|
+
this._finishSelection();
|
|
3810
3859
|
}
|
|
3811
3860
|
else if (target.closest('.month-prev')) {
|
|
3812
3861
|
this.prevMonth();
|
|
@@ -3816,10 +3865,24 @@ var M = (function (exports) {
|
|
|
3816
3865
|
}
|
|
3817
3866
|
}
|
|
3818
3867
|
};
|
|
3868
|
+
_handleDateRangeCalendarClick = (date) => {
|
|
3869
|
+
if (this.endDate == null || !Datepicker._compareDates(date, this.endDate)) {
|
|
3870
|
+
if (Datepicker._isDate(this.date) && Datepicker._comparePastDate(date, this.date)) {
|
|
3871
|
+
return;
|
|
3872
|
+
}
|
|
3873
|
+
this.setDate(date, false, Datepicker._isDate(this.date));
|
|
3874
|
+
return;
|
|
3875
|
+
}
|
|
3876
|
+
this._clearDates();
|
|
3877
|
+
this.draw();
|
|
3878
|
+
};
|
|
3819
3879
|
_handleClearClick = () => {
|
|
3880
|
+
this._clearDates();
|
|
3881
|
+
this.setInputValues();
|
|
3882
|
+
};
|
|
3883
|
+
_clearDates = () => {
|
|
3820
3884
|
this.date = null;
|
|
3821
|
-
this.
|
|
3822
|
-
this.close();
|
|
3885
|
+
this.endDate = null;
|
|
3823
3886
|
};
|
|
3824
3887
|
_handleMonthChange = (e) => {
|
|
3825
3888
|
this.gotoMonth(e.target.value);
|
|
@@ -3843,19 +3906,28 @@ var M = (function (exports) {
|
|
|
3843
3906
|
}
|
|
3844
3907
|
_handleInputChange = (e) => {
|
|
3845
3908
|
let date;
|
|
3909
|
+
const el = e.target;
|
|
3846
3910
|
// Prevent change event from being fired when triggered by the plugin
|
|
3847
3911
|
if (e['detail']?.firedBy === this)
|
|
3848
3912
|
return;
|
|
3913
|
+
// Prevent change event from being fired if an end date is set without a start date
|
|
3914
|
+
if (el == this.endDateEl && !this.date)
|
|
3915
|
+
return;
|
|
3849
3916
|
if (this.options.parse) {
|
|
3850
|
-
date = this.options.parse(
|
|
3917
|
+
date = this.options.parse(e.target.value, typeof this.options.format === 'function'
|
|
3851
3918
|
? this.options.format(new Date(this.el.value))
|
|
3852
3919
|
: this.options.format);
|
|
3853
3920
|
}
|
|
3854
3921
|
else {
|
|
3855
|
-
date = new Date(Date.parse(
|
|
3922
|
+
date = new Date(Date.parse(e.target.value));
|
|
3923
|
+
}
|
|
3924
|
+
if (Datepicker._isDate(date)) {
|
|
3925
|
+
this.setDate(date, false, el == this.endDateEl, true);
|
|
3926
|
+
if (e.type == 'date') {
|
|
3927
|
+
this.setDataDate(e, date);
|
|
3928
|
+
this.setInputValues();
|
|
3929
|
+
}
|
|
3856
3930
|
}
|
|
3857
|
-
if (Datepicker._isDate(date))
|
|
3858
|
-
this.setDate(date);
|
|
3859
3931
|
};
|
|
3860
3932
|
renderDayName(opts, day, abbr = false) {
|
|
3861
3933
|
day += opts.firstDay;
|
|
@@ -3864,41 +3936,31 @@ var M = (function (exports) {
|
|
|
3864
3936
|
}
|
|
3865
3937
|
return abbr ? opts.i18n.weekdaysAbbrev[day] : opts.i18n.weekdays[day];
|
|
3866
3938
|
}
|
|
3939
|
+
createDateInput() {
|
|
3940
|
+
const dateInput = this.el.cloneNode(true);
|
|
3941
|
+
dateInput.addEventListener('click', this._handleInputClick);
|
|
3942
|
+
dateInput.addEventListener('keypress', this._handleInputKeydown);
|
|
3943
|
+
dateInput.addEventListener('change', this._handleInputChange);
|
|
3944
|
+
this.el.parentElement.appendChild(dateInput);
|
|
3945
|
+
return dateInput;
|
|
3946
|
+
}
|
|
3867
3947
|
// Set input value to the selected date and close Datepicker
|
|
3868
3948
|
_finishSelection = () => {
|
|
3869
|
-
this.
|
|
3949
|
+
this.setInputValues();
|
|
3870
3950
|
this.close();
|
|
3871
3951
|
};
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
open = () => {
|
|
3876
|
-
if (this.isOpen)
|
|
3877
|
-
return;
|
|
3878
|
-
this.isOpen = true;
|
|
3879
|
-
if (typeof this.options.onOpen === 'function') {
|
|
3880
|
-
this.options.onOpen.call(this);
|
|
3881
|
-
}
|
|
3882
|
-
this.draw();
|
|
3883
|
-
this.modal.open(undefined);
|
|
3952
|
+
// deprecated
|
|
3953
|
+
open() {
|
|
3954
|
+
console.warn('Datepicker.open() is deprecated. Remove this method and wrap in modal yourself.');
|
|
3884
3955
|
return this;
|
|
3885
|
-
}
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
*/
|
|
3889
|
-
close = () => {
|
|
3890
|
-
if (!this.isOpen)
|
|
3891
|
-
return;
|
|
3892
|
-
this.isOpen = false;
|
|
3893
|
-
if (typeof this.options.onClose === 'function') {
|
|
3894
|
-
this.options.onClose.call(this);
|
|
3895
|
-
}
|
|
3896
|
-
this.modal.close();
|
|
3956
|
+
}
|
|
3957
|
+
close() {
|
|
3958
|
+
console.warn('Datepicker.close() is deprecated. Remove this method and wrap in modal yourself.');
|
|
3897
3959
|
return this;
|
|
3898
|
-
}
|
|
3960
|
+
}
|
|
3899
3961
|
static {
|
|
3900
3962
|
Datepicker._template = `
|
|
3901
|
-
<div class="
|
|
3963
|
+
<div class="datepicker-modal">
|
|
3902
3964
|
<div class="modal-content datepicker-container">
|
|
3903
3965
|
<div class="datepicker-date-display">
|
|
3904
3966
|
<span class="year-text"></span>
|
|
@@ -3921,15 +3983,46 @@ var M = (function (exports) {
|
|
|
3921
3983
|
|
|
3922
3984
|
class Forms {
|
|
3923
3985
|
/**
|
|
3924
|
-
*
|
|
3925
|
-
*
|
|
3926
|
-
* @param
|
|
3986
|
+
* Checks if the label has validation and apply
|
|
3987
|
+
* the correct class and styles
|
|
3988
|
+
* @param textfield
|
|
3927
3989
|
*/
|
|
3928
|
-
static
|
|
3929
|
-
if (!
|
|
3930
|
-
console.error('No
|
|
3990
|
+
static validateField(textfield) {
|
|
3991
|
+
if (!textfield) {
|
|
3992
|
+
console.error('No text field element found');
|
|
3931
3993
|
return;
|
|
3932
3994
|
}
|
|
3995
|
+
const hasLength = textfield.getAttribute('data-length') !== null;
|
|
3996
|
+
const lenAttr = parseInt(textfield.getAttribute('data-length'));
|
|
3997
|
+
const len = textfield.value.length;
|
|
3998
|
+
if (len === 0 &&
|
|
3999
|
+
textfield.validity.badInput === false &&
|
|
4000
|
+
!textfield.required &&
|
|
4001
|
+
textfield.classList.contains('validate')) {
|
|
4002
|
+
textfield.classList.remove('invalid');
|
|
4003
|
+
}
|
|
4004
|
+
else if (textfield.classList.contains('validate')) {
|
|
4005
|
+
// Check for character counter attributes
|
|
4006
|
+
if ((textfield.validity.valid && hasLength && len <= lenAttr) ||
|
|
4007
|
+
(textfield.validity.valid && !hasLength)) {
|
|
4008
|
+
textfield.classList.remove('invalid');
|
|
4009
|
+
}
|
|
4010
|
+
else {
|
|
4011
|
+
textfield.classList.add('invalid');
|
|
4012
|
+
}
|
|
4013
|
+
}
|
|
4014
|
+
}
|
|
4015
|
+
/**
|
|
4016
|
+
* Resizes the given TextArea after updating the
|
|
4017
|
+
* value content dynamically.
|
|
4018
|
+
* @param e EventTarget
|
|
4019
|
+
*/
|
|
4020
|
+
static textareaAutoResize(e) {
|
|
4021
|
+
const textarea = e;
|
|
4022
|
+
// if (!textarea) {
|
|
4023
|
+
// console.error('No textarea element found');
|
|
4024
|
+
// return;
|
|
4025
|
+
// }
|
|
3933
4026
|
// Textarea Auto Resize
|
|
3934
4027
|
let hiddenDiv = document.querySelector('.hiddendiv');
|
|
3935
4028
|
if (!hiddenDiv) {
|
|
@@ -3969,15 +4062,14 @@ var M = (function (exports) {
|
|
|
3969
4062
|
hiddenDiv.style.whiteSpace = 'pre'; //.css('white-space', 'pre');
|
|
3970
4063
|
}
|
|
3971
4064
|
hiddenDiv.innerText = textarea.value + '\n';
|
|
3972
|
-
|
|
3973
|
-
hiddenDiv.innerHTML = content;
|
|
4065
|
+
hiddenDiv.innerHTML = hiddenDiv.innerHTML.replace(/\n/g, '<br>');
|
|
3974
4066
|
// When textarea is hidden, width goes crazy.
|
|
3975
4067
|
// Approximate with half of window size
|
|
3976
4068
|
if (textarea.offsetWidth > 0 && textarea.offsetHeight > 0) {
|
|
3977
4069
|
hiddenDiv.style.width = textarea.getBoundingClientRect().width + 'px'; // ('width', textarea.width() + 'px');
|
|
3978
4070
|
}
|
|
3979
4071
|
else {
|
|
3980
|
-
hiddenDiv.style.width =
|
|
4072
|
+
hiddenDiv.style.width = window.innerWidth / 2 + 'px'; //css('width', window.innerWidth / 2 + 'px');
|
|
3981
4073
|
}
|
|
3982
4074
|
// Resize if the new height is greater than the
|
|
3983
4075
|
// original height of the textarea
|
|
@@ -3996,10 +4088,22 @@ var M = (function (exports) {
|
|
|
3996
4088
|
}
|
|
3997
4089
|
textarea.setAttribute('previous-length', textarea.value.length.toString());
|
|
3998
4090
|
}
|
|
3999
|
-
;
|
|
4000
4091
|
static Init() {
|
|
4001
4092
|
if (typeof document !== 'undefined')
|
|
4002
|
-
document?.addEventListener(
|
|
4093
|
+
document?.addEventListener('DOMContentLoaded', () => {
|
|
4094
|
+
document.addEventListener('change', (e) => {
|
|
4095
|
+
const target = e.target;
|
|
4096
|
+
if (target instanceof HTMLInputElement) {
|
|
4097
|
+
if (target.value.length !== 0 || target.getAttribute('placeholder') !== null) {
|
|
4098
|
+
for (const child of target.parentNode.children) {
|
|
4099
|
+
if (child.tagName == 'label') {
|
|
4100
|
+
child.classList.add('active');
|
|
4101
|
+
}
|
|
4102
|
+
}
|
|
4103
|
+
}
|
|
4104
|
+
Forms.validateField(target);
|
|
4105
|
+
}
|
|
4106
|
+
});
|
|
4003
4107
|
document.addEventListener('keyup', (e) => {
|
|
4004
4108
|
const target = e.target;
|
|
4005
4109
|
// Radio and Checkbox focus class
|
|
@@ -4007,15 +4111,21 @@ var M = (function (exports) {
|
|
|
4007
4111
|
// TAB, check if tabbing to radio or checkbox.
|
|
4008
4112
|
if (Utils.keys.TAB.includes(e.key)) {
|
|
4009
4113
|
target.classList.add('tabbed');
|
|
4010
|
-
target.addEventListener('blur',
|
|
4114
|
+
target.addEventListener('blur', () => target.classList.remove('tabbed'), {
|
|
4115
|
+
once: true
|
|
4116
|
+
});
|
|
4011
4117
|
}
|
|
4012
4118
|
}
|
|
4013
4119
|
});
|
|
4014
|
-
document
|
|
4120
|
+
document
|
|
4121
|
+
.querySelectorAll('.materialize-textarea')
|
|
4122
|
+
.forEach((textArea) => {
|
|
4015
4123
|
Forms.InitTextarea(textArea);
|
|
4016
4124
|
});
|
|
4017
4125
|
// File Input Path
|
|
4018
|
-
document
|
|
4126
|
+
document
|
|
4127
|
+
.querySelectorAll('.file-field input[type="file"]')
|
|
4128
|
+
.forEach((fileInput) => {
|
|
4019
4129
|
Forms.InitFileInputPath(fileInput);
|
|
4020
4130
|
});
|
|
4021
4131
|
});
|
|
@@ -4025,11 +4135,11 @@ var M = (function (exports) {
|
|
|
4025
4135
|
textarea.setAttribute('original-height', textarea.getBoundingClientRect().height.toString());
|
|
4026
4136
|
textarea.setAttribute('previous-length', textarea.value.length.toString());
|
|
4027
4137
|
Forms.textareaAutoResize(textarea);
|
|
4028
|
-
textarea.addEventListener('keyup', e => Forms.textareaAutoResize(
|
|
4029
|
-
textarea.addEventListener('keydown', e => Forms.textareaAutoResize(
|
|
4138
|
+
textarea.addEventListener('keyup', (e) => Forms.textareaAutoResize(e.target));
|
|
4139
|
+
textarea.addEventListener('keydown', (e) => Forms.textareaAutoResize(e.target));
|
|
4030
4140
|
}
|
|
4031
4141
|
static InitFileInputPath(fileInput) {
|
|
4032
|
-
fileInput.addEventListener('change',
|
|
4142
|
+
fileInput.addEventListener('change', () => {
|
|
4033
4143
|
const fileField = fileInput.closest('.file-field');
|
|
4034
4144
|
const pathInput = fileField.querySelector('input.file-path');
|
|
4035
4145
|
const files = fileInput.files;
|
|
@@ -4043,7 +4153,7 @@ var M = (function (exports) {
|
|
|
4043
4153
|
}
|
|
4044
4154
|
}
|
|
4045
4155
|
|
|
4046
|
-
const _defaults$
|
|
4156
|
+
const _defaults$d = {
|
|
4047
4157
|
inDuration: 275,
|
|
4048
4158
|
outDuration: 200,
|
|
4049
4159
|
onOpenStart: null,
|
|
@@ -4075,7 +4185,7 @@ var M = (function (exports) {
|
|
|
4075
4185
|
_photoCaption;
|
|
4076
4186
|
constructor(el, options) {
|
|
4077
4187
|
super(el, options, Materialbox);
|
|
4078
|
-
this.el
|
|
4188
|
+
this.el['M_Materialbox'] = this;
|
|
4079
4189
|
this.options = {
|
|
4080
4190
|
...Materialbox.defaults,
|
|
4081
4191
|
...options
|
|
@@ -4088,13 +4198,14 @@ var M = (function (exports) {
|
|
|
4088
4198
|
this.originalHeight = 0;
|
|
4089
4199
|
this.originInlineStyles = this.el.getAttribute('style');
|
|
4090
4200
|
this.caption = this.el.getAttribute('data-caption') || '';
|
|
4201
|
+
this.el.tabIndex = 0;
|
|
4091
4202
|
// Wrap
|
|
4092
4203
|
this.el.before(this.placeholder);
|
|
4093
4204
|
this.placeholder.append(this.el);
|
|
4094
4205
|
this._setupEventHandlers();
|
|
4095
4206
|
}
|
|
4096
4207
|
static get defaults() {
|
|
4097
|
-
return _defaults$
|
|
4208
|
+
return _defaults$d;
|
|
4098
4209
|
}
|
|
4099
4210
|
/**
|
|
4100
4211
|
* Initializes instances of MaterialBox.
|
|
@@ -4105,11 +4216,11 @@ var M = (function (exports) {
|
|
|
4105
4216
|
return super.init(els, options, Materialbox);
|
|
4106
4217
|
}
|
|
4107
4218
|
static getInstance(el) {
|
|
4108
|
-
return el
|
|
4219
|
+
return el['M_Materialbox'];
|
|
4109
4220
|
}
|
|
4110
4221
|
destroy() {
|
|
4111
4222
|
this._removeEventHandlers();
|
|
4112
|
-
this.el
|
|
4223
|
+
this.el['M_Materialbox'] = undefined;
|
|
4113
4224
|
// Unwrap image
|
|
4114
4225
|
//this.placeholder.after(this.el).remove();
|
|
4115
4226
|
this.placeholder.remove();
|
|
@@ -4117,11 +4228,21 @@ var M = (function (exports) {
|
|
|
4117
4228
|
}
|
|
4118
4229
|
_setupEventHandlers() {
|
|
4119
4230
|
this.el.addEventListener('click', this._handleMaterialboxClick);
|
|
4231
|
+
this.el.addEventListener('keypress', this._handleMaterialboxKeypress);
|
|
4120
4232
|
}
|
|
4121
4233
|
_removeEventHandlers() {
|
|
4122
4234
|
this.el.removeEventListener('click', this._handleMaterialboxClick);
|
|
4235
|
+
this.el.removeEventListener('keypress', this._handleMaterialboxKeypress);
|
|
4123
4236
|
}
|
|
4124
4237
|
_handleMaterialboxClick = () => {
|
|
4238
|
+
this._handleMaterialboxToggle();
|
|
4239
|
+
};
|
|
4240
|
+
_handleMaterialboxKeypress = (e) => {
|
|
4241
|
+
if (Utils.keys.ENTER.includes(e.key)) {
|
|
4242
|
+
this._handleMaterialboxToggle();
|
|
4243
|
+
}
|
|
4244
|
+
};
|
|
4245
|
+
_handleMaterialboxToggle = () => {
|
|
4125
4246
|
// If already modal, return to original
|
|
4126
4247
|
if (this.doneAnimating === false || (this.overlayActive && this.doneAnimating))
|
|
4127
4248
|
this.close();
|
|
@@ -4156,8 +4277,8 @@ var M = (function (exports) {
|
|
|
4156
4277
|
const box = el.getBoundingClientRect();
|
|
4157
4278
|
const docElem = document.documentElement;
|
|
4158
4279
|
return {
|
|
4159
|
-
top: box.top + window.
|
|
4160
|
-
left: box.left + window.
|
|
4280
|
+
top: box.top + window.scrollY - docElem.clientTop,
|
|
4281
|
+
left: box.left + window.scrollX - docElem.clientLeft
|
|
4161
4282
|
};
|
|
4162
4283
|
}
|
|
4163
4284
|
_updateVars() {
|
|
@@ -4184,14 +4305,18 @@ var M = (function (exports) {
|
|
|
4184
4305
|
// to
|
|
4185
4306
|
this.el.style.height = this.newHeight + 'px';
|
|
4186
4307
|
this.el.style.width = this.newWidth + 'px';
|
|
4187
|
-
this.el.style.left =
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4308
|
+
this.el.style.left =
|
|
4309
|
+
Utils.getDocumentScrollLeft() +
|
|
4310
|
+
this.windowWidth / 2 -
|
|
4311
|
+
this._offset(this.placeholder).left -
|
|
4312
|
+
this.newWidth / 2 +
|
|
4313
|
+
'px';
|
|
4314
|
+
this.el.style.top =
|
|
4315
|
+
Utils.getDocumentScrollTop() +
|
|
4316
|
+
this.windowHeight / 2 -
|
|
4317
|
+
this._offset(this.placeholder).top -
|
|
4318
|
+
this.newHeight / 2 +
|
|
4319
|
+
'px';
|
|
4195
4320
|
}, 1);
|
|
4196
4321
|
setTimeout(() => {
|
|
4197
4322
|
this.doneAnimating = true;
|
|
@@ -4248,12 +4373,13 @@ var M = (function (exports) {
|
|
|
4248
4373
|
if (this.attrHeight)
|
|
4249
4374
|
this.el.setAttribute('height', this.attrHeight.toString());
|
|
4250
4375
|
this.el.removeAttribute('style');
|
|
4251
|
-
|
|
4376
|
+
if (this.originInlineStyles)
|
|
4377
|
+
this.el.setAttribute('style', this.originInlineStyles);
|
|
4252
4378
|
// Remove class
|
|
4253
4379
|
this.el.classList.remove('active');
|
|
4254
4380
|
this.doneAnimating = true;
|
|
4255
4381
|
// Remove overflow overrides on ancestors
|
|
4256
|
-
this._changedAncestorList.forEach(anchestor => anchestor.style.overflow = '');
|
|
4382
|
+
this._changedAncestorList.forEach((anchestor) => (anchestor.style.overflow = ''));
|
|
4257
4383
|
// onCloseEnd callback
|
|
4258
4384
|
if (typeof this.options.onCloseEnd === 'function')
|
|
4259
4385
|
this.options.onCloseEnd.call(this, this.el);
|
|
@@ -4287,7 +4413,7 @@ var M = (function (exports) {
|
|
|
4287
4413
|
_addOverlay() {
|
|
4288
4414
|
this._overlay = document.createElement('div');
|
|
4289
4415
|
this._overlay.id = 'materialbox-overlay';
|
|
4290
|
-
this._overlay.addEventListener('click',
|
|
4416
|
+
this._overlay.addEventListener('click', () => {
|
|
4291
4417
|
if (this.doneAnimating)
|
|
4292
4418
|
this.close();
|
|
4293
4419
|
}, { once: true });
|
|
@@ -4403,7 +4529,75 @@ var M = (function (exports) {
|
|
|
4403
4529
|
};
|
|
4404
4530
|
}
|
|
4405
4531
|
|
|
4406
|
-
|
|
4532
|
+
const _defaults$c = {
|
|
4533
|
+
opacity: 0.5,
|
|
4534
|
+
inDuration: 250,
|
|
4535
|
+
outDuration: 250,
|
|
4536
|
+
onOpenStart: null,
|
|
4537
|
+
onOpenEnd: null,
|
|
4538
|
+
onCloseStart: null,
|
|
4539
|
+
onCloseEnd: null,
|
|
4540
|
+
preventScrolling: true,
|
|
4541
|
+
dismissible: true,
|
|
4542
|
+
startingTop: '4%',
|
|
4543
|
+
endingTop: '10%'
|
|
4544
|
+
};
|
|
4545
|
+
class Modal extends Component {
|
|
4546
|
+
constructor(el, options) {
|
|
4547
|
+
super(el, options, Modal);
|
|
4548
|
+
this.el['M_Modal'] = this;
|
|
4549
|
+
this.options = {
|
|
4550
|
+
...Modal.defaults,
|
|
4551
|
+
...options
|
|
4552
|
+
};
|
|
4553
|
+
this.el.tabIndex = 0;
|
|
4554
|
+
this._setupEventHandlers();
|
|
4555
|
+
}
|
|
4556
|
+
static get defaults() {
|
|
4557
|
+
return _defaults$c;
|
|
4558
|
+
}
|
|
4559
|
+
static init(els, options = {}) {
|
|
4560
|
+
return super.init(els, options, Modal);
|
|
4561
|
+
}
|
|
4562
|
+
static getInstance(el) {
|
|
4563
|
+
return el['M_Modal'];
|
|
4564
|
+
}
|
|
4565
|
+
destroy() { }
|
|
4566
|
+
_setupEventHandlers() { }
|
|
4567
|
+
_removeEventHandlers() { }
|
|
4568
|
+
_handleTriggerClick() { }
|
|
4569
|
+
_handleOverlayClick() { }
|
|
4570
|
+
_handleModalCloseClick() { }
|
|
4571
|
+
_handleKeydown() { }
|
|
4572
|
+
_handleFocus() { }
|
|
4573
|
+
open() {
|
|
4574
|
+
return this;
|
|
4575
|
+
}
|
|
4576
|
+
close() {
|
|
4577
|
+
return this;
|
|
4578
|
+
}
|
|
4579
|
+
// Experimental!
|
|
4580
|
+
static #createHtml(config) {
|
|
4581
|
+
return `<dialog id="modal1" class="modal">
|
|
4582
|
+
${config.header ? '<div class="modal-header">' + config.header + '</div>' : ''}
|
|
4583
|
+
<div class="modal-content">
|
|
4584
|
+
${config.content}
|
|
4585
|
+
</div>
|
|
4586
|
+
${config.header ? '<div class="modal-footer">' + config.footer + '</div>' : ''}
|
|
4587
|
+
</dialog>`;
|
|
4588
|
+
}
|
|
4589
|
+
static #createHtmlElement(config) {
|
|
4590
|
+
const dialog = document.createElement('dialog');
|
|
4591
|
+
dialog.id = config.id;
|
|
4592
|
+
return dialog;
|
|
4593
|
+
}
|
|
4594
|
+
static create(config) {
|
|
4595
|
+
return this.#createHtmlElement(config);
|
|
4596
|
+
}
|
|
4597
|
+
static { }
|
|
4598
|
+
}
|
|
4599
|
+
|
|
4600
|
+
const _defaults$b = {
|
|
4407
4601
|
responsiveThreshold: 0 // breakpoint for swipeable
|
|
4408
4602
|
};
|
|
4409
4603
|
class Parallax extends Component {
|
|
@@ -4414,7 +4608,7 @@ var M = (function (exports) {
|
|
|
4414
4608
|
static _handleWindowResizeThrottled;
|
|
4415
4609
|
constructor(el, options) {
|
|
4416
4610
|
super(el, options, Parallax);
|
|
4417
|
-
this.el
|
|
4611
|
+
this.el['M_Parallax'] = this;
|
|
4418
4612
|
this.options = {
|
|
4419
4613
|
...Parallax.defaults,
|
|
4420
4614
|
...options
|
|
@@ -4438,25 +4632,24 @@ var M = (function (exports) {
|
|
|
4438
4632
|
return super.init(els, options, Parallax);
|
|
4439
4633
|
}
|
|
4440
4634
|
static getInstance(el) {
|
|
4441
|
-
return el
|
|
4635
|
+
return el['M_Parallax'];
|
|
4442
4636
|
}
|
|
4443
4637
|
destroy() {
|
|
4444
4638
|
Parallax._parallaxes.splice(Parallax._parallaxes.indexOf(this), 1);
|
|
4445
4639
|
this._img.style.transform = '';
|
|
4446
4640
|
this._removeEventHandlers();
|
|
4447
|
-
this.el
|
|
4641
|
+
this.el['M_Parallax'] = undefined;
|
|
4448
4642
|
}
|
|
4449
4643
|
static _handleScroll() {
|
|
4450
4644
|
for (let i = 0; i < Parallax._parallaxes.length; i++) {
|
|
4451
|
-
|
|
4645
|
+
const parallaxInstance = Parallax._parallaxes[i];
|
|
4452
4646
|
parallaxInstance._updateParallax.call(parallaxInstance);
|
|
4453
4647
|
}
|
|
4454
4648
|
}
|
|
4455
4649
|
static _handleWindowResize() {
|
|
4456
4650
|
for (let i = 0; i < Parallax._parallaxes.length; i++) {
|
|
4457
|
-
|
|
4458
|
-
parallaxInstance._enabled =
|
|
4459
|
-
window.innerWidth > parallaxInstance.options.responsiveThreshold;
|
|
4651
|
+
const parallaxInstance = Parallax._parallaxes[i];
|
|
4652
|
+
parallaxInstance._enabled = window.innerWidth > parallaxInstance.options.responsiveThreshold;
|
|
4460
4653
|
}
|
|
4461
4654
|
}
|
|
4462
4655
|
_setupEventHandlers() {
|
|
@@ -4489,12 +4682,12 @@ var M = (function (exports) {
|
|
|
4489
4682
|
const box = el.getBoundingClientRect();
|
|
4490
4683
|
const docElem = document.documentElement;
|
|
4491
4684
|
return {
|
|
4492
|
-
top: box.top + window.
|
|
4493
|
-
left: box.left + window.
|
|
4685
|
+
top: box.top + window.scrollY - docElem.clientTop,
|
|
4686
|
+
left: box.left + window.scrollX - docElem.clientLeft
|
|
4494
4687
|
};
|
|
4495
4688
|
}
|
|
4496
4689
|
_updateParallax() {
|
|
4497
|
-
const containerHeight = this.el.getBoundingClientRect().height > 0 ? this.el.
|
|
4690
|
+
const containerHeight = this.el.getBoundingClientRect().height > 0 ? this.el.parentElement.offsetHeight : 500;
|
|
4498
4691
|
const imgHeight = this._img.offsetHeight;
|
|
4499
4692
|
const parallaxDist = imgHeight - containerHeight;
|
|
4500
4693
|
const bottom = this._offset(this.el).top + containerHeight;
|
|
@@ -4513,7 +4706,7 @@ var M = (function (exports) {
|
|
|
4513
4706
|
}
|
|
4514
4707
|
}
|
|
4515
4708
|
|
|
4516
|
-
|
|
4709
|
+
const _defaults$a = {
|
|
4517
4710
|
top: 0,
|
|
4518
4711
|
bottom: Infinity,
|
|
4519
4712
|
offset: 0,
|
|
@@ -4524,7 +4717,7 @@ var M = (function (exports) {
|
|
|
4524
4717
|
originalOffset;
|
|
4525
4718
|
constructor(el, options) {
|
|
4526
4719
|
super(el, options, Pushpin);
|
|
4527
|
-
this.el
|
|
4720
|
+
this.el['M_Pushpin'] = this;
|
|
4528
4721
|
this.options = {
|
|
4529
4722
|
...Pushpin.defaults,
|
|
4530
4723
|
...options
|
|
@@ -4546,22 +4739,22 @@ var M = (function (exports) {
|
|
|
4546
4739
|
return super.init(els, options, Pushpin);
|
|
4547
4740
|
}
|
|
4548
4741
|
static getInstance(el) {
|
|
4549
|
-
return el
|
|
4742
|
+
return el['M_Pushpin'];
|
|
4550
4743
|
}
|
|
4551
4744
|
destroy() {
|
|
4552
4745
|
this.el.style.top = null;
|
|
4553
4746
|
this._removePinClasses();
|
|
4554
4747
|
// Remove pushpin Inst
|
|
4555
|
-
|
|
4748
|
+
const index = Pushpin._pushpins.indexOf(this);
|
|
4556
4749
|
Pushpin._pushpins.splice(index, 1);
|
|
4557
4750
|
if (Pushpin._pushpins.length === 0) {
|
|
4558
4751
|
this._removeEventHandlers();
|
|
4559
4752
|
}
|
|
4560
|
-
this.el
|
|
4753
|
+
this.el['M_Pushpin'] = undefined;
|
|
4561
4754
|
}
|
|
4562
4755
|
static _updateElements() {
|
|
4563
|
-
for (
|
|
4564
|
-
|
|
4756
|
+
for (const elIndex in Pushpin._pushpins) {
|
|
4757
|
+
const pInstance = Pushpin._pushpins[elIndex];
|
|
4565
4758
|
pInstance._updatePosition();
|
|
4566
4759
|
}
|
|
4567
4760
|
}
|
|
@@ -4572,7 +4765,7 @@ var M = (function (exports) {
|
|
|
4572
4765
|
document.removeEventListener('scroll', Pushpin._updateElements);
|
|
4573
4766
|
}
|
|
4574
4767
|
_updatePosition() {
|
|
4575
|
-
|
|
4768
|
+
const scrolled = Utils.getDocumentScrollTop() + this.options.offset;
|
|
4576
4769
|
if (this.options.top <= scrolled &&
|
|
4577
4770
|
this.options.bottom >= scrolled &&
|
|
4578
4771
|
!this.el.classList.contains('pinned')) {
|
|
@@ -4616,24 +4809,29 @@ var M = (function (exports) {
|
|
|
4616
4809
|
}
|
|
4617
4810
|
}
|
|
4618
4811
|
|
|
4619
|
-
|
|
4812
|
+
const _defaults$9 = {
|
|
4620
4813
|
throttle: 100,
|
|
4621
4814
|
scrollOffset: 200, // offset - 200 allows elements near bottom of page to scroll
|
|
4622
4815
|
activeClass: 'active',
|
|
4623
|
-
getActiveElement: (id) => {
|
|
4816
|
+
getActiveElement: (id) => {
|
|
4817
|
+
return 'a[href="#' + id + '"]';
|
|
4818
|
+
},
|
|
4819
|
+
keepTopElementActive: false,
|
|
4820
|
+
animationDuration: null
|
|
4624
4821
|
};
|
|
4625
4822
|
class ScrollSpy extends Component {
|
|
4626
4823
|
static _elements;
|
|
4627
4824
|
static _count;
|
|
4628
4825
|
static _increment;
|
|
4629
|
-
tickId;
|
|
4630
|
-
id;
|
|
4631
4826
|
static _elementsInView;
|
|
4632
4827
|
static _visibleElements;
|
|
4633
4828
|
static _ticks;
|
|
4829
|
+
static _keptTopActiveElement = null;
|
|
4830
|
+
tickId;
|
|
4831
|
+
id;
|
|
4634
4832
|
constructor(el, options) {
|
|
4635
4833
|
super(el, options, ScrollSpy);
|
|
4636
|
-
this.el
|
|
4834
|
+
this.el['M_ScrollSpy'] = this;
|
|
4637
4835
|
this.options = {
|
|
4638
4836
|
...ScrollSpy.defaults,
|
|
4639
4837
|
...options
|
|
@@ -4642,7 +4840,7 @@ var M = (function (exports) {
|
|
|
4642
4840
|
ScrollSpy._count++;
|
|
4643
4841
|
ScrollSpy._increment++;
|
|
4644
4842
|
this.tickId = -1;
|
|
4645
|
-
this.id = ScrollSpy._increment;
|
|
4843
|
+
this.id = ScrollSpy._increment.toString();
|
|
4646
4844
|
this._setupEventHandlers();
|
|
4647
4845
|
this._handleWindowScroll();
|
|
4648
4846
|
}
|
|
@@ -4658,7 +4856,7 @@ var M = (function (exports) {
|
|
|
4658
4856
|
return super.init(els, options, ScrollSpy);
|
|
4659
4857
|
}
|
|
4660
4858
|
static getInstance(el) {
|
|
4661
|
-
return el
|
|
4859
|
+
return el['M_ScrollSpy'];
|
|
4662
4860
|
}
|
|
4663
4861
|
destroy() {
|
|
4664
4862
|
ScrollSpy._elements.splice(ScrollSpy._elements.indexOf(this), 1);
|
|
@@ -4668,7 +4866,7 @@ var M = (function (exports) {
|
|
|
4668
4866
|
this._removeEventHandlers();
|
|
4669
4867
|
const actElem = document.querySelector(this.options.getActiveElement(this.el.id));
|
|
4670
4868
|
actElem.classList.remove(this.options.activeClass);
|
|
4671
|
-
this.el
|
|
4869
|
+
this.el['M_ScrollSpy'] = undefined;
|
|
4672
4870
|
}
|
|
4673
4871
|
_setupEventHandlers() {
|
|
4674
4872
|
if (ScrollSpy._count === 1) {
|
|
@@ -4684,7 +4882,9 @@ var M = (function (exports) {
|
|
|
4684
4882
|
document.body.removeEventListener('click', this._handleTriggerClick);
|
|
4685
4883
|
}
|
|
4686
4884
|
}
|
|
4687
|
-
_handleThrottledResize = Utils.throttle(function () {
|
|
4885
|
+
_handleThrottledResize = Utils.throttle(function () {
|
|
4886
|
+
this._handleWindowScroll();
|
|
4887
|
+
}, 200).bind(this);
|
|
4688
4888
|
_handleTriggerClick = (e) => {
|
|
4689
4889
|
const trigger = e.target;
|
|
4690
4890
|
for (let i = ScrollSpy._elements.length - 1; i >= 0; i--) {
|
|
@@ -4692,7 +4892,12 @@ var M = (function (exports) {
|
|
|
4692
4892
|
const x = document.querySelector('a[href="#' + scrollspy.el.id + '"]');
|
|
4693
4893
|
if (trigger === x) {
|
|
4694
4894
|
e.preventDefault();
|
|
4695
|
-
scrollspy.el
|
|
4895
|
+
if (scrollspy.el['M_ScrollSpy'].options.animationDuration) {
|
|
4896
|
+
ScrollSpy._smoothScrollIntoView(scrollspy.el, scrollspy.el['M_ScrollSpy'].options.animationDuration);
|
|
4897
|
+
}
|
|
4898
|
+
else {
|
|
4899
|
+
scrollspy.el.scrollIntoView({ behavior: 'smooth' });
|
|
4900
|
+
}
|
|
4696
4901
|
break;
|
|
4697
4902
|
}
|
|
4698
4903
|
}
|
|
@@ -4701,12 +4906,12 @@ var M = (function (exports) {
|
|
|
4701
4906
|
// unique tick id
|
|
4702
4907
|
ScrollSpy._ticks++;
|
|
4703
4908
|
// viewport rectangle
|
|
4704
|
-
|
|
4909
|
+
const top = Utils.getDocumentScrollTop(), left = Utils.getDocumentScrollLeft(), right = left + window.innerWidth, bottom = top + window.innerHeight;
|
|
4705
4910
|
// determine which elements are in view
|
|
4706
|
-
|
|
4911
|
+
const intersections = ScrollSpy._findElements(top, right, bottom, left);
|
|
4707
4912
|
for (let i = 0; i < intersections.length; i++) {
|
|
4708
|
-
|
|
4709
|
-
|
|
4913
|
+
const scrollspy = intersections[i];
|
|
4914
|
+
const lastTick = scrollspy.tickId;
|
|
4710
4915
|
if (lastTick < 0) {
|
|
4711
4916
|
// entered into view
|
|
4712
4917
|
scrollspy._enter();
|
|
@@ -4715,8 +4920,8 @@ var M = (function (exports) {
|
|
|
4715
4920
|
scrollspy.tickId = ScrollSpy._ticks;
|
|
4716
4921
|
}
|
|
4717
4922
|
for (let i = 0; i < ScrollSpy._elementsInView.length; i++) {
|
|
4718
|
-
|
|
4719
|
-
|
|
4923
|
+
const scrollspy = ScrollSpy._elementsInView[i];
|
|
4924
|
+
const lastTick = scrollspy.tickId;
|
|
4720
4925
|
if (lastTick >= 0 && lastTick !== ScrollSpy._ticks) {
|
|
4721
4926
|
// exited from view
|
|
4722
4927
|
scrollspy._exit();
|
|
@@ -4725,6 +4930,29 @@ var M = (function (exports) {
|
|
|
4725
4930
|
}
|
|
4726
4931
|
// remember elements in view for next tick
|
|
4727
4932
|
ScrollSpy._elementsInView = intersections;
|
|
4933
|
+
if (ScrollSpy._elements.length) {
|
|
4934
|
+
const options = ScrollSpy._elements[0].el['M_ScrollSpy'].options;
|
|
4935
|
+
if (options.keepTopElementActive && ScrollSpy._visibleElements.length === 0) {
|
|
4936
|
+
this._resetKeptTopActiveElementIfNeeded();
|
|
4937
|
+
const topElements = ScrollSpy._elements
|
|
4938
|
+
.filter((value) => ScrollSpy._getDistanceToViewport(value.el) <= 0)
|
|
4939
|
+
.sort((a, b) => {
|
|
4940
|
+
const distanceA = ScrollSpy._getDistanceToViewport(a.el);
|
|
4941
|
+
const distanceB = ScrollSpy._getDistanceToViewport(b.el);
|
|
4942
|
+
if (distanceA < distanceB)
|
|
4943
|
+
return -1;
|
|
4944
|
+
if (distanceA > distanceB)
|
|
4945
|
+
return 1;
|
|
4946
|
+
return 0;
|
|
4947
|
+
});
|
|
4948
|
+
const nearestTopElement = topElements.length
|
|
4949
|
+
? topElements[topElements.length - 1]
|
|
4950
|
+
: ScrollSpy._elements[0];
|
|
4951
|
+
const actElem = document.querySelector(options.getActiveElement(nearestTopElement.el.id));
|
|
4952
|
+
actElem?.classList.add(options.activeClass);
|
|
4953
|
+
ScrollSpy._keptTopActiveElement = actElem;
|
|
4954
|
+
}
|
|
4955
|
+
}
|
|
4728
4956
|
};
|
|
4729
4957
|
static _offset(el) {
|
|
4730
4958
|
const box = el.getBoundingClientRect();
|
|
@@ -4735,13 +4963,13 @@ var M = (function (exports) {
|
|
|
4735
4963
|
};
|
|
4736
4964
|
}
|
|
4737
4965
|
static _findElements(top, right, bottom, left) {
|
|
4738
|
-
|
|
4966
|
+
const hits = [];
|
|
4739
4967
|
for (let i = 0; i < ScrollSpy._elements.length; i++) {
|
|
4740
|
-
|
|
4741
|
-
|
|
4968
|
+
const scrollspy = ScrollSpy._elements[i];
|
|
4969
|
+
const currTop = top + scrollspy.options.scrollOffset || 200;
|
|
4742
4970
|
if (scrollspy.el.getBoundingClientRect().height > 0) {
|
|
4743
|
-
|
|
4744
|
-
|
|
4971
|
+
const elTop = ScrollSpy._offset(scrollspy.el).top, elLeft = ScrollSpy._offset(scrollspy.el).left, elRight = elLeft + scrollspy.el.getBoundingClientRect().width, elBottom = elTop + scrollspy.el.getBoundingClientRect().height;
|
|
4972
|
+
const isIntersect = !(elLeft > right ||
|
|
4745
4973
|
elRight < left ||
|
|
4746
4974
|
elTop > bottom ||
|
|
4747
4975
|
elBottom < currTop);
|
|
@@ -4753,11 +4981,12 @@ var M = (function (exports) {
|
|
|
4753
4981
|
return hits;
|
|
4754
4982
|
}
|
|
4755
4983
|
_enter() {
|
|
4756
|
-
ScrollSpy._visibleElements = ScrollSpy._visibleElements.filter(value => value.getBoundingClientRect().height !== 0);
|
|
4984
|
+
ScrollSpy._visibleElements = ScrollSpy._visibleElements.filter((value) => value.getBoundingClientRect().height !== 0);
|
|
4757
4985
|
if (ScrollSpy._visibleElements[0]) {
|
|
4758
4986
|
const actElem = document.querySelector(this.options.getActiveElement(ScrollSpy._visibleElements[0].id));
|
|
4759
4987
|
actElem?.classList.remove(this.options.activeClass);
|
|
4760
|
-
if (ScrollSpy._visibleElements[0]
|
|
4988
|
+
if (ScrollSpy._visibleElements[0]['M_ScrollSpy'] &&
|
|
4989
|
+
this.id < ScrollSpy._visibleElements[0]['M_ScrollSpy'].id) {
|
|
4761
4990
|
ScrollSpy._visibleElements.unshift(this.el);
|
|
4762
4991
|
}
|
|
4763
4992
|
else {
|
|
@@ -4767,11 +4996,12 @@ var M = (function (exports) {
|
|
|
4767
4996
|
else {
|
|
4768
4997
|
ScrollSpy._visibleElements.push(this.el);
|
|
4769
4998
|
}
|
|
4999
|
+
this._resetKeptTopActiveElementIfNeeded();
|
|
4770
5000
|
const selector = this.options.getActiveElement(ScrollSpy._visibleElements[0].id);
|
|
4771
5001
|
document.querySelector(selector)?.classList.add(this.options.activeClass);
|
|
4772
5002
|
}
|
|
4773
5003
|
_exit() {
|
|
4774
|
-
ScrollSpy._visibleElements = ScrollSpy._visibleElements.filter(value => value.getBoundingClientRect().height !== 0);
|
|
5004
|
+
ScrollSpy._visibleElements = ScrollSpy._visibleElements.filter((value) => value.getBoundingClientRect().height !== 0);
|
|
4775
5005
|
if (ScrollSpy._visibleElements[0]) {
|
|
4776
5006
|
const actElem = document.querySelector(this.options.getActiveElement(ScrollSpy._visibleElements[0].id));
|
|
4777
5007
|
actElem?.classList.remove(this.options.activeClass);
|
|
@@ -4780,8 +5010,39 @@ var M = (function (exports) {
|
|
|
4780
5010
|
// Check if empty
|
|
4781
5011
|
const selector = this.options.getActiveElement(ScrollSpy._visibleElements[0].id);
|
|
4782
5012
|
document.querySelector(selector)?.classList.add(this.options.activeClass);
|
|
5013
|
+
this._resetKeptTopActiveElementIfNeeded();
|
|
5014
|
+
}
|
|
5015
|
+
}
|
|
5016
|
+
}
|
|
5017
|
+
_resetKeptTopActiveElementIfNeeded() {
|
|
5018
|
+
if (ScrollSpy._keptTopActiveElement) {
|
|
5019
|
+
ScrollSpy._keptTopActiveElement.classList.remove(this.options.activeClass);
|
|
5020
|
+
ScrollSpy._keptTopActiveElement = null;
|
|
5021
|
+
}
|
|
5022
|
+
}
|
|
5023
|
+
static _getDistanceToViewport(element) {
|
|
5024
|
+
const rect = element.getBoundingClientRect();
|
|
5025
|
+
const distance = rect.top;
|
|
5026
|
+
return distance;
|
|
5027
|
+
}
|
|
5028
|
+
static _smoothScrollIntoView(element, duration = 300) {
|
|
5029
|
+
const targetPosition = element.getBoundingClientRect().top + (window.scrollY || window.pageYOffset);
|
|
5030
|
+
const startPosition = window.scrollY || window.pageYOffset;
|
|
5031
|
+
const distance = targetPosition - startPosition;
|
|
5032
|
+
const startTime = performance.now();
|
|
5033
|
+
function scrollStep(currentTime) {
|
|
5034
|
+
const elapsed = currentTime - startTime;
|
|
5035
|
+
const progress = Math.min(elapsed / duration, 1);
|
|
5036
|
+
const scrollY = startPosition + distance * progress;
|
|
5037
|
+
if (progress < 1) {
|
|
5038
|
+
window.scrollTo(0, scrollY);
|
|
5039
|
+
requestAnimationFrame(scrollStep);
|
|
5040
|
+
}
|
|
5041
|
+
else {
|
|
5042
|
+
window.scrollTo(0, targetPosition);
|
|
4783
5043
|
}
|
|
4784
5044
|
}
|
|
5045
|
+
requestAnimationFrame(scrollStep);
|
|
4785
5046
|
}
|
|
4786
5047
|
static {
|
|
4787
5048
|
ScrollSpy._elements = [];
|
|
@@ -4829,7 +5090,7 @@ var M = (function (exports) {
|
|
|
4829
5090
|
percentOpen;
|
|
4830
5091
|
constructor(el, options) {
|
|
4831
5092
|
super(el, options, Sidenav);
|
|
4832
|
-
this.el
|
|
5093
|
+
this.el['M_Sidenav'] = this;
|
|
4833
5094
|
this.options = {
|
|
4834
5095
|
...Sidenav.defaults,
|
|
4835
5096
|
...options
|
|
@@ -4860,14 +5121,14 @@ var M = (function (exports) {
|
|
|
4860
5121
|
return super.init(els, options, Sidenav);
|
|
4861
5122
|
}
|
|
4862
5123
|
static getInstance(el) {
|
|
4863
|
-
return el
|
|
5124
|
+
return el['M_Sidenav'];
|
|
4864
5125
|
}
|
|
4865
5126
|
destroy() {
|
|
4866
5127
|
this._removeEventHandlers();
|
|
4867
5128
|
this._enableBodyScrolling();
|
|
4868
5129
|
this._overlay.parentNode.removeChild(this._overlay);
|
|
4869
5130
|
this.dragTarget.parentNode.removeChild(this.dragTarget);
|
|
4870
|
-
this.el
|
|
5131
|
+
this.el['M_Sidenav'] = undefined;
|
|
4871
5132
|
this.el.style.transform = '';
|
|
4872
5133
|
const index = Sidenav._sidenavs.indexOf(this);
|
|
4873
5134
|
if (index >= 0) {
|
|
@@ -4884,18 +5145,21 @@ var M = (function (exports) {
|
|
|
4884
5145
|
if (Sidenav._sidenavs.length === 0) {
|
|
4885
5146
|
document.body.addEventListener('click', this._handleTriggerClick);
|
|
4886
5147
|
}
|
|
4887
|
-
|
|
5148
|
+
const passiveIfSupported = null;
|
|
4888
5149
|
this.dragTarget.addEventListener('touchmove', this._handleDragTargetDrag, passiveIfSupported);
|
|
4889
5150
|
this.dragTarget.addEventListener('touchend', this._handleDragTargetRelease);
|
|
4890
5151
|
this._overlay.addEventListener('touchmove', this._handleCloseDrag, passiveIfSupported);
|
|
4891
5152
|
this._overlay.addEventListener('touchend', this._handleCloseRelease);
|
|
4892
|
-
this.el.addEventListener('touchmove', this._handleCloseDrag, passiveIfSupported);
|
|
5153
|
+
this.el.addEventListener('touchmove', this._handleCloseDrag); // , passiveIfSupported);
|
|
4893
5154
|
this.el.addEventListener('touchend', this._handleCloseRelease);
|
|
4894
5155
|
this.el.addEventListener('click', this._handleCloseTriggerClick);
|
|
4895
5156
|
// Add resize for side nav fixed
|
|
4896
5157
|
if (this.isFixed) {
|
|
4897
5158
|
window.addEventListener('resize', this._handleWindowResize);
|
|
4898
5159
|
}
|
|
5160
|
+
/* Set aria-hidden state */
|
|
5161
|
+
this._setAriaHidden();
|
|
5162
|
+
this._setTabIndex();
|
|
4899
5163
|
}
|
|
4900
5164
|
_removeEventHandlers() {
|
|
4901
5165
|
if (Sidenav._sidenavs.length === 1) {
|
|
@@ -4917,9 +5181,9 @@ var M = (function (exports) {
|
|
|
4917
5181
|
const trigger = e.target.closest('.sidenav-trigger');
|
|
4918
5182
|
if (e.target && trigger) {
|
|
4919
5183
|
const sidenavId = Utils.getIdFromTrigger(trigger);
|
|
4920
|
-
const sidenavInstance = document.getElementById(sidenavId)
|
|
5184
|
+
const sidenavInstance = document.getElementById(sidenavId)['M_Sidenav'];
|
|
4921
5185
|
if (sidenavInstance) {
|
|
4922
|
-
sidenavInstance.open(
|
|
5186
|
+
sidenavInstance.open();
|
|
4923
5187
|
}
|
|
4924
5188
|
e.preventDefault();
|
|
4925
5189
|
}
|
|
@@ -4950,18 +5214,9 @@ var M = (function (exports) {
|
|
|
4950
5214
|
}
|
|
4951
5215
|
_handleDragTargetDrag = (e) => {
|
|
4952
5216
|
// Check if draggable
|
|
4953
|
-
if (!this.
|
|
5217
|
+
if (!this._isDraggable())
|
|
4954
5218
|
return;
|
|
4955
|
-
|
|
4956
|
-
// If not being dragged, set initial drag start variables
|
|
4957
|
-
if (!this.isDragged) {
|
|
4958
|
-
this._startDrag(e);
|
|
4959
|
-
}
|
|
4960
|
-
// Run touchmove updates
|
|
4961
|
-
this._dragMoveUpdate(e);
|
|
4962
|
-
// Calculate raw deltaX
|
|
4963
|
-
let totalDeltaX = this._xPos - this._startingXpos;
|
|
4964
|
-
// dragDirection is the attempted user drag direction
|
|
5219
|
+
let totalDeltaX = this._calculateDelta(e);
|
|
4965
5220
|
const dragDirection = totalDeltaX > 0 ? 'right' : 'left';
|
|
4966
5221
|
// Don't allow totalDeltaX to exceed Sidenav width or be dragged in the opposite direction
|
|
4967
5222
|
totalDeltaX = Math.min(this._width, Math.abs(totalDeltaX));
|
|
@@ -4998,36 +5253,35 @@ var M = (function (exports) {
|
|
|
4998
5253
|
}
|
|
4999
5254
|
};
|
|
5000
5255
|
_handleCloseDrag = (e) => {
|
|
5001
|
-
if
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
// Calculate open/close percentage of sidenav, with open = 1 and close = 0
|
|
5026
|
-
this.percentOpen = Math.min(1, 1 - totalDeltaX / this._width);
|
|
5027
|
-
// Set transform and opacity styles
|
|
5028
|
-
this.el.style.transform = `translateX(${transformX}px)`;
|
|
5029
|
-
this._overlay.style.opacity = this.percentOpen.toString();
|
|
5256
|
+
// Check if open and draggable
|
|
5257
|
+
if (!this.isOpen || !this._isDraggable())
|
|
5258
|
+
return;
|
|
5259
|
+
let totalDeltaX = this._calculateDelta(e);
|
|
5260
|
+
// dragDirection is the attempted user drag direction
|
|
5261
|
+
const dragDirection = totalDeltaX > 0 ? 'right' : 'left';
|
|
5262
|
+
totalDeltaX = Math.min(this._width, Math.abs(totalDeltaX));
|
|
5263
|
+
if (this.options.edge !== dragDirection) {
|
|
5264
|
+
totalDeltaX = 0;
|
|
5265
|
+
}
|
|
5266
|
+
let transformX = -totalDeltaX;
|
|
5267
|
+
if (this.options.edge === 'right') {
|
|
5268
|
+
transformX = -transformX;
|
|
5269
|
+
}
|
|
5270
|
+
// Calculate open/close percentage of sidenav, with open = 1 and close = 0
|
|
5271
|
+
this.percentOpen = Math.min(1, 1 - totalDeltaX / this._width);
|
|
5272
|
+
// Set transform and opacity styles
|
|
5273
|
+
this.el.style.transform = `translateX(${transformX}px)`;
|
|
5274
|
+
this._overlay.style.opacity = this.percentOpen.toString();
|
|
5275
|
+
};
|
|
5276
|
+
_calculateDelta = (e) => {
|
|
5277
|
+
// If not being dragged, set initial drag start variables
|
|
5278
|
+
if (!this.isDragged) {
|
|
5279
|
+
this._startDrag(e);
|
|
5030
5280
|
}
|
|
5281
|
+
// Run touchmove updates
|
|
5282
|
+
this._dragMoveUpdate(e);
|
|
5283
|
+
// Calculate raw deltaX
|
|
5284
|
+
return this._xPos - this._startingXpos;
|
|
5031
5285
|
};
|
|
5032
5286
|
_handleCloseRelease = () => {
|
|
5033
5287
|
if (this.isOpen && this.isDragged) {
|
|
@@ -5075,6 +5329,9 @@ var M = (function (exports) {
|
|
|
5075
5329
|
if (this._isCurrentlyFixed())
|
|
5076
5330
|
this.open();
|
|
5077
5331
|
}
|
|
5332
|
+
_isDraggable() {
|
|
5333
|
+
return this.options.draggable && !this._isCurrentlyFixed() && !this._verticallyScrolling;
|
|
5334
|
+
}
|
|
5078
5335
|
_isCurrentlyFixed() {
|
|
5079
5336
|
return this.isFixed && window.innerWidth > 992;
|
|
5080
5337
|
}
|
|
@@ -5115,6 +5372,9 @@ var M = (function (exports) {
|
|
|
5115
5372
|
this._preventBodyScrolling();
|
|
5116
5373
|
if (!this.isDragged || this.percentOpen != 1)
|
|
5117
5374
|
this._animateIn();
|
|
5375
|
+
/* Set aria-hidden state */
|
|
5376
|
+
this._setAriaHidden();
|
|
5377
|
+
this._setTabIndex();
|
|
5118
5378
|
}
|
|
5119
5379
|
};
|
|
5120
5380
|
/**
|
|
@@ -5142,6 +5402,9 @@ var M = (function (exports) {
|
|
|
5142
5402
|
else {
|
|
5143
5403
|
this._overlay.style.display = 'none';
|
|
5144
5404
|
}
|
|
5405
|
+
/* Set aria-hidden state */
|
|
5406
|
+
this._setAriaHidden();
|
|
5407
|
+
this._setTabIndex();
|
|
5145
5408
|
}
|
|
5146
5409
|
};
|
|
5147
5410
|
_animateIn() {
|
|
@@ -5163,7 +5426,7 @@ var M = (function (exports) {
|
|
|
5163
5426
|
const duration = this.options.inDuration;
|
|
5164
5427
|
// from
|
|
5165
5428
|
this.el.style.transition = 'none';
|
|
5166
|
-
this.el.style.transform = 'translateX(' +
|
|
5429
|
+
this.el.style.transform = 'translateX(' + slideOutPercent * 100 + '%)';
|
|
5167
5430
|
setTimeout(() => {
|
|
5168
5431
|
this.el.style.transition = `transform ${duration}ms ease`; // easeOutQuad
|
|
5169
5432
|
// to
|
|
@@ -5176,15 +5439,18 @@ var M = (function (exports) {
|
|
|
5176
5439
|
}
|
|
5177
5440
|
_animateSidenavOut() {
|
|
5178
5441
|
const endPercent = this.options.edge === 'left' ? -1 : 1;
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
|
|
5442
|
+
// let slideOutPercent = 0;
|
|
5443
|
+
// if (this.isDragged) {
|
|
5444
|
+
// // @todo unused variable
|
|
5445
|
+
// slideOutPercent =
|
|
5446
|
+
// this.options.edge === 'left'
|
|
5447
|
+
// ? endPercent + this.percentOpen
|
|
5448
|
+
// : endPercent - this.percentOpen;
|
|
5449
|
+
// }
|
|
5184
5450
|
const duration = this.options.outDuration;
|
|
5185
5451
|
this.el.style.transition = `transform ${duration}ms ease`; // easeOutQuad
|
|
5186
5452
|
// to
|
|
5187
|
-
this.el.style.transform = 'translateX(' +
|
|
5453
|
+
this.el.style.transform = 'translateX(' + endPercent * 100 + '%)';
|
|
5188
5454
|
setTimeout(() => {
|
|
5189
5455
|
if (typeof this.options.onCloseEnd === 'function')
|
|
5190
5456
|
this.options.onCloseEnd.call(this, this.el);
|
|
@@ -5218,12 +5484,30 @@ var M = (function (exports) {
|
|
|
5218
5484
|
this._overlay.style.display = 'none';
|
|
5219
5485
|
}, duration);
|
|
5220
5486
|
}
|
|
5487
|
+
_setAriaHidden = () => {
|
|
5488
|
+
this.el.ariaHidden = this.isOpen ? 'false' : 'true';
|
|
5489
|
+
const navWrapper = document.querySelector('.nav-wrapper ul');
|
|
5490
|
+
if (navWrapper)
|
|
5491
|
+
navWrapper.ariaHidden = this.isOpen.toString();
|
|
5492
|
+
};
|
|
5493
|
+
_setTabIndex = () => {
|
|
5494
|
+
const navLinks = document.querySelectorAll('.nav-wrapper ul li a');
|
|
5495
|
+
const sideNavLinks = document.querySelectorAll('.sidenav li a');
|
|
5496
|
+
if (navLinks)
|
|
5497
|
+
navLinks.forEach((navLink) => {
|
|
5498
|
+
navLink.tabIndex = this.isOpen ? -1 : 0;
|
|
5499
|
+
});
|
|
5500
|
+
if (sideNavLinks)
|
|
5501
|
+
sideNavLinks.forEach((sideNavLink) => {
|
|
5502
|
+
sideNavLink.tabIndex = this.isOpen ? 0 : -1;
|
|
5503
|
+
});
|
|
5504
|
+
};
|
|
5221
5505
|
static {
|
|
5222
5506
|
Sidenav._sidenavs = [];
|
|
5223
5507
|
}
|
|
5224
5508
|
}
|
|
5225
5509
|
|
|
5226
|
-
|
|
5510
|
+
const _defaults$7 = {
|
|
5227
5511
|
duration: 300,
|
|
5228
5512
|
onShow: null,
|
|
5229
5513
|
swipeable: false,
|
|
@@ -5240,7 +5524,7 @@ var M = (function (exports) {
|
|
|
5240
5524
|
_content;
|
|
5241
5525
|
constructor(el, options) {
|
|
5242
5526
|
super(el, options, Tabs);
|
|
5243
|
-
this.el
|
|
5527
|
+
this.el['M_Tabs'] = this;
|
|
5244
5528
|
this.options = {
|
|
5245
5529
|
...Tabs.defaults,
|
|
5246
5530
|
...options
|
|
@@ -5271,7 +5555,7 @@ var M = (function (exports) {
|
|
|
5271
5555
|
return super.init(els, options, Tabs);
|
|
5272
5556
|
}
|
|
5273
5557
|
static getInstance(el) {
|
|
5274
|
-
return el
|
|
5558
|
+
return el['M_Tabs'];
|
|
5275
5559
|
}
|
|
5276
5560
|
destroy() {
|
|
5277
5561
|
this._removeEventHandlers();
|
|
@@ -5282,12 +5566,14 @@ var M = (function (exports) {
|
|
|
5282
5566
|
else {
|
|
5283
5567
|
this._teardownNormalTabs();
|
|
5284
5568
|
}
|
|
5285
|
-
this.el
|
|
5569
|
+
this.el['M_Tabs'] = undefined;
|
|
5286
5570
|
}
|
|
5287
5571
|
/**
|
|
5288
5572
|
* The index of tab that is currently shown.
|
|
5289
5573
|
*/
|
|
5290
|
-
get index() {
|
|
5574
|
+
get index() {
|
|
5575
|
+
return this._index;
|
|
5576
|
+
}
|
|
5291
5577
|
_setupEventHandlers() {
|
|
5292
5578
|
window.addEventListener('resize', this._handleWindowResize);
|
|
5293
5579
|
this.el.addEventListener('click', this._handleTabClick);
|
|
@@ -5304,8 +5590,14 @@ var M = (function (exports) {
|
|
|
5304
5590
|
}
|
|
5305
5591
|
};
|
|
5306
5592
|
_handleTabClick = (e) => {
|
|
5307
|
-
|
|
5308
|
-
|
|
5593
|
+
let tabLink = e.target;
|
|
5594
|
+
if (!tabLink)
|
|
5595
|
+
return;
|
|
5596
|
+
let tab = tabLink.parentElement;
|
|
5597
|
+
while (tab && !tab.classList.contains('tab')) {
|
|
5598
|
+
tabLink = tabLink.parentElement;
|
|
5599
|
+
tab = tab.parentElement;
|
|
5600
|
+
}
|
|
5309
5601
|
// Handle click on tab link only
|
|
5310
5602
|
if (!tabLink || !tab.classList.contains('tab'))
|
|
5311
5603
|
return;
|
|
@@ -5368,10 +5660,11 @@ var M = (function (exports) {
|
|
|
5368
5660
|
this._activeTabLink = Array.from(this._tabLinks).find((a) => a.getAttribute('href') === location.hash);
|
|
5369
5661
|
// If no match is found, use the first link or any with class 'active' as the initial active tab.
|
|
5370
5662
|
if (!this._activeTabLink) {
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
|
|
5663
|
+
let activeTabLink = this.el.querySelector('li.tab a.active');
|
|
5664
|
+
if (!activeTabLink) {
|
|
5665
|
+
activeTabLink = this.el.querySelector('li.tab a');
|
|
5666
|
+
}
|
|
5667
|
+
this._activeTabLink = activeTabLink;
|
|
5375
5668
|
}
|
|
5376
5669
|
Array.from(this._tabLinks).forEach((a) => a.classList.remove('active'));
|
|
5377
5670
|
this._activeTabLink.classList.add('active');
|
|
@@ -5387,7 +5680,7 @@ var M = (function (exports) {
|
|
|
5387
5680
|
if (window.innerWidth > this.options.responsiveThreshold)
|
|
5388
5681
|
this.options.swipeable = false;
|
|
5389
5682
|
const tabsContent = [];
|
|
5390
|
-
this._tabLinks.forEach(a => {
|
|
5683
|
+
this._tabLinks.forEach((a) => {
|
|
5391
5684
|
if (a.hash) {
|
|
5392
5685
|
const currContent = document.querySelector(a.hash);
|
|
5393
5686
|
currContent.classList.add('carousel-item');
|
|
@@ -5399,7 +5692,7 @@ var M = (function (exports) {
|
|
|
5399
5692
|
tabsWrapper.classList.add('tabs-content', 'carousel', 'carousel-slider');
|
|
5400
5693
|
// Wrap around
|
|
5401
5694
|
tabsContent[0].parentElement.insertBefore(tabsWrapper, tabsContent[0]);
|
|
5402
|
-
tabsContent.forEach(tabContent => {
|
|
5695
|
+
tabsContent.forEach((tabContent) => {
|
|
5403
5696
|
tabsWrapper.appendChild(tabContent);
|
|
5404
5697
|
tabContent.style.display = '';
|
|
5405
5698
|
});
|
|
@@ -5427,7 +5720,7 @@ var M = (function (exports) {
|
|
|
5427
5720
|
const tabsWrapper = this._tabsCarousel.el;
|
|
5428
5721
|
this._tabsCarousel.destroy();
|
|
5429
5722
|
// Unwrap
|
|
5430
|
-
tabsWrapper.
|
|
5723
|
+
tabsWrapper.append(tabsWrapper.parentElement);
|
|
5431
5724
|
tabsWrapper.remove();
|
|
5432
5725
|
}
|
|
5433
5726
|
_setupNormalTabs() {
|
|
@@ -5472,7 +5765,7 @@ var M = (function (exports) {
|
|
|
5472
5765
|
}
|
|
5473
5766
|
_animateIndicator(prevIndex) {
|
|
5474
5767
|
let leftDelay = 0, rightDelay = 0;
|
|
5475
|
-
const isMovingLeftOrStaying =
|
|
5768
|
+
const isMovingLeftOrStaying = this._index - prevIndex >= 0;
|
|
5476
5769
|
if (isMovingLeftOrStaying)
|
|
5477
5770
|
leftDelay = 90;
|
|
5478
5771
|
else
|
|
@@ -5495,7 +5788,7 @@ var M = (function (exports) {
|
|
|
5495
5788
|
}
|
|
5496
5789
|
}
|
|
5497
5790
|
|
|
5498
|
-
|
|
5791
|
+
const _defaults$6 = {
|
|
5499
5792
|
onOpen: null,
|
|
5500
5793
|
onClose: null
|
|
5501
5794
|
};
|
|
@@ -5504,24 +5797,27 @@ var M = (function (exports) {
|
|
|
5504
5797
|
* If the tap target is open.
|
|
5505
5798
|
*/
|
|
5506
5799
|
isOpen;
|
|
5800
|
+
static _taptargets;
|
|
5507
5801
|
wrapper;
|
|
5508
|
-
_origin;
|
|
5802
|
+
// private _origin: HTMLElement;
|
|
5509
5803
|
originEl;
|
|
5510
5804
|
waveEl;
|
|
5511
5805
|
contentEl;
|
|
5512
5806
|
constructor(el, options) {
|
|
5513
5807
|
super(el, options, TapTarget);
|
|
5514
|
-
this.el
|
|
5808
|
+
this.el['M_TapTarget'] = this;
|
|
5515
5809
|
this.options = {
|
|
5516
5810
|
...TapTarget.defaults,
|
|
5517
5811
|
...options
|
|
5518
5812
|
};
|
|
5519
5813
|
this.isOpen = false;
|
|
5520
5814
|
// setup
|
|
5521
|
-
this.
|
|
5815
|
+
this.originEl = document.querySelector(`#${el.dataset.target}`);
|
|
5816
|
+
this.originEl.tabIndex = 0;
|
|
5522
5817
|
this._setup();
|
|
5523
5818
|
this._calculatePositioning();
|
|
5524
5819
|
this._setupEventHandlers();
|
|
5820
|
+
TapTarget._taptargets.push(this);
|
|
5525
5821
|
}
|
|
5526
5822
|
static get defaults() {
|
|
5527
5823
|
return _defaults$6;
|
|
@@ -5535,45 +5831,64 @@ var M = (function (exports) {
|
|
|
5535
5831
|
return super.init(els, options, TapTarget);
|
|
5536
5832
|
}
|
|
5537
5833
|
static getInstance(el) {
|
|
5538
|
-
return el
|
|
5834
|
+
return el['M_TapTarget'];
|
|
5539
5835
|
}
|
|
5540
5836
|
destroy() {
|
|
5541
5837
|
this._removeEventHandlers();
|
|
5542
|
-
this.el
|
|
5838
|
+
this.el['M_TapTarget'] = undefined;
|
|
5839
|
+
const index = TapTarget._taptargets.indexOf(this);
|
|
5840
|
+
if (index >= 0) {
|
|
5841
|
+
TapTarget._taptargets.splice(index, 1);
|
|
5842
|
+
}
|
|
5543
5843
|
}
|
|
5544
5844
|
_setupEventHandlers() {
|
|
5545
|
-
this.
|
|
5546
|
-
this.originEl.addEventListener('
|
|
5845
|
+
this.originEl.addEventListener('click', this._handleTargetToggle);
|
|
5846
|
+
this.originEl.addEventListener('keypress', this._handleKeyboardInteraction, true);
|
|
5847
|
+
// this.originEl.addEventListener('click', this._handleOriginClick);
|
|
5547
5848
|
// Resize
|
|
5548
5849
|
window.addEventListener('resize', this._handleThrottledResize);
|
|
5549
5850
|
}
|
|
5550
5851
|
_removeEventHandlers() {
|
|
5551
|
-
this.
|
|
5552
|
-
this.originEl.removeEventListener('
|
|
5852
|
+
this.originEl.removeEventListener('click', this._handleTargetToggle);
|
|
5853
|
+
this.originEl.removeEventListener('keypress', this._handleKeyboardInteraction, true);
|
|
5854
|
+
// this.originEl.removeEventListener('click', this._handleOriginClick);
|
|
5553
5855
|
window.removeEventListener('resize', this._handleThrottledResize);
|
|
5554
5856
|
}
|
|
5555
|
-
_handleThrottledResize = Utils.throttle(function () {
|
|
5556
|
-
|
|
5557
|
-
|
|
5857
|
+
_handleThrottledResize = Utils.throttle(function () {
|
|
5858
|
+
this._handleResize();
|
|
5859
|
+
}, 200).bind(this);
|
|
5860
|
+
_handleKeyboardInteraction = (e) => {
|
|
5861
|
+
if (Utils.keys.ENTER.includes(e.key)) {
|
|
5862
|
+
this._handleTargetToggle();
|
|
5863
|
+
}
|
|
5558
5864
|
};
|
|
5559
|
-
|
|
5560
|
-
this.
|
|
5865
|
+
_handleTargetToggle = () => {
|
|
5866
|
+
if (!this.isOpen)
|
|
5867
|
+
this.open();
|
|
5868
|
+
else
|
|
5869
|
+
this.close();
|
|
5561
5870
|
};
|
|
5871
|
+
/*_handleOriginClick = () => {
|
|
5872
|
+
this.close();
|
|
5873
|
+
}*/
|
|
5562
5874
|
_handleResize = () => {
|
|
5563
5875
|
this._calculatePositioning();
|
|
5564
5876
|
};
|
|
5565
5877
|
_handleDocumentClick = (e) => {
|
|
5566
|
-
if (
|
|
5878
|
+
if (e.target.closest(`#${this.el.dataset.target}`) !== this.originEl &&
|
|
5879
|
+
!e.target.closest('.tap-target-wrapper')) {
|
|
5567
5880
|
this.close();
|
|
5568
|
-
e.preventDefault();
|
|
5569
|
-
e.stopPropagation();
|
|
5881
|
+
// e.preventDefault();
|
|
5882
|
+
// e.stopPropagation();
|
|
5570
5883
|
}
|
|
5571
5884
|
};
|
|
5572
5885
|
_setup() {
|
|
5573
5886
|
// Creating tap target
|
|
5574
5887
|
this.wrapper = this.el.parentElement;
|
|
5575
5888
|
this.waveEl = this.wrapper.querySelector('.tap-target-wave');
|
|
5576
|
-
this.
|
|
5889
|
+
this.el.parentElement.ariaExpanded = 'false';
|
|
5890
|
+
this.originEl.style.zIndex = '1002';
|
|
5891
|
+
// this.originEl = this.wrapper.querySelector('.tap-target-origin');
|
|
5577
5892
|
this.contentEl = this.el.querySelector('.tap-target-content');
|
|
5578
5893
|
// Creating wrapper
|
|
5579
5894
|
if (!this.wrapper.classList.contains('.tap-target-wrapper')) {
|
|
@@ -5593,13 +5908,13 @@ var M = (function (exports) {
|
|
|
5593
5908
|
this.waveEl = document.createElement('div');
|
|
5594
5909
|
this.waveEl.classList.add('tap-target-wave');
|
|
5595
5910
|
// Creating origin
|
|
5596
|
-
if (!this.originEl) {
|
|
5597
|
-
|
|
5598
|
-
|
|
5599
|
-
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
}
|
|
5911
|
+
/*if (!this.originEl) {
|
|
5912
|
+
this.originEl = <HTMLElement>this._origin.cloneNode(true); // .clone(true, true);
|
|
5913
|
+
this.originEl.classList.add('tap-target-origin');
|
|
5914
|
+
this.originEl.removeAttribute('id');
|
|
5915
|
+
this.originEl.removeAttribute('style');
|
|
5916
|
+
this.waveEl.append(this.originEl);
|
|
5917
|
+
}*/
|
|
5603
5918
|
this.wrapper.append(this.waveEl);
|
|
5604
5919
|
}
|
|
5605
5920
|
}
|
|
@@ -5613,9 +5928,10 @@ var M = (function (exports) {
|
|
|
5613
5928
|
}
|
|
5614
5929
|
_calculatePositioning() {
|
|
5615
5930
|
// Element or parent is fixed position?
|
|
5616
|
-
let isFixed = getComputedStyle(this.
|
|
5931
|
+
let isFixed = getComputedStyle(this.originEl).position === 'fixed';
|
|
5617
5932
|
if (!isFixed) {
|
|
5618
|
-
|
|
5933
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5934
|
+
let currentElem = this.originEl;
|
|
5619
5935
|
const parents = [];
|
|
5620
5936
|
while ((currentElem = currentElem.parentNode) && currentElem !== document)
|
|
5621
5937
|
parents.push(currentElem);
|
|
@@ -5626,10 +5942,14 @@ var M = (function (exports) {
|
|
|
5626
5942
|
}
|
|
5627
5943
|
}
|
|
5628
5944
|
// Calculating origin
|
|
5629
|
-
const originWidth = this.
|
|
5630
|
-
const originHeight = this.
|
|
5631
|
-
const originTop = isFixed
|
|
5632
|
-
|
|
5945
|
+
const originWidth = this.originEl.offsetWidth;
|
|
5946
|
+
const originHeight = this.originEl.offsetHeight;
|
|
5947
|
+
const originTop = isFixed
|
|
5948
|
+
? this._offset(this.originEl).top - Utils.getDocumentScrollTop()
|
|
5949
|
+
: this._offset(this.originEl).top;
|
|
5950
|
+
const originLeft = isFixed
|
|
5951
|
+
? this._offset(this.originEl).left - Utils.getDocumentScrollLeft()
|
|
5952
|
+
: this._offset(this.originEl).left;
|
|
5633
5953
|
// Calculating screen
|
|
5634
5954
|
const windowWidth = window.innerWidth;
|
|
5635
5955
|
const windowHeight = window.innerHeight;
|
|
@@ -5663,8 +5983,12 @@ var M = (function (exports) {
|
|
|
5663
5983
|
const tapTargetWaveLeft = tapTargetWidth / 2 - tapTargetWaveWidth / 2;
|
|
5664
5984
|
// Setting tap target
|
|
5665
5985
|
this.wrapper.style.top = isTop ? tapTargetTop + 'px' : '';
|
|
5666
|
-
this.wrapper.style.right = isRight
|
|
5667
|
-
|
|
5986
|
+
this.wrapper.style.right = isRight
|
|
5987
|
+
? windowWidth - tapTargetLeft - tapTargetWidth - scrollBarWidth + 'px'
|
|
5988
|
+
: '';
|
|
5989
|
+
this.wrapper.style.bottom = isBottom
|
|
5990
|
+
? windowHeight - tapTargetTop - tapTargetHeight + 'px'
|
|
5991
|
+
: '';
|
|
5668
5992
|
this.wrapper.style.left = isLeft ? tapTargetLeft + 'px' : '';
|
|
5669
5993
|
this.wrapper.style.position = tapTargetPosition;
|
|
5670
5994
|
// Setting content
|
|
@@ -5690,11 +6014,13 @@ var M = (function (exports) {
|
|
|
5690
6014
|
return;
|
|
5691
6015
|
// onOpen callback
|
|
5692
6016
|
if (typeof this.options.onOpen === 'function') {
|
|
5693
|
-
this.options.onOpen.call(this, this.
|
|
6017
|
+
this.options.onOpen.call(this, this.originEl);
|
|
5694
6018
|
}
|
|
5695
6019
|
this.isOpen = true;
|
|
5696
6020
|
this.wrapper.classList.add('open');
|
|
6021
|
+
this.wrapper.ariaExpanded = 'true';
|
|
5697
6022
|
document.body.addEventListener('click', this._handleDocumentClick, true);
|
|
6023
|
+
document.body.addEventListener('keypress', this._handleDocumentClick, true);
|
|
5698
6024
|
document.body.addEventListener('touchend', this._handleDocumentClick);
|
|
5699
6025
|
};
|
|
5700
6026
|
/**
|
|
@@ -5705,16 +6031,21 @@ var M = (function (exports) {
|
|
|
5705
6031
|
return;
|
|
5706
6032
|
// onClose callback
|
|
5707
6033
|
if (typeof this.options.onClose === 'function') {
|
|
5708
|
-
this.options.onClose.call(this, this.
|
|
6034
|
+
this.options.onClose.call(this, this.originEl);
|
|
5709
6035
|
}
|
|
5710
6036
|
this.isOpen = false;
|
|
5711
6037
|
this.wrapper.classList.remove('open');
|
|
6038
|
+
this.wrapper.ariaExpanded = 'false';
|
|
5712
6039
|
document.body.removeEventListener('click', this._handleDocumentClick, true);
|
|
6040
|
+
document.body.removeEventListener('keypress', this._handleDocumentClick, true);
|
|
5713
6041
|
document.body.removeEventListener('touchend', this._handleDocumentClick);
|
|
5714
6042
|
};
|
|
6043
|
+
static {
|
|
6044
|
+
TapTarget._taptargets = [];
|
|
6045
|
+
}
|
|
5715
6046
|
}
|
|
5716
6047
|
|
|
5717
|
-
|
|
6048
|
+
const _defaults$5 = {
|
|
5718
6049
|
dialRadius: 135,
|
|
5719
6050
|
outerRadius: 105,
|
|
5720
6051
|
innerRadius: 70,
|
|
@@ -5730,19 +6061,13 @@ var M = (function (exports) {
|
|
|
5730
6061
|
clear: 'Clear',
|
|
5731
6062
|
done: 'Ok'
|
|
5732
6063
|
},
|
|
5733
|
-
autoClose: false, // auto close when minute is selected
|
|
5734
6064
|
twelveHour: true, // change to 12 hour AM/PM clock from 24 hour
|
|
5735
6065
|
vibrate: true, // vibrate the device when dragging clock hand
|
|
5736
6066
|
// Callbacks
|
|
5737
|
-
onOpenStart: null,
|
|
5738
|
-
onOpenEnd: null,
|
|
5739
|
-
onCloseStart: null,
|
|
5740
|
-
onCloseEnd: null,
|
|
5741
6067
|
onSelect: null
|
|
5742
6068
|
};
|
|
5743
6069
|
class Timepicker extends Component {
|
|
5744
6070
|
id;
|
|
5745
|
-
modal;
|
|
5746
6071
|
modalEl;
|
|
5747
6072
|
plate;
|
|
5748
6073
|
digitalClock;
|
|
@@ -5770,8 +6095,6 @@ var M = (function (exports) {
|
|
|
5770
6095
|
*/
|
|
5771
6096
|
amOrPm;
|
|
5772
6097
|
static _template;
|
|
5773
|
-
/** If the picker is open. */
|
|
5774
|
-
isOpen;
|
|
5775
6098
|
/** Vibrate device when dragging clock hand. */
|
|
5776
6099
|
vibrate;
|
|
5777
6100
|
_canvas;
|
|
@@ -5784,18 +6107,16 @@ var M = (function (exports) {
|
|
|
5784
6107
|
bearing;
|
|
5785
6108
|
g;
|
|
5786
6109
|
toggleViewTimer;
|
|
5787
|
-
canvas;
|
|
5788
6110
|
vibrateTimer;
|
|
5789
6111
|
constructor(el, options) {
|
|
5790
6112
|
super(el, options, Timepicker);
|
|
5791
|
-
this.el
|
|
6113
|
+
this.el['M_Timepicker'] = this;
|
|
5792
6114
|
this.options = {
|
|
5793
6115
|
...Timepicker.defaults,
|
|
5794
6116
|
...options
|
|
5795
6117
|
};
|
|
5796
6118
|
this.id = Utils.guid();
|
|
5797
6119
|
this._insertHTMLIntoDOM();
|
|
5798
|
-
this._setupModal();
|
|
5799
6120
|
this._setupVariables();
|
|
5800
6121
|
this._setupEventHandlers();
|
|
5801
6122
|
this._clockSetup();
|
|
@@ -5816,24 +6137,26 @@ var M = (function (exports) {
|
|
|
5816
6137
|
return (num < 10 ? '0' : '') + num;
|
|
5817
6138
|
}
|
|
5818
6139
|
static _createSVGEl(name) {
|
|
5819
|
-
|
|
6140
|
+
const svgNS = 'http://www.w3.org/2000/svg';
|
|
5820
6141
|
return document.createElementNS(svgNS, name);
|
|
5821
6142
|
}
|
|
5822
6143
|
static _Pos(e) {
|
|
5823
|
-
if (e.type.startsWith(
|
|
5824
|
-
return {
|
|
6144
|
+
if (e.type.startsWith('touch') && e.targetTouches.length >= 1) {
|
|
6145
|
+
return {
|
|
6146
|
+
x: e.targetTouches[0].clientX,
|
|
6147
|
+
y: e.targetTouches[0].clientY
|
|
6148
|
+
};
|
|
5825
6149
|
}
|
|
5826
6150
|
// mouse event
|
|
5827
6151
|
return { x: e.clientX, y: e.clientY };
|
|
5828
6152
|
}
|
|
5829
6153
|
static getInstance(el) {
|
|
5830
|
-
return el
|
|
6154
|
+
return el['M_Timepicker'];
|
|
5831
6155
|
}
|
|
5832
6156
|
destroy() {
|
|
5833
6157
|
this._removeEventHandlers();
|
|
5834
|
-
this.modal.destroy();
|
|
5835
6158
|
this.modalEl.remove();
|
|
5836
|
-
this.el
|
|
6159
|
+
this.el['M_Timepicker'] = undefined;
|
|
5837
6160
|
}
|
|
5838
6161
|
_setupEventHandlers() {
|
|
5839
6162
|
this.el.addEventListener('click', this._handleInputClick);
|
|
@@ -5841,8 +6164,10 @@ var M = (function (exports) {
|
|
|
5841
6164
|
this.plate.addEventListener('mousedown', this._handleClockClickStart);
|
|
5842
6165
|
this.plate.addEventListener('touchstart', this._handleClockClickStart);
|
|
5843
6166
|
this.digitalClock.addEventListener('keyup', this._inputFromTextField);
|
|
5844
|
-
this.inputHours.addEventListener('
|
|
5845
|
-
this.
|
|
6167
|
+
this.inputHours.addEventListener('focus', () => this.showView('hours'));
|
|
6168
|
+
this.inputHours.addEventListener('focusout', () => this.formatHours());
|
|
6169
|
+
this.inputMinutes.addEventListener('focus', () => this.showView('minutes'));
|
|
6170
|
+
this.inputMinutes.addEventListener('focusout', () => this.formatMinutes());
|
|
5846
6171
|
}
|
|
5847
6172
|
_removeEventHandlers() {
|
|
5848
6173
|
this.el.removeEventListener('click', this._handleInputClick);
|
|
@@ -5865,12 +6190,12 @@ var M = (function (exports) {
|
|
|
5865
6190
|
};
|
|
5866
6191
|
_handleClockClickStart = (e) => {
|
|
5867
6192
|
e.preventDefault();
|
|
5868
|
-
|
|
5869
|
-
|
|
6193
|
+
const clockPlateBR = this.plate.getBoundingClientRect();
|
|
6194
|
+
const offset = { x: clockPlateBR.left, y: clockPlateBR.top };
|
|
5870
6195
|
this.x0 = offset.x + this.options.dialRadius;
|
|
5871
6196
|
this.y0 = offset.y + this.options.dialRadius;
|
|
5872
6197
|
this.moved = false;
|
|
5873
|
-
|
|
6198
|
+
const clickPos = Timepicker._Pos(e);
|
|
5874
6199
|
this.dx = clickPos.x - this.x0;
|
|
5875
6200
|
this.dy = clickPos.y - this.y0;
|
|
5876
6201
|
// Set clock hands
|
|
@@ -5884,9 +6209,9 @@ var M = (function (exports) {
|
|
|
5884
6209
|
};
|
|
5885
6210
|
_handleDocumentClickMove = (e) => {
|
|
5886
6211
|
e.preventDefault();
|
|
5887
|
-
|
|
5888
|
-
|
|
5889
|
-
|
|
6212
|
+
const clickPos = Timepicker._Pos(e);
|
|
6213
|
+
const x = clickPos.x - this.x0;
|
|
6214
|
+
const y = clickPos.y - this.y0;
|
|
5890
6215
|
this.moved = true;
|
|
5891
6216
|
this.setHand(x, y, false);
|
|
5892
6217
|
};
|
|
@@ -5894,16 +6219,16 @@ var M = (function (exports) {
|
|
|
5894
6219
|
e.preventDefault();
|
|
5895
6220
|
document.removeEventListener('mouseup', this._handleDocumentClickEnd);
|
|
5896
6221
|
document.removeEventListener('touchend', this._handleDocumentClickEnd);
|
|
5897
|
-
|
|
5898
|
-
|
|
5899
|
-
|
|
6222
|
+
const clickPos = Timepicker._Pos(e);
|
|
6223
|
+
const x = clickPos.x - this.x0;
|
|
6224
|
+
const y = clickPos.y - this.y0;
|
|
5900
6225
|
if (this.moved && x === this.dx && y === this.dy) {
|
|
5901
6226
|
this.setHand(x, y);
|
|
5902
6227
|
}
|
|
5903
6228
|
if (this.currentView === 'hours') {
|
|
5904
6229
|
this.showView('minutes', this.options.duration / 2);
|
|
5905
6230
|
}
|
|
5906
|
-
else
|
|
6231
|
+
else {
|
|
5907
6232
|
this.minutesView.classList.add('timepicker-dial-out');
|
|
5908
6233
|
setTimeout(() => {
|
|
5909
6234
|
this.done();
|
|
@@ -5931,24 +6256,11 @@ var M = (function (exports) {
|
|
|
5931
6256
|
this.el.parentElement.appendChild(this.modalEl);
|
|
5932
6257
|
}
|
|
5933
6258
|
}
|
|
5934
|
-
_setupModal() {
|
|
5935
|
-
this.modal = Modal.init(this.modalEl, {
|
|
5936
|
-
onOpenStart: this.options.onOpenStart,
|
|
5937
|
-
onOpenEnd: this.options.onOpenEnd,
|
|
5938
|
-
onCloseStart: this.options.onCloseStart,
|
|
5939
|
-
onCloseEnd: () => {
|
|
5940
|
-
if (typeof this.options.onCloseEnd === 'function') {
|
|
5941
|
-
this.options.onCloseEnd.call(this);
|
|
5942
|
-
}
|
|
5943
|
-
this.isOpen = false;
|
|
5944
|
-
}
|
|
5945
|
-
});
|
|
5946
|
-
}
|
|
5947
6259
|
_setupVariables() {
|
|
5948
6260
|
this.currentView = 'hours';
|
|
5949
6261
|
this.vibrate = navigator.vibrate
|
|
5950
6262
|
? 'vibrate'
|
|
5951
|
-
: navigator
|
|
6263
|
+
: navigator['webkitVibrate']
|
|
5952
6264
|
? 'webkitVibrate'
|
|
5953
6265
|
: null;
|
|
5954
6266
|
this._canvas = this.modalEl.querySelector('.timepicker-canvas');
|
|
@@ -5964,10 +6276,10 @@ var M = (function (exports) {
|
|
|
5964
6276
|
}
|
|
5965
6277
|
_createButton(text, visibility) {
|
|
5966
6278
|
const button = document.createElement('button');
|
|
5967
|
-
button.classList.add('btn-flat', 'waves-effect');
|
|
6279
|
+
button.classList.add('btn', 'btn-flat', 'waves-effect', 'text');
|
|
5968
6280
|
button.style.visibility = visibility;
|
|
5969
6281
|
button.type = 'button';
|
|
5970
|
-
button.tabIndex =
|
|
6282
|
+
button.tabIndex = -1;
|
|
5971
6283
|
button.innerText = text;
|
|
5972
6284
|
return button;
|
|
5973
6285
|
}
|
|
@@ -5985,20 +6297,20 @@ var M = (function (exports) {
|
|
|
5985
6297
|
confirmationBtnsContainer.appendChild(cancelButton);
|
|
5986
6298
|
const doneButton = this._createButton(this.options.i18n.done, '');
|
|
5987
6299
|
doneButton.classList.add('timepicker-close');
|
|
5988
|
-
doneButton.addEventListener('click', this.
|
|
6300
|
+
//doneButton.addEventListener('click', this._finishSelection);
|
|
5989
6301
|
confirmationBtnsContainer.appendChild(doneButton);
|
|
5990
6302
|
}
|
|
5991
6303
|
_clockSetup() {
|
|
5992
6304
|
if (this.options.twelveHour) {
|
|
5993
6305
|
// AM Button
|
|
5994
6306
|
this._amBtn = document.createElement('div');
|
|
5995
|
-
this._amBtn.classList.add('am-btn');
|
|
6307
|
+
this._amBtn.classList.add('am-btn', 'btn');
|
|
5996
6308
|
this._amBtn.innerText = 'AM';
|
|
5997
6309
|
this._amBtn.addEventListener('click', this._handleAmPmClick);
|
|
5998
6310
|
this.spanAmPm.appendChild(this._amBtn);
|
|
5999
6311
|
// PM Button
|
|
6000
6312
|
this._pmBtn = document.createElement('div');
|
|
6001
|
-
this._pmBtn.classList.add('pm-btn');
|
|
6313
|
+
this._pmBtn.classList.add('pm-btn', 'btn');
|
|
6002
6314
|
this._pmBtn.innerText = 'PM';
|
|
6003
6315
|
this._pmBtn.addEventListener('click', this._handleAmPmClick);
|
|
6004
6316
|
this.spanAmPm.appendChild(this._pmBtn);
|
|
@@ -6009,24 +6321,24 @@ var M = (function (exports) {
|
|
|
6009
6321
|
}
|
|
6010
6322
|
_buildSVGClock() {
|
|
6011
6323
|
// Draw clock hands and others
|
|
6012
|
-
|
|
6013
|
-
|
|
6014
|
-
|
|
6015
|
-
|
|
6324
|
+
const dialRadius = this.options.dialRadius;
|
|
6325
|
+
const tickRadius = this.options.tickRadius;
|
|
6326
|
+
const diameter = dialRadius * 2;
|
|
6327
|
+
const svg = Timepicker._createSVGEl('svg');
|
|
6016
6328
|
svg.setAttribute('class', 'timepicker-svg');
|
|
6017
6329
|
svg.setAttribute('width', diameter.toString());
|
|
6018
6330
|
svg.setAttribute('height', diameter.toString());
|
|
6019
|
-
|
|
6331
|
+
const g = Timepicker._createSVGEl('g');
|
|
6020
6332
|
g.setAttribute('transform', 'translate(' + dialRadius + ',' + dialRadius + ')');
|
|
6021
|
-
|
|
6333
|
+
const bearing = Timepicker._createSVGEl('circle');
|
|
6022
6334
|
bearing.setAttribute('class', 'timepicker-canvas-bearing');
|
|
6023
6335
|
bearing.setAttribute('cx', '0');
|
|
6024
6336
|
bearing.setAttribute('cy', '0');
|
|
6025
6337
|
bearing.setAttribute('r', '4');
|
|
6026
|
-
|
|
6338
|
+
const hand = Timepicker._createSVGEl('line');
|
|
6027
6339
|
hand.setAttribute('x1', '0');
|
|
6028
6340
|
hand.setAttribute('y1', '0');
|
|
6029
|
-
|
|
6341
|
+
const bg = Timepicker._createSVGEl('circle');
|
|
6030
6342
|
bg.setAttribute('class', 'timepicker-canvas-bg');
|
|
6031
6343
|
bg.setAttribute('r', tickRadius.toString());
|
|
6032
6344
|
g.appendChild(hand);
|
|
@@ -6040,35 +6352,37 @@ var M = (function (exports) {
|
|
|
6040
6352
|
this.g = g;
|
|
6041
6353
|
}
|
|
6042
6354
|
_buildHoursView() {
|
|
6043
|
-
const $tick = document.createElement('div');
|
|
6044
|
-
$tick.classList.add('timepicker-tick');
|
|
6355
|
+
// const $tick = document.createElement('div');
|
|
6356
|
+
// $tick.classList.add('timepicker-tick');
|
|
6045
6357
|
// Hours view
|
|
6046
6358
|
if (this.options.twelveHour) {
|
|
6047
6359
|
for (let i = 1; i < 13; i += 1) {
|
|
6048
|
-
const tick =
|
|
6360
|
+
// const tick = <HTMLElement>$tick.cloneNode(true);
|
|
6049
6361
|
const radian = (i / 6) * Math.PI;
|
|
6050
6362
|
const radius = this.options.outerRadius;
|
|
6051
|
-
|
|
6052
|
-
tick.style.top = this.options.dialRadius - Math.cos(radian) * radius - this.options.tickRadius + 'px';
|
|
6053
|
-
tick.innerHTML = i === 0 ? '00' : i.toString();
|
|
6054
|
-
this.hoursView.appendChild(tick);
|
|
6055
|
-
// tick.on(mousedownEvent, mousedown);
|
|
6363
|
+
this._buildHoursTick(i, radian, radius);
|
|
6056
6364
|
}
|
|
6057
6365
|
}
|
|
6058
6366
|
else {
|
|
6059
6367
|
for (let i = 0; i < 24; i += 1) {
|
|
6060
|
-
const tick =
|
|
6368
|
+
// const tick = <HTMLElement>$tick.cloneNode(true);
|
|
6061
6369
|
const radian = (i / 6) * Math.PI;
|
|
6062
6370
|
const inner = i > 0 && i < 13;
|
|
6063
6371
|
const radius = inner ? this.options.innerRadius : this.options.outerRadius;
|
|
6064
|
-
|
|
6065
|
-
tick.style.top = this.options.dialRadius - Math.cos(radian) * radius - this.options.tickRadius + 'px';
|
|
6066
|
-
tick.innerHTML = i === 0 ? '00' : i.toString();
|
|
6067
|
-
this.hoursView.appendChild(tick);
|
|
6068
|
-
// tick.on(mousedownEvent, mousedown);
|
|
6372
|
+
this._buildHoursTick(i, radian, radius);
|
|
6069
6373
|
}
|
|
6070
6374
|
}
|
|
6071
6375
|
}
|
|
6376
|
+
_buildHoursTick(i, radian, radius) {
|
|
6377
|
+
const tick = document.createElement('div');
|
|
6378
|
+
tick.classList.add('timepicker-tick');
|
|
6379
|
+
tick.style.left =
|
|
6380
|
+
this.options.dialRadius + Math.sin(radian) * radius - this.options.tickRadius + 'px';
|
|
6381
|
+
tick.style.top =
|
|
6382
|
+
this.options.dialRadius - Math.cos(radian) * radius - this.options.tickRadius + 'px';
|
|
6383
|
+
tick.innerHTML = i === 0 ? '00' : i.toString();
|
|
6384
|
+
this.hoursView.appendChild(tick);
|
|
6385
|
+
}
|
|
6072
6386
|
_buildMinutesView() {
|
|
6073
6387
|
const _tick = document.createElement('div');
|
|
6074
6388
|
_tick.classList.add('timepicker-tick');
|
|
@@ -6098,12 +6412,12 @@ var M = (function (exports) {
|
|
|
6098
6412
|
_updateAmPmView() {
|
|
6099
6413
|
if (this.options.twelveHour) {
|
|
6100
6414
|
if (this.amOrPm === 'PM') {
|
|
6101
|
-
this._amBtn.classList.remove('
|
|
6102
|
-
this._pmBtn.classList.add('
|
|
6415
|
+
this._amBtn.classList.remove('filled');
|
|
6416
|
+
this._pmBtn.classList.add('filled');
|
|
6103
6417
|
}
|
|
6104
6418
|
else if (this.amOrPm === 'AM') {
|
|
6105
|
-
this._amBtn.classList.add('
|
|
6106
|
-
this._pmBtn.classList.remove('
|
|
6419
|
+
this._amBtn.classList.add('filled');
|
|
6420
|
+
this._pmBtn.classList.remove('filled');
|
|
6107
6421
|
}
|
|
6108
6422
|
}
|
|
6109
6423
|
}
|
|
@@ -6120,7 +6434,7 @@ var M = (function (exports) {
|
|
|
6120
6434
|
value[1] = value[1].replace('AM', '').replace('PM', '');
|
|
6121
6435
|
}
|
|
6122
6436
|
if (value[0] === 'now') {
|
|
6123
|
-
|
|
6437
|
+
const now = new Date(+new Date() + this.options.fromNow);
|
|
6124
6438
|
value = [now.getHours().toString(), now.getMinutes().toString()];
|
|
6125
6439
|
if (this.options.twelveHour) {
|
|
6126
6440
|
this.amOrPm = parseInt(value[0]) >= 12 && parseInt(value[0]) < 24 ? 'PM' : 'AM';
|
|
@@ -6128,17 +6442,18 @@ var M = (function (exports) {
|
|
|
6128
6442
|
}
|
|
6129
6443
|
this.hours = +value[0] || 0;
|
|
6130
6444
|
this.minutes = +value[1] || 0;
|
|
6131
|
-
this.inputHours.value = this.hours;
|
|
6445
|
+
this.inputHours.value = Timepicker._addLeadingZero(this.hours);
|
|
6132
6446
|
this.inputMinutes.value = Timepicker._addLeadingZero(this.minutes);
|
|
6133
6447
|
this._updateAmPmView();
|
|
6134
6448
|
}
|
|
6135
6449
|
/**
|
|
6136
6450
|
* Show hours or minutes view on timepicker.
|
|
6137
6451
|
* @param view The name of the view you want to switch to, 'hours' or 'minutes'.
|
|
6452
|
+
* @param delay
|
|
6138
6453
|
*/
|
|
6139
6454
|
showView = (view, delay = null) => {
|
|
6140
6455
|
if (view === 'minutes' && getComputedStyle(this.hoursView).visibility === 'visible') ;
|
|
6141
|
-
|
|
6456
|
+
const isHours = view === 'hours', nextView = isHours ? this.hoursView : this.minutesView, hideView = isHours ? this.minutesView : this.hoursView;
|
|
6142
6457
|
this.currentView = view;
|
|
6143
6458
|
if (isHours) {
|
|
6144
6459
|
this.inputHours.classList.add('text-primary');
|
|
@@ -6161,12 +6476,12 @@ var M = (function (exports) {
|
|
|
6161
6476
|
}, this.options.duration);
|
|
6162
6477
|
};
|
|
6163
6478
|
resetClock(delay) {
|
|
6164
|
-
|
|
6479
|
+
const view = this.currentView, value = this[view], isHours = view === 'hours', unit = Math.PI / (isHours ? 6 : 30), radian = value * unit, radius = isHours && value > 0 && value < 13 ? this.options.innerRadius : this.options.outerRadius, x = Math.sin(radian) * radius, y = -Math.cos(radian) * radius;
|
|
6165
6480
|
if (delay) {
|
|
6166
|
-
this.
|
|
6481
|
+
this._canvas?.classList.add('timepicker-canvas-out');
|
|
6167
6482
|
setTimeout(() => {
|
|
6168
|
-
|
|
6169
|
-
|
|
6483
|
+
this._canvas?.classList.remove('timepicker-canvas-out');
|
|
6484
|
+
this.setHand(x, y);
|
|
6170
6485
|
}, delay);
|
|
6171
6486
|
}
|
|
6172
6487
|
else {
|
|
@@ -6175,31 +6490,26 @@ var M = (function (exports) {
|
|
|
6175
6490
|
}
|
|
6176
6491
|
_inputFromTextField = () => {
|
|
6177
6492
|
const isHours = this.currentView === 'hours';
|
|
6178
|
-
if (isHours) {
|
|
6493
|
+
if (isHours && this.inputHours.value !== '') {
|
|
6179
6494
|
const value = parseInt(this.inputHours.value);
|
|
6180
|
-
if (value > 0 && value < 13) {
|
|
6181
|
-
this.drawClockFromTimeInput(value, isHours);
|
|
6182
|
-
this.showView('minutes', this.options.duration / 2);
|
|
6495
|
+
if (value > 0 && value < (this.options.twelveHour ? 13 : 24)) {
|
|
6183
6496
|
this.hours = value;
|
|
6184
|
-
this.inputMinutes.focus();
|
|
6185
6497
|
}
|
|
6186
6498
|
else {
|
|
6187
|
-
|
|
6188
|
-
this.inputHours.value = (hour % 12).toString();
|
|
6499
|
+
this.setHoursDefault();
|
|
6189
6500
|
}
|
|
6501
|
+
this.drawClockFromTimeInput(this.hours, isHours);
|
|
6190
6502
|
}
|
|
6191
|
-
else {
|
|
6503
|
+
else if (!isHours && this.inputMinutes.value !== '') {
|
|
6192
6504
|
const value = parseInt(this.inputMinutes.value);
|
|
6193
6505
|
if (value >= 0 && value < 60) {
|
|
6194
|
-
this.inputMinutes.value = Timepicker._addLeadingZero(value);
|
|
6195
|
-
this.drawClockFromTimeInput(value, isHours);
|
|
6196
6506
|
this.minutes = value;
|
|
6197
|
-
this.modalEl.querySelector('.confirmation-btns :nth-child(2)').focus();
|
|
6198
6507
|
}
|
|
6199
6508
|
else {
|
|
6200
|
-
|
|
6201
|
-
this.inputMinutes.value =
|
|
6509
|
+
this.minutes = new Date().getMinutes();
|
|
6510
|
+
this.inputMinutes.value = this.minutes.toString();
|
|
6202
6511
|
}
|
|
6512
|
+
this.drawClockFromTimeInput(this.minutes, isHours);
|
|
6203
6513
|
}
|
|
6204
6514
|
};
|
|
6205
6515
|
drawClockFromTimeInput(value, isHours) {
|
|
@@ -6209,14 +6519,15 @@ var M = (function (exports) {
|
|
|
6209
6519
|
if (this.options.twelveHour) {
|
|
6210
6520
|
radius = this.options.outerRadius;
|
|
6211
6521
|
}
|
|
6212
|
-
|
|
6213
|
-
|
|
6214
|
-
|
|
6215
|
-
|
|
6216
|
-
this.
|
|
6522
|
+
else {
|
|
6523
|
+
radius =
|
|
6524
|
+
isHours && value > 0 && value < 13 ? this.options.innerRadius : this.options.outerRadius;
|
|
6525
|
+
}
|
|
6526
|
+
this.setClockAttributes(radian, radius);
|
|
6217
6527
|
}
|
|
6218
6528
|
setHand(x, y, roundBy5 = false) {
|
|
6219
|
-
|
|
6529
|
+
const isHours = this.currentView === 'hours', unit = Math.PI / (isHours || roundBy5 ? 6 : 30), z = Math.sqrt(x * x + y * y), inner = isHours && z < (this.options.outerRadius + this.options.innerRadius) / 2;
|
|
6530
|
+
let radian = Math.atan2(x, -y), radius = inner ? this.options.innerRadius : this.options.outerRadius;
|
|
6220
6531
|
if (this.options.twelveHour) {
|
|
6221
6532
|
radius = this.options.outerRadius;
|
|
6222
6533
|
}
|
|
@@ -6271,41 +6582,39 @@ var M = (function (exports) {
|
|
|
6271
6582
|
}
|
|
6272
6583
|
this[this.currentView] = value;
|
|
6273
6584
|
if (isHours) {
|
|
6274
|
-
this.inputHours.value =
|
|
6585
|
+
this.inputHours.value = Timepicker._addLeadingZero(value);
|
|
6275
6586
|
}
|
|
6276
6587
|
else {
|
|
6277
6588
|
this.inputMinutes.value = Timepicker._addLeadingZero(value);
|
|
6278
6589
|
}
|
|
6279
6590
|
// Set clock hand and others' position
|
|
6280
|
-
|
|
6591
|
+
this.setClockAttributes(radian, radius);
|
|
6592
|
+
}
|
|
6593
|
+
setClockAttributes(radian, radius) {
|
|
6594
|
+
const cx1 = Math.sin(radian) * (radius - this.options.tickRadius), cy1 = -Math.cos(radian) * (radius - this.options.tickRadius), cx2 = Math.sin(radian) * radius, cy2 = -Math.cos(radian) * radius;
|
|
6281
6595
|
this.hand.setAttribute('x2', cx1.toString());
|
|
6282
6596
|
this.hand.setAttribute('y2', cy1.toString());
|
|
6283
6597
|
this.bg.setAttribute('cx', cx2.toString());
|
|
6284
6598
|
this.bg.setAttribute('cy', cy2.toString());
|
|
6285
6599
|
}
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
this.
|
|
6293
|
-
|
|
6294
|
-
this.
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
if (!this.isOpen)
|
|
6302
|
-
return;
|
|
6303
|
-
this.isOpen = false;
|
|
6304
|
-
this.modal.close();
|
|
6305
|
-
};
|
|
6600
|
+
formatHours() {
|
|
6601
|
+
if (this.inputHours.value == '')
|
|
6602
|
+
this.setHoursDefault();
|
|
6603
|
+
this.inputHours.value = Timepicker._addLeadingZero(Number(this.inputHours.value));
|
|
6604
|
+
}
|
|
6605
|
+
formatMinutes() {
|
|
6606
|
+
if (this.inputMinutes.value == '')
|
|
6607
|
+
this.minutes = new Date().getMinutes();
|
|
6608
|
+
this.inputMinutes.value = Timepicker._addLeadingZero(Number(this.inputMinutes.value));
|
|
6609
|
+
}
|
|
6610
|
+
setHoursDefault() {
|
|
6611
|
+
this.hours = new Date().getHours();
|
|
6612
|
+
this.inputHours.value = (this.hours % (this.options.twelveHour ? 12 : 24)).toString();
|
|
6613
|
+
}
|
|
6614
|
+
// todo: remove e
|
|
6306
6615
|
done = (e = null, clearValue = null) => {
|
|
6307
6616
|
// Set input value
|
|
6308
|
-
|
|
6617
|
+
const last = this.el.value;
|
|
6309
6618
|
let value = clearValue
|
|
6310
6619
|
? ''
|
|
6311
6620
|
: Timepicker._addLeadingZero(this.hours) + ':' + Timepicker._addLeadingZero(this.minutes);
|
|
@@ -6318,12 +6627,23 @@ var M = (function (exports) {
|
|
|
6318
6627
|
if (value !== last) {
|
|
6319
6628
|
this.el.dispatchEvent(new Event('change', { bubbles: true, cancelable: true, composed: true }));
|
|
6320
6629
|
}
|
|
6321
|
-
this.
|
|
6322
|
-
|
|
6630
|
+
//this.el.focus();
|
|
6631
|
+
return e; // just for passing linter, can be removed
|
|
6323
6632
|
};
|
|
6324
6633
|
clear = () => {
|
|
6325
6634
|
this.done(null, true);
|
|
6326
6635
|
};
|
|
6636
|
+
// deprecated
|
|
6637
|
+
open() {
|
|
6638
|
+
// this._updateTimeFromInput();
|
|
6639
|
+
// this.showView('hours');
|
|
6640
|
+
console.warn('Timepicker.close() is deprecated. Remove this method and wrap in modal yourself.');
|
|
6641
|
+
return this;
|
|
6642
|
+
}
|
|
6643
|
+
close() {
|
|
6644
|
+
console.warn('Timepicker.close() is deprecated. Remove this method and wrap in modal yourself.');
|
|
6645
|
+
return this;
|
|
6646
|
+
}
|
|
6327
6647
|
static {
|
|
6328
6648
|
Timepicker._template = `
|
|
6329
6649
|
<div class="modal timepicker-modal">
|
|
@@ -6331,9 +6651,15 @@ var M = (function (exports) {
|
|
|
6331
6651
|
<div class="timepicker-digital-display">
|
|
6332
6652
|
<div class="timepicker-text-container">
|
|
6333
6653
|
<div class="timepicker-display-column">
|
|
6334
|
-
<
|
|
6335
|
-
|
|
6336
|
-
|
|
6654
|
+
<div class="timepicker-input-hours-wrapper">
|
|
6655
|
+
<input type="text" maxlength="2" autofocus class="timepicker-input-hours text-primary" />
|
|
6656
|
+
</div>
|
|
6657
|
+
<div class="timepicker-input-divider-wrapper">
|
|
6658
|
+
<span class="timepicker-input-divider">:</span>
|
|
6659
|
+
</div>
|
|
6660
|
+
<div class="timepicker-input-minutes-wrapper">
|
|
6661
|
+
<input type="text" maxlength="2" class="timepicker-input-minutes" />
|
|
6662
|
+
</div>
|
|
6337
6663
|
</div>
|
|
6338
6664
|
<div class="timepicker-display-column timepicker-display-am-pm">
|
|
6339
6665
|
<div class="timepicker-span-am-pm"></div>
|
|
@@ -6349,7 +6675,7 @@ var M = (function (exports) {
|
|
|
6349
6675
|
<div class="timepicker-footer"></div>
|
|
6350
6676
|
</div>
|
|
6351
6677
|
</div>
|
|
6352
|
-
</div
|
|
6678
|
+
</div>`;
|
|
6353
6679
|
}
|
|
6354
6680
|
}
|
|
6355
6681
|
|
|
@@ -6384,7 +6710,7 @@ var M = (function (exports) {
|
|
|
6384
6710
|
yMovement;
|
|
6385
6711
|
constructor(el, options) {
|
|
6386
6712
|
super(el, options, Tooltip);
|
|
6387
|
-
this.el
|
|
6713
|
+
this.el['M_Tooltip'] = this;
|
|
6388
6714
|
this.options = {
|
|
6389
6715
|
...Tooltip.defaults,
|
|
6390
6716
|
...this._getAttributeOptions(),
|
|
@@ -6408,12 +6734,12 @@ var M = (function (exports) {
|
|
|
6408
6734
|
return super.init(els, options, Tooltip);
|
|
6409
6735
|
}
|
|
6410
6736
|
static getInstance(el) {
|
|
6411
|
-
return el
|
|
6737
|
+
return el['M_Tooltip'];
|
|
6412
6738
|
}
|
|
6413
6739
|
destroy() {
|
|
6414
6740
|
this.tooltipEl.remove();
|
|
6415
6741
|
this._removeEventHandlers();
|
|
6416
|
-
this.el
|
|
6742
|
+
this.el['M_Tooltip'] = undefined;
|
|
6417
6743
|
}
|
|
6418
6744
|
_appendTooltipEl() {
|
|
6419
6745
|
this.tooltipEl = document.createElement('div');
|
|
@@ -6422,7 +6748,7 @@ var M = (function (exports) {
|
|
|
6422
6748
|
? document.getElementById(this.options.tooltipId)
|
|
6423
6749
|
: document.createElement('div');
|
|
6424
6750
|
this.tooltipEl.append(tooltipContentEl);
|
|
6425
|
-
tooltipContentEl.style.display =
|
|
6751
|
+
tooltipContentEl.style.display = '';
|
|
6426
6752
|
tooltipContentEl.classList.add('tooltip-content');
|
|
6427
6753
|
this._setTooltipContent(tooltipContentEl);
|
|
6428
6754
|
this.tooltipEl.appendChild(tooltipContentEl);
|
|
@@ -6491,7 +6817,8 @@ var M = (function (exports) {
|
|
|
6491
6817
|
_positionTooltip() {
|
|
6492
6818
|
const tooltip = this.tooltipEl;
|
|
6493
6819
|
const origin = this.el, originHeight = origin.offsetHeight, originWidth = origin.offsetWidth, tooltipHeight = tooltip.offsetHeight, tooltipWidth = tooltip.offsetWidth, margin = this.options.margin;
|
|
6494
|
-
|
|
6820
|
+
this.xMovement = 0;
|
|
6821
|
+
this.yMovement = 0;
|
|
6495
6822
|
let targetTop = origin.getBoundingClientRect().top + Utils.getDocumentScrollTop();
|
|
6496
6823
|
let targetLeft = origin.getBoundingClientRect().left + Utils.getDocumentScrollLeft();
|
|
6497
6824
|
if (this.options.position === 'top') {
|
|
@@ -6604,7 +6931,7 @@ var M = (function (exports) {
|
|
|
6604
6931
|
this.close();
|
|
6605
6932
|
};
|
|
6606
6933
|
_getAttributeOptions() {
|
|
6607
|
-
|
|
6934
|
+
const attributeOptions = {};
|
|
6608
6935
|
const tooltipTextOption = this.el.getAttribute('data-tooltip');
|
|
6609
6936
|
const tooltipId = this.el.getAttribute('data-tooltip-id');
|
|
6610
6937
|
const positionOption = this.el.getAttribute('data-position');
|
|
@@ -6641,11 +6968,22 @@ var M = (function (exports) {
|
|
|
6641
6968
|
}
|
|
6642
6969
|
const frame = timestamp - animationStart;
|
|
6643
6970
|
if (frame < duration) {
|
|
6644
|
-
const easing = (frame / duration) * (2 -
|
|
6645
|
-
const circle = isCentered
|
|
6971
|
+
const easing = (frame / duration) * (2 - frame / duration);
|
|
6972
|
+
const circle = isCentered
|
|
6973
|
+
? 'circle at 50% 50%'
|
|
6974
|
+
: `circle at ${position.x}px ${position.y}px`;
|
|
6646
6975
|
const waveColor = `rgba(${color?.r || 0}, ${color?.g || 0}, ${color?.b || 0}, ${0.3 * (1 - easing)})`;
|
|
6647
|
-
const stop = 90 * easing +
|
|
6648
|
-
targetElement.style.backgroundImage =
|
|
6976
|
+
const stop = 90 * easing + '%';
|
|
6977
|
+
targetElement.style.backgroundImage =
|
|
6978
|
+
'radial-gradient(' +
|
|
6979
|
+
circle +
|
|
6980
|
+
', ' +
|
|
6981
|
+
waveColor +
|
|
6982
|
+
' ' +
|
|
6983
|
+
stop +
|
|
6984
|
+
', transparent ' +
|
|
6985
|
+
stop +
|
|
6986
|
+
')';
|
|
6649
6987
|
animationFrame = window.requestAnimationFrame(animationStep);
|
|
6650
6988
|
}
|
|
6651
6989
|
else {
|
|
@@ -6657,8 +6995,8 @@ var M = (function (exports) {
|
|
|
6657
6995
|
}
|
|
6658
6996
|
static Init() {
|
|
6659
6997
|
if (typeof document !== 'undefined')
|
|
6660
|
-
document?.addEventListener(
|
|
6661
|
-
document.body.addEventListener('click', e => {
|
|
6998
|
+
document?.addEventListener('DOMContentLoaded', () => {
|
|
6999
|
+
document.body.addEventListener('click', (e) => {
|
|
6662
7000
|
const trigger = e.target;
|
|
6663
7001
|
const el = trigger.closest('.waves-effect');
|
|
6664
7002
|
if (el && el.contains(trigger)) {
|
|
@@ -6683,7 +7021,7 @@ var M = (function (exports) {
|
|
|
6683
7021
|
thumb;
|
|
6684
7022
|
constructor(el, options) {
|
|
6685
7023
|
super(el, options, Range);
|
|
6686
|
-
this.el
|
|
7024
|
+
this.el['M_Range'] = this;
|
|
6687
7025
|
this.options = {
|
|
6688
7026
|
...Range.defaults,
|
|
6689
7027
|
...options
|
|
@@ -6704,12 +7042,12 @@ var M = (function (exports) {
|
|
|
6704
7042
|
return super.init(els, options, Range);
|
|
6705
7043
|
}
|
|
6706
7044
|
static getInstance(el) {
|
|
6707
|
-
return el
|
|
7045
|
+
return el['M_Range'];
|
|
6708
7046
|
}
|
|
6709
7047
|
destroy() {
|
|
6710
7048
|
this._removeEventHandlers();
|
|
6711
7049
|
this._removeThumb();
|
|
6712
|
-
this.el
|
|
7050
|
+
this.el['M_Range'] = undefined;
|
|
6713
7051
|
}
|
|
6714
7052
|
_setupEventHandlers() {
|
|
6715
7053
|
this.el.addEventListener('change', this._handleRangeChange);
|
|
@@ -6790,7 +7128,7 @@ var M = (function (exports) {
|
|
|
6790
7128
|
top ${duration}ms ease,
|
|
6791
7129
|
margin ${duration}ms ease
|
|
6792
7130
|
`;
|
|
6793
|
-
// to
|
|
7131
|
+
// to
|
|
6794
7132
|
this.thumb.style.height = '0';
|
|
6795
7133
|
this.thumb.style.width = '0';
|
|
6796
7134
|
this.thumb.style.top = '0';
|
|
@@ -6840,7 +7178,7 @@ var M = (function (exports) {
|
|
|
6840
7178
|
*/
|
|
6841
7179
|
static Init() {
|
|
6842
7180
|
if (typeof document !== 'undefined')
|
|
6843
|
-
Range.init(
|
|
7181
|
+
Range.init(document?.querySelectorAll('input[type=range]'), {});
|
|
6844
7182
|
}
|
|
6845
7183
|
}
|
|
6846
7184
|
|
|
@@ -6854,7 +7192,7 @@ var M = (function (exports) {
|
|
|
6854
7192
|
isValidLength;
|
|
6855
7193
|
constructor(el, options) {
|
|
6856
7194
|
super(el, {}, CharacterCounter);
|
|
6857
|
-
this.el
|
|
7195
|
+
this.el['M_CharacterCounter'] = this;
|
|
6858
7196
|
this.options = {
|
|
6859
7197
|
...CharacterCounter.defaults,
|
|
6860
7198
|
...options
|
|
@@ -6876,11 +7214,11 @@ var M = (function (exports) {
|
|
|
6876
7214
|
return super.init(els, options, CharacterCounter);
|
|
6877
7215
|
}
|
|
6878
7216
|
static getInstance(el) {
|
|
6879
|
-
return el
|
|
7217
|
+
return el['M_CharacterCounter'];
|
|
6880
7218
|
}
|
|
6881
7219
|
destroy() {
|
|
6882
7220
|
this._removeEventHandlers();
|
|
6883
|
-
this.el
|
|
7221
|
+
this.el['CharacterCounter'] = undefined;
|
|
6884
7222
|
this._removeCounter();
|
|
6885
7223
|
}
|
|
6886
7224
|
_setupEventHandlers() {
|
|
@@ -6903,7 +7241,7 @@ var M = (function (exports) {
|
|
|
6903
7241
|
this.counterEl.remove();
|
|
6904
7242
|
}
|
|
6905
7243
|
updateCounter = () => {
|
|
6906
|
-
|
|
7244
|
+
const maxLength = parseInt(this.el.getAttribute('maxlength')), actualLength = this.el.value.length;
|
|
6907
7245
|
this.isValidLength = actualLength <= maxLength;
|
|
6908
7246
|
let counterString = actualLength.toString();
|
|
6909
7247
|
if (maxLength) {
|
|
@@ -6925,7 +7263,7 @@ var M = (function (exports) {
|
|
|
6925
7263
|
}
|
|
6926
7264
|
}
|
|
6927
7265
|
|
|
6928
|
-
|
|
7266
|
+
const _defaults$1 = {
|
|
6929
7267
|
indicators: true,
|
|
6930
7268
|
height: 400,
|
|
6931
7269
|
duration: 500,
|
|
@@ -6949,7 +7287,7 @@ var M = (function (exports) {
|
|
|
6949
7287
|
_sliderId;
|
|
6950
7288
|
constructor(el, options) {
|
|
6951
7289
|
super(el, options, Slider);
|
|
6952
|
-
this.el
|
|
7290
|
+
this.el['M_Slider'] = this;
|
|
6953
7291
|
this.options = {
|
|
6954
7292
|
...Slider.defaults,
|
|
6955
7293
|
...options
|
|
@@ -6963,7 +7301,7 @@ var M = (function (exports) {
|
|
|
6963
7301
|
// setup
|
|
6964
7302
|
this._slider = this.el.querySelector('.slides');
|
|
6965
7303
|
this._slides = Array.from(this._slider.querySelectorAll('li'));
|
|
6966
|
-
this.activeIndex = this._slides.findIndex(li => li.classList.contains('active'));
|
|
7304
|
+
this.activeIndex = this._slides.findIndex((li) => li.classList.contains('active'));
|
|
6967
7305
|
if (this.activeIndex !== -1) {
|
|
6968
7306
|
this._activeSlide = this._slides[this.activeIndex];
|
|
6969
7307
|
}
|
|
@@ -6977,7 +7315,7 @@ var M = (function (exports) {
|
|
|
6977
7315
|
}
|
|
6978
7316
|
const placeholderBase64 = 'data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
|
|
6979
7317
|
// Set initial positions of captions
|
|
6980
|
-
this._slides.forEach(slide => {
|
|
7318
|
+
this._slides.forEach((slide) => {
|
|
6981
7319
|
// Caption
|
|
6982
7320
|
//const caption = <HTMLElement|null>slide.querySelector('.caption');
|
|
6983
7321
|
//if (caption) this._animateCaptionIn(caption, 0);
|
|
@@ -7028,13 +7366,13 @@ var M = (function (exports) {
|
|
|
7028
7366
|
return super.init(els, options, Slider);
|
|
7029
7367
|
}
|
|
7030
7368
|
static getInstance(el) {
|
|
7031
|
-
return el
|
|
7369
|
+
return el['M_Slider'];
|
|
7032
7370
|
}
|
|
7033
7371
|
destroy() {
|
|
7034
7372
|
this.pause();
|
|
7035
7373
|
this._removeIndicators();
|
|
7036
7374
|
this._removeEventHandlers();
|
|
7037
|
-
this.el
|
|
7375
|
+
this.el['M_Slider'] = undefined;
|
|
7038
7376
|
}
|
|
7039
7377
|
_setupEventHandlers() {
|
|
7040
7378
|
if (this.options.pauseOnFocus) {
|
|
@@ -7139,7 +7477,7 @@ var M = (function (exports) {
|
|
|
7139
7477
|
if (!this.el.classList.contains('fullscreen')) {
|
|
7140
7478
|
if (this.options.indicators) {
|
|
7141
7479
|
// Add height if indicators are present
|
|
7142
|
-
this.el.style.height =
|
|
7480
|
+
this.el.style.height = this.options.height + 40 + 'px'; //.css('height', this.options.height + 40 + 'px');
|
|
7143
7481
|
}
|
|
7144
7482
|
else {
|
|
7145
7483
|
this.el.style.height = this.options.height + 'px';
|
|
@@ -7182,11 +7520,11 @@ var M = (function (exports) {
|
|
|
7182
7520
|
const _caption = this._activeSlide.querySelector('.caption');
|
|
7183
7521
|
this._activeSlide.classList.remove('active');
|
|
7184
7522
|
// Enables every slide
|
|
7185
|
-
this._slides.forEach(slide => slide.style.visibility = 'visible');
|
|
7523
|
+
this._slides.forEach((slide) => (slide.style.visibility = 'visible'));
|
|
7186
7524
|
//--- Hide active Slide + Caption
|
|
7187
7525
|
this._activeSlide.style.opacity = '0';
|
|
7188
7526
|
setTimeout(() => {
|
|
7189
|
-
this._slides.forEach(slide => {
|
|
7527
|
+
this._slides.forEach((slide) => {
|
|
7190
7528
|
if (slide.classList.contains('active'))
|
|
7191
7529
|
return;
|
|
7192
7530
|
slide.style.opacity = '0';
|
|
@@ -7204,7 +7542,7 @@ var M = (function (exports) {
|
|
|
7204
7542
|
const nextIndicator = this._indicators[index].children[0];
|
|
7205
7543
|
activeIndicator.classList.remove('active');
|
|
7206
7544
|
nextIndicator.classList.add('active');
|
|
7207
|
-
if (typeof this.options.indicatorLabelFunc ===
|
|
7545
|
+
if (typeof this.options.indicatorLabelFunc === 'function') {
|
|
7208
7546
|
activeIndicator.ariaLabel = this.options.indicatorLabelFunc.call(this, this.activeIndex, false);
|
|
7209
7547
|
nextIndicator.ariaLabel = this.options.indicatorLabelFunc.call(this, index, true);
|
|
7210
7548
|
}
|
|
@@ -7264,7 +7602,7 @@ var M = (function (exports) {
|
|
|
7264
7602
|
};
|
|
7265
7603
|
}
|
|
7266
7604
|
|
|
7267
|
-
|
|
7605
|
+
const _defaults = {
|
|
7268
7606
|
text: '',
|
|
7269
7607
|
displayLength: 4000,
|
|
7270
7608
|
inDuration: 300,
|
|
@@ -7310,8 +7648,8 @@ var M = (function (exports) {
|
|
|
7310
7648
|
}
|
|
7311
7649
|
// Create new toast
|
|
7312
7650
|
Toast._toasts.push(this);
|
|
7313
|
-
|
|
7314
|
-
toastElement
|
|
7651
|
+
const toastElement = this._createToast();
|
|
7652
|
+
toastElement['M_Toast'] = this;
|
|
7315
7653
|
this.el = toastElement;
|
|
7316
7654
|
this._animateIn();
|
|
7317
7655
|
this._setTimer();
|
|
@@ -7320,7 +7658,7 @@ var M = (function (exports) {
|
|
|
7320
7658
|
return _defaults;
|
|
7321
7659
|
}
|
|
7322
7660
|
static getInstance(el) {
|
|
7323
|
-
return el
|
|
7661
|
+
return el['M_Toast'];
|
|
7324
7662
|
}
|
|
7325
7663
|
static _createContainer() {
|
|
7326
7664
|
const container = document.createElement('div');
|
|
@@ -7344,7 +7682,7 @@ var M = (function (exports) {
|
|
|
7344
7682
|
static _onDragStart(e) {
|
|
7345
7683
|
if (e.target && e.target.closest('.toast')) {
|
|
7346
7684
|
const toastElem = e.target.closest('.toast');
|
|
7347
|
-
const toast = toastElem
|
|
7685
|
+
const toast = toastElem['M_Toast'];
|
|
7348
7686
|
toast.panning = true;
|
|
7349
7687
|
Toast._draggedToast = toast;
|
|
7350
7688
|
toast.el.classList.add('panning');
|
|
@@ -7370,12 +7708,12 @@ var M = (function (exports) {
|
|
|
7370
7708
|
}
|
|
7371
7709
|
static _onDragEnd() {
|
|
7372
7710
|
if (!!Toast._draggedToast) {
|
|
7373
|
-
|
|
7711
|
+
const toast = Toast._draggedToast;
|
|
7374
7712
|
toast.panning = false;
|
|
7375
7713
|
toast.el.classList.remove('panning');
|
|
7376
|
-
|
|
7377
|
-
|
|
7378
|
-
|
|
7714
|
+
const totalDeltaX = toast.xPos - toast.startingXPos;
|
|
7715
|
+
const activationDistance = toast.el.offsetWidth * toast.options.activationPercent;
|
|
7716
|
+
const shouldBeDismissed = Math.abs(totalDeltaX) > activationDistance || toast.velocityX > 1;
|
|
7379
7717
|
// Remove toast
|
|
7380
7718
|
if (shouldBeDismissed) {
|
|
7381
7719
|
toast.wasSwiped = true;
|
|
@@ -7391,7 +7729,7 @@ var M = (function (exports) {
|
|
|
7391
7729
|
}
|
|
7392
7730
|
}
|
|
7393
7731
|
static _xPos(e) {
|
|
7394
|
-
if (e.type.startsWith(
|
|
7732
|
+
if (e.type.startsWith('touch') && e.targetTouches.length >= 1) {
|
|
7395
7733
|
return e.targetTouches[0].clientX;
|
|
7396
7734
|
}
|
|
7397
7735
|
// mouse event
|
|
@@ -7401,7 +7739,7 @@ var M = (function (exports) {
|
|
|
7401
7739
|
* dismiss all toasts.
|
|
7402
7740
|
*/
|
|
7403
7741
|
static dismissAll() {
|
|
7404
|
-
for (
|
|
7742
|
+
for (const toastIndex in Toast._toasts) {
|
|
7405
7743
|
Toast._toasts[toastIndex].dismiss();
|
|
7406
7744
|
}
|
|
7407
7745
|
}
|
|
@@ -7428,7 +7766,7 @@ var M = (function (exports) {
|
|
|
7428
7766
|
}
|
|
7429
7767
|
_animateIn() {
|
|
7430
7768
|
// Animate toast in
|
|
7431
|
-
this.el.style.display =
|
|
7769
|
+
this.el.style.display = '';
|
|
7432
7770
|
this.el.style.opacity = '0';
|
|
7433
7771
|
// easeOutCubic
|
|
7434
7772
|
this.el.style.transition = `
|
|
@@ -7462,8 +7800,8 @@ var M = (function (exports) {
|
|
|
7462
7800
|
* Dismiss toast with animation.
|
|
7463
7801
|
*/
|
|
7464
7802
|
dismiss() {
|
|
7465
|
-
|
|
7466
|
-
|
|
7803
|
+
clearInterval(this.counterInterval);
|
|
7804
|
+
const activationDistance = this.el.offsetWidth * this.options.activationPercent;
|
|
7467
7805
|
if (this.wasSwiped) {
|
|
7468
7806
|
this.el.style.transition = 'transform .05s, opacity .05s';
|
|
7469
7807
|
this.el.style.transform = `translateX(${activationDistance}px)`;
|
|
@@ -7499,20 +7837,17 @@ var M = (function (exports) {
|
|
|
7499
7837
|
}
|
|
7500
7838
|
}
|
|
7501
7839
|
|
|
7502
|
-
|
|
7503
|
-
const
|
|
7504
|
-
return `<div class="row">${children}</row>`;
|
|
7505
|
-
};
|
|
7506
|
-
function Button(children = '') {
|
|
7507
|
-
return `<button class="btn">${children}</button>`;
|
|
7508
|
-
}
|
|
7840
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
7841
|
+
const version = '2.2.1';
|
|
7509
7842
|
/**
|
|
7510
7843
|
* Automatically initialize components.
|
|
7511
7844
|
* @param context Root element to initialize. Defaults to `document.body`.
|
|
7845
|
+
* @param options Options for each component.
|
|
7512
7846
|
*/
|
|
7513
|
-
function AutoInit(context = document.body) {
|
|
7514
|
-
|
|
7847
|
+
function AutoInit(context = document.body, options) {
|
|
7848
|
+
const registry = {
|
|
7515
7849
|
Autocomplete: context.querySelectorAll('.autocomplete:not(.no-autoinit)'),
|
|
7850
|
+
Cards: context.querySelectorAll('.cards:not(.no-autoinit)'),
|
|
7516
7851
|
Carousel: context.querySelectorAll('.carousel:not(.no-autoinit)'),
|
|
7517
7852
|
Chips: context.querySelectorAll('.chips:not(.no-autoinit)'),
|
|
7518
7853
|
Collapsible: context.querySelectorAll('.collapsible:not(.no-autoinit)'),
|
|
@@ -7531,24 +7866,25 @@ var M = (function (exports) {
|
|
|
7531
7866
|
Tooltip: context.querySelectorAll('.tooltipped:not(.no-autoinit)'),
|
|
7532
7867
|
FloatingActionButton: context.querySelectorAll('.fixed-action-btn:not(.no-autoinit)')
|
|
7533
7868
|
};
|
|
7534
|
-
Autocomplete.init(registry.Autocomplete, {});
|
|
7535
|
-
|
|
7536
|
-
|
|
7537
|
-
|
|
7538
|
-
|
|
7539
|
-
|
|
7540
|
-
|
|
7541
|
-
|
|
7542
|
-
|
|
7543
|
-
|
|
7544
|
-
|
|
7545
|
-
|
|
7546
|
-
|
|
7547
|
-
|
|
7548
|
-
|
|
7549
|
-
|
|
7550
|
-
|
|
7551
|
-
|
|
7869
|
+
Autocomplete.init(registry.Autocomplete, options?.Autocomplete ?? {});
|
|
7870
|
+
Cards.init(registry.Cards, options?.Cards ?? {});
|
|
7871
|
+
Carousel.init(registry.Carousel, options?.Carousel ?? {});
|
|
7872
|
+
Chips.init(registry.Chips, options?.Chips ?? {});
|
|
7873
|
+
Collapsible.init(registry.Collapsible, options?.Collapsible ?? {});
|
|
7874
|
+
Datepicker.init(registry.Datepicker, options?.Datepicker ?? {});
|
|
7875
|
+
Dropdown.init(registry.Dropdown, options?.Dropdown ?? {});
|
|
7876
|
+
Materialbox.init(registry.Materialbox, options?.Materialbox ?? {});
|
|
7877
|
+
Modal.init(registry.Modal, options?.Modal ?? {});
|
|
7878
|
+
Parallax.init(registry.Parallax, options?.Parallax ?? {});
|
|
7879
|
+
Pushpin.init(registry.Pushpin, options?.Pushpin ?? {});
|
|
7880
|
+
ScrollSpy.init(registry.ScrollSpy, options?.ScrollSpy ?? {});
|
|
7881
|
+
FormSelect.init(registry.FormSelect, options?.FormSelect ?? {});
|
|
7882
|
+
Sidenav.init(registry.Sidenav, options?.Sidenav ?? {});
|
|
7883
|
+
Tabs.init(registry.Tabs, options?.Tabs ?? {});
|
|
7884
|
+
TapTarget.init(registry.TapTarget, options?.TapTarget ?? {});
|
|
7885
|
+
Timepicker.init(registry.Timepicker, options?.Timepicker ?? {});
|
|
7886
|
+
Tooltip.init(registry.Tooltip, options?.Tooltip ?? {});
|
|
7887
|
+
FloatingActionButton.init(registry.FloatingActionButton, options?.FloatingActionButton ?? {});
|
|
7552
7888
|
}
|
|
7553
7889
|
// Init
|
|
7554
7890
|
if (typeof document !== 'undefined') {
|
|
@@ -7557,7 +7893,6 @@ var M = (function (exports) {
|
|
|
7557
7893
|
document.addEventListener('focus', Utils.docHandleFocus, true);
|
|
7558
7894
|
document.addEventListener('blur', Utils.docHandleBlur, true);
|
|
7559
7895
|
}
|
|
7560
|
-
Cards.Init();
|
|
7561
7896
|
Forms.Init();
|
|
7562
7897
|
Chips.Init();
|
|
7563
7898
|
Waves.Init();
|
|
@@ -7565,7 +7900,6 @@ var M = (function (exports) {
|
|
|
7565
7900
|
|
|
7566
7901
|
exports.AutoInit = AutoInit;
|
|
7567
7902
|
exports.Autocomplete = Autocomplete;
|
|
7568
|
-
exports.Button = Button;
|
|
7569
7903
|
exports.Cards = Cards;
|
|
7570
7904
|
exports.Carousel = Carousel;
|
|
7571
7905
|
exports.CharacterCounter = CharacterCounter;
|
|
@@ -7576,7 +7910,6 @@ var M = (function (exports) {
|
|
|
7576
7910
|
exports.FloatingActionButton = FloatingActionButton;
|
|
7577
7911
|
exports.FormSelect = FormSelect;
|
|
7578
7912
|
exports.Forms = Forms;
|
|
7579
|
-
exports.Grid = Grid;
|
|
7580
7913
|
exports.Materialbox = Materialbox;
|
|
7581
7914
|
exports.Modal = Modal;
|
|
7582
7915
|
exports.Parallax = Parallax;
|