SIGN IN SIGN UP
app.views.Menu = class Menu extends app.View {
static el = "._menu";
static activeClass = "active";
2024-01-06 11:51:57 +01:00
static events = { click: "onClick" };
2017-02-20 15:50:15 -05:00
init() {
$.on(document.body, "click", (event) => this.onGlobalClick(event));
}
2017-02-20 15:50:15 -05:00
onClick(event) {
const target = $.eventTarget(event);
2024-01-06 11:51:57 +01:00
if (target.tagName === "A") {
target.blur();
}
}
2017-02-20 15:50:15 -05:00
onGlobalClick(event) {
2024-01-06 11:51:57 +01:00
if (event.which !== 1) {
return;
}
if (
typeof event.target.hasAttribute === "function"
? event.target.hasAttribute("data-toggle-menu")
: undefined
) {
this.toggleClass(this.constructor.activeClass);
} else if (this.hasClass(this.constructor.activeClass)) {
this.removeClass(this.constructor.activeClass);
}
}
};