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.1.5 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.1.4 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.1.3 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.1.2 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.1.1 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.1.0 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.0.145 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.0.144 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.0.143 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.0.142 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.0.141 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.0.140 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.0.139 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.0.138 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.0.137 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.0.136 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.0.135 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.0.134 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.0.133 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js
station-0.0.132 lib/nexmo_developer/app/webpacker/javascript/topnav/index.js