| 
									
										
										
										
											2017-11-04 19:38:50 -04:00
										 |  |  | "use strict"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-04 13:59:43 -04:00
										 |  |  | const jumpToNote = (function() { | 
					
						
							|  |  |  |     const dialogEl = $("#jump-to-note-dialog"); | 
					
						
							|  |  |  |     const autoCompleteEl = $("#jump-to-note-autocomplete"); | 
					
						
							|  |  |  |     const formEl = $("#jump-to-note-form"); | 
					
						
							| 
									
										
										
										
											2017-09-09 12:06:15 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-04 13:59:43 -04:00
										 |  |  |     function showDialog() { | 
					
						
							| 
									
										
										
										
											2017-11-04 17:03:15 -04:00
										 |  |  |         glob.activeDialog = dialogEl; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-04 13:59:43 -04:00
										 |  |  |         autoCompleteEl.val(''); | 
					
						
							| 
									
										
										
										
											2017-09-09 12:06:15 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-04 13:59:43 -04:00
										 |  |  |         dialogEl.dialog({ | 
					
						
							|  |  |  |             modal: true, | 
					
						
							|  |  |  |             width: 800 | 
					
						
							|  |  |  |         }); | 
					
						
							| 
									
										
										
										
											2017-10-10 20:37:45 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-04 13:59:43 -04:00
										 |  |  |         autoCompleteEl.autocomplete({ | 
					
						
							|  |  |  |             source: getAutocompleteItems(glob.allNoteIds), | 
					
						
							|  |  |  |             minLength: 0 | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-09-09 12:06:15 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-04 13:59:43 -04:00
										 |  |  |     $(document).bind('keydown', 'alt+j', showDialog); | 
					
						
							| 
									
										
										
										
											2017-09-09 12:06:15 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-04 13:59:43 -04:00
										 |  |  |     formEl.submit(() => { | 
					
						
							|  |  |  |         const val = autoCompleteEl.val(); | 
					
						
							| 
									
										
										
										
											2017-11-04 17:07:03 -04:00
										 |  |  |         const noteId = link.getNodeIdFromLabel(val); | 
					
						
							| 
									
										
										
										
											2017-09-09 12:06:15 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-04 13:59:43 -04:00
										 |  |  |         if (noteId) { | 
					
						
							| 
									
										
										
										
											2017-11-04 22:18:36 -04:00
										 |  |  |             treeUtils.activateNode(noteId); | 
					
						
							| 
									
										
										
										
											2017-11-04 13:59:43 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |             dialogEl.dialog('close'); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2017-09-09 12:06:15 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-04 13:59:43 -04:00
										 |  |  |     return { | 
					
						
							|  |  |  |         showDialog | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | })(); |