| 
									
										
										
										
											2020-01-12 19:05:09 +01:00
										 |  |  | import BasicWidget from "./basic_widget.js"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export default class TabAwareWidget extends BasicWidget { | 
					
						
							| 
									
										
										
										
											2020-01-18 19:46:30 +01:00
										 |  |  |     setTabContextListener({tabContext}) { | 
					
						
							| 
									
										
										
										
											2020-01-12 19:05:09 +01:00
										 |  |  |         /** @var {TabContext} */ | 
					
						
							| 
									
										
										
										
											2020-01-16 22:44:36 +01:00
										 |  |  |         this.tabContext = tabContext; | 
					
						
							| 
									
										
										
										
											2020-01-18 18:01:16 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-18 19:46:30 +01:00
										 |  |  |         this.noteSwitched(); | 
					
						
							| 
									
										
										
										
											2020-01-12 19:05:09 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-18 18:01:16 +01:00
										 |  |  |     tabNoteSwitchedListener({tabId}) { | 
					
						
							|  |  |  |         if (this.tabContext && tabId === this.tabContext.tabId) { | 
					
						
							|  |  |  |             this.noteSwitched(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-18 19:46:30 +01:00
										 |  |  |     noteSwitched() { | 
					
						
							|  |  |  |         this.refresh(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-01-18 18:01:16 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-12 19:05:09 +01:00
										 |  |  |     // to override
 | 
					
						
							| 
									
										
										
										
											2020-01-18 19:46:30 +01:00
										 |  |  |     activeTabChanged() { | 
					
						
							|  |  |  |         this.refresh(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     refresh() {} | 
					
						
							| 
									
										
										
										
											2020-01-12 19:05:09 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     activeTabChangedListener() { | 
					
						
							|  |  |  |         this.tabContext = this.appContext.getActiveTabContext(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         this.activeTabChanged(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |