提交 014602e1 编写于 作者: K kohsuke

redid the negative check box support


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@8327 71c3de6d-444a-0410-be80-ed276b4c234a
上级 912aad11
......@@ -2,5 +2,5 @@
<input type="checkbox"> tag that takes true/false for @checked
-->
<input type="checkbox" name="${attrs.name}" value="${attrs.value}"
onclick="${attrs.onclick}" id="${attrs.id}"
onclick="${attrs.onclick}" id="${attrs.id}" class="${h.ifThenElse(attrs.negative,'negative',null)}"
checked="${h.ifThenElse(attrs.checked,'true',null)}"/>
\ No newline at end of file
......@@ -14,9 +14,10 @@
-->
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<j:set var="id" value="${h.generateId()}" />
<tr id="oe_s${id}" class="optional-block-start ${h.ifThenElse(attrs.negative!=null,'negative','')}" hasHelp="${attrs.help!=null}"><!-- this ID marks the beginning -->
<tr id="oe_s${id}" class="optional-block-start" hasHelp="${attrs.help!=null}"><!-- this ID marks the beginning -->
<td colspan="3">
<f:checkbox name="${name}" onclick="javascript:updateOptionalBlock(this,true)"
negative="${attrs.negative}"
id="oe_c${id}" checked="${checked}" />
<st:nbsp/>
<label class="attach-previous">${title}</label>
......
......@@ -492,12 +492,11 @@ function updateOptionalBlock(c,scroll) {
var s = c;
while(!Element.hasClassName(s, "optional-block-start"))
s = s.parentNode;
var isNegative = Element.hasClassName(s,"negative"); // is this a negative check box?
var tbl = s.parentNode;
var i = false;
var o = false;
var checked = c.checked;
var checked = c.checked^Element.hasClassName(c,"negative");
var lastRow = null;
for (var j = 0; tbl.rows[j]; j++) {
......@@ -507,7 +506,7 @@ function updateOptionalBlock(c,scroll) {
o = true;
if (i && !o) {
if (checked ^ isNegative) {
if (checked) {
n.style.display = "";
lastRow = n;
} else
......@@ -1044,7 +1043,7 @@ function buildFormTree(form) {
var name = e.getAttribute("name");
if(name!=null) {
if(e.tagName=="INPUT" && !e.checked)
if(e.tagName=="INPUT" && !(e.checked^Element.hasClassName(e,"negative")))
return {}; // field is not active
var m = e.formDom;
......@@ -1091,10 +1090,11 @@ function buildFormTree(form) {
break;
case "checkbox":
p = findParent(e);
var checked = e.checked ^ Element.hasClassName(e,"negative");
if(!e.groupingNode)
addProperty(p, e.name, e.checked);
addProperty(p, e.name, checked);
else {
if(e.checked)
if(checked)
addProperty(p, e.name, e.formDom = {});
}
break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册