ccs-frontend
Version:
CCS Frontend contains assets and components used in CCS projects
28 lines (26 loc) • 941 B
JavaScript
class Header {
static moduleName = 'ccs-header';
$menuButton;
$menu;
constructor($header) {
this.$menuButton = $header.find('.ccs-js-header-toggle');
this.$menu = $header.find(`#${this.$menuButton.attr('aria-controls')}`);
}
init() {
this.syncState(this.$menu.hasClass('ccs-header__navigation-lists--open'));
this.setEventListeners();
this.$menuButton.removeAttr('hidden');
}
syncState(isVisible) {
this.$menuButton.toggleClass('ccs-header__menu-button--open', isVisible);
this.$menuButton.attr('aria-expanded', String(isVisible));
}
setEventListeners() {
this.$menuButton.on('click', () => {
this.$menu.toggleClass('ccs-header__navigation-lists--open');
this.syncState(this.$menu.hasClass('ccs-header__navigation-lists--open'));
});
}
}
export { Header };
//# sourceMappingURL=header.bundle.mjs.map