mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 02:45:54 +01:00
moved all sources to src directory
This commit is contained in:
56
src/public/javascripts/dialogs/jump_to_note.js
Normal file
56
src/public/javascripts/dialogs/jump_to_note.js
Normal file
@@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
|
||||
const jumpToNote = (function() {
|
||||
const dialogEl = $("#jump-to-note-dialog");
|
||||
const autoCompleteEl = $("#jump-to-note-autocomplete");
|
||||
const formEl = $("#jump-to-note-form");
|
||||
|
||||
async function showDialog() {
|
||||
glob.activeDialog = dialogEl;
|
||||
|
||||
autoCompleteEl.val('');
|
||||
|
||||
dialogEl.dialog({
|
||||
modal: true,
|
||||
width: 800
|
||||
});
|
||||
|
||||
await autoCompleteEl.autocomplete({
|
||||
source: await stopWatch("building autocomplete", noteTree.getAutocompleteItems),
|
||||
minLength: 0
|
||||
});
|
||||
}
|
||||
|
||||
function getSelectedNotePath() {
|
||||
const val = autoCompleteEl.val();
|
||||
return link.getNodePathFromLabel(val);
|
||||
}
|
||||
|
||||
function goToNote() {
|
||||
const notePath = getSelectedNotePath();
|
||||
|
||||
if (notePath) {
|
||||
noteTree.activateNode(notePath);
|
||||
|
||||
dialogEl.dialog('close');
|
||||
}
|
||||
}
|
||||
|
||||
$(document).bind('keydown', 'ctrl+j', e => {
|
||||
showDialog();
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
formEl.submit(() => {
|
||||
const action = dialogEl.find("button:focus").val();
|
||||
|
||||
goToNote();
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
return {
|
||||
showDialog
|
||||
};
|
||||
})();
|
||||
Reference in New Issue
Block a user