gitlab-org--gitlab-foss/app/assets/javascripts/new_sidebar.js

24 lines
593 B
JavaScript
Raw Normal View History

2017-07-17 22:33:12 +00:00
const SIDEBAR_EXPANDED_CLASS = 'nav-sidebar-expanded';
export default class NewNavSidebar {
constructor() {
this.initDomElements();
this.bindEvents();
}
initDomElements() {
this.$sidebar = $('.nav-sidebar');
this.$openSidebar = $('.toggle-mobile-nav');
this.$closeSidebar = $('.close-nav-button');
}
bindEvents() {
this.$openSidebar.on('click', e => this.toggleSidebarNav(e, true));
this.$closeSidebar.on('click', e => this.toggleSidebarNav(e, false));
}
toggleSidebarNav(show) {
this.$sidebar.toggleClass(SIDEBAR_EXPANDED_CLASS, show);
}
}