JavaScript infinite Tree Menu effect code (1/3)

Source: Internet
Author: User

Tree.js Code

********************************
List of tree organization frames
v1.0
January 6, 2011
Author: Flycrosscloud
********************************/
Initializing the framework
var allimages = {
Hasnodeclose: "Hasnodeopen: "Lasthasnodeclose: "Lasthasnodeopen: "Commonnode: "Lastcommonnode: "Nodeline: "Nodeclose: "Nodeopen: "Nodeblank: "};
$ (function ()
{
$.post ("Http://localhost/system/asmx/wstree.asmx/helloworld", function (data) {inittree (data);});
});
function Inittree (org_data)
{
var org = eval ("+ Org_data +"));
Drawtree (org, 1, "", "#nodetree");
$ ("#nodetree img"). Bind ("click", Function (event)
{
$ (this). Parent (). FIND ("ul"). Toggle ();

});
}
function Drawtree (org, S, Ppreline, Ulname)
{
var orglength = org.length;
var preline;
var count = s;

for (var i = 0; i < orglength; i++)
{
var nodeimg = Allimages.nodeclose; Project Front icon
var prenodeline; Project Icon Front Line
To determine the front icon for a project
if (org[i].childunits!= null)//If a child node is included
{
nodeimg = Allimages.nodeopen;
}
To determine the front line of a graphic
if ((org[i].childunits!= null) && (i = = orglength-1))
{
Contains child nodes and is the last node in this layer
Prenodeline = Allimages.lasthasnodeopen;
}
if ((org[i].childunits = null) && (i = = orglength-1))
{
Does not contain child nodes and is the last node in this layer
Prenodeline = Allimages.lastcommonnode;
}
if ((org[i].childunits!= null) && (i!= orglength-1))
{
Contains child nodes and is not the last node in this layer
Prenodeline = Allimages.hasnodeopen;
}
if ((org[i].childunits = null) && (i!= orglength-1))
{
Does not contain child nodes and is not the last node in this layer
Prenodeline = Allimages.commonnode;
}
if (i = = orglength-1)
{
Preline = Ppreline + Allimages.nodeblank;
}
Else
{
Preline = Ppreline + allimages.nodeline;
}
var temp = $ ("<li>" + ppreline + prenodeline + nodeimg + "<a href= ' # ' >" + org[i].unit_name + "</a></l I> ");
$ (ulname). Append (temp);
if (org[i].childunits!= null)
{
Temp.append ("<ul></ul>");
var content = Temp.find ("ul");
Drawtree (Org[i].childunits, Count + 1, preline,content);
}
}

}

TREE.CSS Tutorial

Home 1 2 3 last
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.