libs/cbi: fix dynamic tab hiding
[project/luci.git] / libs / cbi / luasrc / view / cbi / tabmenu.htm
1 <%#
2 LuCI - Lua Configuration Interface
3 Copyright 2009 Jo-Philipp Wich <xm@subsignal.org>
4
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9         http://www.apache.org/licenses/LICENSE-2.0
10
11 $Id$
12
13 -%>
14
15 <%- if self.tabs then %>
16         <ul class="cbi-tabmenu">
17         <%- self.selected_tab = luci.http.formvalue("tab." .. self.config .. "." .. section) %>
18         <%- for _, tab in ipairs(self.tab_names) do if #self.tabs[tab].childs > 0 then %>
19                 <script type="text/javascript">cbi_c['container.<%=self.config%>.<%=section%>.<%=tab%>'] = <%=#self.tabs[tab].childs%>;</script>
20                 <%- if not self.selected_tab then self.selected_tab = tab end %>
21                 <li id="tab.<%=self.config%>.<%=section%>.<%=tab%>" class="cbi-tab<%=(tab == self.selected_tab) and '' or '-disabled'%>">
22                         <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>
23                         <% if tab == self.selected_tab then %><input type="hidden" id="tab.<%=self.config%>.<%=section%>" name="tab.<%=self.config%>.<%=section%>" value="<%=tab%>" /><% end %>
24                 </li>
25         <% end end -%>
26         </ul>
27 <% end -%>