context menu converted to module

This commit is contained in:
azivner 2017-11-04 19:33:39 -04:00
parent 9880a4d6f6
commit ad7803f9dc
2 changed files with 94 additions and 85 deletions

View File

@ -1,3 +1,4 @@
const contextMenu = (function() {
const treeEl = $("#tree"); const treeEl = $("#tree");
function pasteAfter(node) { function pasteAfter(node) {
@ -20,7 +21,7 @@ function cut(node) {
glob.clipboardNoteId = node.key; glob.clipboardNoteId = node.key;
} }
const contextMenuSetup = { const contextMenuSettings = {
delegate: "span.fancytree-title", delegate: "span.fancytree-title",
autoFocus: true, autoFocus: true,
menu: [ menu: [
@ -84,3 +85,11 @@ const contextMenuSetup = {
} }
} }
}; };
return {
pasteAfter,
pasteInto,
cut,
contextMenuSettings
}
})();

View File

@ -161,7 +161,7 @@ const noteTree = (function() {
console.log("CTRL-V"); console.log("CTRL-V");
if (event.ctrlKey) { // Ctrl-V if (event.ctrlKey) { // Ctrl-V
pasteAfter(node); contextMenu.pasteAfter(node);
return false; return false;
} }
break; break;
@ -169,7 +169,7 @@ const noteTree = (function() {
console.log("CTRL-X"); console.log("CTRL-X");
if (event.ctrlKey) { // Ctrl-X if (event.ctrlKey) { // Ctrl-X
cut(node); contextMenu.cut(node);
return false; return false;
} }
break; break;
@ -177,7 +177,7 @@ const noteTree = (function() {
} }
}); });
treeEl.contextmenu(contextMenuSetup); treeEl.contextmenu(contextMenu.contextMenuSettings);
} }
function loadTree() { function loadTree() {