Subversion Repository Public Repository

Nextrek

@ 745
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
function openNode(node, level) {
	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")+'">';
			htmlToAppend +=  "<div class='node-container'>"+nodes[i].ramodescrizione+"</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.parent().find(".level-node-"+level+"[leaf='0']").click(function() {
			openNode($(this), level+1);
		});
	}

	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 +=  nodes[i].ramodescrizione+"</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").click(function() {
		openNode($(this), 2);
	});
}

Commits for Nextrek/legal-map/js/tree.js

Diff revisions: vs.
Revision Author Commited Message
745 Diff Diff FSallustio picture FSallustio Wed 16 Sep, 2015 14:08:30 +0000
743 Diff Diff FSallustio picture FSallustio Wed 16 Sep, 2015 10:09:05 +0000

Lista da div a ul/li

741 Diff Diff FSallustio picture FSallustio Wed 16 Sep, 2015 09:05:33 +0000
738 Diff Diff FSallustio picture FSallustio Tue 15 Sep, 2015 15:55:51 +0000
737 FSallustio picture FSallustio Tue 15 Sep, 2015 15:23:06 +0000