提交 ea27259a 编写于 作者: K Kohsuke Kawaguchi

added JavaScript library for dealing with sections

上级 4aeed199
......@@ -36,6 +36,7 @@ THE SOFTWARE.
</st:attribute>
</st:documentation>
<st:adjunct includes="lib.form.section_" />
<f:rowSet name="${attrs.name}">
<j:if test="${attrs.title!=null}">
<f:block>
......
.section-header {
font-weight: bold;
border-bottom: 1px solid black;
margin-bottom: 0.2em;
margin-top: 0.4em;
}
var section = (function (){
var SectionNode = function(e) {
this.section = e;
this.children = [];
};
SectionNode.prototype = {
/**
* Points to the DIV node of the section header.
* @type {HTMLElement}
*/
section : null,
/**
* Child sections.
*
* @type {Array<SectionNode>}
*/
children : null,
getHTML : function() {
return this.section.innerHTML;
}
};
return {
"SectionNode" : SectionNode,
/**
* Builds the tree of SectionNode that represents the section hierarchy.
*
* @param {HTMLElement|string} root
* The root DOM node or its ID from which we build the tree model.
* @return {SectionNode}
* Tree structure that represents the nesting of sections.
* For root node, the 'section' property refers to null.
*/
"buildTree" : function(root) {
root = $(root);
/**
* Recursively visit elements and find all section headers.
*
* @param {HTMLElement} dom
* Parent element
* @param {SectionNode} parent
* Function that returns the array to which discovered section headers and child elements are added.
*/
function visitor(dom,parent) {
for (var e=dom.firstChild; e!=null; e=e.nextSibling) {
if (e.nodeType==1) {
if (e.className=="section-header") {
var child = new SectionNode(e);
parent.children.push(child);
visitor(e,child);
} else {
visitor(e,parent);
}
}
}
}
var top = new SectionNode(null);
visitor(root,top);
return top;
}
};
})();
\ No newline at end of file
......@@ -284,13 +284,6 @@ pre.console {
padding-left: 1em;
}
.section-header {
font-weight: bold;
border-bottom: 1px solid black;
margin-bottom: 0.2em;
margin-top: 0.4em;
}
.main-table {
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册