From 7462178e7989d9c5a9af1d36881942f53348927f Mon Sep 17 00:00:00 2001 From: kohsuke Date: Mon, 29 Oct 2007 01:05:58 +0000 Subject: [PATCH] bug fix for fieldset. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@5564 71c3de6d-444a-0410-be80-ed276b4c234a --- war/resources/scripts/hudson-behavior.js | 178 ++++++++++++----------- 1 file changed, 92 insertions(+), 86 deletions(-) diff --git a/war/resources/scripts/hudson-behavior.js b/war/resources/scripts/hudson-behavior.js index f7a8a16936..89af221bf7 100644 --- a/war/resources/scripts/hudson-behavior.js +++ b/war/resources/scripts/hudson-behavior.js @@ -910,107 +910,113 @@ function createSearchBox(searchURL) { // structured form submission handling // see http://hudson.gotdns.com/wiki/display/HUDSON/Structured+Form+Submission function buildFormTree(form) { - // I initially tried to use an associative array with DOM elemnets as keys - // but that doesn't seem to work neither on IE nor Firefox. - // so I switch back to adding a dynamic property on DOM. - form.formDom = {}; // root object - - var doms = []; // DOMs that we added 'formDom' for. - doms.push(form); - - function addProperty(parent,name,value) { - // abc.def.ghi -> ghi - var idx = name.lastIndexOf('.'); - if(idx>=0) name = name.substring(idx+1); - - if(parent[name]!=null) { - if(parent[name].push==null) // is this array? - parent[name] = [ parent[name] ]; - parent[name].push(value); - } else { - parent[name] = value; + try { + // I initially tried to use an associative array with DOM elemnets as keys + // but that doesn't seem to work neither on IE nor Firefox. + // so I switch back to adding a dynamic property on DOM. + form.formDom = {}; // root object + + var doms = []; // DOMs that we added 'formDom' for. + doms.push(form); + + function addProperty(parent,name,value) { + // abc.def.ghi -> ghi + var idx = name.lastIndexOf('.'); + if(idx>=0) name = name.substring(idx+1); + + if(parent[name]!=null) { + if(parent[name].push==null) // is this array? + parent[name] = [ parent[name] ]; + parent[name].push(value); + } else { + parent[name] = value; + } } - } - // find the grouping parent node, which will have @name. - // then return the corresponding object in the map - function findParent(e) { - while(e!=form) { - e = e.parentNode; - - // this is used to create a group where no single containing parent node exists, - // like - var nameRef = e.getAttribute("nameRef"); - if(nameRef!=null) - e = $(nameRef); - - var name = e.getAttribute("name"); - if(name!=null) { - if(e.tagName=="INPUT" && !e.checked) - return {}; // field is not active - - var m = e.formDom; - if(m==null) { - // this is a new grouping node - doms.push(e); - e.formDom = m = {}; - addProperty(findParent(e), name, m); + // find the grouping parent node, which will have @name. + // then return the corresponding object in the map + function findParent(e) { + while(e!=form) { + e = e.parentNode; + + // this is used to create a group where no single containing parent node exists, + // like + var nameRef = e.getAttribute("nameRef"); + if(nameRef!=null) + e = $(nameRef); + + var name = e.getAttribute("name"); + if(name!=null) { + if(e.tagName=="INPUT" && !e.checked) + return {}; // field is not active + + var m = e.formDom; + if(m==null) { + // this is a new grouping node + doms.push(e); + e.formDom = m = {}; + addProperty(findParent(e), name, m); + } + return m; } - return m; } - } - return form.formDom; // guaranteed non-null - } + return form.formDom; // guaranteed non-null + } - var jsonElement = null; + var jsonElement = null; - for( var i=0; i