luci-base: rework reveal/hide CBI password template button
[project/luci.git] / modules / luci-base / luasrc / view / cbi / value.htm
1 <%+cbi/valueheader%>
2 <%- if self.password then -%>
3 <input type="password" style="position:absolute; left:-1000px"<%=
4 attr("name", "password." .. cbid)
5 %> />
6 <%- end -%>
7 <input data-update="change"<%=
8 attr("id", cbid) ..
9 attr("name", cbid) ..
10 attr("type", self.password and "password" or "text") ..
11 attr("class", self.password and "cbi-input-password" or "cbi-input-text") ..
12 attr("value", self:cfgvalue(section) or self.default) ..
13 ifattr(self.password, "autocomplete", "new-password") ..
14 ifattr(self.size, "size") ..
15 ifattr(self.placeholder, "placeholder") ..
16 ifattr(self.readonly, "readonly") ..
17 ifattr(self.maxlength, "maxlength") ..
18 ifattr(self.datatype, "data-type", self.datatype) ..
19 ifattr(self.datatype, "data-optional", self.optional or self.rmempty) ..
20 ifattr(self.combobox_manual, "data-manual", self.combobox_manual) ..
21 ifattr(#self.keylist > 0, "data-choices", { self.keylist, self.vallist })
22 %> />
23 <%- if self.password then -%>
24 <div class="cbi-button cbi-button-neutral" title="<%:Reveal/hide password%>" onclick="var e = this.previousElementSibling; e.type = (e.type === 'password') ? 'text' : 'password'"></div>
25 <% end %>
26 <%+cbi/valuefooter%>