this.#activeTabName = tabName;
}
- showTab(tabName: string, title?: string): void {
- this.#tabs
- .filter((element) => element.dataset.name === tabName)
- .forEach((element) => {
- element.hidden = false;
-
- // Set new title
- if (title) {
- element.querySelector("span")!.textContent = title;
- }
- });
+ showTab(tabName: string): void {
+ const tab = this.#tabs.find((element) => element.dataset.name === tabName);
+ if (tab === undefined) {
+ return;
+ }
+
+ tab.hidden = false;
}
hideTab(tabName: string): void {
- this.#tabs
- .filter((element) => element.dataset.name === tabName)
- .forEach((element) => {
- element.hidden = true;
-
- if (element.classList.contains("active")) {
- this.#closeAllTabs();
- }
- });
+ const tab = this.#tabs.find((element) => element.dataset.name === tabName);
+ if (tab === undefined) {
+ return;
+ }
+
+ tab.hidden = false;
+
+ if (tab.classList.contains("active")) {
+ this.#closeAllTabs();
+ }
}
setTabCounter(tabName: string, value: number): void {
});
}
+ const tabMenu = getTabMenu(this.#editorId);
+ if (tabMenu === undefined) {
+ throw new Error(`Could not find the tab menu for '${this.#editorId}'.`);
+ }
+
+ tabMenu.setTabCounter("quotes", quotesCount);
+
if (quotesCount > 0) {
- getTabMenu(this.#editorId)?.showTab(
- "quotes",
- getPhrase("wcf.message.quote.showQuotes", {
- count: quotesCount,
- }),
- );
+ tabMenu.showTab("quotes");
} else {
- getTabMenu(this.#editorId)?.hideTab("quotes");
+ tabMenu.hideTab("quotes");
}
}
}
this.#tabContainers[tabIndex].classList.add("active");
this.#activeTabName = tabName;
}
- showTab(tabName, title) {
- this.#tabs
- .filter((element) => element.dataset.name === tabName)
- .forEach((element) => {
- element.hidden = false;
- // Set new title
- if (title) {
- element.querySelector("span").textContent = title;
- }
- });
+ showTab(tabName) {
+ const tab = this.#tabs.find((element) => element.dataset.name === tabName);
+ if (tab === undefined) {
+ return;
+ }
+ tab.hidden = false;
}
hideTab(tabName) {
- this.#tabs
- .filter((element) => element.dataset.name === tabName)
- .forEach((element) => {
- element.hidden = true;
- if (element.classList.contains("active")) {
- this.#closeAllTabs();
- }
- });
+ const tab = this.#tabs.find((element) => element.dataset.name === tabName);
+ if (tab === undefined) {
+ return;
+ }
+ tab.hidden = false;
+ if (tab.classList.contains("active")) {
+ this.#closeAllTabs();
+ }
}
setTabCounter(tabName, value) {
const tab = this.#tabs.find((element) => element.dataset.name === tabName);
this.#container.append(fragment);
});
}
+ const tabMenu = (0, MessageTabMenu_1.getTabMenu)(this.#editorId);
+ if (tabMenu === undefined) {
+ throw new Error(`Could not find the tab menu for '${this.#editorId}'.`);
+ }
+ tabMenu.setTabCounter("quotes", quotesCount);
if (quotesCount > 0) {
- (0, MessageTabMenu_1.getTabMenu)(this.#editorId)?.showTab("quotes", (0, Language_1.getPhrase)("wcf.message.quote.showQuotes", {
- count: quotesCount,
- }));
+ tabMenu.showTab("quotes");
}
else {
- (0, MessageTabMenu_1.getTabMenu)(this.#editorId)?.hideTab("quotes");
+ tabMenu.hideTab("quotes");
}
}
}