luci-base: add basic support for CBI map level tabbing
[project/luci.git] / modules / luci-base / luasrc / view / cbi / map.htm
1 <%- if firstmap and messages then local msg; for _, msg in ipairs(messages) do -%>
2         <div class="errorbox"><%=pcdata(msg)%></div>
3 <%- end end -%>
4
5 <%-+cbi/apply_xhr-%>
6
7 <div class="cbi-map" id="cbi-<%=self.config%>">
8         <% if self.title and #self.title > 0 then %><h2 name="content"><%=self.title%></h2><% end %>
9         <% if self.description and #self.description > 0 then %><div class="cbi-map-descr"><%=self.description%></div><% end %>
10         <%- if firstmap and applymap then cbi_apply_xhr(self.config, parsechain, redirect) end -%>
11
12         <% if self.tabbed then %>
13                 <ul class="cbi-tabmenu">
14                         <%- self.selected_tab = luci.http.formvalue("tab.m-" .. self.config) %>
15                         <% for i, section in ipairs(self.children) do %>
16                                 <script type="text/javascript">cbi_c['container.m-<%=self.config%>.<%=section.sectiontype%>'] = 1;</script>
17                                 <%- if not self.selected_tab then self.selected_tab = section.sectiontype end %>
18                                 <li id="tab.m-<%=self.config%>.<%=section.sectiontype%>" class="cbi-tab<%=(section.sectiontype == self.selected_tab) and '' or '-disabled'%>">
19                                         <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>
20                                         <% if section.sectiontype == self.selected_tab then %><input type="hidden" id="tab.m-<%=self.config%>" name="tab.m-<%=self.config%>" value="<%=section.sectiontype%>" /><% end %>
21                                 </li>
22                         <% end %>
23                 </ul>
24                 <% for i, section in ipairs(self.children) do %>
25                         <div class="cbi-tabcontainer" id="container.m-<%=self.config%>.<%=section.sectiontype%>"<% if section.sectiontype ~= self.selected_tab then %> style="display:none"<% end %>>
26                                 <% section:render() %>
27                         </div>
28                         <script type="text/javascript">cbi_t_add('m-<%=self.config%>', '<%=section.sectiontype%>')</script>
29                 <% end %>
30         <% else %>
31                 <%- self:render_children() %>
32         <% end %>
33         <br />
34 </div>