提交 52166088 编写于 作者: K kohsuke

rules that extract innerHTML needs to be done before other behavior rules kick in and alter HTML.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@5618 71c3de6d-444a-0410-be80-ed276b4c234a
上级 e3f236ef
......@@ -126,6 +126,53 @@ var hudsonRules = {
tooltip = new YAHOO.widget.Tooltip("tt", {context:[], zindex:999});
},
// do the ones that extract innerHTML so that they can get their original HTML before
// other behavior rules change them (like YUI buttons.)
"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);
});
},
"DIV.repeated-container" : function(e) {
// compute the insertion point
var ip = e.lastChild;
while (!Element.hasClassName(ip, "repeatable-insertion-point"))
ip = ip.previousSibling;
// set up the logic
object(repeatableSupport).init(e, e.firstChild, ip);
},
"TABLE.sortable" : function(e) {// sortable table
ts_makeSortable(e);
},
......@@ -248,15 +295,6 @@ var hudsonRules = {
});
},
"DIV.repeated-container" : function(e) {
// compute the insertion point
var ip = e.lastChild;
while (!Element.hasClassName(ip, "repeatable-insertion-point"))
ip = ip.previousSibling;
// set up the logic
object(repeatableSupport).init(e, e.firstChild, ip);
},
// button to add a new repeatable block
"INPUT.repeatable-add" : function(e) {
makeButton(e,function(e) {
......@@ -328,41 +366,6 @@ var hudsonRules = {
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);
});
},
"INPUT.submit-button" : function(e) {
makeButton(e);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册