2022-04-11 14:04:30 +02:00
|
|
|
/******/ (function() { // webpackBootstrap
|
|
|
|
var __webpack_exports__ = {};
|
2022-09-20 17:43:29 +02:00
|
|
|
// Open on click functionality.
|
2021-11-09 03:17:17 +01: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 07:01:30 +01:00
|
|
|
} // Necessary for some themes such as TT1 Blocks, where
|
|
|
|
// scripts could be loaded before the body.
|
2021-11-09 03:17:17 +01:00
|
|
|
|
|
|
|
|
2021-12-14 02:57:26 +01:00
|
|
|
window.addEventListener('load', () => {
|
2021-11-10 07:01:30 +01: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 17:43:29 +02:00
|
|
|
}); // Close on focus outside or escape key.
|
2021-11-09 03:17:17 +01:00
|
|
|
|
2021-11-10 07:01:30 +01: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 17:43:29 +02: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 16:24:19 +02:00
|
|
|
toggle?.focus();
|
2021-11-10 07:01:30 +01:00
|
|
|
}
|
|
|
|
});
|
2021-11-09 03:17:17 +01:00
|
|
|
});
|
2021-12-14 02:57:26 +01:00
|
|
|
});
|
2021-11-09 03:17:17 +01:00
|
|
|
|
2022-04-11 14:04:30 +02:00
|
|
|
/******/ })()
|
|
|
|
;
|