8 return this.each(function() {
10 if ($this.hasClass("simpleTreeMenu") === false) {
12 $(this).addClass("simpleTreeMenu");
13 $this.children("li").each(function() {
14 methods.buildNode($(this));
21 buildNode: function($li) {
22 if ($li.children("ul").length > 0) {
23 $li.children("ul").hide();
24 $li.addClass("Node").click(function(event) {
26 if ($t.hasClass("expanded")) {
27 $t.removeClass("expanded");
28 $t.children("ul").hide();
30 $t.addClass("expanded");
31 $t.children("ul").show();
33 event.stopPropagation();
35 $li.children("ul").children("li").each(function() {
36 methods.buildNode($(this));
39 $li.addClass("Leaf").click(function(event) {
40 event.stopPropagation();
46 expandToNode: function($li) {
47 if ($li.parent().hasClass("simpleTreeMenu")) {
48 if (!$li.hasClass("expanded")) {
49 $li.addClass("expanded");
50 $li.children("ul").show();
53 $li.parents("li", "ul.simpleTreeMenu").each(function() {
54 var $t = jQuery(this);
55 if (!$t.hasClass("expanded")) {
56 $t.addClass("expanded");
57 $t.children("ul").show();
62 expandAll: function() {
63 jQuery(this).find("li.Node").each(function() {
65 if (!$t.hasClass("expanded")) {
66 $t.addClass("expanded");
67 $t.children("ul").show();
72 closeAll: function() {
73 jQuery("ul", jQuery(this)).hide();
74 var $li = jQuery("li.Node");
75 if ($li.hasClass("expanded")) {
76 $li.removeClass("expanded");
82 $.fn.simpleTreeMenu = function(method) {
83 if (methods[method]) {
84 return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
85 } else if (typeof method === 'object' || !method) {
86 return methods.init.apply(this, arguments);
88 $.error('Method ' + method + ' does not exist on jQuery.simpleTreeMenu');