From 649386e58e0b0cf663b1ebede5dcd912331b81fe Mon Sep 17 00:00:00 2001 From: kohsuke Date: Sat, 27 Oct 2007 05:48:06 +0000 Subject: [PATCH] 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 --- .../main/resources/lib/form/hetero-list.jelly | 38 +++++++++++++++++++ war/resources/css/style.css | 1 + war/resources/scripts/hudson-behavior.js | 35 +++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 core/src/main/resources/lib/form/hetero-list.jelly diff --git a/core/src/main/resources/lib/form/hetero-list.jelly b/core/src/main/resources/lib/form/hetero-list.jelly new file mode 100644 index 0000000000..96fedaffef --- /dev/null +++ b/core/src/main/resources/lib/form/hetero-list.jelly @@ -0,0 +1,38 @@ + + +
+ + + + + + +
+
+ +
+ + +
+ +
+
+ \ No newline at end of file diff --git a/war/resources/css/style.css b/war/resources/css/style.css index 754f601b21..717328c974 100644 --- a/war/resources/css/style.css +++ b/war/resources/css/style.css @@ -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 { diff --git a/war/resources/scripts/hudson-behavior.js b/war/resources/scripts/hudson-behavior.js index 88d617165e..ff66b57644 100644 --- a/war/resources/scripts/hudson-behavior.js +++ b/war/resources/scripts/hudson-behavior.js @@ -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); + }); } }; -- GitLab