tabs: render tabs when visible, destroy them when hidden
This commit is contained in:
parent
3954ec5eaf
commit
e67c61d7d3
|
@ -3,9 +3,23 @@ define(["chroma-js", "virtual-dom", "numeral-intl"],
|
||||||
|
|
||||||
return function (config) {
|
return function (config) {
|
||||||
var self = this
|
var self = this
|
||||||
var fwTable, hwTable, geoTable, autoTable, gwTable
|
|
||||||
var scale = Chroma.scale("YlGnBu").mode("lab")
|
var scale = Chroma.scale("YlGnBu").mode("lab")
|
||||||
|
|
||||||
|
var fwTable = document.createElement("table")
|
||||||
|
fwTable.classList.add("proportion")
|
||||||
|
|
||||||
|
var hwTable = document.createElement("table")
|
||||||
|
hwTable.classList.add("proportion")
|
||||||
|
|
||||||
|
var geoTable = document.createElement("table")
|
||||||
|
geoTable.classList.add("proportion")
|
||||||
|
|
||||||
|
var autoTable = document.createElement("table")
|
||||||
|
autoTable.classList.add("proportion")
|
||||||
|
|
||||||
|
var gwTable = document.createElement("table")
|
||||||
|
gwTable.classList.add("proportion")
|
||||||
|
|
||||||
function showStatGlobal(o) {
|
function showStatGlobal(o) {
|
||||||
var content, caption
|
var content, caption
|
||||||
|
|
||||||
|
@ -135,41 +149,26 @@ define(["chroma-js", "virtual-dom", "numeral-intl"],
|
||||||
h2 = document.createElement("h2")
|
h2 = document.createElement("h2")
|
||||||
h2.textContent = "Firmwareversionen"
|
h2.textContent = "Firmwareversionen"
|
||||||
el.appendChild(h2)
|
el.appendChild(h2)
|
||||||
|
|
||||||
fwTable = document.createElement("table")
|
|
||||||
fwTable.classList.add("proportion")
|
|
||||||
el.appendChild(fwTable)
|
el.appendChild(fwTable)
|
||||||
|
|
||||||
h2 = document.createElement("h2")
|
h2 = document.createElement("h2")
|
||||||
h2.textContent = "Hardwaremodelle"
|
h2.textContent = "Hardwaremodelle"
|
||||||
el.appendChild(h2)
|
el.appendChild(h2)
|
||||||
|
|
||||||
hwTable = document.createElement("table")
|
|
||||||
hwTable.classList.add("proportion")
|
|
||||||
el.appendChild(hwTable)
|
el.appendChild(hwTable)
|
||||||
|
|
||||||
h2 = document.createElement("h2")
|
h2 = document.createElement("h2")
|
||||||
h2.textContent = "Auf der Karte sichtbar"
|
h2.textContent = "Auf der Karte sichtbar"
|
||||||
el.appendChild(h2)
|
el.appendChild(h2)
|
||||||
|
|
||||||
geoTable = document.createElement("table")
|
|
||||||
geoTable.classList.add("proportion")
|
|
||||||
el.appendChild(geoTable)
|
el.appendChild(geoTable)
|
||||||
|
|
||||||
h2 = document.createElement("h2")
|
h2 = document.createElement("h2")
|
||||||
h2.textContent = "Autoupdater"
|
h2.textContent = "Autoupdater"
|
||||||
el.appendChild(h2)
|
el.appendChild(h2)
|
||||||
|
|
||||||
autoTable = document.createElement("table")
|
|
||||||
autoTable.classList.add("proportion")
|
|
||||||
el.appendChild(autoTable)
|
el.appendChild(autoTable)
|
||||||
|
|
||||||
h2 = document.createElement("h2")
|
h2 = document.createElement("h2")
|
||||||
h2.textContent = "Gewählter Gateway"
|
h2.textContent = "Gewählter Gateway"
|
||||||
el.appendChild(h2)
|
el.appendChild(h2)
|
||||||
|
|
||||||
gwTable = document.createElement("table")
|
|
||||||
gwTable.classList.add("proportion")
|
|
||||||
el.appendChild(gwTable)
|
el.appendChild(gwTable)
|
||||||
|
|
||||||
if (config.globalInfos)
|
if (config.globalInfos)
|
||||||
|
|
31
lib/tabs.js
31
lib/tabs.js
|
@ -8,14 +8,18 @@ define([], function () {
|
||||||
var container = document.createElement("div")
|
var container = document.createElement("div")
|
||||||
|
|
||||||
function gotoTab(li) {
|
function gotoTab(li) {
|
||||||
for (var i = 0; i < tabs.children.length; i++) {
|
for (var i = 0; i < tabs.children.length; i++)
|
||||||
var el = tabs.children[i]
|
tabs.children[i].classList.remove("visible")
|
||||||
el.classList.remove("visible")
|
|
||||||
el.tab.classList.remove("visible")
|
while (container.firstChild)
|
||||||
}
|
container.removeChild(container.firstChild)
|
||||||
|
|
||||||
li.classList.add("visible")
|
li.classList.add("visible")
|
||||||
li.tab.classList.add("visible")
|
|
||||||
|
var tab = document.createElement("div")
|
||||||
|
tab.classList.add("tab")
|
||||||
|
container.appendChild(tab)
|
||||||
|
li.child.render(tab)
|
||||||
}
|
}
|
||||||
|
|
||||||
function switchTab() {
|
function switchTab() {
|
||||||
|
@ -25,15 +29,10 @@ define([], function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.add = function (title, d) {
|
self.add = function (title, d) {
|
||||||
var tab = document.createElement("div")
|
|
||||||
tab.classList.add("tab")
|
|
||||||
container.appendChild(tab)
|
|
||||||
|
|
||||||
var li = document.createElement("li")
|
var li = document.createElement("li")
|
||||||
li.textContent = title
|
li.textContent = title
|
||||||
li.onclick = switchTab
|
li.onclick = switchTab
|
||||||
tab.li = li
|
li.child = d
|
||||||
li.tab = tab
|
|
||||||
tabs.appendChild(li)
|
tabs.appendChild(li)
|
||||||
|
|
||||||
var anyVisible = false
|
var anyVisible = false
|
||||||
|
@ -44,12 +43,8 @@ define([], function () {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!anyVisible) {
|
if (!anyVisible)
|
||||||
tab.classList.add("visible")
|
gotoTab(li)
|
||||||
li.classList.add("visible")
|
|
||||||
}
|
|
||||||
|
|
||||||
d.render(tab)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.render = function (el) {
|
self.render = function (el) {
|
||||||
|
|
|
@ -61,14 +61,6 @@ $buttondistance: 12pt;
|
||||||
color: #dc0067;
|
color: #dc0067;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tab {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tab.visible {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
|
Loading…
Reference in a new issue