libs/web: fix invalid html after r8224 - the whitespace trimming removed the space...
[project/luci.git] / libs / web / luasrc / view / cbi / tblsection.htm
index 0224610..c352cda 100644 (file)
@@ -1,23 +1,19 @@
-<%#
-LuCI - Lua Configuration Interface
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
--%>
 <%-
 local rowcnt = 1
 function rowstyle()
        rowcnt = rowcnt + 1
        return (rowcnt % 2) + 1
 end
+
+function width(o)
+       if o.width then
+               if type(o.width) == 'number' then
+                       return ' style="width:%dpx"' % o.width
+               end
+               return ' style="width:%s"' % o.width
+       end
+       return ''
+end
 -%>
 
 <!-- tblsection -->
@@ -25,6 +21,9 @@ end
        <% if self.title and #self.title > 0 then -%>
                <legend><%=self.title%></legend>
        <%- end %>
+       <%- if self.sortable then -%>
+               <input type="hidden" id="cbi.sts.<%=self.config%>.<%=self.sectiontype%>" name="cbi.sts.<%=self.config%>.<%=self.sectiontype%>" value="" />
+       <%- end -%>
        <div class="cbi-section-descr"><%=self.description%></div>
        <div class="cbi-section-node">
                <%- local count = 0 -%>
@@ -38,12 +37,14 @@ end
                                <%- end -%>
                        <%- end -%>
                        <%- for i, k in pairs(self.children) do if not k.optional then -%>
-                               <th class="cbi-section-table-cell">
+                               <th class="cbi-section-table-cell"<%=width(k)%>>
                                <%- if k.titleref then -%><a title="<%=self.titledesc or translate('Go to relevant configuration page')%>" class="cbi-title-ref" href="<%=k.titleref%>"><%- end -%>
                                        <%-=k.title-%>
                                <%- if k.titleref then -%></a><%- end -%>
                                </th>
-                       <%- count = count + 1; end; end; if self.extedit or self.addremove then -%>
+                       <%- count = count + 1; end; end; if self.sortable then -%>
+                               <th class="cbi-section-table-cell"><%:Sort%></th>
+                       <%- end; if self.extedit or self.addremove then -%>
                                <th class="cbi-section-table-cell">&#160;</th>
                        <%- count = count + 1; end -%>
                        </tr>
@@ -56,8 +57,10 @@ end
                                <%- end -%>
                        <%- end -%>
                        <%- for i, k in pairs(self.children) do if not k.optional then -%>
-                               <th class="cbi-section-table-cell"><%=k.description%></th>
-                       <%- end; end; if self.extedit or self.addremove then -%>
+                               <th class="cbi-section-table-cell"<%=width(k)%>><%=k.description%></th>
+                       <%- end; end; if self.sortable then -%>
+                               <th class="cbi-section-table-cell"></th>
+                       <%- end; if self.extedit or self.addremove then -%>
                                <th class="cbi-section-table-cell"></th>
                        <%- end -%>
                        </tr>
@@ -81,18 +84,25 @@ end
                                        end
                                -%>
 
+                               <%- if self.sortable then -%>
+                                       <td class="cbi-section-table-cell" style="padding:3px; white-space:nowrap">
+                                               <input class="cbi-button cbi-button-add" type="button" value=""  onclick="return cbi_row_swap(this, true, 'cbi.sts.<%=self.config%>.<%=self.sectiontype%>')" alt="<%:Move up%>" title="<%:Move up%>" style="background-image:url(<%=resource%>/cbi/up.gif)" />
+                                               <input class="cbi-button cbi-button-add" type="button" value=""  onclick="return cbi_row_swap(this, false, 'cbi.sts.<%=self.config%>.<%=self.sectiontype%>')" alt="<%:Move down%>" title="<%:Move down%>" style="background-image:url(<%=resource%>/cbi/down.gif)" />
+                                       </td>
+                               <%- end -%>
+
                                <%- if self.extedit or self.addremove then -%>
-                                       <td class="cbi-section-table-cell">
+                                       <td class="cbi-section-table-cell" style="padding:3px; white-space:nowrap">
                                                <%- if self.extedit then -%>
-                                                       <a href="
-                                                       <%- if type(self.extedit) == "string" then -%>
-                                                               <%=self.extedit:format(section)%>
-                                                       <%- elseif type(self.extedit) == "function" then -%>
-                                                               <%=self:extedit(section)%>
-                                                       <%- end -%>
-                                                       " title="<%:Edit%>"><img style="border: none" src="<%=resource%>/cbi/edit.gif" alt="<%:Edit%>" /></a>
+                                                       <input class="cbi-button cbi-button-add" type="button" value="<%:Edit%>"
+                                                       <%- if type(self.extedit) == "string" then
+                                                       %> onclick="window.location='<%=self.extedit:format(section)%>'"
+                                                       <%- elseif type(self.extedit) == "function" then
+                                                       %> onclick="window.location='<%=self:extedit(section)%>'"
+                                                       <%- end 
+                                                       %> alt="<%:Edit%>" title="<%:Edit%>" style="text-align: center;background-image:url(<%=resource%>/cbi/edit.gif)" />
                                                <%- end; if self.addremove then %>
-                                                       <input type="image" value="<%:Delete%>" name="cbi.rts.<%=self.config%>.<%=k%>" alt="<%:Delete%>" title="<%:Delete%>" src="<%=resource%>/cbi/remove.gif" />
+                                                       <input class="cbi-button cbi-button-add" type="button" value="<%:Delete%>"  onclick="this.form.cbi_state='del-section'; return true" name="cbi.rts.<%=self.config%>.<%=k%>" alt="<%:Delete%>" title="<%:Delete%>" style="text-align: center;background-image:url(<%=resource%>/cbi/remove.gif)" />
                                                <%- end -%>
                                        </td>
                                <%- end -%>
@@ -118,11 +128,12 @@ end
                        <% if self.template_addremove then include(self.template_addremove) else -%>
                        <div class="cbi-section-create cbi-tblsection-create">
                                <% if self.anonymous then %>
-                                       <input class="cbi-button cbi-button-add" type="submit" value="<%:Add%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" title="<%:Add%>" />
+                                       <input class="cbi-button cbi-button-add" type="submit" value="<%:Add%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" title="<%:Add%>" />
                                <% else %>
                                        <% if self.invalid_cts then -%><div class="cbi-section-error"><% end %>
-                                       <input type="text" class="cbi-section-create-name" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" />
-                                       <input class="cbi-button cbi-button-add" type="submit" value="<%:Add%>" title="<%:Add%>" />
+                                       <input type="text" class="cbi-section-create-name" id="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" />
+                                       <script type="text/javascript">cbi_validate_field('cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>', true, 'uciname');</script>
+                                       <input class="cbi-button cbi-button-add" type="submit" onclick="this.form.cbi_state='add-section'; return true" value="<%:Add%>" title="<%:Add%>" />
                                        <% if self.invalid_cts then -%>
                                                <br /><%:Invalid%></div>
                                        <%- end %>