﻿var Node = function(id, parentid, title, islabel, href, target, checked) { this.id = id; this.parentid = parentid; this.title = title; this.islabel = islabel; this.href = href; this.target = target; this.childs = new Array(); this.step = 0; this.checked = checked }; var Root = new Node(10000, 0, "根目录"); var Nodes = { Root: null, nodes: new Array(), Add: function(node) { if (node.parentid == Root.parentid) { this.Root = node } this.nodes[this.nodes.length] = node; this.Range(node) }, Range: function(node) { var c = this.nodes.length; for (var i = 0; i < c; i++) { if (this.nodes[i].id == node.parentid) { this.nodes[i].childs[this.nodes[i].childs.length] = node; node.step = this.nodes[i].step + 1; break } } }, Get: function(id) { var c = this.nodes.length; for (var i = 0; i < c; i++) { if (this.nodes[i].id == id) { return this.nodes[i] } } return null } }; var Tree = { Expand: function(img) { var d = $(img).parent().get(0); var u = $(d).siblings('ul'); if (u.length > 0) { if ($(u[0]).hasClass('closed')) { $(u[0]).removeClass('closed'); var img = $(d).children('img'); if (img.length >= 2) { if ($(img[0]).hasClass('ep')) { $(img[0]).removeClass('ep').addClass('em') } else { $(img[0]).removeClass('epend').addClass('emend') } $(img[1]).removeClass('fclose').addClass('fopen') } } else { $(u[0]).addClass('closed'); var img = $(d).children('img'); if (img.length >= 2) { if ($(img[0]).hasClass('em')) { $(img[0]).removeClass('em').addClass('ep') } else { $(img[0]).removeClass('emend').addClass('epend') } $(img[1]).removeClass('fopen').addClass('fclose') } } } } };
