-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtabs.js
53 lines (42 loc) · 1.35 KB
/
tabs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
class Tabs extends Window {
constructor(themeColor = [64,64,64]) {
super();
this.AddCssDependencies("tabs.css");
this.tabsList = [];
this.content.classList.add("tabs-content");
this.content.style.overflow = "hidden";
this.tabsBox = document.createElement("div");
this.tabsBox.tabIndex = -1;
this.tabsBox.className = "tabs-box";
this.content.appendChild(this.tabsBox);
this.tabsPanel = document.createElement("div");
this.tabsPanel.tabIndex = -1;
this.tabsPanel.className = "tabs-panel";
this.tabsPanel.setAttribute("role", "tabpanel");
this.content.appendChild(this.tabsPanel);
}
AddTab(text, icon) {
const newTab = document.createElement("button");
newTab.tabIndex = 0;
newTab.setAttribute("role", "tab");
newTab.setAttribute("aria-label", text);
this.tabsBox.appendChild(newTab);
this.tabsList.push(newTab);
const divIcon = document.createElement("div");
if (icon) divIcon.style.backgroundImage = "url(" + icon + ")";
newTab.appendChild(divIcon);
const divText = document.createElement("div");
divText.textContent = text;
newTab.appendChild(divText);
newTab.addEventListener("click", ()=> {
this.DeselectAllTabs();
newTab.className = "v-tab-selected";
});
return newTab;
}
DeselectAllTabs() {
for (let i = 0; i < this.tabsList.length; i++)
this.tabsList[i].className = "";
}
RemoveTab() { }
}