add manager for popup entry points
This commit is contained in:
		
							parent
							
								
									a549cbe76a
								
							
						
					
					
						commit
						ca15164def
					
				
					 4 changed files with 90 additions and 6 deletions
				
			
		|  | @ -1,12 +1,8 @@ | ||||||
| import Tabs from "/scripts/GUI/tabs.js"; | import Tabs from "/scripts/GUI/tabs.js"; | ||||||
| import Entry_Manager from "/scripts/external/entries/manager.js" | import EntryManager from "/scripts/external/entries/manager.js" | ||||||
| 
 | 
 | ||||||
| export default class Watcher_Tabs { | export default class Watcher_Tabs { | ||||||
|      constructor () { |      constructor () { | ||||||
|           new Entry_Manager(); |           new EntryManager(); | ||||||
|           Tabs.addActionListener(`update`, this.check); |  | ||||||
|      }; |      }; | ||||||
| 
 |  | ||||||
|      check(data) { |  | ||||||
|      } |  | ||||||
| } | } | ||||||
							
								
								
									
										49
									
								
								scripts/external/entries/manager.js
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								scripts/external/entries/manager.js
									
										
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,49 @@ | ||||||
|  | // Manage all entries. 
 | ||||||
|  | 
 | ||||||
|  | import {read} from '../../secretariat.js'; | ||||||
|  | import Tabs from "/scripts/GUI/tabs.js"; | ||||||
|  | import MenuEntry from "./menu.js"; | ||||||
|  | import ManagedSidebar from "./sidebar.js"; | ||||||
|  | import IconIndicator from "./icons.js"; | ||||||
|  | import filters from '../../filters.js'; | ||||||
|  | 
 | ||||||
|  | export default class EntryManager { | ||||||
|  |      constructor () { | ||||||
|  |           this.instances = {}; | ||||||
|  |           this.instances.menu = new MenuEntry(); | ||||||
|  |           Tabs.addActionListener(`onActivated`, (data) => {this.check(data)}); | ||||||
|  |      } | ||||||
|  | 
 | ||||||
|  |      async check(data) { | ||||||
|  |           console.error(JSON.stringify(data)); | ||||||
|  |           ((data != null && (typeof data).includes(`obj`)) ? ((data.tab) ? data.tab.url : false) : false)  | ||||||
|  | 			? (!!await ((new filters).select(data.tab.url))) | ||||||
|  | 				? (this.enable()) | ||||||
|  | 				: (this.disable()) | ||||||
|  | 			: false; | ||||||
|  |      } | ||||||
|  | 
 | ||||||
|  |      /*  | ||||||
|  |      Enable the entries.  | ||||||
|  |      */ | ||||||
|  |      enable () { | ||||||
|  |           this.instances.menu.enable(); | ||||||
|  |           IconIndicator.enable(); | ||||||
|  | 
 | ||||||
|  |           // Open the side panel, if supported. 
 | ||||||
|  | 		read([`settings`,`behavior`,`autoOpen`]).then((result) => { | ||||||
|  | 			result = (result == null) ? false : result; | ||||||
|  | 			if (result) { | ||||||
|  | 				new ManagedSidebar(); | ||||||
|  | 			} | ||||||
|  | 		}); | ||||||
|  |      } | ||||||
|  | 
 | ||||||
|  |      /*  | ||||||
|  |      Disable the entries and the existing opened side panel.  | ||||||
|  |      */ | ||||||
|  |      disable () { | ||||||
|  |           this.instances.menu.disable(); | ||||||
|  |           IconIndicator.disable(); | ||||||
|  |      } | ||||||
|  | } | ||||||
							
								
								
									
										27
									
								
								scripts/external/entries/menu.js
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								scripts/external/entries/menu.js
									
										
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,27 @@ | ||||||
|  | import Menu from '/scripts/GUI/context_menus.js'; | ||||||
|  | import texts from "/scripts/strings/read.js"; | ||||||
|  | import ManagedSidebar from "./sidebar.js"; | ||||||
|  | 
 | ||||||
|  | export default class MenuEntry { | ||||||
|  |      /* Create all entries. */ | ||||||
|  | 	constructor() { | ||||||
|  | 		// Add the context menu.
 | ||||||
|  | 		this.menu = new Menu({title: (new texts(`entry_contextMenu`)).localized, contexts: [`all`], event: {"onClicked": MenuEntry.onclick}, hidden: true}); | ||||||
|  | 	}; | ||||||
|  | 
 | ||||||
|  |      /*  | ||||||
|  | 	Enable the sidebar.  | ||||||
|  | 	*/ | ||||||
|  | 	enable () { | ||||||
|  | 		this.menu.show(); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	/* Disable. */ | ||||||
|  | 	disable () { | ||||||
|  | 		this.menu.remove(); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	static onclick() { | ||||||
|  | 		new ManagedSidebar(); | ||||||
|  | 	}; | ||||||
|  | } | ||||||
							
								
								
									
										12
									
								
								scripts/external/entries/sidebar.js
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								scripts/external/entries/sidebar.js
									
										
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,12 @@ | ||||||
|  | import Sidebar from '/scripts/GUI/sidepanel.js' | ||||||
|  | 
 | ||||||
|  | export default class ManagedSidebar { | ||||||
|  |      constructor () { | ||||||
|  |           // WIP
 | ||||||
|  |           console.warn(`hello world`); | ||||||
|  |      } | ||||||
|  | 
 | ||||||
|  |      manage() { | ||||||
|  |            | ||||||
|  |      } | ||||||
|  | } | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue