e571cb212ee571171d7c766a0725760de9d00f5f
[project/luci.git] / libs / cbi / luasrc / view / cbi / ucisection.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 <% self:render_children(section, scope or {}) %>
17
18 <% if self.tag_deperror[section] then -%>
19         <div class="cbi-error"><%:cbi_deperror%></div>
20 <% elseif self.tag_invalid[section] then -%>
21         <div class="cbi-error"><%:cbi_invalid_section%></div>
22 <%- elseif self.tag_error[section] then -%>
23         <div class="cbi-error"><%=self.tag_error[section]%></div>
24 <%- end %>
25
26 <% if self.optionals[section] and #self.optionals[section] > 0 or self.dynamic then %>
27         <div class="cbi-optionals">
28                 <% if self.dynamic then %>
29                         <input type="text" id="cbi.opt.<%=self.config%>.<%=section%>" name="cbi.opt.<%=self.config%>.<%=section%>" />
30                         <% if self.optionals[section] and #self.optionals[section] > 0 then %>
31                         <script type="text/javascript">
32                                 cbi_combobox_init('cbi.opt.<%=self.config%>.<%=section%>', {
33                                 <%-
34                                         for i, val in pairs(self.optionals[section]) do
35                                 -%>
36                                         <%-=string.format("%q", striptags(val.title)) .. ":" .. string.format("%q", val.option)-%>,
37                                 <%-
38                                         end
39                                 -%>
40                                 }, '', '<%-:cbi_manual-%>');
41                         </script>
42                         <% end %>
43                 <% else %>
44                 <select name="cbi.opt.<%=self.config%>.<%=section%>">
45                         <option><%:cbi_addopt%></option>
46                         <% for key, val in pairs(self.optionals[section]) do -%>
47                                 <option id="cbi-<%=self.config.."-"..section.."-"..val.option%>" value="<%=val.option%>"><%=striptags(val.title)%></option>
48                         <%- end %>
49                 </select>
50                 <script type="text/javascript"><% for key, val in pairs(self.optionals[section]) do %>
51                         <% if #val.deps > 0 then %><% for j, d in ipairs(val.deps) do -%>
52                         cbi_d_add("cbi-<%=self.config.."-"..section.."-"..val.option..d.add%>", {
53                 <%-
54                         for k,v in pairs(d.deps) do
55                 -%>
56                         <%-=string.format('"cbid.%s.%s.%s"', self.config, section, k) .. ":" .. string.format("%q", v)-%>,
57                 <%-
58                         end
59                 -%>
60                         });
61                 <%- end %><% end %>
62                 <% end %></script>
63         <% end %>
64                 <input type="submit" class="cbi-button cbi-button-fieldadd" value="<%:add%>" />
65         </div>
66 <% end %>