From 8423ef72779e6009222aaaa4089a66ad8dfaa937 Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Sun, 12 Jul 2015 00:46:15 +0200 Subject: [PATCH] Revert "tabs: do not open tabs by default" This reverts commit 0b56e0f407829d3f85f3a73a8ec982511c40889b. --- lib/tabs.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/tabs.js b/lib/tabs.js index 58c36e1..7605742 100644 --- a/lib/tabs.js +++ b/lib/tabs.js @@ -8,17 +8,12 @@ define([], function () { var container = document.createElement("div") function gotoTab(li) { - var visible = li.classList.contains("visible") - for (var i = 0; i < tabs.children.length; i++) tabs.children[i].classList.remove("visible") while (container.firstChild) container.removeChild(container.firstChild) - if (visible) - return - li.classList.add("visible") var tab = document.createElement("div") @@ -39,6 +34,17 @@ define([], function () { li.onclick = switchTab li.child = d tabs.appendChild(li) + + var anyVisible = false + + for (var i = 0; i < tabs.children.length; i++) + if (tabs.children[i].classList.contains("visible")) { + anyVisible = true + break + } + + if (!anyVisible) + gotoTab(li) } self.render = function (el) {