1 2document.addEventListener('DOMContentLoaded', function () { 3 document.querySelectorAll('[data-cdw-menu]').forEach(function (menu) { 4 var trigger = menu.querySelector('[data-cdw-menu-trigger]'); 5 var overlay = menu.querySelector('[data-cdw-menu-overlay]'); 6 var topcards = menu.querySelector('[data-cdw-topcards]'); 7 var desktopTabs = Array.prototype.slice.call(menu.querySelectorAll('[data-cdw-section]')); 8 var desktopPanels = Array.prototype.slice.call(menu.querySelectorAll('[data-cdw-panel]')); 9 var mobileTabs = Array.prototype.slice.call(menu.querySelectorAll('[data-cdw-mobile-section]')); 10 var mobilePanels = Array.prototype.slice.call(menu.querySelectorAll('[data-cdw-mobile-panel]')); 11 var mobileTitle = menu.querySelector('[data-cdw-mobile-title]'); 12 var mobileBack = menu.querySelector('[data-cdw-mobile-back]'); 13 var activeIndex = 0; 14 var isMobile = false; 15 var slickInitialized = false; 16 17 function updateOverlayTop() { 18 var rect = menu.getBoundingClientRect(); 19 var top = Math.max(0, rect.bottom); 20 menu.style.setProperty('--cdw-menu-overlay-top', top + 'px'); 21 } 22 23 function openMenu() { 24 updateOverlayTop(); 25 menu.classList.add('is-open'); 26 if (trigger) { 27 trigger.setAttribute('aria-expanded', 'true'); 28 } 29 document.body.classList.add('cdw-menu-open'); 30 if (isMobile) { 31 ensureMobileSlider(); 32 } 33 } 34 35 function closeMenu() { 36 menu.classList.remove('is-open'); 37 menu.classList.remove('is-mobile-section-open'); 38 if (trigger) { 39 trigger.setAttribute('aria-expanded', 'false'); 40 } 41 document.body.classList.remove('cdw-menu-open'); 42 } 43 44 function setActive(index, openMobileDetail) { 45 activeIndex = parseInt(index, 10) || 0;
46 desktopTabs.forEach(function (tab) { 47 tab.classList.toggle('is-active', String(tab.getAttribute('data-cdw-section')) === String(activeIndex)); 48 }); 49 desktopPanels.forEach(function (panel) { 50 panel.classList.toggle('is-active', String(panel.getAttribute('data-cdw-panel')) === String(activeIndex)); 51 }); 52 mobileTabs.forEach(function (tab) { 53 tab.classList.toggle('is-active', String(tab.getAttribute('data-cdw-mobile-section')) === String(activeIndex)); 54 if (tab.classList.contains('is-active') && mobileTitle) { 55 var label = tab.querySelector('span'); 56 mobileTitle.textContent = label ? label.textContent : ''; 57 } 58 }); 59 mobilePanels.forEach(function (panel) { 60 panel.classList.toggle('is-active', String(panel.getAttribute('data-cdw-mobile-panel')) === String(activeIndex)); 61 }); 62 if (isMobile && openMobileDetail) { 63 menu.classList.add('is-mobile-section-open'); 64 } 65 } 66 67 function ensureMobileSlider() { 68 /*if (!topcards || !window.jQuery || !window.jQuery.fn || !window.jQuery.fn.slick || !isMobile || slickInitialized) { 69 return; 70 } 71 72 var $topcards = window.jQuery(topcards); 73 if ($topcards.hasClass('slick-initialized')) { 74 slickInitialized = true; 75 return; 76 } 77 78 $topcards.slick({ 79 slidesToShow: 3, 80 slidesToScroll: 1, 81 arrows: true, 82 dots: false, 83 autoplay: true, 84 autoplaySpeed: 2600, 85 speed: 500, 86 infinite: true, 87 swipe: true, 88 responsive: [ 89 { 90 breakpoint: 576, 91 settings: { 92 slidesToShow: 3 93 } 94 } 95 ] 96 }); 97 slickInitialized = true;*/ 98 } 99 100 function destroyMobileSlider() { 101 if (!topcards || !window.jQuery || !window.jQuery.fn || !window.jQuery.fn.slick || !slickInitialized) { 102 return; 103 } 104 105 var $topcards = window.jQuery(topcards); 106 if ($topcards.hasClass('slick-initialized')) { 107 $topcards.slick('unslick'); 108 } 109 slickInitialized = false; 110 } 111 112 function syncMode() { 113 isMobile = window.matchMedia('(max-width: 991px)').matches; 114 menu.classList.toggle('is-mobile', isMobile); 115 if (!isMobile) { 116 destroyMobileSlider(); 117 menu.classList.remove('is-mobile-section-open'); 118 } else { 119 ensureMobileSlider(); 120 } 121 updateOverlayTop(); 122 setActive(activeIndex, false); 123 } 124 125 if (trigger) { 126 trigger.addEventListener('click', function (event) { 127 event.preventDefault(); 128 event.stopPropagation(); 129 if (menu.classList.contains('is-open')) { 130 closeMenu(); 131 } else { 132 openMenu(); 133 } 134 }); 135 } 136 137 if (overlay) { 138 overlay.addEventListener('click', function () { 139 closeMenu(); 140 }); 141 } 142
143 desktopTabs.forEach(function (tab) { 144 var activate = function () { 145 setActive(tab.getAttribute('data-cdw-section'), false); 146 }; 147 tab.addEventListener('click', activate); 148 tab.addEventListener('focus', activate); 149 tab.addEventListener('mouseenter', function () { 150 if (!isMobile) { 151 activate(); 152 } 153 }); 154 }); 155 156 mobileTabs.forEach(function (tab) { 157 tab.addEventListener('click', function () { 158 setActive(tab.getAttribute('data-cdw-mobile-section'), true); 159 }); 160 }); 161 162 if (mobileBack) { 163 mobileBack.addEventListener('click', function () { 164 menu.classList.remove('is-mobile-section-open'); 165 }); 166 } 167 168 document.addEventListener('click', function (event) { 169 if (!menu.classList.contains('is-open')) { 170 return; 171 } 172 if (menu.contains(event.target)) { 173 return; 174 } 175 closeMenu(); 176 }); 177 178 document.addEventListener('keydown', function (event) { 179 if (event.key === 'Escape') { 180 closeMenu(); 181 } 182 }); 183 184 window.addEventListener('resize', syncMode); 185 window.addEventListener('scroll', function () { 186 if (menu.classList.contains('is-open')) { 187 updateOverlayTop(); 188 } 189 }, { passive: true }); 190 191 setActive(0, false); 192 syncMode(); 193 }); 194});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.