diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2016-02-10 18:11:49 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2016-02-10 18:11:49 +0100 |
commit | 6d126649f01ac817149d4f36324c161bb1a4650b (patch) | |
tree | b941064af6f43c20b6a8bd2a7bc7b97f859fadce /modules/luci-base/luasrc/view/cbi/dynlist.htm | |
parent | 4990ec831c7190946106d5073c02ad85616c04b8 (diff) |
luci-base: cbi: further refactoring
Eliminate more inline scripts in favor to global initialization, use a global
object for sharing fixed strings instead of passing them to each invocation.
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Diffstat (limited to 'modules/luci-base/luasrc/view/cbi/dynlist.htm')
-rw-r--r-- | modules/luci-base/luasrc/view/cbi/dynlist.htm | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/modules/luci-base/luasrc/view/cbi/dynlist.htm b/modules/luci-base/luasrc/view/cbi/dynlist.htm index 80cbee839..4d0b50942 100644 --- a/modules/luci-base/luasrc/view/cbi/dynlist.htm +++ b/modules/luci-base/luasrc/view/cbi/dynlist.htm @@ -1,5 +1,15 @@ <%+cbi/valueheader%> -<div> +<div<%= + attr("data-prefix", cbid) .. + attr("data-browser-path", self.default_path) .. + attr("data-dynlist", luci.util.serialize_json({ + self.keylist, self.vallist, + self.datatype, self.optional or self.rmempty + })) .. + + ifattr(self.size, "data-size", self.size) .. + ifattr(self.placeholder, "data-placeholder", self.placeholder) +%>> <% local vals = self:cfgvalue(section) or {} for i=1, #vals + 1 do @@ -7,22 +17,11 @@ if (val and #val > 0) or (i == 1) then %> <input class="cbi-input-text" value="<%=pcdata(val)%>" data-update="change" type="text"<%= - attr("id", cbid .. "." .. i) .. attr("name", cbid) .. ifattr(self.size, "size") .. + attr("id", cbid .. "." .. i) .. + attr("name", cbid) .. + ifattr(self.size, "size") .. ifattr(i == 1 and self.placeholder, "placeholder", self.placeholder) %> /><br /> <% end end %> </div> -<script type="text/javascript"> -cbi_dynlist_init( - '<%=cbid%>', '<%=resource%>', '<%=self.datatype%>', - <%=tostring(self.optional or self.rmempty)%>, - '<%=url('admin/filebrowser')%>', - '<%=self.default_path and self.default_path%>' - <%- if #self.keylist > 0 then -%>, [{ - <%- for i, k in ipairs(self.keylist) do -%> - <%-=string.format("%q", k) .. ":" .. string.format("%q", self.vallist[i])-%> - <%-if i<#self.keylist then-%>,<%-end-%> - <%- end -%> - }, '<%: -- custom -- %>']<% end -%>); -</script> <%+cbi/valuefooter%> |