More IE compatibility fixes
authorSteven Barth <steven@midlink.org>
Tue, 16 Sep 2008 15:51:35 +0000 (15:51 +0000)
committerSteven Barth <steven@midlink.org>
Tue, 16 Sep 2008 15:51:35 +0000 (15:51 +0000)
libs/cbi/htdocs/luci-static/resources/cbi.js
libs/cbi/luasrc/view/cbi/cell_valuefooter.htm
libs/cbi/luasrc/view/cbi/cell_valueheader.htm
libs/cbi/luasrc/view/cbi/full_valuefooter.htm
libs/cbi/luasrc/view/cbi/nullsection.htm
libs/cbi/luasrc/view/cbi/ucisection.htm

index 227e33269d6bd8fbc40f6bafea335278933fe681..f70818e16e1a8c503ba67f3548efdcc665f9c636 100644 (file)
@@ -1,6 +1,6 @@
 var cbi_d = [];
 
-function cbi_d_add(field, dep) {       
+function cbi_d_add(field, dep, next) {
        var obj = document.getElementById(field);
        if (obj) {
                var entry
@@ -12,10 +12,10 @@ function cbi_d_add(field, dep) {
                }
                if (!entry) {
                        entry = {
-                               "id": field,
                                "node": obj,
-                               "parent": obj.parentNode,
-                               "next": obj.nextSibling,
+                               "id": field,
+                               "parent": obj.parentNode.id,
+                               "next": next,
                                "deps": []
                        };
                        cbi_d.unshift(entry);
@@ -57,16 +57,20 @@ function cbi_d_update() {
        var state = false;
        for (var i=0; i<cbi_d.length; i++) {
                var entry = cbi_d[i];
-               if (entry.node.parentNode && !cbi_d_check(entry.deps)) {
-                       entry.parent.removeChild(entry.node);
-                       state = (state || !entry.node.parentNode)
-               } else if (!entry.node.parentNode && cbi_d_check(entry.deps)) {
-                       if (!entry.next) {
-                               entry.parent.appendChild(entry.node);
+               var next  = document.getElementById(entry.next)
+               var node  = document.getElementById(entry.id)
+               var parent = document.getElementById(entry.parent)
+
+               if (node && node.parentNode && !cbi_d_check(entry.deps)) {
+                       node.parentNode.removeChild(node);
+                       state = (state || !node.parentNode)
+               } else if ((!node || !node.parentNode) && cbi_d_check(entry.deps)) {
+                       if (!next) {
+                               parent.appendChild(entry.node);
                        } else {
-                               entry.parent.insertBefore(entry.node, entry.next);
+                               next.parentNode.insertBefore(entry.node, next);
                        }               
-                       state = (state || entry.node.parentNode)
+                       state = (state || (node && node.parentNode))
                }
        }
        if (state) {
index e4f7982942d3e84c2938ad7ba33c2cfdafdc6af3..c325e49cb40cb39197f828d35898bcedd9fcb0cf 100644 (file)
@@ -12,6 +12,8 @@ You may obtain a copy of the License at
 $Id$
 
 -%>
+</div>
+<div id="cbip-<%=self.config.."-"..section.."-"..self.option%>"></div>
 </td>
 
 <% if #self.deps > 0 then -%>
@@ -26,7 +28,7 @@ $Id$
                <%-
                        end
                -%>
-                       });
+                       }, "cbip-<%=self.config.."-"..section.."-"..self.option%>");
                <%- end %>
        </script>
-<%- end %>
+<%- end %>
\ No newline at end of file
index dda17463cf0bd88a9c0bb64372d7311538c2dc0e..0f24f1f764840c5529989747927c6944f29ac804 100644 (file)
@@ -13,4 +13,5 @@ $Id$
 
 -%>
 
-<td class="cbi-value-field<% if self.error and self.error[section] then %> cbi-value-error<% end %>" id="cbi-<%=self.config.."-"..section.."-"..self.option%>">
+<td class="cbi-value-field<% if self.error and self.error[section] then %> cbi-value-error<% end %>">
+<div id="cbi-<%=self.config.."-"..section.."-"..self.option%>">
index d05714033c31bb270adaade76ee5c1225aba0e62..a9596441b5e4c5f7b493c19a2c9ed35c6d7d8573 100644 (file)
@@ -28,7 +28,7 @@ $Id$
 </div>
 
 <% if #self.deps > 0 then -%>
-       <script type="text/javascript">
+       <script type="text/javascript" id="cbip-<%=self.config.."-"..section.."-"..self.option%>">
                <% for j, d in ipairs(self.deps) do -%>
                        cbi_d_add("cbi-<%=self.config.."-"..section.."-"..self.option..d.add%>", {
                <%-
@@ -39,7 +39,7 @@ $Id$
                <%-
                        end
                -%>
-                       });
+                       }, "cbip-<%=self.config.."-"..section.."-"..self.option%>");
                <%- end %>
        </script>
-<%- end %>
+<%- end %>
\ No newline at end of file
index 476db96d87137b5fac1753304d6218fa98936bbe..9520b47cabb155da6f2b682802e744741dbac7ae 100644 (file)
@@ -16,7 +16,7 @@ $Id$
                        <% if self.title and #self.title > 0 then -%>
                                <legend><%=self.title%></legend>
                        <%- end %>
-                       <div class="cbi-section-node">
+                       <div class="cbi-section-node" id="cbi-<%=self.config%>-<%=tostring(self):sub(8)%>">
                                <% self:render_children(1, scope or {}) %>
                        </div>
                        <br />
index 5023f6a2f399c9763bd5ee0305ba5baefc3bccbc..5504a7476c562db0cd9ed2ca580d11212a20a9d6 100644 (file)
@@ -40,7 +40,7 @@ $Id$
                        </script>
                        <% end %>
                <% else %>
-               <select name="cbi.opt.<%=self.config%>.<%=section%>">
+               <select id="cbi.opt.<%=self.config%>.<%=section%>" name="cbi.opt.<%=self.config%>.<%=section%>">
                        <option><%:cbi_addopt%></option>
                        <% for key, val in pairs(self.optionals[section]) do -%>
                                <option id="cbi-<%=self.config.."-"..section.."-"..val.option%>" value="<%=val.option%>"><%=striptags(val.title)%></option>
@@ -52,7 +52,8 @@ $Id$
                <%-
                        for k,v in pairs(d.deps) do
                -%>
-                       <%-=string.format('"cbid.%s.%s.%s"', self.config, section, k) .. ":" .. string.format("%q", v)-%>,
+                       <%-=string.format('"cbid.%s.%s.%s"', self.config, section, k) .. ":" .. string.format("%q", v)-%>
+                       <%-if next(d.deps, k) then-%>,<%-end-%>
                <%-
                        end
                -%>