1/** 2* DO NOT EDIT THIS FILE. 3* See the following change record for more information, 4* https://www.drupal.org/node/2815083 5* @preserve 6**/ 7(function (Drupal) { 8 var isDesktopNav = Drupal.martinmayer.isDesktopNav; 9 var secondLevelNavMenus = document.querySelectorAll('[data-drupal-selector="primary-nav-menu-item-has-children"]'); 10 function toggleSubNav(topLevelMenuItem, toState) { 11 var buttonSelector = '[data-drupal-selector="primary-nav-submenu-toggle-button"]'; 12 var button = topLevelMenuItem.querySelector(buttonSelector); 13 var state = toState !== undefined ? toState : button.getAttribute('aria-expanded') !== 'true'; 14 if (state) { 15 if (isDesktopNav()) { 16 secondLevelNavMenus.forEach(function (el) { 17 el.querySelector(buttonSelector).setAttribute('aria-expanded', 'false'); 18 el.querySelector('[data-drupal-selector="primary-nav-menu--level-2"]').classList.remove('is-active-menu-parent'); 19 el.querySelector('[data-drupal-selector="primary-nav-menu-ð¥"]').classList.remove('is-active-menu-parent'); 20 }); 21 } 22 button.setAttribute('aria-expanded', 'true'); 23 topLevelMenuItem.querySelector('[data-drupal-selector="primary-nav-menu--level-2"]').classList.add('is-active-menu-parent'); 24 topLevelMenuItem.querySelector('[data-drupal-selector="primary-nav-menu-ð¥"]').classList.add('is-active-menu-parent'); 25 } else { 26 button.setAttribute('aria-expanded', 'false'); 27 topLevelMenuItem.classList.remove('is-touch-event'); 28 topLevelMenuItem.querySelector('[data-drupal-selector="primary-nav-menu--level-2"]').classList.remove('is-active-menu-parent'); 29 topLevelMenuItem.querySelector('[data-drupal-selector="primary-nav-menu-ð¥"]').classList.remove('is-active-menu-parent'); 30 } 31 } 32 Drupal.martinmayer.toggleSubNav = toggleSubNav; 33 function handleBlur(e) { 34 if (!Drupal.martinmayer.isDesktopNav()) return; 35 setTimeout(function () { 36 var menuParentItem = e.target.closest('[data-drupal-selector="primary-nav-menu-item-has-children"]'); 37 if (!menuParentItem.contains(document.activeElement)) { 38 toggleSubNav(menuParentItem, false); 39 } 40 }, 200); 41 } 42 secondLevelNavMenus.forEach(function (el) { 43 var button = el.querySelector('[data-drupal-selector="primary-nav-submenu-toggle-button"]'); 44 button.removeAttribute('aria-hidden'); 45 button.removeAttribute('tabindex'); 46 el.addEventListener('touchstart', function () { 47 el.classList.add('is-touch-event'); 48 }, { 49 passive: true 50 }); 51 el.addEventListener('mouseover', function () { 52 if (isDesktopNav() && !el.classList.contains('is-touch-event')) { 53 el.classList.add('is-active-mouseover-event'); 54 toggleSubNav(el, true); 55 setTimeout(function () { 56 el.classList.remove('is-active-mouseover-event'); 57 }, 500); 58 } 59 }); 60 button.addEventListener('click', function () { 61 if (!el.classList.contains('is-active-mouseover-event')) { 62 toggleSubNav(el); 63 } 64 }); 65 el.addEventListener('mouseout', function () { 66 if (isDesktopNav() && !document.activeElement.matches('[aria-expanded="true"], .is-active-menu-parent *')) { 67 toggleSubNav(el, false); 68 } 69 }); 70 el.addEventListener('blur', handleBlur, true); 71 }); 72 function closeAllSubNav() { 73 secondLevelNavMenus.forEach(function (el) { 74 if (el.contains(document.activeElement)) { 75 el.querySelector('[data-drupal-selector="primary-nav-submenu-toggle-button"]').focus(); 76 } 77 toggleSubNav(el, false); 78 }); 79 } 80 Drupal.martinmayer.closeAllSubNav = closeAllSubNav; 81 82 function areAnySubNavsOpen() { 83 var subNavsAreOpen = false; 84 secondLevelNavMenus.forEach(function (el) { 85 var button = el.querySelector('[data-drupal-selector="primary-nav-submenu-toggle-button"]'); 86 var state = button.getAttribute('aria-expanded') === 'true'; 87 if (state) { 88 subNavsAreOpen = true; 89 } 90 }); 91 return subNavsAreOpen; 92 } 93 Drupal.martinmayer.areAnySubNavsOpen = areAnySubNavsOpen; 94 document.addEventListener('keyup', function (e) { 95 if (e.key === 'Escape' || e.key === 'Esc') { 96 if (isDesktopNav()) closeAllSubNav(); 97 } 98 }); 99 document.addEventListener('touchstart', function (e) { 100 if (areAnySubNavsOpen() && !e.target.matches('[data-drupal-selector="header-nav"], [data-drupal-selector="header-nav"] *')) { 101 closeAllSubNav(); 102 } 103 }, { 104 passive: true 105 }); 106})(Drupal);
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.