mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
global actions context menu, logout
This commit is contained in:
parent
458ed1faff
commit
78d9fac1e6
@ -6,8 +6,6 @@ function initContextMenu(event, itemContainer, selectContextMenuItem) {
|
||||
$contextMenuContainer.empty();
|
||||
|
||||
for (const item of itemContainer.getItems()) {
|
||||
console.log("Adding " + item.title);
|
||||
|
||||
if (item.title === '----') {
|
||||
$contextMenuContainer.append($("<div>").addClass("dropdown-divider"));
|
||||
} else {
|
||||
|
@ -90,21 +90,36 @@ $("#note-menu-button").click(async e => {
|
||||
|
||||
itemsContainer.enableItem("delete", isNotRoot && parentNote.type !== 'search');
|
||||
|
||||
contextMenuWidget.initContextMenu(e, itemsContainer, noteContextMenuHandler);
|
||||
contextMenuWidget.initContextMenu(e, itemsContainer, (event, cmd) => {
|
||||
if (cmd === "delete") {
|
||||
treeChangesService.deleteNodes([node]);
|
||||
|
||||
// move to the tree
|
||||
togglePanes();
|
||||
}
|
||||
else {
|
||||
throw new Error("Unrecognized command " + cmd);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
async function noteContextMenuHandler(event, cmd) {
|
||||
const node = treeService.getCurrentNode();
|
||||
$("#global-actions-button").click(async e => {
|
||||
const itemsContainer = new ContextMenuItemsContainer([
|
||||
{title: "Switch to desktop version", cmd: "switch-to-desktop", uiIcon: "computer"},
|
||||
{title: "Logout", cmd: "log-out", uiIcon: "log-out"}
|
||||
]);
|
||||
|
||||
if (cmd === "delete") {
|
||||
treeChangesService.deleteNodes([node]);
|
||||
|
||||
// move to the tree
|
||||
togglePanes();
|
||||
}
|
||||
else {
|
||||
throw new Error("Unrecognized command " + cmd);
|
||||
}
|
||||
}
|
||||
contextMenuWidget.initContextMenu(e, itemsContainer, (event, cmd) => {
|
||||
if (cmd === "switch-to-desktop") {
|
||||
alert("switch to desktop");
|
||||
}
|
||||
else if (cmd === 'log-out') {
|
||||
$("#logout-form").submit();
|
||||
}
|
||||
else {
|
||||
throw new Error("Unrecognized command " + cmd);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
showTree();
|
@ -14,6 +14,8 @@
|
||||
<a id="collapse-tree-button" title="Collapse note tree. Shortcut ALT+C" class="icon-action jam jam-layers"></a>
|
||||
|
||||
<a id="scroll-to-current-note-button" title="Scroll to current note. Shortcut CTRL+." class="icon-action jam jam-download"></a>
|
||||
|
||||
<a id="global-actions-button" title="Global actions" class="icon-action jam jam-cogs"></a>
|
||||
</div>
|
||||
|
||||
<div id="tree"></div>
|
||||
@ -54,6 +56,8 @@
|
||||
<% include dialogs/protected_session_password.ejs %>
|
||||
|
||||
<div class="dropdown-menu dropdown-menu-sm" id="context-menu-container"></div>
|
||||
|
||||
<form action="logout" id="logout-form" method="POST" style="display: none;"></form>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
Loading…
x
Reference in New Issue
Block a user