add manager for popup entry points

This commit is contained in:
buzz-lightsnack-2007 2024-04-24 16:25:15 +08:00
parent a549cbe76a
commit ca15164def
4 changed files with 90 additions and 6 deletions

View file

@ -1,12 +1,8 @@
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 {
constructor () {
new Entry_Manager();
Tabs.addActionListener(`update`, this.check);
new EntryManager();
};
check(data) {
}
}

49
scripts/external/entries/manager.js vendored Normal file
View 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
View 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
View file

@ -0,0 +1,12 @@
import Sidebar from '/scripts/GUI/sidepanel.js'
export default class ManagedSidebar {
constructor () {
// WIP
console.warn(`hello world`);
}
manage() {
}
}