summaryrefslogtreecommitdiffhomepage
path: root/modules
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2016-01-18 11:23:07 +0100
committerJo-Philipp Wich <jow@openwrt.org>2016-01-18 11:23:11 +0100
commitbe8dba57a9824179a6b942e27e7203d0ba921129 (patch)
tree2cbaae9f248e87fb0165ffda1fb27f0de6fd3b38 /modules
parent1600b600dddc1a563e421dbbc39764766aa8639a (diff)
luci-base: improve tab hide logic
Do not rely on explicit child counts but inspect the code instead to decide when to hide tabs or not. Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Diffstat (limited to 'modules')
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/cbi.js26
-rw-r--r--modules/luci-base/luasrc/view/cbi/tabmenu.htm1
2 files changed, 10 insertions, 17 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js
index 15645d902..dd8d7b8ee 100644
--- a/modules/luci-base/htdocs/luci-static/resources/cbi.js
+++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js
@@ -13,7 +13,6 @@
var cbi_d = [];
var cbi_t = [];
-var cbi_c = [];
var cbi_validators = {
@@ -475,8 +474,6 @@ function cbi_d_update() {
if (node && node.parentNode && !cbi_d_check(entry.deps)) {
node.parentNode.removeChild(node);
state = true;
- if( entry.parent && typeof(cbi_c[entry.parent]) == 'number')
- cbi_c[entry.parent]--;
} else if ((!node || !node.parentNode) && cbi_d_check(entry.deps)) {
if (!next) {
parent.appendChild(entry.node);
@@ -484,8 +481,6 @@ function cbi_d_update() {
next.parentNode.insertBefore(entry.node, next);
}
state = true;
- if( entry.parent && typeof(cbi_c[entry.parent]) == 'number' )
- cbi_c[entry.parent]++;
}
}
@@ -935,25 +930,24 @@ function cbi_t_update() {
for( var sid in cbi_t )
for( var tid in cbi_t[sid] )
{
- if (typeof(cbi_c[cbi_t[sid][tid].cid]) !== 'number') {
- continue;
- }
- else if( cbi_c[cbi_t[sid][tid].cid] == 0 ) {
- cbi_t[sid][tid].tab.style.display = 'none';
- }
- else if( cbi_t[sid][tid].tab && cbi_t[sid][tid].tab.style.display == 'none' ) {
- cbi_t[sid][tid].tab.style.display = '';
+ var t = cbi_t[sid][tid].tab;
+ var c = cbi_t[sid][tid].container;
+ var n = c.getElementsByTagName('div');
- var t = cbi_t[sid][tid].tab;
+ if (n.length === 0) {
+ t.style.display = 'none';
+ }
+ else if (t.style.display == 'none') {
+ t.style.display = '';
t.className += ' cbi-tab-highlighted';
hl_tabs.push(t);
}
- cbi_tag_last(cbi_t[sid][tid].container);
+ cbi_tag_last(c);
updated = true;
}
- if( hl_tabs.length > 0 )
+ if (hl_tabs.length > 0)
window.setTimeout(function() {
for( var i = 0; i < hl_tabs.length; i++ )
hl_tabs[i].className = hl_tabs[i].className.replace(/ cbi-tab-highlighted/g, '');
diff --git a/modules/luci-base/luasrc/view/cbi/tabmenu.htm b/modules/luci-base/luasrc/view/cbi/tabmenu.htm
index b96ac9ce4..06c1414bf 100644
--- a/modules/luci-base/luasrc/view/cbi/tabmenu.htm
+++ b/modules/luci-base/luasrc/view/cbi/tabmenu.htm
@@ -2,7 +2,6 @@
<ul class="cbi-tabmenu">
<%- self.selected_tab = luci.http.formvalue("tab." .. self.config .. "." .. section) %>
<%- for _, tab in ipairs(self.tab_names) do if #self.tabs[tab].childs > 0 then %>
- <script type="text/javascript">cbi_c['container.<%=self.config%>.<%=section%>.<%=tab%>'] = <%=#self.tabs[tab].childs%>;</script>
<%- if not self.selected_tab then self.selected_tab = tab end %>
<li id="tab.<%=self.config%>.<%=section%>.<%=tab%>" class="cbi-tab<%=(tab == self.selected_tab) and '' or '-disabled'%>">
<a onclick="this.blur(); return cbi_t_switch('<%=self.config%>.<%=section%>', '<%=tab%>')" href="<%=REQUEST_URI%>?tab.<%=self.config%>.<%=section%>=<%=tab%>"><%=self.tabs[tab].title%></a>