1(function () { 2 'use strict'; 3 4 function setActiveCategory(menu, categoryId) { 5 menu.querySelectorAll('[data-mega-category]').forEach(function (tab) { 6 var active = tab.dataset.megaCategory === categoryId; 7 tab.classList.toggle('is-active', active); 8 tab.setAttribute('aria-selected', active ? 'true' : 'false'); 9 }); 10 11 menu.querySelectorAll('[data-mega-panel]').forEach(function (panel) { 12 var active = panel.dataset.megaPanel === categoryId; 13 panel.classList.toggle('is-active', active); 14 panel.hidden = !active; 15 }); 16 } 17 18 function initFeaturesMega(menu) { 19 var trigger = menu.querySelector('.indev-mega-trigger'); 20 var tabs = Array.prototype.slice.call(menu.querySelectorAll('[data-mega-category]')); 21 22 if (!trigger || !tabs.length) { 23 return; 24 } 25 26 tabs.forEach(function (tab, index) { 27 ['mouseenter', 'focus', 'click'].forEach(function (eventName) { 28 tab.addEventListener(eventName, function () {
29 setActiveCategory(menu, tab.dataset.megaCategory); 30 }); 31 }); 32 33 tab.addEventListener('keydown', function (event) { 34 if (event.key !== 'ArrowDown' && event.key !== 'ArrowUp') { 35 return; 36 } 37 38 event.preventDefault(); 39 var direction = event.key === 'ArrowDown' ? 1 : -1; 40 tabs[(index + direction + tabs.length) % tabs.length].focus(); 41 }); 42 }); 43 44 initDesktopDisclosure(menu, trigger); 45 } 46 47 function updateNewsPreview(menu, category) { 48 var preview = menu.querySelector('.indev-news-preview'); 49 var image = preview && preview.querySelector('img'); 50 var title = preview && preview.querySelector('strong'); 51 var imagePath = category.dataset.image || ''; 52if (!preview || !image || !title) { 53 return; 54 } 55 56 preview.href = category.dataset.imageLink || category.href; 57 title.textContent = category.dataset.imageAlt || category.querySelector('strong').textContent; 58 59 if (imagePath && imagePath !== '/') { 60 image.src = new URL(imagePath, window.location.origin).href; 61 image.alt = category.dataset.imageAlt || ''; 62 image.hidden = false; 63 } else { 64 image.removeAttribute('src'); 65 image.alt = ''; 66 image.hidden = true; 67 } 68 } 69 70 function initNewsMega(menu) { 71 var trigger = menu.querySelector('.indev-news-trigger'); 72 var list = menu.querySelector('.indev-news-list'); 73 var categories = Array.prototype.slice.call(menu.querySelectorAll('[data-news-category]')); 74 75 if (!trigger || !categories.length) { 76 return; 77 } 78 79 if (categories.length > 6) { 80 list.classList.add('is-two-columns'); 81 } 82 83 categories.forEach(function (category) { 84 category.addEventListener('mouseenter', function () { 85 updateNewsPreview(menu, category); 86 }); 87 category.addEventListener('focus', function () { 88 updateNewsPreview(menu, category); 89 }); 90 }); 91 92 updateNewsPreview(menu, categories[0]); 93 initDesktopDisclosure(menu, trigger); 94 } 95 96 function initDesktopDisclosure(menu, trigger) { 97 menu.addEventListener('mouseenter', function () { 98 trigger.setAttribute('aria-expanded', 'true'); 99 }); 100 101 menu.addEventListener('mouseleave', function () { 102 trigger.setAttribute('aria-expanded', 'false'); 103 menu.classList.remove('is-open'); 104 }); 105 106 menu.addEventListener('focusin', function () { 107 trigger.setAttribute('aria-expanded', 'true'); 108 }); 109 110 menu.addEventListener('focusout', function (event) { 111 if (!menu.contains(event.relatedTarget)) { 112 trigger.setAttribute('aria-expanded', 'false'); 113 } 114 }); 115 116 trigger.addEventListener('click', function (event) { 117 if (window.matchMedia('(hover: none)').matches && !menu.classList.contains('is-open')) { 118 event.preventDefault(); 119 menu.classList.add('is-open'); 120 trigger.setAttribute('aria-expanded', 'true'); 121 } 122 }); 123 124 menu.addEventListener('keydown', function (event) { 125 if (event.key === 'Escape') { 126 menu.classList.remove('is-open'); 127 trigger.setAttribute('aria-expanded', 'false'); 128 trigger.focus(); 129 } 130 }); 131 } 132 133 function setMobileExpanded(item, expanded) { 134 var button = item.querySelector(':scope > .indev-mobile-row .indev-mobile-toggle'); 135 var submenu = item.querySelector(':scope > .indev-mobile-submenu'); 136 137 if (!button || !submenu) { 138 return; 139 } 140 141 item.classList.toggle('is-expanded', expanded); 142 button.setAttribute('aria-expanded', expanded ? 'true' : 'false'); 143 submenu.hidden = !expanded; 144 } 145 146 function initMobileMenu() { 147 document.querySelectorAll('.indev-mobile-parent').forEach(function (item) { 148 var button = item.querySelector(':scope > .indev-mobile-row .indev-mobile-toggle'); 149 var shouldExpand = item.classList.contains('active') || item.classList.contains('current'); 150 151 if (!button) { 152 return; 153 } 154 155 if (shouldExpand) { 156 setMobileExpanded(item, true); 157 } 158 159 if (item.dataset.indevMobileReady === '1') { 160 return; 161 } 162 163 item.dataset.indevMobileReady = '1'; 164 165 button.addEventListener('click', function (event) { 166 event.preventDefault(); 167 event.stopPropagation(); 168 setMobileExpanded(item, !item.classList.contains('is-expanded')); 169 }); 170 }); 171 } 172 173 function normalizePath(url) { 174 var path = new URL(url, window.location.href).pathname.replace(/\/+$/, ''); 175 return path || '/'; 176 } 177 178 function fixActiveState() { 179 var currentPath = normalizePath(window.location.href); 180 181 document.querySelectorAll('.indev-menu-root, .indev-mobile-menu-root').forEach(function (root) { 182 root.querySelectorAll('.active').forEach(function (element) { 183 element.classList.remove('active'); 184 }); 185 186 root.querySelectorAll('a[href]').forEach(function (link) { 187 if (link.origin !== window.location.origin || normalizePath(link.href) !== currentPath) { 188 return; 189 } 190 191 link.classList.add('active'); 192 var parent = link.parentElement; 193 194 while (parent && parent !== root) { 195 if (parent.tagName === 'LI') { 196 parent.classList.add('active'); 197 } 198 parent = parent.parentElement; 199 } 200 }); 201 }); 202 } 203
204 function init() { 205 document.querySelectorAll('.indev-mega-menu').forEach(initFeaturesMega); 206 document.querySelectorAll('.indev-news-menu').forEach(initNewsMega); 207 initMobileMenu(); 208 window.setTimeout(function () { 209 fixActiveState(); 210 initMobileMenu(); 211 }, 0); 212 } 213 214 if (document.readyState === 'loading') { 215 document.addEventListener('DOMContentLoaded', init); 216 } else { 217 init(); 218 } 219}());
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.