Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWinston Prakash2014-01-23 17:39:02 -0500
committerWinston Prakash2014-01-23 17:39:02 -0500
commitf96344cce6bae8ed13911b8092261dc4654846ba (patch)
treef493898b1c932051123a3c52ee24a82931877ed0
parenta5202786254a5d4d07e69f89381aa5d70a35ad3e (diff)
downloadorg.eclipse.hudson.core-f96344cce6bae8ed13911b8092261dc4654846ba.tar.gz
org.eclipse.hudson.core-f96344cce6bae8ed13911b8092261dc4654846ba.tar.xz
org.eclipse.hudson.core-f96344cce6bae8ed13911b8092261dc4654846ba.zip
Revert "Fixes to make the Conditional Build Step to work properly"
-rw-r--r--hudson-core/src/main/java/hudson/Functions.java7
-rw-r--r--hudson-core/src/main/java/hudson/model/Descriptor.java6
-rw-r--r--hudson-core/src/main/java/hudson/widgets/RenderOnDemandClosure.java136
-rw-r--r--hudson-core/src/main/resources/lib/form/dropdownDescriptorSelector.jelly13
-rw-r--r--hudson-core/src/main/resources/lib/form/dropdownListBlock.jelly77
-rw-r--r--hudson-core/src/main/resources/lib/form/hetero-list.jelly25
-rw-r--r--hudson-core/src/main/resources/lib/hudson/listScmBrowsers.jelly40
-rw-r--r--hudson-core/src/main/resources/lib/layout/renderOnDemand.jelly59
-rw-r--r--hudson-war/src/main/webapp/scripts/hudson-behavior.js113
9 files changed, 84 insertions, 392 deletions
diff --git a/hudson-core/src/main/java/hudson/Functions.java b/hudson-core/src/main/java/hudson/Functions.java
index 377e631e..4ef8f8b0 100644
--- a/hudson-core/src/main/java/hudson/Functions.java
+++ b/hudson-core/src/main/java/hudson/Functions.java
@@ -66,7 +66,6 @@ import org.eclipse.hudson.security.captcha.CaptchaSupport;
import hudson.util.Secret;
import hudson.views.MyViewsTabBar;
import hudson.views.ViewsTabBar;
-import hudson.widgets.RenderOnDemandClosure;
import org.apache.commons.lang3.StringUtils;
import org.springframework.security.providers.anonymous.AnonymousAuthenticationToken;
import org.apache.commons.jelly.JellyContext;
@@ -1532,10 +1531,4 @@ public class Functions {
}
return null;
}
-
- public static String createRenderOnDemandProxy(JellyContext context, String attributesToCapture) {
- return Stapler.getCurrentRequest().createJavaScriptProxy(new RenderOnDemandClosure(context,attributesToCapture));
- }
-
-
}
diff --git a/hudson-core/src/main/java/hudson/model/Descriptor.java b/hudson-core/src/main/java/hudson/model/Descriptor.java
index 3208b180..bb8aead9 100644
--- a/hudson-core/src/main/java/hudson/model/Descriptor.java
+++ b/hudson-core/src/main/java/hudson/model/Descriptor.java
@@ -291,12 +291,6 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable {
private String getCurrentDescriptorByNameUrl() {
StaplerRequest req = Stapler.getCurrentRequest();
-
- // this override allows RenderOnDemandClosure to preserve the proper value
- Object url = req.getAttribute("currentDescriptorByNameUrl");
- if (url!=null) return url.toString();
-
-
Ancestor a = req.findAncestor(DescriptorByNameOwner.class);
return a.getUrl();
}
diff --git a/hudson-core/src/main/java/hudson/widgets/RenderOnDemandClosure.java b/hudson-core/src/main/java/hudson/widgets/RenderOnDemandClosure.java
deleted file mode 100644
index 25ccf33b..00000000
--- a/hudson-core/src/main/java/hudson/widgets/RenderOnDemandClosure.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************
- *
- * Copyright (c) 2011, CloudBees, Inc.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *
- * Kohsuke Kawaguchi
- *
- *******************************************************************************/
-/*
- * The MIT License
- *
- * Copyright (c) 2011, CloudBees, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package hudson.widgets;
-
-import hudson.Util;
-import hudson.model.DescriptorByNameOwner;
-import hudson.util.IOException2;
-import hudson.util.PackedMap;
-import org.apache.commons.jelly.JellyContext;
-import org.apache.commons.jelly.JellyTagException;
-import org.apache.commons.jelly.Script;
-import org.kohsuke.stapler.Ancestor;
-import org.kohsuke.stapler.HttpResponse;
-import org.kohsuke.stapler.Stapler;
-import org.kohsuke.stapler.StaplerRequest;
-import org.kohsuke.stapler.StaplerResponse;
-import org.kohsuke.stapler.bind.JavaScriptMethod;
-import org.kohsuke.stapler.jelly.DefaultScriptInvoker;
-
-import javax.servlet.ServletException;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Captured Jelly {@link Script} that can be rendered later on demand from JavaScript.
- *
- * @author Kohsuke Kawaguchi
- */
-public class RenderOnDemandClosure {
- /**
- * Captures the recursive taglib call stack.
- */
- private final Script[] bodyStack;
- private final Map<String,Object> variables;
- private final String currentDescriptorByNameUrl;
-
- public RenderOnDemandClosure(JellyContext context, String attributesToCapture) {
- List<Script> bodyStack = new ArrayList<Script>();
- for (JellyContext c = context; c!=null; c=c.getParent()) {
- Script script = (Script) c.getVariables().get("org.apache.commons.jelly.body");
- if(script!=null) bodyStack.add(script);
- }
- this.bodyStack = bodyStack.toArray(new Script[bodyStack.size()]);
- assert !bodyStack.isEmpty(); // there must be at least one, which is the direct child of <l:renderOnDemand>
-
- Map<String,Object> variables = new HashMap<String, Object>();
- for (String v : Util.fixNull(attributesToCapture).split(","))
- variables.put(v,context.getVariable(v));
-
- // capture the current base of context for descriptors
- StaplerRequest req = Stapler.getCurrentRequest();
- Ancestor a = req.findAncestor(DescriptorByNameOwner.class);
- currentDescriptorByNameUrl = a.getUrl();
-
-
- this.variables = PackedMap.of(variables);
- }
-
- /**
- * Renders the captured fragment.
- */
- @JavaScriptMethod
- public HttpResponse render() {
- return new HttpResponse() {
- public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException {
- try {
- new DefaultScriptInvoker() {
- @Override
- protected JellyContext createContext(StaplerRequest req, StaplerResponse rsp, Script script, Object it) {
- JellyContext context = super.createContext(req, rsp, script, it);
- for (int i=bodyStack.length-1; i>0; i--) {// exclude bodyStack[0]
- context = new JellyContext(context);
- context.setVariable("org.apache.commons.jelly.body",bodyStack[i]);
- }
- return context;
- }
-
- @Override
- protected void exportVariables(StaplerRequest req, StaplerResponse rsp, Script script, Object it, JellyContext context) {
- super.exportVariables(req, rsp, script, it, context);
- context.setVariables(variables);
- req.setAttribute("currentDescriptorByNameUrl",currentDescriptorByNameUrl);
- }
- }.invokeScript(req,rsp,bodyStack[0],null);
- } catch (JellyTagException e) {
- LOGGER.log(Level.WARNING, "Failed to evaluate the template closure", e);
- throw new IOException2("Failed to evaluate the template closure",e);
- }
- }
- };
- }
-
- private static final Logger LOGGER = Logger.getLogger(RenderOnDemandClosure.class.getName());
-}
-
-
diff --git a/hudson-core/src/main/resources/lib/form/dropdownDescriptorSelector.jelly b/hudson-core/src/main/resources/lib/form/dropdownDescriptorSelector.jelly
index ee8ddc66..d7b94bf5 100644
--- a/hudson-core/src/main/resources/lib/form/dropdownDescriptorSelector.jelly
+++ b/hudson-core/src/main/resources/lib/form/dropdownDescriptorSelector.jelly
@@ -43,14 +43,11 @@
<j:set var="current" value="${instance[attrs.field]}"/>
<j:forEach var="descriptor" items="${attrs.descriptors}" varStatus="loop">
- <f:dropdownListBlock value="${loop.index}" title="${descriptor.displayName}"
- selected="${current.descriptor==descriptor || (current==null and descriptor==attrs.default)}" staplerClass="${descriptor.clazz.name}"
- lazy="descriptor">
- <l:ajax>
- <j:set var="instance" value="${current.descriptor==descriptor ? current : null}" />
- <st:include from="${descriptor}" page="${descriptor.configPage}" />
- </l:ajax>
- </f:dropdownListBlock>
+ <f:dropdownListBlock value="${loop.index}" title="${descriptor.displayName}"
+ selected="${current.descriptor==descriptor || (current==null and descriptor==attrs.default)}" staplerClass="${descriptor.clazz.name}">
+ <j:set var="instance" value="${current.descriptor==descriptor ? current : null}" />
+ <st:include from="${descriptor}" page="${descriptor.configPage}" />
+ </f:dropdownListBlock>
</j:forEach>
</f:dropdownList>
</j:jelly>
diff --git a/hudson-core/src/main/resources/lib/form/dropdownListBlock.jelly b/hudson-core/src/main/resources/lib/form/dropdownListBlock.jelly
index bd1d956d..026b6216 100644
--- a/hudson-core/src/main/resources/lib/form/dropdownListBlock.jelly
+++ b/hudson-core/src/main/resources/lib/form/dropdownListBlock.jelly
@@ -16,51 +16,36 @@
<?jelly escape-by-default='true'?>
<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">
- <st:documentation>
- Foldable block expanded when the corresponding item is selected in the drop-down list.
+ <st:documentation>
+ Foldable block expanded when the corresponding item is selected in the drop-down list.
- <st:attribute name="value" use="required">
- value of the list item. set to &lt;option value="...">
- </st:attribute>
- <st:attribute name="title" use="required">
- human readable text displayed for this list item.
- </st:attribute>
- <st:attribute name="selected" type="boolean">
- is this value initially selected?
- </st:attribute>
- <st:attribute name="staplerClass">
- provide hint for stapler data binding.
- typically set to ${descriptor.clazz.name} if dropdownList is for a list of descriptors.
- </st:attribute>
- <st:attribute name="lazy">
- If specified, the content of the dropdownListBlock will be rendered lazily when it first becomes visible.
- The attribute value must be the variables to be captured. See the @capture of &lt;renderOnDemand> tag.
- </st:attribute>
- </st:documentation>
- <j:choose>
- <j:when test="${dropdownListMode=='createSelectField'}">
- <f:option selected="${attrs.selected}" value="${value}">${title}</f:option>
- </j:when>
- <j:when test="${dropdownListMode=='generateEntries'}">
- <!-- sandwich them by markers so that we know what to show/hide -->
- <tr class="dropdownList-start rowvg-start">
- <j:if test="${!empty(attrs.staplerClass)}">
- <td style="display:none">
- <input type="hidden" name="stapler-class" value="${attrs.staplerClass}"/>
- </td>
- </j:if>
- </tr>
- <j:choose>
- <j:when test="${attrs.lazy!=null and !attrs.selected}">
- <l:renderOnDemand capture="${attrs.lazy}" tag="tr">
- <d:invokeBody />
- </l:renderOnDemand>
- </j:when>
- <j:otherwise>
- <d:invokeBody />
- </j:otherwise>
- </j:choose>
- <tr class="dropdownList-end rowvg-end" />
- </j:when>
- </j:choose>
+ <st:attribute name="value" use="required">
+ value of the list item. set to &lt;option value="...">
+ </st:attribute>
+ <st:attribute name="title" use="required">
+ human readable text displayed for this list item.
+ </st:attribute>
+ <st:attribute name="selected" type="boolean">
+ is this value initially selected?
+ </st:attribute>
+ <st:attribute name="staplerClass">
+ provide hint for stapler data binding.
+ typically set to ${descriptor.clazz.name} if dropdownList is for a list of descriptors.
+ </st:attribute>
+ </st:documentation>
+ <j:choose>
+ <j:when test="${dropdownListMode=='createSelectField'}">
+ <f:option selected="${attrs.selected}" value="${value}">${title}</f:option>
+ </j:when>
+ <j:when test="${dropdownListMode=='generateEntries'}">
+ <!-- sandwich them by markers so that we know what to show/hide -->
+ <tr class="dropdownList-start" style="display:none">
+ <j:if test="${!empty(attrs.staplerClass)}">
+ <td><input type="hidden" name="stapler-class" value="${attrs.staplerClass}"/></td>
+ </j:if>
+ </tr>
+ <d:invokeBody />
+ <tr class="dropdownList-end" style="display:none" />
+ </j:when>
+ </j:choose>
</j:jelly>
diff --git a/hudson-core/src/main/resources/lib/form/hetero-list.jelly b/hudson-core/src/main/resources/lib/form/hetero-list.jelly
index a369a4b6..039f95d2 100644
--- a/hudson-core/src/main/resources/lib/form/hetero-list.jelly
+++ b/hudson-core/src/main/resources/lib/form/hetero-list.jelly
@@ -22,8 +22,6 @@
arbitrary items from the given list of descriptors, and configure them independently.
The submission can be data-bound into List&lt;T> where T is the common base type for the describable instances.
-
- For databinding use, please use &lt;f:repeatableHeteroProperty />
<st:attribute name="name" use="required">
form name that receives an array for all the items in the heterogeneous list.
@@ -76,9 +74,10 @@
<f:helpArea />
</j:if>
</j:if>
-
- <d:invokeBody/>
-
+ <!-- optional added to keep from breaking page rendering when
+ a descriptor doesn't have a config.jelly. -->
+ <st:include from="${descriptor}"
+ page="${descriptor.configPage}" optional="true" />
<f:block>
<div align="right">
<input type="hidden" name="stapler-class" value="${descriptor.clazz.name}" />
@@ -106,9 +105,7 @@
<j:set var="descriptor" value="${i.descriptor}" />
<j:set var="instance" value="${i}" />
<div name="${attrs.name}" class="repeated-chunk">
- <local:body deleteCaption="${attrs.deleteCaption}">
- <st:include from="${descriptor}" page="${descriptor.configPage}" optional="true" />
- </local:body>
+ <local:body deleteCaption="${attrs.deleteCaption}" />
</div>
</j:forEach>
@@ -117,15 +114,9 @@
<!-- 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}" tooltip="${descriptor.tooltip}" descriptorId="${descriptor.id}">
- <local:body deleteCaption="${attrs.deleteCaption}">
- <l:renderOnDemand tag="tr" clazz="config-page" capture="descriptor,it">
- <l:ajax>
- <st:include from="${descriptor}" page="${descriptor.configPage}" optional="true" />
- </l:ajax>
- </l:renderOnDemand>
- </local:body>
- </div>
+ <div name="${attrs.name}" title="${descriptor.displayName}" tooltip="${descriptor.tooltip}">
+ <local:body deleteCaption="${attrs.deleteCaption}" />
+ </div>
</j:forEach>
</div>
diff --git a/hudson-core/src/main/resources/lib/hudson/listScmBrowsers.jelly b/hudson-core/src/main/resources/lib/hudson/listScmBrowsers.jelly
index bb635f27..53fd295d 100644
--- a/hudson-core/src/main/resources/lib/hudson/listScmBrowsers.jelly
+++ b/hudson-core/src/main/resources/lib/hudson/listScmBrowsers.jelly
@@ -16,26 +16,22 @@
<?jelly escape-by-default='true'?>
<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">
- <st:documentation>
- List browser SCMs
- <st:attribute name="name" use="required">
- form field name.
- </st:attribute>
- </st:documentation>
- <f:dropdownList name="${name}" title="${%Repository browser}" help="/help/scm-browsers/list.html">
- <f:dropdownListBlock value="auto" title="(${%Auto})" />
- <j:set var="currentBrowser" value="${scm.browser}"/>
- <j:forEach var="descriptor" items="${scmd.browserDescriptors}" varStatus="loop">
- <j:set var="browser" value="${currentBrowser.descriptor==descriptor ? currentBrowser : null}"/><!-- for compatibility -->
- <f:dropdownListBlock value="${loop.index}" title="${descriptor.displayName}"
- selected="${currentBrowser.descriptor==descriptor}" staplerClass="${descriptor.clazz.name}"
- lazy="browser,descriptor,it">
- <l:ajax>
- <j:set var="instance" value="${browser}" />
- <st:include from="${descriptor}" page="${descriptor.configPage}"/>
- </l:ajax>
- </f:dropdownListBlock>
- </j:forEach>
- </f:dropdownList>
+ <st:documentation>
+ List browser SCMs
+ <st:attribute name="name" use="required">
+ form field name.
+ </st:attribute>
+ </st:documentation>
+ <f:dropdownList name="${name}" title="${%Repository browser}" help="/help/scm-browsers/list.html">
+ <f:dropdownListBlock value="auto" title="(${%Auto})" />
+ <j:set var="currentBrowser" value="${scm.browser}"/>
+ <j:forEach var="descriptor" items="${scmd.browserDescriptors}" varStatus="loop">
+ <f:dropdownListBlock value="${loop.index}" title="${descriptor.displayName}"
+ selected="${currentBrowser.descriptor==descriptor}" staplerClass="${descriptor.clazz.name}">
+ <j:set var="browser" value="${currentBrowser.descriptor==descriptor ? currentBrowser : null}"/><!-- for compatibility -->
+ <j:set var="instance" value="${browser}" />
+ <st:include from="${descriptor}" page="${descriptor.configPage}"/>
+ </f:dropdownListBlock>
+ </j:forEach>
+ </f:dropdownList>
</j:jelly>
-
diff --git a/hudson-core/src/main/resources/lib/layout/renderOnDemand.jelly b/hudson-core/src/main/resources/lib/layout/renderOnDemand.jelly
deleted file mode 100644
index 18b3c22b..00000000
--- a/hudson-core/src/main/resources/lib/layout/renderOnDemand.jelly
+++ /dev/null
@@ -1,59 +0,0 @@
-<!-- **************************************************************************
-#
-# Copyright (c) 2011, CloudBees, Inc.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-#
-# Kohsuke Kawaguchi
-#
-#************************************************************************** -->
-<!--
-The MIT License
-
-Copyright (c) 2011, CloudBees, Inc.
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
--->
-
-<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" xmlns:x="jelly:xml">
- <st:documentation>
- <st:attribute name="tag">
- Place holder HTML tag. By default it's DIV, but depending on where this is used,
- you might need other tags (e.g., inside a table.)
- </st:attribute>
- <st:attribute name="clazz">
- Additional CSS class names, so that you can discover this tag more easily from your JavaScript.
- </st:attribute>
- <st:attribute name="capture">
- ','-separated list of variables to capture and make available when later evaluating the body.
- </st:attribute>
- </st:documentation>
-
-
- <x:element name="${attrs.tag?:'div'}">
- <x:attribute name="class">render-on-demand ${attrs.clazz}</x:attribute>
- <x:attribute name="proxy">${h.createRenderOnDemandProxy(context,attrs.capture)}</x:attribute>
- </x:element>
-</j:jelly>
-
diff --git a/hudson-war/src/main/webapp/scripts/hudson-behavior.js b/hudson-war/src/main/webapp/scripts/hudson-behavior.js
index 69d57fd8..dc6b4f81 100644
--- a/hudson-war/src/main/webapp/scripts/hudson-behavior.js
+++ b/hudson-war/src/main/webapp/scripts/hudson-behavior.js
@@ -506,25 +506,7 @@ function makeButton(e, onclick) {
// }
// return btn;
}
-
-/**
- * Render the template captured by &lt;l:renderOnDemand> at the element 'e' and replace 'e' by the content.
- *
- * @param {HTMLElement} e
- * The place holder element to be lazy-rendered.
- * @param {boolean} noBehaviour
- * if specified, skip the application of behaviour rule.
- */
-function renderOnDemand(e,callback,noBehaviour) {
- if (!e || !Element.hasClassName(e,"render-on-demand")) return;
- var proxy = eval(e.getAttribute("proxy"));
- proxy.render(function (t) {
- Element.replace(e, t.responseText);
- if (callback) callback(t);
- noBehaviour || Behaviour.applySubtree(e);
- });
-}
-
+
/*
If we are inside 'to-be-removed' class, some HTML altering behaviors interact badly, because
the behavior re-executes when the removed master copy gets reinserted later.
@@ -543,49 +525,45 @@ var hudsonRules = {
"DIV.hetero-list-container" : function(e) {
if(isInsideRemovable(e)) return;
-
+
// components for the add button
var menu = document.createElement("SELECT");
var btns = findElementsBySelector(e,"INPUT.hetero-list-add"),
btn = btns[btns.length-1]; // In case nested content also uses hetero-list
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");
var tooltip = n.getAttribute("tooltip");
- var descriptorId = n.getAttribute("descriptorId");
menu.options[i] = new Option(n.getAttribute("title"),""+i);
- templates.push({html:n.innerHTML, name:name, tooltip:tooltip,descriptorId:descriptorId});
+ templates.push({html:n.innerHTML, name:name, tooltip:tooltip});
}
Element.remove(prototypes);
-
+
var withDragDrop = initContainerDD(e);
-
+
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;
-
- renderOnDemand(findElementsBySelector(nc,"TR.config-page")[0],function() {
- insertionPoint.parentNode.insertBefore(nc, insertionPoint);
- if(withDragDrop) prepareDD(nc);
-
- hudsonRules['DIV.repeated-chunk'](nc); // applySubtree doesn't get nc itself
- Behaviour.applySubtree(nc);
- },true);
+ insertionPoint.parentNode.insertBefore(nc, insertionPoint);
+ if(withDragDrop) prepareDD(nc);
+
+ hudsonRules['DIV.repeated-chunk'](nc); // applySubtree doesn't get nc itself
+ Behaviour.applySubtree(nc);
});
-
+
menuButton.getMenu().renderEvent.subscribe(function(type,args,value) {
// hook up tooltip for menu items
var items = menuButton.getMenu().getItems();
@@ -1460,13 +1438,10 @@ function updateDropDownList(sel) {
var tr = f.start;
while (true) {
tr.style.display = (show ? "" : "none");
- if(show){
+ if(show)
tr.removeAttribute("field-disabled");
- renderOnDemand(tr);
- }else{
- // buildFormData uses this attribute and ignores the contents
+ else // buildFormData uses this attribute and ignores the contents
tr.setAttribute("field-disabled","true");
- }
if (tr == f.end) break;
tr = tr.nextSibling;
}
@@ -2255,55 +2230,11 @@ function createComboBox(idOrField,valueFunction) {
// If an ID given, create when page has loaded (backward compatibility); otherwise now.
if (typeof idOrField == "string") Behaviour.addLoadEvent(creator); else creator();
}
-
-
-// bind tag takes care of the dependency as an adjunct
-function makeStaplerProxy(url, crumb, methods) {
- if (url.substring(url.length - 1) !== '/')
- url += '/';
- var proxy = {};
- var stringify;
- if (Object.toJSON) // needs to use Prototype.js if it's present. See commit comment for discussion
- stringify = Object.toJSON; // from prototype
- else if (typeof(JSON) == "object" && JSON.stringify)
- stringify = JSON.stringify; // standard
- var genMethod = function(methodName) {
- proxy[methodName] = function() {
- var args = arguments;
- // the final argument can be a callback that receives the return value
- var callback = (function() {
- if (args.length == 0)
- return null;
- var tail = args[args.length - 1];
- return (typeof(tail) == 'function') ? tail : null;
- })();
- // 'arguments' is not an array so we convert it into an array
- var a = [];
- for (var i = 0; i < args.length - (callback != null?1:0); i++)
- a.push(args[i]);
-
- new Ajax.Request(url + methodName, {
- method: 'post',
- requestHeaders: {'Content-type': 'application/x-stapler-method-invocation;charset=UTF-8', 'Crumb': crumb},
- postBody: stringify(a),
- onSuccess: function(t) {
- if (callback != null) {
- t.responseObject = function() {
- return eval('(' + this.responseText + ')');
- };
- callback(t);
- }
- }
- });
- }
- };
-
- for (var mi = 0; mi < methods.length; mi++) {
- genMethod(methods[mi]);
+
+
+if (isRunAsTest) {
+ // during the unit test, make Ajax errors fatal
+ Ajax.Request.prototype.dispatchException = function(e) {
+ throw e;
}
- return proxy;
-}
-
-Ajax.Request.prototype.dispatchException = function(e) {
- throw e;
} \ No newline at end of file

Back to the top