luci-base: add extra css class for map level tabs, don't track tab child count

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
This commit is contained in:
Jo-Philipp Wich 2016-01-18 11:04:15 +01:00
parent 879804f1d4
commit aa12e53333
2 changed files with 7 additions and 5 deletions

View file

@ -475,7 +475,7 @@ function cbi_d_update() {
if (node && node.parentNode && !cbi_d_check(entry.deps)) {
node.parentNode.removeChild(node);
state = true;
if( entry.parent )
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) {
@ -484,7 +484,7 @@ function cbi_d_update() {
next.parentNode.insertBefore(entry.node, next);
}
state = true;
if( entry.parent )
if( entry.parent && typeof(cbi_c[entry.parent]) == 'number' )
cbi_c[entry.parent]++;
}
}
@ -935,7 +935,10 @@ function cbi_t_update() {
for( var sid in cbi_t )
for( var tid in cbi_t[sid] )
{
if( cbi_c[cbi_t[sid][tid].cid] == 0 ) {
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' ) {

View file

@ -10,10 +10,9 @@
<%- if firstmap and applymap then cbi_apply_xhr(self.config, parsechain, redirect) end -%>
<% if self.tabbed then %>
<ul class="cbi-tabmenu">
<ul class="cbi-tabmenu map">
<%- self.selected_tab = luci.http.formvalue("tab.m-" .. self.config) %>
<% for i, section in ipairs(self.children) do %>
<script type="text/javascript">cbi_c['container.m-<%=self.config%>.<%=section.sectiontype%>'] = 1;</script>
<%- if not self.selected_tab then self.selected_tab = section.sectiontype end %>
<li id="tab.m-<%=self.config%>.<%=section.sectiontype%>" class="cbi-tab<%=(section.sectiontype == self.selected_tab) and '' or '-disabled'%>">
<a onclick="this.blur(); return cbi_t_switch('m-<%=self.config%>', '<%=section.sectiontype%>')" href="<%=REQUEST_URI%>?tab.m-<%=self.config%>=<%=section.sectiontype%>"><%=section.title or section.sectiontype %></a>