Sha256: e7ca799edb1758cf8b00b403bc8de9a9926430a3b4bc7af997ce3380d459e396

Contents?: true

Size: 1.14 KB

Versions: 71

Compression:

Stored size: 1.14 KB

Contents

export default class Topnav {
  constructor() {
    this.domNode = document.getElementById('subnav');
    this.backdrop = this.domNode.querySelector('.Vlt-header__backdrop');

    this.setupListeners();
  }

  setupListeners() {
    this.domNode.querySelectorAll('.Vlt-tabs__link-menu').forEach((menu) => {
      menu.addEventListener('click', this.toggleMenu.bind(this));
    });

    this.domNode.querySelector('.Adp-header__hamburger').addEventListener('click', this.toggleMobileMenu.bind(this));
  }

  toggleMobileMenu() {
    this.backdrop.classList.toggle('Vlt-header__backdrop-active');
    this.domNode.querySelector('.Adp-header__sub__menu').classList.toggle('Vlt-M-plus');
  }

  toggleMenu(event) {
    let menu   = event.target.closest('.Vlt-tabs__link-menu');
    let active = menu.querySelector('.Vlt-topmenu').classList.contains('Vlt-topmenu-active');

    this.backdrop.classList.toggle('Vlt-header__backdrop-active', !active);

    this.domNode.querySelectorAll('.Vlt-topmenu').forEach((elem) => {
      elem.classList.remove('Vlt-topmenu-active');
    });
    menu.querySelector('.Vlt-topmenu').classList.toggle('Vlt-topmenu-active', !active);
  }
}

Version data entries

71 entries across 71 versions & 1 rubygems

Version Path
station-0.5.16 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.5.15 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.5.14 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.5.13 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.5.12 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.5.11 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.5.10 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.5.9 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.5.8 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.5.7 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.5.6 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.5.5 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.5.4 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.5.3 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.5.2 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.5.1 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.5.0 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.4.9 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.4.8 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.4.7 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js