* luci/libs: changed template for tblsection to save more vertical space
[project/luci.git] / libs / cbi / luasrc / view / cbi / tblsection.htm
1 <%#
2 LuCI - Lua Configuration Interface
3 Copyright 2008 Steven Barth <steven@midlink.org>
4 Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 $Id$
13
14 -%>
15 <%-
16 local rowcnt = 1
17 function rowstyle()
18 rowcnt = rowcnt + 1
19 return (rowcnt % 2) + 1
20 end
21 -%>
22
23 <!-- tblsection -->
24 <div class="cbi-section" id="cbi-<%=self.config%>-<%=self.sectiontype%>">
25 <h2><%=self.title%></h2>
26 <div class="cbi-section-descr"><%=self.description%></div>
27 <div class="cbi-section-node">
28 <%- local count = 0 -%>
29 <table class="cbi-section-table">
30 <tr class="cbi-section-table-titles">
31 <%- if not self.anonymous then -%>
32 <th>&nbsp;</th>
33 <%- end -%>
34 <%- for i, k in pairs(self.children) do if not k.optional then -%>
35 <th class="cbi-section-table-cell"><%=k.title%></th>
36 <%- count = count + 1; end; end; if self.extedit or self.addremove then -%>
37 <th class="cbi-section-table-cell">&nbsp;</th>
38 <%- count = count + 1; end -%>
39 </tr>
40 <tr class="cbi-section-table-descr">
41 <%- if not self.anonymous then -%>
42 <th></th>
43 <%- end -%>
44 <%- for i, k in pairs(self.children) do if not k.optional then -%>
45 <th class="cbi-section-table-cell"><%=k.description%></th>
46 <%- end; end; if self.extedit or self.addremove then -%>
47 <th class="cbi-section-table-cell"></th>
48 <%- end -%>
49 </tr>
50 <%- local isempty = true
51 for i, k in ipairs(self:cfgsections()) do
52 section = k
53 isempty = false
54 scope = { valueheader = "cbi/cell_valueheader", valuefooter = "cbi/cell_valuefooter" }
55 -%>
56 <tr class="cbi-section-table-row<% if self.extedit then %> cbi-rowstyle-<%=rowstyle()%><% end %>" id="cbi-<%=self.config%>-<%=section%>">
57 <% if not self.anonymous then -%>
58 <th><h3><%=k%></h3></th>
59 <%- end %>
60
61
62 <%-
63 for k, node in ipairs(self.children) do
64 if not node.optional then
65 node:render(section, scope or {})
66 end
67 end
68 -%>
69
70 <%- if self.extedit or self.addremove then -%>
71 <td class="cbi-section-table-cell">
72 <%- if self.extedit then -%>
73 <a href="<%=self.extedit:format(section)%>"><img style="border: none" src="<%=resource%>/cbi/edit.gif" alt="<%:edit%>" /></a>
74 <%- end; if self.addremove then %>
75 <input type="image" value="<%:cbi_del%>" name="cbi.rts.<%=self.config%>.<%=k%>" alt="<%:cbi_del%>" title="<%:cbi_del%>" src="<%=resource%>/cbi/remove.gif" />
76 <%- end -%>
77 </td>
78 <%- end -%>
79 </tr>
80 <%- end -%>
81
82 <%- if isempty then -%>
83 <tr class="cbi-section-table-row">
84 <td colspan="<%=count%>"><em><br /><%:cbi_sectempty%></em></td>
85 </tr>
86 <%- end -%>
87 </table>
88 <%- if self.addremove then -%>
89 <div class="cbi-section-table-row">
90 <td colspan="<%=count%>" class="cbi-section-table-optionals">
91 <div class="cbi-section-create">
92 <% if self.anonymous then %>
93 <input class="cbi-button cbi-button-add" type="submit" value="<%:cbi_add%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" title="<%:cbi_add%>" />
94 <% else %>
95 <input type="text" class="cbi-section-create-name" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" />
96 <input class="cbi-button cbi-button-add" type="submit" value="<%:cbi_add%>" title="<%:cbi_add%>" />
97 <% end %>
98
99 <% if self.err_invalid then %>
100 <div class="cbi-error"><%:cbi_invalid%></div>
101 <% end %>
102 </div>
103 </td>
104 </div>
105 <%- end -%>
106 </div>
107 </div>
108 <!-- /tblsection -->