| 
									
										
										
										
											2017-11-04 19:38:50 -04:00
										 |  |  | "use strict"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-04 13:59:43 -04:00
										 |  |  | const jumpToNote = (function() { | 
					
						
							| 
									
										
										
										
											2018-03-24 00:54:50 -04:00
										 |  |  |     const $showDialogButton = $("#jump-to-note-button"); | 
					
						
							| 
									
										
										
										
											2018-02-10 08:44:34 -05:00
										 |  |  |     const $dialog = $("#jump-to-note-dialog"); | 
					
						
							|  |  |  |     const $autoComplete = $("#jump-to-note-autocomplete"); | 
					
						
							|  |  |  |     const $form = $("#jump-to-note-form"); | 
					
						
							| 
									
										
										
										
											2017-09-09 12:06:15 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-19 20:36:13 -05:00
										 |  |  |     async function showDialog() { | 
					
						
							| 
									
										
										
										
											2018-02-10 08:44:34 -05:00
										 |  |  |         glob.activeDialog = $dialog; | 
					
						
							| 
									
										
										
										
											2017-11-04 17:03:15 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-10 08:44:34 -05:00
										 |  |  |         $autoComplete.val(''); | 
					
						
							| 
									
										
										
										
											2017-09-09 12:06:15 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-10 08:44:34 -05:00
										 |  |  |         $dialog.dialog({ | 
					
						
							| 
									
										
										
										
											2017-11-04 13:59:43 -04:00
										 |  |  |             modal: true, | 
					
						
							|  |  |  |             width: 800 | 
					
						
							|  |  |  |         }); | 
					
						
							| 
									
										
										
										
											2017-10-10 20:37:45 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-10 08:44:34 -05:00
										 |  |  |         await $autoComplete.autocomplete({ | 
					
						
							| 
									
										
										
										
											2018-03-24 21:39:15 -04:00
										 |  |  |             source: await stopWatch("building autocomplete", treeService.getAutocompleteItems), | 
					
						
							| 
									
										
										
										
											2017-11-04 13:59:43 -04:00
										 |  |  |             minLength: 0 | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-09-09 12:06:15 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-19 22:31:30 -05:00
										 |  |  |     function getSelectedNotePath() { | 
					
						
							| 
									
										
										
										
											2018-02-10 08:44:34 -05:00
										 |  |  |         const val = $autoComplete.val(); | 
					
						
							| 
									
										
										
										
											2017-11-19 22:31:30 -05:00
										 |  |  |         return link.getNodePathFromLabel(val); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function goToNote() { | 
					
						
							|  |  |  |         const notePath = getSelectedNotePath(); | 
					
						
							| 
									
										
										
										
											2017-09-09 12:06:15 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-19 20:36:13 -05:00
										 |  |  |         if (notePath) { | 
					
						
							| 
									
										
										
										
											2018-03-24 21:39:15 -04:00
										 |  |  |             treeService.activateNode(notePath); | 
					
						
							| 
									
										
										
										
											2017-11-04 13:59:43 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-10 08:44:34 -05:00
										 |  |  |             $dialog.dialog('close'); | 
					
						
							| 
									
										
										
										
											2017-11-04 13:59:43 -04:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2017-11-19 20:36:13 -05:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-18 23:41:13 -05:00
										 |  |  |     $(document).bind('keydown', 'ctrl+j', e => { | 
					
						
							|  |  |  |         showDialog(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         e.preventDefault(); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2017-11-19 20:36:13 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-10 08:44:34 -05:00
										 |  |  |     $form.submit(() => { | 
					
						
							|  |  |  |         const action = $dialog.find("button:focus").val(); | 
					
						
							| 
									
										
										
										
											2017-11-19 20:36:13 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 22:03:13 -05:00
										 |  |  |         goToNote(); | 
					
						
							| 
									
										
										
										
											2017-11-04 13:59:43 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2017-09-09 12:06:15 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-24 00:54:50 -04:00
										 |  |  |     $showDialogButton.click(showDialog); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-04 13:59:43 -04:00
										 |  |  |     return { | 
					
						
							|  |  |  |         showDialog | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | })(); |