6 if rowcnt % 2 == 0 then
7 return " cbi-rowstyle-1"
9 return " cbi-rowstyle-2"
15 if type(o.width) == 'number' then
16 return ' style="width:%dpx"' % o.width
18 return ' style="width:%s"' % o.width
23 local has_titles = false
24 local has_descriptions = false
26 local anonclass = (not self.anonymous or self.sectiontitle) and "named" or "anonymous"
27 local titlename = ifattr(not self.anonymous or self.sectiontitle, "data-title", translate("Name"))
30 for i, k in pairs(self.children) do
31 if not k.typename then
32 k.typename = k.template and k.template:gsub("^.+/", "") or ""
35 if not has_titles and k.title and #k.title > 0 then
39 if not has_descriptions and k.description and #k.description > 0 then
40 has_descriptions = true
44 function render_titles()
45 if not has_titles then
49 %><div class="tr cbi-section-table-titles <%=anonclass%>"<%=titlename%>><%
52 for i, k in ipairs(self.children) do
53 if not k.optional then
54 %><div class="th cbi-section-table-cell"<%=
55 width(k) .. attr('data-type', k.typename) %>><%
58 %><a title="<%=self.titledesc or translate('Go to relevant configuration page')%>" class="cbi-title-ref" href="<%=k.titleref%>"><%
71 if self.sortable or self.extedit or self.addremove then
72 %><div class="th cbi-section-table-cell cbi-section-actions"></div><%
80 function render_descriptions()
81 if not has_descriptions then
85 %><div class="tr cbi-section-table-descr <%=anonclass%>"><%
88 for i, k in ipairs(self.children) do
89 if not k.optional then
90 %><div class="th cbi-section-table-cell"<%=
91 width(k) .. attr("data-type", k.typename) %>><%
99 if self.sortable or self.extedit or self.addremove then
100 %><div class="th cbi-section-table-cell cbi-section-actions"></div><%
111 <div class="cbi-section cbi-tblsection" id="cbi-<%=self.config%>-<%=self.sectiontype%>">
112 <% if self.title and #self.title > 0 then -%>
113 <h3><%=self.title%></h3>
115 <%- if self.sortable then -%>
116 <input type="hidden" id="cbi.sts.<%=self.config%>.<%=self.sectiontype%>" name="cbi.sts.<%=self.config%>.<%=self.sectiontype%>" value="" />
118 <div class="cbi-section-descr"><%=self.description%></div>
119 <div class="table cbi-section-table">
122 render_descriptions()
124 local isempty, section, i, k = true, nil, nil
125 for i, k in ipairs(self:cfgsections()) do
129 local sectionname = striptags((type(self.sectiontitle) == "function") and self:sectiontitle(section) or k)
130 local sectiontitle = ifattr(sectionname and (not self.anonymous or self.sectiontitle), "data-title", sectionname, true)
131 local colorclass = (self.extedit or self.rowcolors) and rowstyle() or ""
133 valueheader = "cbi/cell_valueheader",
134 valuefooter = "cbi/cell_valuefooter"
137 <div class="tr cbi-section-table-row<%=colorclass%>" id="cbi-<%=self.config%>-<%=section%>"<%=sectiontitle%>>
140 for k, node in ipairs(self.children) do
141 if not node.optional then
142 node:render(section, scope or {})
147 <%- if self.sortable or self.extedit or self.addremove then -%>
148 <div class="td cbi-section-table-cell nowrap cbi-section-actions">
150 <%- if self.sortable then -%>
151 <input class="cbi-button cbi-button-up" type="button" value="<%:Up%>" onclick="return cbi_row_swap(this, true, 'cbi.sts.<%=self.config%>.<%=self.sectiontype%>')" title="<%:Move up%>" />
152 <input class="cbi-button cbi-button-down" type="button" value="<%:Down%>" onclick="return cbi_row_swap(this, false, 'cbi.sts.<%=self.config%>.<%=self.sectiontype%>')" title="<%:Move down%>" />
153 <% end; if self.extedit then -%>
154 <input class="cbi-button cbi-button-edit" type="button" value="<%:Edit%>"
155 <%- if type(self.extedit) == "string" then
156 %> onclick="location.href='<%=self.extedit:format(section)%>'"
157 <%- elseif type(self.extedit) == "function" then
158 %> onclick="location.href='<%=self:extedit(section)%>'"
160 %> alt="<%:Edit%>" title="<%:Edit%>" />
161 <% end; if self.addremove then %>
162 <input class="cbi-button cbi-button-remove" type="submit" value="<%:Delete%>" onclick="this.form.cbi_state='del-section'; return true" name="cbi.rts.<%=self.config%>.<%=k%>" alt="<%:Delete%>" title="<%:Delete%>" />
170 <%- if isempty then -%>
171 <div class="tr cbi-section-table-row placeholder">
172 <div class="td"><em><%:This section contains no values yet%></em></div>
177 <% if self.error then %>
178 <div class="cbi-section-error">
179 <ul><% for _, c in pairs(self.error) do for _, e in ipairs(c) do -%>
180 <li><%=pcdata(e):gsub("\n","<br />")%></li>
185 <%- if self.addremove then -%>
186 <% if self.template_addremove then include(self.template_addremove) else -%>
187 <div class="cbi-section-create cbi-tblsection-create">
188 <% if self.anonymous then %>
189 <input class="cbi-button cbi-button-add" type="submit" value="<%:Add%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" title="<%:Add%>" />
191 <% if self.invalid_cts then -%>
192 <div class="cbi-section-error"><%:Invalid%></div>
195 <input type="text" class="cbi-section-create-name" id="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" data-type="uciname" data-optional="true" />
197 <input class="cbi-button cbi-button-add" type="submit" onclick="this.form.cbi_state='add-section'; return true" value="<%:Add%>" title="<%:Add%>" />