提交 5c3aae5a 编写于 作者: K kohsuke

cleaned up the scripting behind radioBlock.jelly. This also fixes #570.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@3392 71c3de6d-444a-0410-be80-ed276b4c234a
上级 396bec74
......@@ -11,56 +11,15 @@
<tr id="rb_s${rb_id}"><!-- this ID marks the beginning -->
<td colspan="3">
<script>
<!-- this is way too clumsy. there must be a better way to do it. -->
<![CDATA[
function showRb${rb_id}(show) {
var tbl = document.getElementById('rb_s${rb_id}').parentNode;
var i = false;
var o = false;
for( j=0; tbl.rows[j]; j++ ) {
n = tbl.rows[j];
if(n.id=="rb_e${rb_id}")
o = true;
if( i && !o ) {
if( show )
n.style.display = "";
else
n.style.display = "none";
}
if(n.id=="rb_s${rb_id}")
i = true;
}
}
function updateRb${rb_id}() {
// update other radios
var x = document.getElementById('Rb${rb_id}');
col = x.form.${name};
for(c=0;c<col.length;c++) {
var item = col.item(c);
eval("show"+item.id+"("+(item==x)+")");
}
}
]]></script>
<input type="radio" name="${name}" value="${value}"
onclick="javascript:updateRb${rb_id}()" onchange="javascript:updateRb${rb_id}()"
id="Rb${rb_id}" checked="${h.ifThenElse(checked,'true',null)}" />
<st:nbsp/>
<label for="Rb${rb_id}">${title}</label>
</td>
</td>
</tr>
<d:invokeBody />
<!-- end marker -->
<tr id="rb_e${rb_id}" style="display:none">
<j:if test="${!checked}">
<script>
showRb${rb_id}(false);
</script>
</j:if>
<script>addRadioBlock("${rb_id}");</script>
</tr>
</j:jelly>
\ No newline at end of file
......@@ -498,6 +498,69 @@ var repetableSupport = {
}
};
var radioBlockSupport = {
buttons : null,
updateButtons : function() {
for( var i=0; i<this.buttons.length; i++ )
this.buttons[i]();
},
// update one block based on the status of the given radio button
updateSingleButton : function(radio,blockStart,blockEnd) {
var tbl = blockStart.parentNode;
var i = false;
var o = false;
var show = radio.checked;
for( j=0; tbl.rows[j]; j++ ) {
var n = tbl.rows[j];
if(n==blockEnd)
o = true;
if( i && !o ) {
if( show )
n.style.display = "";
else
n.style.display = "none";
}
if(n==blockStart)
i = true;
}
}
};
function addRadioBlock(id) {
var r = document.getElementById('Rb' + id);
var f = r.form;
var radios = f.radios;
if (radios == null)
f.radios = radios = {};
var g = radios[r.name];
if (g == null) {
radios[r.name] = g = object(radioBlockSupport);
g.buttons = [];
}
var u = function() {
g.updateSingleButton(r,
document.getElementById("rb_s"+id),
document.getElementById("rb_e"+id));
};
g.buttons.push(u);
// apply the initial visibility
u();
// install event handlers to update visibility.
// needs to use onclick and onchange for Safari compatibility
r.onclick = r.onchange = function() { g.updateButtons(); };
}
function updateBuildHistory(nBuild) {
$('buildHistory').headers = ["n",nBuild];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册