UNPKG

ccs-frontend

Version:
36 lines (32 loc) 1.41 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.CCSFrontend = {})); })(this, (function (exports) { 'use strict'; 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')); }); } } exports.Header = Header; })); //# sourceMappingURL=header.bundle.js.map