Nextrek
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
function openNode(clicked, level) {
var node = clicked.parent().parent();
function ajaxResOpenNode(data) {
var nodes = data.nodes;
for (var i = 0; i<nodes.length; i++) {
/*var htmlToAppend = '<div id="container-id-'+nodes[i].id+'">';
htmlToAppend += '<div id="node-id-'+nodes[i].id+'" ';
htmlToAppend += 'node-id="'+nodes[i].id+'" ';
htmlToAppend += 'level="'+nodes[i].level+'" ';
htmlToAppend += 'cat="'+node.attr("cat")+'" ';
htmlToAppend += 'leaf="'+((nodes[i].is_leaf) ? 1 : 0)+'" ';
htmlToAppend += 'class="level-node-'+nodes[i].level+' ';
htmlToAppend += 'cat-node-'+node.attr("cat")+'">';
htmlToAppend += "<div class='node-container'>"+nodes[i].ramodescrizione+"</div></div></div>";*/
var htmlToAppend = '<li id="node-id-'+nodes[i].id+'" ';
htmlToAppend += 'node-id="'+nodes[i].id+'" ';
htmlToAppend += 'level="'+nodes[i].level+'" ';
htmlToAppend += 'cat="'+node.attr("cat")+'" ';
htmlToAppend += 'leaf="'+((nodes[i].is_leaf) ? 1 : 0)+'" ';
htmlToAppend += 'class="level-node-'+nodes[i].level+' ';
htmlToAppend += (i==nodes.length-1) ? 'last-node ' : "";
htmlToAppend += 'cat-node-'+node.attr("cat")+'">';
if (level==3 || level==4) {
htmlToAppend += "<div class='node-container child-node'><div class='light-close-button close-button'></div><div class='node-text'>"+nodes[i].ramodescrizione+"</div></div>";
} else if (level>4) {
htmlToAppend += "<div class='node-container child-node'><div class='dark-close-button close-button'></div><div class='node-text'>"+nodes[i].ramodescrizione+"</div></div>";
} else {
htmlToAppend += "<div class='node-container child-node'><div class='node-text'>"+nodes[i].ramodescrizione+"</div></div>";
}
htmlToAppend += (!nodes[i].is_leaf) ? "<ul id='list-id-"+nodes[i].id+"' class='level-list-"+(level+1)+"' style='display:none;'></ul></li>" : "";
//node.parent().append(htmlToAppend);
$("#list-id-"+node.attr("node-id")).append(htmlToAppend);
}
$("#list-id-"+node.attr("node-id")).show();
node.find(".close-button").show();
$("#list-id-"+node.attr("node-id")+" .close-button").hide();
node.parent().find(".level-node-"+level+"[leaf='0'] .node-container .node-text").click(function() {
openNode($(this), level+1);
});
$("#list-id-"+node.attr("node-id")+" .close-button").click(function() {
$(this).parent().parent().find("ul").hide();
$(this).hide();
})
}
if ($("#list-id-"+node.attr("node-id")+" li").length>0) { //nodi giĆ presenti
//da decidere
} else {
$.ajax({
url: "./ajax/treeLoader.php",
data: {
filename: "jobsact",
idpadre: node.attr("node-id")
},
dataType: "JSON",
type: "GET",
success: function(data) {
ajaxResOpenNode(data);
},
error: function() {
alert("Errore nel caricamento dei nodi figli");
}
});
}
}
function loadTree(data) {
var nodes = data.nodes;
for (var i = 0; i<nodes.length; i++) {
/*var htmlToAppend = '<div id="container-id-'+nodes[i].id+'">';
htmlToAppend += '<div id="node-id-'+nodes[i].id+'" ';
htmlToAppend += 'node-id="'+nodes[i].id+'" ';
htmlToAppend += 'level="'+nodes[i].level+'" ';
htmlToAppend += 'cat="'+(i+1)+'" ';
htmlToAppend += 'leaf="'+((nodes[i].is_leaf) ? 1 : 0)+'" ';
htmlToAppend += 'class="level-node-1 cat-node-'+(i+1)+'">';
htmlToAppend += nodes[i].ramodescrizione+"</div></div>";*/
var htmlToAppend = '<li id="node-id-'+nodes[i].id+'" ';
htmlToAppend += 'node-id="'+nodes[i].id+'" ';
htmlToAppend += 'level="'+nodes[i].level+'" ';
htmlToAppend += 'cat="'+(i+1)+'" ';
htmlToAppend += 'leaf="'+((nodes[i].is_leaf) ? 1 : 0)+'" ';
htmlToAppend += 'class="level-node-1 cat-node-'+(i+1)+'">';
htmlToAppend += "<div class='node-container'><div class='node-text'>"+nodes[i].ramodescrizione+"</div></div>"+"</li>";
htmlToAppend += (!nodes[i].is_leaf) ? "<ul id='list-id-"+nodes[i].id+"' class='level-list-2' style='display:none;'></ul>" : "";
$("#treeContainer").append(htmlToAppend);
}
$("#treeContainer .level-node-1 .node-container .node-text").click(function() {
openNode($(this), 2);
});
}
|