mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-11-09 20:00:12 +00:00
Harvey Tindall
88f4de9c46
also: * added a homemade loading animation to buttons * respect disabled invite emails and email address as username
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
export class Tabs implements Tabs {
|
|
tabs: Array<Tab>;
|
|
|
|
constructor() {
|
|
this.tabs = [];
|
|
}
|
|
|
|
addTab = (tabID: string, preFunc = () => void {}, postFunc = () => void {}) => {
|
|
let tab = {} as Tab;
|
|
tab.tabID = tabID;
|
|
tab.tabEl = document.getElementById(tabID) as HTMLDivElement;
|
|
tab.buttonEl = document.getElementById(tabID + "-button") as HTMLSpanElement;
|
|
tab.buttonEl.onclick = () => { this.switch(tabID); };
|
|
tab.preFunc = preFunc;
|
|
tab.postFunc = postFunc;
|
|
this.tabs.push(tab);
|
|
}
|
|
|
|
switch = (tabID: string) => {
|
|
for (let t of this.tabs) {
|
|
if (t.tabID == tabID) {
|
|
t.buttonEl.classList.add("active", "~urge");
|
|
if (t.preFunc) { t.preFunc(); }
|
|
t.tabEl.classList.remove("unfocused");
|
|
if (t.postFunc) { t.postFunc(); }
|
|
} else {
|
|
t.buttonEl.classList.remove("active");
|
|
t.buttonEl.classList.remove("~urge");
|
|
t.tabEl.classList.add("unfocused");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|