change code style to ffrgb/meshviewer fork
This commit is contained in:
parent
59ba0ba29e
commit
418b630e02
42 changed files with 3505 additions and 3154 deletions
70
lib/tabs.js
70
lib/tabs.js
|
|
@ -1,57 +1,61 @@
|
|||
define([], function () {
|
||||
return function () {
|
||||
var self = this
|
||||
var self = this;
|
||||
|
||||
var tabs = document.createElement("ul")
|
||||
tabs.classList.add("tabs")
|
||||
var tabs = document.createElement("ul");
|
||||
tabs.classList.add("tabs");
|
||||
|
||||
var container = document.createElement("div")
|
||||
var container = document.createElement("div");
|
||||
|
||||
function gotoTab(li) {
|
||||
for (var i = 0; i < tabs.children.length; i++)
|
||||
tabs.children[i].classList.remove("visible")
|
||||
for (var i = 0; i < tabs.children.length; i++) {
|
||||
tabs.children[i].classList.remove("visible");
|
||||
}
|
||||
|
||||
while (container.firstChild)
|
||||
container.removeChild(container.firstChild)
|
||||
while (container.firstChild) {
|
||||
container.removeChild(container.firstChild);
|
||||
}
|
||||
|
||||
li.classList.add("visible")
|
||||
li.classList.add("visible");
|
||||
|
||||
var tab = document.createElement("div")
|
||||
tab.classList.add("tab")
|
||||
container.appendChild(tab)
|
||||
li.child.render(tab)
|
||||
var tab = document.createElement("div");
|
||||
tab.classList.add("tab");
|
||||
container.appendChild(tab);
|
||||
li.child.render(tab);
|
||||
}
|
||||
|
||||
function switchTab() {
|
||||
gotoTab(this)
|
||||
gotoTab(this);
|
||||
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
|
||||
self.add = function (title, d) {
|
||||
var li = document.createElement("li")
|
||||
li.textContent = title
|
||||
li.onclick = switchTab
|
||||
li.child = d
|
||||
tabs.appendChild(li)
|
||||
var li = document.createElement("li");
|
||||
li.textContent = title;
|
||||
li.onclick = switchTab;
|
||||
li.child = d;
|
||||
tabs.appendChild(li);
|
||||
|
||||
var anyVisible = false
|
||||
var anyVisible = false;
|
||||
|
||||
for (var i = 0; i < tabs.children.length; i++)
|
||||
for (var i = 0; i < tabs.children.length; i++) {
|
||||
if (tabs.children[i].classList.contains("visible")) {
|
||||
anyVisible = true
|
||||
break
|
||||
anyVisible = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!anyVisible)
|
||||
gotoTab(li)
|
||||
}
|
||||
if (!anyVisible) {
|
||||
gotoTab(li);
|
||||
}
|
||||
};
|
||||
|
||||
self.render = function (el) {
|
||||
el.appendChild(tabs)
|
||||
el.appendChild(container)
|
||||
}
|
||||
el.appendChild(tabs);
|
||||
el.appendChild(container);
|
||||
};
|
||||
|
||||
return self
|
||||
}
|
||||
})
|
||||
return self;
|
||||
};
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue