
| Current Path : /var/www/html1/bbp/web/core/themes/olivero/js/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/html1/bbp/web/core/themes/olivero/js/tabs.es6.js |
((Drupal) => {
function init(el) {
const tabs = el.querySelector('.tabs');
const expandedClass = 'is-expanded';
const activeTab = tabs.querySelector('.is-active');
function isTabsMobileLayout() {
return tabs.querySelector('.tabs__trigger').clientHeight > 0;
}
function handleTriggerClick(e) {
if (!tabs.classList.contains(expandedClass)) {
e.currentTarget.setAttribute('aria-expanded', 'true');
tabs.classList.add(expandedClass);
} else {
e.currentTarget.setAttribute('aria-expanded', 'false');
tabs.classList.remove(expandedClass);
}
}
if (isTabsMobileLayout() && !activeTab.matches('.tabs__tab:first-child')) {
const newActiveTab = activeTab.cloneNode(true);
const firstTab = tabs.querySelector('.tabs__tab:first-child');
tabs.insertBefore(newActiveTab, firstTab);
tabs.removeChild(activeTab);
}
tabs
.querySelector('.tabs__trigger')
.addEventListener('click', handleTriggerClick);
}
Drupal.behaviors.tabs = {
attach(context) {
context
.querySelectorAll('[data-drupal-nav-tabs]')
.forEach((el) => init(el));
},
};
})(Drupal);