More IE compatibility fixes

This commit is contained in:
Steven Barth 2008-09-16 15:51:11 +00:00
parent 7f0ff5c655
commit 38e60dcf9b
6 changed files with 29 additions and 21 deletions

View file

@ -1,6 +1,6 @@
var cbi_d = []; var cbi_d = [];
function cbi_d_add(field, dep) { function cbi_d_add(field, dep, next) {
var obj = document.getElementById(field); var obj = document.getElementById(field);
if (obj) { if (obj) {
var entry var entry
@ -12,10 +12,10 @@ function cbi_d_add(field, dep) {
} }
if (!entry) { if (!entry) {
entry = { entry = {
"id": field,
"node": obj, "node": obj,
"parent": obj.parentNode, "id": field,
"next": obj.nextSibling, "parent": obj.parentNode.id,
"next": next,
"deps": [] "deps": []
}; };
cbi_d.unshift(entry); cbi_d.unshift(entry);
@ -57,16 +57,20 @@ function cbi_d_update() {
var state = false; var state = false;
for (var i=0; i<cbi_d.length; i++) { for (var i=0; i<cbi_d.length; i++) {
var entry = cbi_d[i]; var entry = cbi_d[i];
if (entry.node.parentNode && !cbi_d_check(entry.deps)) { var next = document.getElementById(entry.next)
entry.parent.removeChild(entry.node); var node = document.getElementById(entry.id)
state = (state || !entry.node.parentNode) var parent = document.getElementById(entry.parent)
} else if (!entry.node.parentNode && cbi_d_check(entry.deps)) {
if (!entry.next) { if (node && node.parentNode && !cbi_d_check(entry.deps)) {
entry.parent.appendChild(entry.node); 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 { } 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) { if (state) {

View file

@ -12,6 +12,8 @@ You may obtain a copy of the License at
$Id$ $Id$
-%> -%>
</div>
<div id="cbip-<%=self.config.."-"..section.."-"..self.option%>"></div>
</td> </td>
<% if #self.deps > 0 then -%> <% if #self.deps > 0 then -%>
@ -26,7 +28,7 @@ $Id$
<%- <%-
end end
-%> -%>
}); }, "cbip-<%=self.config.."-"..section.."-"..self.option%>");
<%- end %> <%- end %>
</script> </script>
<%- end %> <%- end %>

View 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%>">

View file

@ -28,7 +28,7 @@ $Id$
</div> </div>
<% if #self.deps > 0 then -%> <% 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 -%> <% for j, d in ipairs(self.deps) do -%>
cbi_d_add("cbi-<%=self.config.."-"..section.."-"..self.option..d.add%>", { cbi_d_add("cbi-<%=self.config.."-"..section.."-"..self.option..d.add%>", {
<%- <%-
@ -39,7 +39,7 @@ $Id$
<%- <%-
end end
-%> -%>
}); }, "cbip-<%=self.config.."-"..section.."-"..self.option%>");
<%- end %> <%- end %>
</script> </script>
<%- end %> <%- end %>

View file

@ -16,7 +16,7 @@ $Id$
<% if self.title and #self.title > 0 then -%> <% if self.title and #self.title > 0 then -%>
<legend><%=self.title%></legend> <legend><%=self.title%></legend>
<%- end %> <%- 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 {}) %> <% self:render_children(1, scope or {}) %>
</div> </div>
<br /> <br />

View file

@ -40,7 +40,7 @@ $Id$
</script> </script>
<% end %> <% end %>
<% else %> <% 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> <option><%:cbi_addopt%></option>
<% for key, val in pairs(self.optionals[section]) do -%> <% for key, val in pairs(self.optionals[section]) do -%>
<option id="cbi-<%=self.config.."-"..section.."-"..val.option%>" value="<%=val.option%>"><%=striptags(val.title)%></option> <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 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 end
-%> -%>