mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			61 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			61 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| "use strict";
 | |
| 
 | |
| import treeService from '../services/tree_service.js';
 | |
| import link from '../services/link.js';
 | |
| import utils from '../services/utils.js';
 | |
| 
 | |
| const $showDialogButton = $("#jump-to-note-button");
 | |
| const $dialog = $("#jump-to-note-dialog");
 | |
| const $autoComplete = $("#jump-to-note-autocomplete");
 | |
| const $form = $("#jump-to-note-form");
 | |
| 
 | |
| async function showDialog() {
 | |
|     glob.activeDialog = $dialog;
 | |
| 
 | |
|     $autoComplete.val('');
 | |
| 
 | |
|     $dialog.dialog({
 | |
|         modal: true,
 | |
|         width: 800
 | |
|     });
 | |
| 
 | |
|     await $autoComplete.autocomplete({
 | |
|         source: await utils.stopWatch("building autocomplete", treeService.getAutocompleteItems),
 | |
|         minLength: 0
 | |
|     });
 | |
| }
 | |
| 
 | |
| function getSelectedNotePath() {
 | |
|     const val = $autoComplete.val();
 | |
|     return link.getNodePathFromLabel(val);
 | |
| }
 | |
| 
 | |
| function goToNote() {
 | |
|     const notePath = getSelectedNotePath();
 | |
| 
 | |
|     if (notePath) {
 | |
|         treeService.activateNode(notePath);
 | |
| 
 | |
|         $dialog.dialog('close');
 | |
|     }
 | |
| }
 | |
| 
 | |
| $(document).bind('keydown', 'ctrl+j', e => {
 | |
|     showDialog();
 | |
| 
 | |
|     e.preventDefault();
 | |
| });
 | |
| 
 | |
| $form.submit(() => {
 | |
|     const action = $dialog.find("button:focus").val();
 | |
| 
 | |
|     goToNote();
 | |
| 
 | |
|     return false;
 | |
| });
 | |
| 
 | |
| $showDialogButton.click(showDialog);
 | |
| 
 | |
| export default {
 | |
|     showDialog
 | |
| }; |