The entry points management technically falls under GUI as well
This commit is contained in:
parent
45e4a54b53
commit
6265695a5c
5 changed files with 1 additions and 1 deletions
15
scripts/GUI/entrypoints/icons.js
Normal file
15
scripts/GUI/entrypoints/icons.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
import BrowserIcon from '/scripts/GUI/extensionIcon.js';
|
||||
import Image from '/scripts/mapping/image.js';
|
||||
|
||||
class IconIndicator {
|
||||
static async enable() {
|
||||
// WIP. Make sure to determine if the product is bad / good
|
||||
BrowserIcon.set(await Image.get('default'));
|
||||
}
|
||||
|
||||
static async disable() {
|
||||
BrowserIcon.set(await Image.get('disabled'));
|
||||
}
|
||||
}
|
||||
|
||||
export {IconIndicator as default};
|
50
scripts/GUI/entrypoints/manager.js
Normal file
50
scripts/GUI/entrypoints/manager.js
Normal file
|
@ -0,0 +1,50 @@
|
|||
// 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 check from "/scripts/external/check.js";
|
||||
|
||||
export default class EntryManager {
|
||||
constructor () {
|
||||
this.instances = {};
|
||||
this.instances.menu = new MenuEntry();
|
||||
Tabs.addActionListener(`onActivated`, (data) => {this.onRefresh()});
|
||||
}
|
||||
|
||||
async onRefresh() {
|
||||
const DATA = await Tabs.query(null, 0)
|
||||
|
||||
if (DATA.url) {
|
||||
(!!await check.platform(DATA.url))
|
||||
? (this.enable())
|
||||
: (this.disable())
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
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/GUI/entrypoints/menu.js
Normal file
27
scripts/GUI/entrypoints/menu.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
import Menu from '/scripts/GUI/menus.js';
|
||||
import texts from "/scripts/mapping/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();
|
||||
};
|
||||
}
|
8
scripts/GUI/entrypoints/sidebar.js
Normal file
8
scripts/GUI/entrypoints/sidebar.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
import Sidebar from '/scripts/GUI/sidepanel.js'
|
||||
|
||||
export default class ManagedSidebar {
|
||||
constructor () {
|
||||
// WIP
|
||||
new Sidebar(`/pages/popup.htm`);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue