Aquarius.component.define('Tools/Menu', function ($element, options) { var defaults = {}; function Menu() { } Menu.prototype = { init: function () { var self = this; this.$element = $element; this.options = $.extend(true, defaults, options); this.$window = $(window); this.buttonHamburger = $('#wp-menu-open'); this.buttonClose = $('#wp-menu-close'); this.wpMobileHolder = $('#wp-mobile-holder'); this.wpDesktopHolder = $('#wp-desktop-holder'); this.backdrop = $('#wp-backdrop'); this.events(); }, events: function () { const self = this; this.buttonHamburger.off('click').on('click', function () { self.open(); }); this.backdrop.on('click', function () { self.close(); }); this.buttonClose.off('click').on('click', function () { self.close(); }); this.wpMobileHolder.find('a').on('click', function (e) { if ($(this).attr('href').indexOf('#') > -1) { self.close(); } }); }, close: function () { this.wpMobileHolder.removeClass('open'); this.backdrop.removeClass('active'); }, open: function () { this.wpMobileHolder.addClass('open'); this.backdrop.addClass('active'); } }; return Menu; });