5 return (rowcnt % 2) + 1
10 if type(o.width) == 'number' then
11 return ' style="width:%dpx"' % o.width
13 return ' style="width:%s"' % o.width
18 local anonclass = (not self.anonymous or self.sectiontitle) and "named" or "anonymous"
19 local titlename = ifattr(not self.anonymous or self.sectiontitle, "data-title", translate("Name"))
24 <div class="cbi-section cbi-tblsection" id="cbi-<%=self.config%>-<%=self.sectiontype%>">
25 <% if self.title and #self.title > 0 then -%>
26 <legend><%=self.title%></legend>
28 <%- if self.sortable then -%>
29 <input type="hidden" id="cbi.sts.<%=self.config%>.<%=self.sectiontype%>" name="cbi.sts.<%=self.config%>.<%=self.sectiontype%>" value="" />
31 <div class="cbi-section-descr"><%=self.description%></div>
32 <%- local count = 0 -%>
33 <div class="table cbi-section-table">
34 <div class="tr cbi-section-table-titles <%=anonclass%>"<%=titlename%>>
35 <%- for i, k in pairs(self.children) do if not k.optional then -%>
36 <div class="th cbi-section-table-cell"<%=
38 attr("data-type", k.template and k.template:gsub("^.+/", "") or "")
40 <%- if k.titleref then -%><a title="<%=self.titledesc or translate('Go to relevant configuration page')%>" class="cbi-title-ref" href="<%=k.titleref%>"><%- end -%>
42 <%- if k.titleref then -%></a><%- end -%>
44 <%- count = count + 1; end; end; if self.sortable or self.extedit or self.addremove then -%>
45 <div class="th cbi-section-table-cell cbi-section-actions"></div>
46 <%- count = count + 1; end -%>
48 <div class="tr cbi-section-table-descr <%=anonclass%>">
49 <%- for i, k in pairs(self.children) do if not k.optional then -%>
50 <div class="th cbi-section-table-cell"<%=
52 attr("data-type", k.template and k.template:gsub("^.+/", "") or "")
53 %>><%=k.description%></div>
54 <%- end; end; if self.sortable or self.extedit or self.addremove then -%>
55 <div class="th cbi-section-table-cell cbi-section-actions"></div>
58 <%- local isempty, i, k = true, nil, nil
59 for i, k in ipairs(self:cfgsections()) do
63 local sectionname = striptags((type(self.sectiontitle) == "function") and self:sectiontitle(section) or k)
64 local sectiontitle = ifattr(sectionname and (not self.anonymous or self.sectiontitle), "data-title", sectionname)
65 local colorclass = (self.extedit or self.rowcolors) and " cbi-rowstyle-%d" % rowstyle() or ""
67 valueheader = "cbi/cell_valueheader",
68 valuefooter = "cbi/cell_valuefooter"
71 <div class="tr cbi-section-table-row<%=colorclass%>" id="cbi-<%=self.config%>-<%=section%>"<%=sectiontitle%>>
74 for k, node in ipairs(self.children) do
75 if not node.optional then
76 node:render(section, scope or {})
81 <%- if self.sortable or self.extedit or self.addremove then -%>
82 <div class="td cbi-section-table-cell nowrap cbi-section-actions">
83 <%- if self.sortable then -%>
84 <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%>" />
85 <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%>" />
86 <% end; if self.extedit then -%>
87 <input class="cbi-button cbi-button-edit" type="button" value="<%:Edit%>"
88 <%- if type(self.extedit) == "string" then
89 %> onclick="location.href='<%=self.extedit:format(section)%>'"
90 <%- elseif type(self.extedit) == "function" then
91 %> onclick="location.href='<%=self:extedit(section)%>'"
93 %> alt="<%:Edit%>" title="<%:Edit%>" />
94 <% end; if self.addremove then %>
95 <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%>" />
102 <%- if isempty then -%>
103 <div class="tr cbi-section-table-row placeholder">
104 <div class="td"><em><%:This section contains no values yet%></em></div>
109 <% if self.error then %>
110 <div class="cbi-section-error">
111 <ul><% for _, c in pairs(self.error) do for _, e in ipairs(c) do -%>
112 <li><%=pcdata(e):gsub("\n","<br />")%></li>
117 <%- if self.addremove then -%>
118 <% if self.template_addremove then include(self.template_addremove) else -%>
119 <div class="cbi-section-create cbi-tblsection-create">
120 <% if self.anonymous then %>
121 <input class="cbi-button cbi-button-add" type="submit" value="<%:Add%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" title="<%:Add%>" />
123 <% if self.invalid_cts then -%>
124 <div class="cbi-section-error"><%:Invalid%></div>
127 <input type="text" class="cbi-section-create-name" id="cbi.cts.<%=self.config%>.<%=self.sectiontype%>." name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>." data-type="uciname" data-optional="true" />
129 <input class="cbi-button cbi-button-add" type="submit" onclick="this.form.cbi_state='add-section'; return true" value="<%:Add%>" title="<%:Add%>" />