| 
									
										
										
										
											2017-08-15 22:32:30 -04:00
										 |  |  | $(function() { | 
					
						
							|  |  |  |     $(window).resize(function() { | 
					
						
							| 
									
										
										
										
											2017-08-23 23:36:16 -04:00
										 |  |  |         $('ul.fancytree-container').height($(window).height() - $('ul.fancytree-container').offset().top - 10); | 
					
						
							| 
									
										
										
										
											2017-08-15 22:32:30 -04:00
										 |  |  |         $('div.note-editable').height($(window).height() - $('div.note-editable').offset().top); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |     $(window).resize(); | 
					
						
							| 
									
										
										
										
											2017-08-21 22:04:08 -04:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | jQuery.hotkeys.options.filterInputAcceptingElements = true; | 
					
						
							|  |  |  | jQuery.hotkeys.options.filterContentEditable = true; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-24 22:48:00 -04:00
										 |  |  | $(document).bind('keydown', 'alt+ctrl+h', function() { | 
					
						
							| 
									
										
										
										
											2017-08-21 22:04:08 -04:00
										 |  |  |     const toggle = $(".hide-toggle"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-22 20:19:46 -04:00
										 |  |  |     // use visibility instead of display so that content isn't moved around and stays set in place
 | 
					
						
							| 
									
										
										
										
											2017-08-21 22:04:08 -04:00
										 |  |  |     toggle.css('visibility', toggle.css('visibility') === 'hidden' ? 'visible' : 'hidden'); | 
					
						
							| 
									
										
										
										
											2017-08-22 22:40:54 -04:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-24 22:48:00 -04:00
										 |  |  | $(document).bind('keydown', 'alt+q', function() { | 
					
						
							| 
									
										
										
										
											2017-08-22 22:40:54 -04:00
										 |  |  |     $("#recentNotesDialog").dialog({ | 
					
						
							|  |  |  |         modal: true | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     let recentNotesSelectBox = $('#recentNotesSelectBox'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     recentNotesSelectBox.find('option').remove(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // remove the current note
 | 
					
						
							| 
									
										
										
										
											2017-08-23 19:57:44 -04:00
										 |  |  |     let recNotes = recentNotes.filter(note => note.noteId !== globalNote.detail.note_id); | 
					
						
							| 
									
										
										
										
											2017-08-22 22:40:54 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     $.each(recNotes, function(key, value) { | 
					
						
							|  |  |  |         let option = $("<option></option>") | 
					
						
							|  |  |  |                 .attr("value", value.noteId) | 
					
						
							|  |  |  |                 .text(value.noteTitle); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // select the first one (most recent one) by default
 | 
					
						
							|  |  |  |         if (key === 0) { | 
					
						
							|  |  |  |             option.attr("selected", "selected"); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         recentNotesSelectBox.append(option); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-23 18:47:37 -04:00
										 |  |  | function setActiveNoteBasedOnRecentNotes() { | 
					
						
							|  |  |  |     let noteId = $("#recentNotesSelectBox option:selected").val(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $("#tree").fancytree('getNodeByKey', noteId).setActive(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     $("#recentNotesDialog").dialog('close'); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-22 22:40:54 -04:00
										 |  |  | $('#recentNotesSelectBox').keydown(function(e) { | 
					
						
							|  |  |  |     let key = e.which; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (key === 13)// the enter key code
 | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-08-23 18:47:37 -04:00
										 |  |  |         setActiveNoteBasedOnRecentNotes(); | 
					
						
							| 
									
										
										
										
											2017-08-22 22:40:54 -04:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-08-23 18:47:37 -04:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $('#recentNotesSelectBox').dblclick(function(e) { | 
					
						
							|  |  |  |     setActiveNoteBasedOnRecentNotes(); | 
					
						
							| 
									
										
										
										
											2017-08-15 22:32:30 -04:00
										 |  |  | }); |