Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
converted jump to note to module
azivner1d0e96a314ee
diff --git a/public/javascripts/jump_to_note.js b/public/javascripts/jump_to_note.jsindex 1886492145..47056bf80f 100644--- a/public/javascripts/jump_to_note.js+++ b/public/javascripts/jump_to_note.js@@ -1,28 +1,38 @@-function showJumpToNote() {- $("#jump-to-note-autocomplete").val('');+const jumpToNote = (function() {+ const dialogEl = $("#jump-to-note-dialog");+ const autoCompleteEl = $("#jump-to-note-autocomplete");+ const formEl = $("#jump-to-note-form");- $("#jump-to-note-dialog").dialog({- modal: true,- width: 800- });+ function showDialog() {+ autoCompleteEl.val('');- $("#jump-to-note-autocomplete").autocomplete({- source: getAutocompleteItems(glob.allNoteIds),- minLength: 0- });-}+ dialogEl.dialog({+ modal: true,+ width: 800+ });-$(document).bind('keydown', 'alt+j', showJumpToNote);+ autoCompleteEl.autocomplete({+ source: getAutocompleteItems(glob.allNoteIds),+ minLength: 0+ });+ }-$("#jump-to-note-form").submit(() => {- const val = $("#jump-to-note-autocomplete").val();- const noteId = getNodeIdFromLabel(val);+ $(document).bind('keydown', 'alt+j', showDialog);- if (noteId) {- getNodeByKey(noteId).setActive();+ formEl.submit(() => {+ const val = autoCompleteEl.val();+ const noteId = getNodeIdFromLabel(val);- $("#jump-to-note-dialog").dialog('close');- }+ if (noteId) {+ getNodeByKey(noteId).setActive();++ dialogEl.dialog('close');+ }++ return false;+ });- return false;-});\ No newline at end of file+ return {+ showDialog+ };+})();\ No newline at end of filediff --git a/views/index.ejs b/views/index.ejsindex a520f6f308..241719ef71 100644--- a/views/index.ejs+++ b/views/index.ejs@@ -14,7 +14,7 @@<div style="flex-grow: 100;"><button class="btn btn-xs" onclick="recentChanges.showDialog();">Recent changes</button><button class="btn btn-xs" onclick="recentNotes.showDialog();">Recent notes</button>- <button class="btn btn-xs" onclick="showJumpToNote();">Jump to note</button>+ <button class="btn btn-xs" onclick="jumpToNote.showDialog();">Jump to note</button><button class="btn btn-xs" onclick="showEventLog();">Event log</button></div>