2022-04-11 08:04:30 -04:00
|
|
|
/******/ (function() { // webpackBootstrap
|
|
|
|
var __webpack_exports__ = {};
|
2022-09-20 11:43:29 -04:00
|
|
|
// Open on click functionality.
|
2021-11-08 21:17:17 -05:00
|
|
|
function closeSubmenus(element) {
|
|
|
|
element.querySelectorAll('[aria-expanded="true"]').forEach(function (toggle) {
|
|
|
|
toggle.setAttribute('aria-expanded', 'false');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function toggleSubmenuOnClick(event) {
|
|
|
|
const buttonToggle = event.target.closest('[aria-expanded]');
|
|
|
|
const isSubmenuOpen = buttonToggle.getAttribute('aria-expanded');
|
|
|
|
|
|
|
|
if (isSubmenuOpen === 'true') {
|
|
|
|
closeSubmenus(buttonToggle.closest('.wp-block-navigation-item'));
|
|
|
|
} else {
|
|
|
|
// Close all sibling submenus.
|
|
|
|
const parentElement = buttonToggle.closest('.wp-block-navigation-item');
|
|
|
|
const navigationParent = buttonToggle.closest('.wp-block-navigation__submenu-container, .wp-block-navigation__container, .wp-block-page-list');
|
|
|
|
navigationParent.querySelectorAll('.wp-block-navigation-item').forEach(function (child) {
|
|
|
|
if (child !== parentElement) {
|
|
|
|
closeSubmenus(child);
|
|
|
|
}
|
|
|
|
}); // Open submenu.
|
|
|
|
|
|
|
|
buttonToggle.setAttribute('aria-expanded', 'true');
|
|
|
|
}
|
2021-11-10 01:01:30 -05:00
|
|
|
} // Necessary for some themes such as TT1 Blocks, where
|
|
|
|
// scripts could be loaded before the body.
|
2021-11-08 21:17:17 -05:00
|
|
|
|
|
|
|
|
2021-12-13 20:57:26 -05:00
|
|
|
window.addEventListener('load', () => {
|
2021-11-10 01:01:30 -05:00
|
|
|
const submenuButtons = document.querySelectorAll('.wp-block-navigation-submenu__toggle');
|
|
|
|
submenuButtons.forEach(function (button) {
|
|
|
|
button.addEventListener('click', toggleSubmenuOnClick);
|
|
|
|
}); // Close on click outside.
|
|
|
|
|
|
|
|
document.addEventListener('click', function (event) {
|
|
|
|
const navigationBlocks = document.querySelectorAll('.wp-block-navigation');
|
|
|
|
navigationBlocks.forEach(function (block) {
|
|
|
|
if (!block.contains(event.target)) {
|
|
|
|
closeSubmenus(block);
|
|
|
|
}
|
|
|
|
});
|
2022-09-20 11:43:29 -04:00
|
|
|
}); // Close on focus outside or escape key.
|
2021-11-08 21:17:17 -05:00
|
|
|
|
2021-11-10 01:01:30 -05:00
|
|
|
document.addEventListener('keyup', function (event) {
|
|
|
|
const submenuBlocks = document.querySelectorAll('.wp-block-navigation-item.has-child');
|
|
|
|
submenuBlocks.forEach(function (block) {
|
|
|
|
if (!block.contains(event.target)) {
|
|
|
|
closeSubmenus(block);
|
2022-09-20 11:43:29 -04:00
|
|
|
} else if (event.key === 'Escape') {
|
|
|
|
const toggle = block.querySelector('[aria-expanded="true"]');
|
|
|
|
closeSubmenus(block); // Focus the submenu trigger so focus does not get trapped in the closed submenu.
|
|
|
|
|
2023-06-27 10:24:19 -04:00
|
|
|
toggle?.focus();
|
2021-11-10 01:01:30 -05:00
|
|
|
}
|
|
|
|
});
|
2021-11-08 21:17:17 -05:00
|
|
|
});
|
2021-12-13 20:57:26 -05:00
|
|
|
});
|
2021-11-08 21:17:17 -05:00
|
|
|
|
2022-04-11 08:04:30 -04:00
|
|
|
/******/ })()
|
|
|
|
;
|