2 LuCI - Lua Configuration Interface
3 Copyright
2008 Steven Barth
<steven@midlink.org
>
4 Copyright
2008 Jo-Philipp Wich
<xm@leipzig.freifunk.net
>
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
10 http://www.apache.org/licenses/LICENSE-
2.0
19 return (rowcnt %
2) +
1
24 if type(o.width) == 'number' then
25 return '
style=
"width:%dpx"' % o.width
27 return '
style=
"width:%s"' % o.width
34 <fieldset class=
"cbi-section" id=
"cbi-<%=self.config%>-<%=self.sectiontype%>">
35 <% if self.title and #self.title
> 0 then -%
>
36 <legend><%=self.title%
></legend>
38 <%- if self.sortable then -%
>
39 <input type=
"hidden" id=
"cbi.sts.<%=self.config%>.<%=self.sectiontype%>" name=
"cbi.sts.<%=self.config%>.<%=self.sectiontype%>" value=
"" />
41 <div class=
"cbi-section-descr"><%=self.description%
></div>
42 <div class=
"cbi-section-node">
43 <%- local count =
0 -%
>
44 <table class=
"cbi-section-table">
45 <tr class=
"cbi-section-table-titles">
46 <%- if not self.anonymous then -%
>
47 <%- if self.sectionhead then -%
>
48 <th class=
"cbi-section-table-cell"><%=self.sectionhead%
></th>
53 <%- for i, k in pairs(self.children) do if not k.optional then -%
>
54 <th class=
"cbi-section-table-cell"<%=width(k)%
>>
55 <%- if k.titleref then -%
><a title=
"<%=self.titledesc or translate('Go to relevant configuration page')%>" class=
"cbi-title-ref" href=
"<%=k.titleref%>"><%- end -%
>
57 <%- if k.titleref then -%
></a><%- end -%
>
59 <%- count = count +
1; end; end; if self.sortable then -%
>
60 <th class=
"cbi-section-table-cell"><%:Sort%
></th>
61 <%- end; if self.extedit or self.addremove then -%
>
62 <th class=
"cbi-section-table-cell"> </th>
63 <%- count = count +
1; end -%
>
65 <tr class=
"cbi-section-table-descr">
66 <%- if not self.anonymous then -%
>
67 <%- if self.sectiondesc then -%
>
68 <th class=
"cbi-section-table-cell"><%=self.sectiondesc%
></th>
73 <%- for i, k in pairs(self.children) do if not k.optional then -%
>
74 <th class=
"cbi-section-table-cell"<%=width(k)%
>><%=k.description%
></th>
75 <%- end; end; if self.sortable then -%
>
76 <th class=
"cbi-section-table-cell"></th>
77 <%- end; if self.extedit or self.addremove then -%
>
78 <th class=
"cbi-section-table-cell"></th>
81 <%- local isempty = true
82 for i, k in ipairs(self:cfgsections()) do
85 scope = { valueheader =
"cbi/cell_valueheader", valuefooter =
"cbi/cell_valuefooter" }
87 <tr class=
"cbi-section-table-row<% if self.extedit or self.rowcolors then %> cbi-rowstyle-<%=rowstyle()%><% end %>" id=
"cbi-<%=self.config%>-<%=section%>">
88 <% if not self.anonymous then -%
>
89 <th><h3><%=(type(self.sectiontitle) ==
"function") and self:sectiontitle(section) or k%
></h3></th>
94 for k, node in ipairs(self.children) do
95 if not node.optional then
96 node:render(section, scope or {})
101 <%- if self.sortable then -%
>
102 <td class=
"cbi-section-table-cell" style=
"width:50px">
103 <a href=
"#" onclick=
"return cbi_row_swap(this, true, 'cbi.sts.<%=self.config%>.<%=self.sectiontype%>')" title=
"<%:Move up%>"><img src=
"<%=resource%>/cbi/up.gif" alt=
"<%:Move up%>" /></a>
104 <a href=
"#" onclick=
"return cbi_row_swap(this, false, 'cbi.sts.<%=self.config%>.<%=self.sectiontype%>')" title=
"<%:Move down%>"><img src=
"<%=resource%>/cbi/down.gif" alt=
"<%:Move down%>" /></a>
108 <%- if self.extedit or self.addremove then -%
>
109 <td class=
"cbi-section-table-cell" style=
"width:50px">
110 <%- if self.extedit then -%
>
112 <%- if type(self.extedit) == "string
" then -%>
113 <%=self.extedit:format(section)%>
114 <%- elseif type(self.extedit) == "function
" then -%>
115 <%=self:extedit(section)%>
117 " title=
"<%:Edit%>"><img style=
"border: none" src=
"<%=resource%>/cbi/edit.gif" alt=
"<%:Edit%>" /></a>
118 <%- end; if self.addremove then %
>
119 <input type=
"image" value=
"<%:Delete%>" onclick=
"this.form.cbi_state='del-section'; return true" name=
"cbi.rts.<%=self.config%>.<%=k%>" alt=
"<%:Delete%>" title=
"<%:Delete%>" src=
"<%=resource%>/cbi/remove.gif" />
126 <%- if isempty then -%
>
127 <tr class=
"cbi-section-table-row">
128 <td colspan=
"<%=count%>"><em><br /><%:This section contains no values yet%
></em></td>
133 <% if self.error then %
>
134 <div class=
"cbi-section-error">
135 <ul><% for _, c in pairs(self.error) do for _, e in ipairs(c) do -%
>
136 <li><%=pcdata(e):gsub(
"\n",
"<br />")%
></li>
141 <%- if self.addremove then -%
>
142 <% if self.template_addremove then include(self.template_addremove) else -%
>
143 <div class=
"cbi-section-create cbi-tblsection-create">
144 <% if self.anonymous then %
>
145 <input class=
"cbi-button cbi-button-add" type=
"submit" value=
"<%:Add%>" name=
"cbi.cts.<%=self.config%>.<%=self.sectiontype%>" title=
"<%:Add%>" />
147 <% if self.invalid_cts then -%
><div class=
"cbi-section-error"><% end %
>
148 <input type=
"text" class=
"cbi-section-create-name" id=
"cbi.cts.<%=self.config%>.<%=self.sectiontype%>" name=
"cbi.cts.<%=self.config%>.<%=self.sectiontype%>" />
149 <script type=
"text/javascript">cbi_validate_field('cbi.cts.<%=self.config%
>.<%=self.sectiontype%
>', true, 'uciname');
</script>
150 <input class=
"cbi-button cbi-button-add" type=
"submit" onclick=
"this.form.cbi_state='add-section'; return true" value=
"<%:Add%>" title=
"<%:Add%>" />
151 <% if self.invalid_cts then -%
>
152 <br /><%:Invalid%
></div>