| 
									
										
										
										
											2020-01-11 21:19:56 +01:00
										 |  |  | import GlobalButtonsWidget from "../widgets/global_buttons.js"; | 
					
						
							|  |  |  | import SearchBoxWidget from "../widgets/search_box.js"; | 
					
						
							|  |  |  | import SearchResultsWidget from "../widgets/search_results.js"; | 
					
						
							|  |  |  | import NoteTreeWidget from "../widgets/note_tree.js"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-12 09:57:28 +01:00
										 |  |  | class AppContext { | 
					
						
							| 
									
										
										
										
											2020-01-11 21:19:56 +01:00
										 |  |  |     constructor() { | 
					
						
							|  |  |  |         this.widgets = []; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     trigger(name, data) { | 
					
						
							|  |  |  |         for (const widget of this.widgets) { | 
					
						
							|  |  |  |             widget.eventReceived(name, data); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     showWidgets() { | 
					
						
							|  |  |  |         const $leftPane = $("#left-pane"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         this.widgets = [ | 
					
						
							|  |  |  |             new GlobalButtonsWidget(this), | 
					
						
							|  |  |  |             new SearchBoxWidget(this), | 
					
						
							|  |  |  |             new SearchResultsWidget(this), | 
					
						
							|  |  |  |             new NoteTreeWidget(this) | 
					
						
							|  |  |  |         ]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for (const widget of this.widgets) { | 
					
						
							|  |  |  |             const $widget = widget.render(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             $leftPane.append($widget); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-01-12 09:57:28 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const appContext = new AppContext(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export default appContext; |