Subversion Repository Public Repository

Nextrek

@ 771
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
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);
		});*/

		node.parent().find("#list-id-"+node.attr("node-id")+" .level-node-"+level+"[leaf='0'] > .node-container .node-text").click(function() {
			openNode($(this), level+1);
		});

		node.parent().find()

		$("#list-id-"+node.attr("node-id")+" .close-button").click(function() {
			$(this).parent().parent().find("ul").hide();
			$(this).hide();
			/*$(this).parent().find(".node-text").click(function() {
				openNode($(this), level+1);;
			});*/
		})
	}

	if ($("#list-id-"+node.attr("node-id")+" > li").length>0) { //nodi giĆ  presenti
		$("#list-id-"+node.attr("node-id")).show();
		node.find(".close-button").show();
		$("#list-id-"+node.attr("node-id")+" .close-button").hide();
	} 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");
			}
		});
	}

	//clicked.unbind("click");

}

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='cat-icon'></div>";
		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);
	});

	$("#treeContainer .level-node-1 .node-container .node-text").trigger("click"); //apertura nodi primo livello
}

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

Diff revisions: vs.
Revision Author Commited Message
771 Diff Diff FSallustio picture FSallustio Tue 22 Sep, 2015 15:51:05 +0000
756 Diff Diff FSallustio picture FSallustio Thu 17 Sep, 2015 10:36:24 +0000
754 Diff Diff FSallustio picture FSallustio Thu 17 Sep, 2015 08:13:32 +0000
751 Diff Diff FSallustio picture FSallustio Wed 16 Sep, 2015 16:24:55 +0000
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