提交 649386e5 编写于 作者: K kohsuke

added support for heterogeneous list support.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@5493 71c3de6d-444a-0410-be80-ed276b4c234a
上级 dfa511ac
<!--
Outer most tag for creating a heterogeneous list, where the user can add different contents.
Attributes:
name: form name that receives an array for all the items in the heterogeneous list.
items: existing items to be displayed
descriptors: all types that the user can add.
-->
<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">
<div class="hetero-list-container">
<!-- display existing items -->
<j:forEach var="i" items="${attrs.items}">
<j:set var="descriptor" value="${i.descriptor}" />
<j:set var="instance" value="${i}" />
<table>
<st:include from="${descriptor}" page="${descriptor.configPage}" />
</table>
</j:forEach>
<div class="repeatable-insertion-point" />
<div class="prototypes" style="display:none">
<!-- render one prototype for each type -->
<j:set var="instance" value="${null}" />
<j:forEach var="descriptor" items="${attrs.descriptors}" varStatus="loop">
<div name="${attrs.name}" title="${descriptor.displayName}">
<input type="hidden" name="kind" value="${loop.index}" />
<table>
<st:include from="${descriptor}" page="${descriptor.configPage}" />
</table>
</div>
</j:forEach>
</div>
<div>
<input type="button" value="Add" class="hetero-list-add" />
</div>
</div>
</j:jelly>
\ No newline at end of file
......@@ -626,6 +626,7 @@ DIV.yahooTree td {
background: white url(../images/16x16/search.gif) no-repeat 2px center;
padding-left: 20px;
width: 10em;
position: static;
}
#search-box.defaulted {
......
......@@ -311,6 +311,41 @@ var hudsonRules = {
e.onmouseout = function(ev) { return tooltip.onContextMouseOut .call(this,YAHOO.util.Event.getEvent(ev),tooltip); }
e.title = e.getAttribute("tooltip");
e = null; // avoid memory leak
},
"DIV.hetero-list-container" : function(e) {
// components for the add button
var menu = document.createElement("SELECT");
var btn = findElementsBySelector(e,"INPUT.hetero-list-add")[0];
YAHOO.util.Dom.insertAfter(menu,btn);
var prototypes = e.lastChild;
while(!Element.hasClassName(prototypes,"prototypes"))
prototypes = prototypes.previousSibling;
var insertionPoint = prototypes.previousSibling; // this is where the new item is inserted.
// extract templates
var templates = []; var i=0;
for(var n=prototypes.firstChild;n!=null;n=n.nextSibling,i++) {
var name = n.getAttribute("name");
menu.options[i] = new Option(n.getAttribute("title"),""+i);
templates.push({html:n.innerHTML, name:name});
}
Element.remove(prototypes);
var menuButton = new YAHOO.widget.Button(btn, { type: "menu", menu: menu });
menuButton.getMenu().clickEvent.subscribe(function(type,args,value) {
var t = templates[parseInt(args[1].value)]; // where this args[1] comes is a real mystery
var nc = document.createElement("div");
nc.className = "repeated-chunk";
nc.setAttribute("name",t.name);
nc.innerHTML = t.html;
insertionPoint.parentNode.insertBefore(nc, insertionPoint);
Behaviour.applySubtree(nc);
});
}
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册