2026-03-27 19:53:19 +01:00
|
|
|
const generalTab = require("./general-tab");
|
|
|
|
|
const serverPluginsTab = require("./server-plugins-tab");
|
|
|
|
|
|
|
|
|
|
function createNavEl(tab, setting) {
|
|
|
|
|
const nav = document.createElement("div");
|
|
|
|
|
nav.className = "vertical-tab-nav-item tappable";
|
|
|
|
|
|
|
|
|
|
const title = document.createElement("div");
|
|
|
|
|
title.className = "vertical-tab-nav-item-title";
|
|
|
|
|
title.textContent = tab.name;
|
|
|
|
|
nav.appendChild(title);
|
|
|
|
|
|
|
|
|
|
const chevron = document.createElement("div");
|
|
|
|
|
chevron.className = "vertical-tab-nav-item-chevron";
|
|
|
|
|
nav.appendChild(chevron);
|
|
|
|
|
|
|
|
|
|
nav.addEventListener("click", () => {
|
|
|
|
|
setting.openTab(tab);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return nav;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-27 23:11:19 +01:00
|
|
|
function createTab(id, name, displayFn, app) {
|
2026-03-27 19:53:19 +01:00
|
|
|
const tab = {
|
|
|
|
|
id,
|
|
|
|
|
name,
|
|
|
|
|
containerEl: createDiv("vertical-tab-content"),
|
|
|
|
|
navEl: null,
|
|
|
|
|
|
|
|
|
|
display() {
|
|
|
|
|
this.containerEl.empty();
|
2026-03-27 23:11:19 +01:00
|
|
|
displayFn(this.containerEl, app);
|
2026-03-27 19:53:19 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
hide() {
|
|
|
|
|
this.containerEl.empty();
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return tab;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-28 14:52:41 +01:00
|
|
|
function createGroup(name) {
|
2026-03-27 19:53:19 +01:00
|
|
|
const group = document.createElement("div");
|
|
|
|
|
group.className = "vertical-tab-header-group";
|
|
|
|
|
|
|
|
|
|
const title = document.createElement("div");
|
|
|
|
|
title.className = "vertical-tab-header-group-title";
|
2026-03-28 14:52:41 +01:00
|
|
|
title.textContent = name;
|
2026-03-27 19:53:19 +01:00
|
|
|
group.appendChild(title);
|
|
|
|
|
|
|
|
|
|
const items = document.createElement("div");
|
|
|
|
|
items.className = "vertical-tab-header-group-items";
|
|
|
|
|
group.appendChild(items);
|
|
|
|
|
|
2026-03-28 14:52:41 +01:00
|
|
|
return { group, items };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function injectIgnisSettings(setting, app) {
|
|
|
|
|
const ignis = createGroup("Ignis");
|
|
|
|
|
|
2026-03-27 19:53:19 +01:00
|
|
|
const tabs = [
|
2026-03-27 23:11:19 +01:00
|
|
|
createTab("ignis-general", "General", generalTab.display, app),
|
2026-03-28 14:52:41 +01:00
|
|
|
createTab(
|
|
|
|
|
"ignis-core-plugins",
|
|
|
|
|
"Core plugins",
|
|
|
|
|
serverPluginsTab.display,
|
|
|
|
|
app,
|
|
|
|
|
),
|
2026-03-27 19:53:19 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
for (const tab of tabs) {
|
|
|
|
|
tab.navEl = createNavEl(tab, setting);
|
2026-03-28 14:52:41 +01:00
|
|
|
ignis.items.appendChild(tab.navEl);
|
2026-03-27 19:53:19 +01:00
|
|
|
}
|
|
|
|
|
|
2026-03-28 14:52:41 +01:00
|
|
|
setting.tabHeadersEl.appendChild(ignis.group);
|
|
|
|
|
|
|
|
|
|
const corePlugins = createGroup("Ignis Core Plugins");
|
|
|
|
|
setting.tabHeadersEl.appendChild(corePlugins.group);
|
2026-03-27 19:53:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function patchSettingsModal(plugin) {
|
|
|
|
|
const original = plugin.app.setting.onOpen;
|
2026-03-27 23:11:19 +01:00
|
|
|
const app = plugin.app;
|
2026-03-27 19:53:19 +01:00
|
|
|
plugin._originalOnOpen = original;
|
|
|
|
|
|
|
|
|
|
plugin.app.setting.onOpen = function () {
|
|
|
|
|
original.call(this);
|
2026-03-27 23:11:19 +01:00
|
|
|
injectIgnisSettings(this, app);
|
2026-03-27 19:53:19 +01:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function unpatchSettingsModal(plugin) {
|
|
|
|
|
if (plugin._originalOnOpen) {
|
|
|
|
|
plugin.app.setting.onOpen = plugin._originalOnOpen;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports = { patchSettingsModal, unpatchSettingsModal };
|