@@ -3,8 +3,36 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
.querySelector("meta[name='csrf-token']")
|
||||
.getAttribute("content");
|
||||
|
||||
const Hooks = {
|
||||
SidebarInteractions: {
|
||||
mounted() {
|
||||
this.handleDblClick = (event) => {
|
||||
const button = event.target.closest("[data-testid='sidebar-open-item']");
|
||||
|
||||
if (!button || !this.el.contains(button)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.pushEvent("pin_sidebar_item", {
|
||||
route: button.dataset.route,
|
||||
id: button.dataset.itemId,
|
||||
title: button.dataset.openTitle || "",
|
||||
subtitle: button.dataset.openSubtitle || ""
|
||||
});
|
||||
};
|
||||
|
||||
this.el.addEventListener("dblclick", this.handleDblClick);
|
||||
},
|
||||
|
||||
destroyed() {
|
||||
this.el.removeEventListener("dblclick", this.handleDblClick);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const liveSocket = new LiveView.LiveSocket("/live", Phoenix.Socket, {
|
||||
params: { _csrf_token: csrfToken }
|
||||
params: { _csrf_token: csrfToken },
|
||||
hooks: Hooks
|
||||
});
|
||||
|
||||
liveSocket.connect();
|
||||
|
||||
Reference in New Issue
Block a user