UNPKG

29.4 kBJavaScriptView Raw
1define(function () { 'use strict';
2
3 let showDialog, closeDialog;
4
5 const evtShowDialog = (event) => {
6
7 let curElement = event.target;
8
9 let modalDialog = curElement.parentElement.querySelector('.hoo-mdldialog-outer');
10 modalDialog.classList.remove('is-hidden');
11 modalDialog.classList.add('is-visible');
12
13 };
14
15 const evtHideDialog = (event) => {
16
17 let curElement = event.target;
18
19 let modalDialog = curElement.closest('.hoo-mdldialog-outer');
20
21 modalDialog.classList.remove('is-visible');
22 modalDialog.classList.add('is-hidden');
23
24 };
25
26 const registerDialog = () => {
27
28 showDialog = document.querySelectorAll('.show-dialog');
29 closeDialog = document.querySelectorAll('.hoo-dlgheader-closer');
30
31 if (showDialog) {
32
33 showDialog.forEach(item => {
34 item.addEventListener('click', evtShowDialog);
35 });
36
37 }
38
39 if (closeDialog) {
40
41 closeDialog.forEach(item => {
42 item.addEventListener('click', evtHideDialog);
43 });
44 }
45
46 };
47
48 // Origin 1: https://24ways.org/2019/making-a-better-custom-select-element/
49 // Origin 2: https://css-tricks.com/making-a-better-custom-select-element/
50 // Code Pen: https://codepen.io/chriscoyier/pen/yLyyZrr
51 // SETUP
52 // /////////////////////////////////
53 // assign names to things we'll need to use more than once
54
55 const ariaSelect = (listItem) => {
56 // console.log('listItem',listItem);
57 const csSelector = listItem; // the input, svg and ul as a group
58 console.log('csSelector', csSelector);
59 const csInput = csSelector.querySelector('input');
60 // console.log('csInput', csInput);
61 const csList = csSelector.querySelector('ul');
62 // console.log('csList', csList);
63 const csOptions = csList.querySelectorAll('li');
64 // console.log('csOptions', csOptions);
65 csSelector.querySelectorAll('svg');
66 // console.log('csIcons', csIcons);
67 const csStatus = document.querySelector('#custom-select-status');
68 // console.log('csStatus', csStatus);
69 const aOptions = Array.from(csOptions);
70
71 // when JS is loaded, set up our starting point
72 // if JS fails to load, the custom select remains a plain text input
73 // create and set start point for the state tracker
74 let csState = "initial";
75 // inform assistive tech (screen readers) of the names & roles of the elements in our group
76 csSelector.setAttribute('role', 'combobox');
77 csSelector.setAttribute('aria-haspopup', 'listbox');
78 csSelector.setAttribute('aria-owns', 'custom-select-list'); // container owns the list...
79 csInput.setAttribute('aria-autocomplete', 'both');
80 csInput.setAttribute('aria-controls', 'custom-select-list'); // ...but the input controls it
81 csList.setAttribute('role', 'listbox');
82 csOptions.forEach((option) => {
83 option.setAttribute('role', 'option');
84 option.setAttribute('tabindex', "-1"); // make li elements keyboard focusable by script only
85 });
86 // set up a message to keep screen reader users informed of what the custom input is for/doing
87 csStatus.textContent = csOptions.length + " options available. Arrow down to browse or start typing to filter.";
88
89 // EVENTS
90 // /////////////////////////////////
91 csSelector.addEventListener('click', function (e) {
92 const currentFocus = findFocus();
93 switch (csState) {
94 case 'initial': // if state = initial, toggleOpen and set state to opened
95 toggleList('Open');
96 setState('opened');
97 break
98 case 'opened':
99 // if state = opened and focus on input, toggleShut and set state to initial
100 if (currentFocus === csInput) {
101 toggleList('Shut');
102 setState('initial');
103 } else if (currentFocus.tagName === 'LI') {
104 // if state = opened and focus on list, makeChoice, toggleShut and set state to closed
105 makeChoice(currentFocus);
106 toggleList('Shut');
107 setState('closed');
108 }
109 break
110 case 'filtered':
111 // if state = filtered and focus on list, makeChoice and set state to closed
112 if (currentFocus.tagName === 'LI') {
113 makeChoice(currentFocus);
114 toggleList('Shut');
115 setState('closed');
116 } // if state = filtered and focus on input, do nothing (wait for next user input)
117
118 break
119 case 'closed': // if state = closed, toggleOpen and set state to filtered? or opened?
120 toggleList('Open');
121 setState('filtered');
122 break
123 }
124 });
125
126 csSelector.addEventListener('keyup', function (e) {
127 doKeyAction(e.key);
128 });
129
130 document.addEventListener('click', function (e) {
131 if (!e.target.closest('.hoo-select')) {
132 // click outside of the custom group
133 toggleList('Shut');
134 setState('initial');
135 }
136 });
137
138 // FUNCTIONS
139 // /////////////////////////////////
140
141 function toggleList(whichWay) {
142 if (whichWay === 'Open') {
143 csList.classList.remove('hidden-all');
144 csSelector.setAttribute('aria-expanded', 'true');
145 } else { // === 'Shut'
146 csList.classList.add('hidden-all');
147 csSelector.setAttribute('aria-expanded', 'false');
148 }
149 }
150
151 function findFocus() {
152 const focusPoint = document.activeElement;
153 return focusPoint
154 }
155
156 function moveFocus(fromHere, toThere) {
157 // grab the currently showing options, which might have been filtered
158 const aCurrentOptions = aOptions.filter(function (option) {
159 if (option.style.display === '') {
160 return true
161 }
162 });
163 // don't move if all options have been filtered out
164 if (aCurrentOptions.length === 0) {
165 return
166 }
167 if (toThere === 'input') {
168 csInput.focus();
169 }
170 // possible start points
171 switch (fromHere) {
172 case csInput:
173 if (toThere === 'forward') {
174 aCurrentOptions[0].focus();
175 } else if (toThere === 'back') {
176 aCurrentOptions[aCurrentOptions.length - 1].focus();
177 }
178 break
179 case csOptions[0]:
180 if (toThere === 'forward') {
181 aCurrentOptions[1].focus();
182 } else if (toThere === 'back') {
183 csInput.focus();
184 }
185 break
186 case csOptions[csOptions.length - 1]:
187 if (toThere === 'forward') {
188 aCurrentOptions[0].focus();
189 } else if (toThere === 'back') {
190 aCurrentOptions[aCurrentOptions.length - 2].focus();
191 }
192 break
193 default: // middle list or filtered items
194 const currentItem = findFocus();
195 const whichOne = aCurrentOptions.indexOf(currentItem);
196 if (toThere === 'forward') {
197 const nextOne = aCurrentOptions[whichOne + 1];
198 nextOne.focus();
199 } else if (toThere === 'back' && whichOne > 0) {
200 const previousOne = aCurrentOptions[whichOne - 1];
201 previousOne.focus();
202 } else { // if whichOne = 0
203 csInput.focus();
204 }
205 break
206 }
207 }
208
209 function doFilter() {
210 const terms = csInput.value;
211 const aFilteredOptions = aOptions.filter(function (option) {
212 if (option.innerText.toUpperCase().startsWith(terms.toUpperCase())) {
213 return true
214 }
215 });
216 csOptions.forEach(option => option.style.display = "none");
217 aFilteredOptions.forEach(function (option) {
218 option.style.display = "";
219 });
220 setState('filtered');
221 updateStatus(aFilteredOptions.length);
222 }
223
224 function updateStatus(howMany) {
225 csStatus.textContent = howMany + " options available.";
226 }
227
228 function makeChoice(whichOption) {
229 const optionValue = whichOption.dataset.value;
230 csInput.value = optionValue;
231 moveFocus(document.activeElement, 'input');
232 // update aria-selected, if using
233 }
234
235 function setState(newState) {
236 switch (newState) {
237 case 'initial':
238 csState = 'initial';
239 break
240 case 'opened':
241 csState = 'opened';
242 break
243 case 'filtered':
244 csState = 'filtered';
245 break
246 case 'closed':
247 csState = 'closed';
248 }
249 // console.log({csState})
250 }
251
252 function doKeyAction(whichKey) {
253 const currentFocus = findFocus();
254 switch (whichKey) {
255 case 'Enter':
256 if (csState === 'initial') {
257 // if state = initial, toggleOpen and set state to opened
258 toggleList('Open');
259 setState('opened');
260 } else if (csState === 'opened' && currentFocus.tagName === 'LI') {
261 // if state = opened and focus on list, makeChoice and set state to closed
262 makeChoice(currentFocus);
263 toggleList('Shut');
264 setState('closed');
265 } else if (csState === 'opened' && currentFocus === csInput) {
266 // if state = opened and focus on input, close it
267 toggleList('Shut');
268 setState('closed');
269 } else if (csState === 'filtered' && currentFocus.tagName === 'LI') {
270 // if state = filtered and focus on list, makeChoice and set state to closed
271 makeChoice(currentFocus);
272 toggleList('Shut');
273 setState('closed');
274 } else if (csState === 'filtered' && currentFocus === csInput) {
275 // if state = filtered and focus on input, set state to opened
276 toggleList('Open');
277 setState('opened');
278 } else { // i.e. csState is closed, or csState is opened/filtered but other focus point?
279 // if state = closed, set state to filtered? i.e. open but keep existing input?
280 toggleList('Open');
281 setState('filtered');
282 }
283 break
284
285 case 'Escape':
286 // if state = initial, do nothing
287 // if state = opened or filtered, set state to initial
288 // if state = closed, do nothing
289 if (csState === 'opened' || csState === 'filtered') {
290 toggleList('Shut');
291 setState('initial');
292 }
293 break
294
295 case 'ArrowDown':
296 if (csState === 'initial' || csState === 'closed') {
297 // if state = initial or closed, set state to opened and moveFocus to first
298 toggleList('Open');
299 moveFocus(csInput, 'forward');
300 setState('opened');
301 } else {
302 // if state = opened and focus on input, moveFocus to first
303 // if state = opened and focus on list, moveFocus to next/first
304 // if state = filtered and focus on input, moveFocus to first
305 // if state = filtered and focus on list, moveFocus to next/first
306 toggleList('Open');
307 moveFocus(currentFocus, 'forward');
308 }
309 break
310 case 'ArrowUp':
311 if (csState === 'initial' || csState === 'closed') {
312 // if state = initial, set state to opened and moveFocus to last
313 // if state = closed, set state to opened and moveFocus to last
314 toggleList('Open');
315 moveFocus(csInput, 'back');
316 setState('opened');
317 } else {
318 // if state = opened and focus on input, moveFocus to last
319 // if state = opened and focus on list, moveFocus to prev/last
320 // if state = filtered and focus on input, moveFocus to last
321 // if state = filtered and focus on list, moveFocus to prev/last
322 moveFocus(currentFocus, 'back');
323 }
324 break
325 default:
326 if (csState === 'initial') {
327 // if state = initial, toggle open, doFilter and set state to filtered
328 toggleList('Open');
329 doFilter();
330 setState('filtered');
331 } else if (csState === 'opened') {
332 // if state = opened, doFilter and set state to filtered
333 doFilter();
334 setState('filtered');
335 } else if (csState === 'closed') {
336 // if state = closed, doFilter and set state to filtered
337 doFilter();
338 setState('filtered');
339 } else { // already filtered
340 doFilter();
341 }
342 break
343 }
344 }
345
346 };
347
348 const collapseAndExpand = (event) => {
349
350 const parentRow = event.target.closest("tr");
351 // console.debug("Parent Row", parentRow);
352
353 const parentTable = event.target.closest("table");
354 // console.debug("Current Table", parentTable);
355
356 const section = parentRow.dataset.sectionheader;
357 // console.debug("Current Section", section);
358
359 let query = null;
360
361 if (section === "all") {
362 query = "tr[data-section]";
363 } else {
364 query = 'tr[data-section=' + section + ']';
365 }
366
367 const sectionRows = parentTable.querySelectorAll(query);
368
369 for (let i = 0; i < sectionRows.length; i++) {
370
371 const currentItem = sectionRows[i];
372
373 if (currentItem.classList.contains('is-hidden')) {
374
375 currentItem.classList.remove('is-hidden');
376 currentItem.classList.add('is-visible');
377 currentItem.setAttribute('aria-hidden', 'false');
378 parentRow.setAttribute('aria-expanded', 'true');
379
380 } else {
381
382 currentItem.classList.add('is-hidden');
383 currentItem.classList.remove('is-visible');
384 currentItem.setAttribute('aria-hidden', 'true');
385 parentRow.setAttribute('aria-expanded', 'false');
386
387 }
388
389 }
390
391 if (section === "all") {
392
393 let subSection = document.querySelectorAll("tbody tr.collapsable");
394
395 if (parentRow.getAttribute('aria-expanded') === "true") {
396
397 for (let i = 0; i < subSection.length; i++) {
398
399 const currentItem = subSection[i];
400
401 currentItem.setAttribute('aria-hidden', 'false');
402 currentItem.setAttribute('aria-expanded', 'true');
403
404 }
405
406 } else {
407
408 for (let i = 0; i < subSection.length; i++) {
409
410 const currentItem = subSection[i];
411
412 currentItem.setAttribute('aria-hidden', 'true');
413 currentItem.setAttribute('aria-expanded', 'false');
414
415 }
416
417 }
418
419 }
420
421 };
422
423 const initCollapsability = () => {
424
425 const collapseTable = document.querySelectorAll('.hoo-table.is-collapsable');
426 collapseTable.forEach(table => {
427
428 const collapseRow = table.querySelectorAll('.collapsable');
429
430 collapseRow.forEach(tableRow => {
431 tableRow.addEventListener('click', collapseAndExpand);
432 });
433
434 });
435
436 };
437
438 const position = {
439 "left": "left",
440 "right": "right",
441 "top": "top",
442 "bottom": "bottom"
443 };
444
445 const stickyOffsetFixup = (parent, selector, offset) => {
446
447 const innerDefinition = parent.querySelectorAll(selector);
448
449 for (let j = 0; j < innerDefinition.length; j++) {
450
451 const innerElement = innerDefinition[j];
452
453 if (offset === position.left) {
454 innerElement.style[offset] = innerElement.offsetLeft + "px";
455 }
456 if (offset === position.right) {
457 innerElement.style[offset] = innerElement.offsetRight + "px";
458 }
459 if (offset === position.top) {
460 innerElement.style[offset] = innerElement.offsetTop + "px";
461 }
462 if (offset === position.bottom) {
463 innerElement.style[offset] = innerElement.offsetBottom + "px";
464 }
465
466 }
467
468 };
469
470 const initSticky = () => {
471
472 const allStickyTables = document.querySelectorAll("table.sticky");
473
474 for (let i = 0; i < allStickyTables.length; i++) {
475
476 const stickyTable = allStickyTables[i];
477
478 stickyOffsetFixup(stickyTable, "tr td.is-sticky.left", position.left);
479 stickyOffsetFixup(stickyTable, "tr th.is-sticky.left", position.left);
480
481 }
482 };
483
484 const initTables = () => {
485
486 initCollapsability();
487 initSticky();
488
489 };
490
491 const elemPivotBar = '.hoo-pivotbar';
492 const elemPivotButton = '.hoo-button-pivot';
493 const dropDownPivotButton = '.hoo-navitem-text';
494 const stateIsActive = 'is-active';
495
496 const changePivot = (event) => {
497 event.preventDefault();
498
499 console.log(event.target);
500
501 let currentButton = event.target.classList.contains(elemPivotButton.substr(1)) ? event.target : event.target.closest(elemPivotButton);
502 if (!currentButton) {
503 currentButton = event.target.classList.contains(dropDownPivotButton.substr(1)) ? event.target : event.target.closest(dropDownPivotButton);
504 }
505
506 const currentPivotBar = event.target.closest(elemPivotBar);
507
508 const allButtons = currentPivotBar.querySelectorAll(elemPivotButton);
509
510 allButtons.forEach(item => {
511 item.classList.remove(stateIsActive);
512 });
513
514 currentButton.classList.add(stateIsActive);
515
516 };
517
518
519 const initPivot = () => {
520
521 // register event on regular buttons
522 const pivotBarsButtons = document.querySelectorAll(`${elemPivotBar} ${elemPivotButton}`);
523 pivotBarsButtons.forEach(pivotBarsButton => {
524 pivotBarsButton.dataset.ref = pivotBarsButton.textContent.trim();
525 pivotBarsButton.addEventListener('click', changePivot);
526 });
527
528 };
529
530 /** MENU ITEM */
531
532 const handleMenuItems = (event) => {
533
534 console.log(event);
535
536 let curNavItem = event.target;
537 let curNavMenu = curNavItem.closest('.hoo-navitem');
538
539 console.log(curNavMenu);
540 console.log(curNavMenu.getAttribute('aria-expanded'));
541 console.log(typeof curNavMenu.getAttribute('aria-expanded'));
542
543 console.log(" LOOMA ::: ",
544 curNavMenu.getAttribute('aria-expanded'),
545 Boolean(curNavMenu.getAttribute('aria-expanded')),
546 Boolean(curNavMenu.getAttribute('aria-expanded')) === true
547 );
548
549 if (curNavMenu.getAttribute('aria-expanded') === 'true') {
550
551 curNavMenu.setAttribute('aria-expanded', false);
552
553 } else {
554
555 curNavMenu.setAttribute('aria-expanded', true);
556
557 }
558
559 };
560
561 const initMenu = () => {
562
563 let menuItems = document.querySelectorAll('.hoo-navitem[aria-expanded]');
564
565 menuItems.forEach(item => {
566
567 item.addEventListener('click', handleMenuItems);
568
569 });
570
571
572 };
573
574 const overflowItems = [];
575 const defaultOffset = 40; // Default offset for overflow width
576
577 /**
578 *
579 * @param {*} targetWidth width of the '.hoo-overflow'
580 * @param {*} children all child elements inside the '.hoo-overflow' container
581 * @param {*} curContainer current '.hoo-overflow' container
582 */
583 const getOverflowItems = (targetWidth, children, curContainer, itemIndex) => {
584
585 let curOverFlowItems = overflowItems[itemIndex].filter(item => {
586 return item.overallWidth > targetWidth - defaultOffset;
587 });
588
589 let curItems = overflowItems[itemIndex].filter(item => {
590 return item.overallWidth < targetWidth - defaultOffset;
591 });
592
593 // Flyout Button ellipses
594 let overflowControl = curContainer.querySelector('.hoo-buttonicon-overflow .hoo-buttonflyout');
595
596 if (overflowControl && overflowControl.children.length < curOverFlowItems.length) {
597
598 for (let i = 0; i < curOverFlowItems.length; i++) {
599
600 if (curContainer.querySelector("[data-ref=" + curOverFlowItems[i].ref + "]") !== null) {
601
602 let listItem = document.createElement('li');
603
604 // Moves the Element into a new list item with all Events attached
605 listItem.appendChild(
606 curContainer.querySelector("[data-ref=" + curOverFlowItems[i].ref + "]")
607 );
608
609 // Append list item
610 overflowControl.appendChild(listItem);
611
612 }
613
614 }
615 }
616
617 // if
618 if(overflowControl.children.length !== 0){
619
620 var buttonEnabled = overflowControl.closest('.hoo-buttonicon-overflow');
621
622 if(buttonEnabled){
623 buttonEnabled.classList.add('is-active');
624 }
625
626 } else {
627
628 var buttonEnabled = overflowControl.closest('.hoo-buttonicon-overflow');
629
630 if(buttonEnabled){
631 buttonEnabled.classList.remove('is-active');
632 }
633
634 }
635
636 if (overflowControl && overflowControl.children.length > curOverFlowItems.length) {
637
638 for (let i = 0; i < curItems.length; i++) {
639
640 if (overflowControl.querySelector("[data-ref=" + curItems[i].ref + "]") !== null) {
641
642 let overflowElement = overflowControl.querySelector("[data-ref=" + curItems[i].ref + "]");
643
644 // Move elements back from overflow menu
645 curContainer.appendChild(overflowElement);
646
647 }
648
649 }
650
651 }
652
653
654 /**
655 * Cleanup left over <li> elements
656 */
657 for(let i = 0; i < overflowControl.children.length; i++){
658
659 if(overflowControl.children[i].children.length === 0){
660
661 overflowControl.children[i].remove();
662
663 }
664
665 }
666
667
668 };
669
670
671 /**
672 * Handle all entries in the overflow menu
673 */
674 const entryHandler = (entry, index) => {
675
676 let childButtons = entry.target.parentElement.querySelectorAll('.hoo-overflow > *');
677
678 getOverflowItems(entry.target.parentElement.clientWidth, childButtons, entry.target, index);
679
680 };
681
682 /**
683 *
684 * @param {ResizeObserverEntry} entries
685 * @param {ResizeObserver} observer
686 */
687 const overflow = (entries, observer) => {
688
689 // handle the overflow behaviour for all '.hoo.overflow' container
690 entries.forEach((item, index) => {
691
692 initOverflowElements(item.target.children, index);
693 // handle the resizing:::
694 entryHandler(item, index);
695
696 });
697
698 };
699
700 /**
701 *
702 * @param {HTMLCollection} children
703 * @param {number} index
704 */
705 const initOverflowElements = (children, index) => {
706
707 let overallWidth = 0;
708
709 if (overflowItems.length <= index) {
710
711 overflowItems[index] = [];
712
713 for (let i = 0; i < children.length; i++) {
714
715 overallWidth += children[i].clientWidth;
716
717 if (!children[i].classList.contains("hoo-buttonicon-overflow")) {
718
719 let currentItem = {
720 chlld: children[i],
721 ref: "ref-" + index + "-" + i,
722 width: children[i].clientWidth,
723 overallWidth: overallWidth
724 };
725
726 children[i].dataset.ref = currentItem.ref;
727
728 overflowItems[index].push(currentItem);
729
730 }
731
732 }
733
734 }
735
736 };
737
738 /// OnInit register [ResizeObserver](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver) all overflow container
739 const init = () => {
740
741 let items = document.querySelectorAll('.hoo-overflow');
742
743 if (items.length !== 0) {
744
745 const ofObserver = new ResizeObserver(overflow);
746
747 items.forEach(item => {
748
749 ofObserver.observe(item);
750
751 });
752
753 }
754
755 };
756
757 const splitButtonReg = (classSelector, handleWith) => {
758
759 let allSplitButtons = document.querySelectorAll(classSelector);
760
761 allSplitButtons.forEach(element => {
762
763 element.addEventListener('click', (event) => {
764 handleWith(event);
765 });
766
767 });
768
769 };
770
771 const _btnFlyOut = (curSplitButton, parentElement) => {
772
773 // console.log(curSplitButton)
774 // set aria values
775 let ariaPressed = curSplitButton.getAttribute('aria-pressed');
776 if (ariaPressed === undefined) {
777 curSplitButton.setAttribute('aria-pressed', true);
778 } else {
779 curSplitButton.setAttribute('aria-pressed', !ariaPressed);
780 }
781
782 parentElement.classList.toggle('show-flyout');
783
784 };
785
786 const buttonClick = (event) => {
787
788 let curSplitButton = event.target;
789 let parentElement = curSplitButton.parentElement;
790
791 _btnFlyOut(curSplitButton, parentElement);
792
793 };
794
795 const splitButtonClick = (event) => {
796
797 console.log("\nEVENT: splitButtonClick");
798 let curSplitButton = event.target;
799 let parentElement = curSplitButton.parentElement;
800
801 _btnFlyOut(curSplitButton, parentElement);
802
803 };
804
805 const animateDeleteAndSlide = (event) => {
806
807
808 let eventTarget = event.target;
809 let animationClass = eventTarget.parentElement.dataset.animation;
810
811 // Add class
812 eventTarget.classList.add(animationClass);
813
814 let computedStyles = window.getComputedStyle(eventTarget);
815 let animationDuration = parseFloat(computedStyles.getPropertyValue('animation-duration')) * 1000;
816
817
818 console.log(
819 computedStyles,
820 computedStyles.getPropertyValue('animation-duration'),
821 animationDuration
822 // parseFloat(computedStyles.getPropertyValue('animation-duration')),
823 // parseInt("16s")
824 );
825
826 setTimeout(
827 () => {
828 eventTarget.remove();
829 }, animationDuration
830 );
831
832 };
833
834 const animateAddAndSlide = (event) => {
835
836 let eventTarget = event.target;
837
838 let animationClass = eventTarget.parentElement.dataset.animation;
839
840 // Add class
841 eventTarget.classList.add(animationClass);
842
843 let newDomElement = document.importNode(eventTarget, true);
844 newDomElement.classList.add(animationClass);
845
846 let computedStyles = window.getComputedStyle(newDomElement);
847 let animationDuration = parseFloat(computedStyles.getPropertyValue('animation-duration')) * 1000;
848
849
850 event.target.parentElement.appendChild(newDomElement);
851
852 newDomElement.addEventListener('click', animateAddAndSlide);
853
854 console.log(
855 computedStyles,
856 computedStyles.getPropertyValue('animation-duration'),
857 animationDuration
858 // parseFloat(computedStyles.getPropertyValue('animation-duration')),
859 // parseInt("16s")
860 );
861
862 setTimeout(
863 () => {
864 newDomElement.classList.remove('anim-add-slide');
865 }, animationDuration
866 );
867
868 };
869
870 const registerAnimation = (classname, handleWith) => {
871
872 let animAtionBlocks = document.querySelectorAll(classname + ' > .sg-anim-block');
873
874 animAtionBlocks.forEach(element => {
875 element.addEventListener('click', handleWith);
876 });
877
878 };
879
880 const registerAriaSelect = () => {
881
882 let selects = document.querySelectorAll('.hoo-select');
883
884 // debugger;
885
886 if (selects) {
887 selects.forEach((item, idx) => {
888 ariaSelect(item);
889 });
890 }
891 };
892
893
894 const afterLoaded = () => {
895
896 splitButtonReg('.hoo-buttonsplit > .hoo-buttonsplit-carret', splitButtonClick);
897 splitButtonReg('.hoo-buttonsplit-primary > .hoo-buttonsplit-carret', splitButtonClick);
898 splitButtonReg('button.hoo-buttonicon-overflow', buttonClick);
899
900 splitButtonReg('button.hoo-buttoncmd', buttonClick);
901 splitButtonReg('button.hoo-buttoncmdbar', buttonClick);
902 splitButtonReg('button.hoo-buttonicon-flyout', buttonClick);
903 splitButtonReg('button.hoo-buttoncontext', buttonClick);
904
905
906 registerAnimation('.anim-deleteNslide', animateDeleteAndSlide);
907 registerAnimation('.anim-addNslide', animateAddAndSlide);
908
909 registerDialog();
910 registerAriaSelect();
911
912 /** Init Table Helper */
913 initTables();
914 /** Init Pivot Bars */
915 initPivot();
916 /** Init Menu Bars */
917 initMenu();
918
919 init();
920
921 setTimeout(() => {
922 let tmpHidden = document.querySelectorAll('.tmp-hidden');
923
924 console.log(tmpHidden);
925
926 tmpHidden.forEach(item => {
927 item.addEventListener("focus", (event) => {
928
929 event.target.classList.remove('.tmp-hidden');
930
931 console.log(tmpHidden);
932
933 });
934 });
935 }, 1000);
936
937
938 };
939
940 window.onload = afterLoaded();
941
942});