Newer
Older
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Fancytree - Example: ext-clones</title>
<!--
<link href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet">
<script src="//code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
-->
<script src="../lib/jquery.js"></script>
<script src="../lib/jquery-ui.custom.js"></script>
<link href="../src/skin-win8/ui.fancytree.css" class="skinswitcher" rel="stylesheet">
<script src="../src/jquery.fancytree.js"></script>
<script src="../src/jquery.fancytree.clones.js"></script>
<!-- Start_Exclude: This block is not part of the sample code -->
<link href="../lib/prettify.css" rel="stylesheet">
<script src="../lib/prettify.js"></script>
<link href="sample.css" rel="stylesheet">
<script src="sample.js"></script>
<!-- End_Exclude -->
<style type="text/css">
span.fancytree-node.fancytree-clone span.fancytree-title {
color: blue;
}
span.fancytree-node.fancytree-clone span.fancytree-title:after {
content: "";
background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAMAAAC67D+PAAAAFVBMVEVmmcwzmcyZzP8AZswAZv////////9E6giVAAAAB3RSTlP///////8AGksDRgAAADhJREFUGFcly0ESAEAEA0Ei6/9P3sEcVB8kmrwFyni0bOeyyDpy9JTLEaOhQq7Ongf5FeMhHS/4AVnsAZubxDVmAAAAAElFTkSuQmCC") 100% 50% no-repeat;
padding-right: 13px;
}
span.fancytree-node.fancytree-active-clone {
border-color: blue;
-moz-animation: flash 1s ease-out;
-moz-animation-iteration-count: 1;
-webkit-animation: flash 1s ease-out;
-webkit-animation-iteration-count: 1;
-ms-animation: flash 1s ease-out;
-ms-animation-iteration-count: 1;
}
@-ms-keyframes flash {
0% { background-color:none;}
50% { background-color:#fbf8b2;}
100% {background-color:none;}
}
@-moz-keyframes flash {
0% { background-color:none;}
50% { background-color:#fbf8b2;}
100% {background-color:none;}
}
@-ms-keyframes flash {
0% { background-color:none;}
50% { background-color:#fbf8b2;}
100% {background-color:none;}
}
</style>
<!-- Add code to initialize the tree when the document is loaded: -->
<script type="text/javascript">
var SOURCE = [
{title: "Item 1", key: "node1"},
{title: "Folder 2", folder: true, expanded: true, key: "node2",
children: [
{title: "Sub-item 2.1, refKey=3", key: "node2.1", refKey: "3"},
{title: "Sub-item 2.2", key: "node2.2", refKey: "2"}
]
},
{title: "Folder 3", folder: true, expanded: true, key: "node3",
children: [
{title: "Sub-item 2.1", key: "node3.1", selected: false,
children: [
{title: "Sub-item 3.1.1", key: "node3.1.1"},
{title: "Sub-item 3.1.2", key: "node3.1.2", refKey: "2"}
]
},
{title: "Sub-item 2.2", key: "node3.2"}
]
},
{title: "Folder 4", folder: true, expanded: true, key: "node4",
children: [
{title: "Sub-item 2.1", key: "node4.1", refKey: "1"},
{title: "Sub-item 2.2", key: "node4.2", refKey: "1", selected: false},
{title: "Sub-item 2.3 (unselectable)", key: "node4.3", selected: false, unselectable: true}
]
},
{title: "Item 3", key: "node5", lazy: true}
];
// Lazy sub nodes
var SOURCE_2 = [
{title: "Lazy Folder 3.1", folder: true, expanded: true,
children: [
{title: "Lazy Sub-item 3.1.1", selected: false, refKey: "rk311",
children: [
{title: "Sub-item 3.1.1.1", refKey: "rk3111"},
{title: "Sub-item 3.1.1.2", refKey: "rk3112", selected: false}
]
},
{title: "Sub-item 3.1.2"}
]
}
];
$(function(){
$("#tree").fancytree({
extensions: ["clones"],
// source: { url: "ajax-tree-plain.json" },
source: SOURCE,
clones: {
highlightClones: true
},
lazyLoad: function(e, data) {
// data.result = {url: "ajax-sub2.json"}
data.result = SOURCE_2
},
activate: function(e, data){
var clones = data.node.getCloneList();
if( clones ) {
// alert("Clones: "+ $.map(clones, function(n){ return "" + n;}).join(", "));
}
}
});
});
</script>
<!-- Start_Exclude: This block is not part of the sample code -->
<script>
$(function(){
addSampleButton({
label: "find clones",
newline: false,
code: function(){
var tree = $("#tree").fancytree("getTree"),
node3 = tree.getNodeByKey("node3");
alert("refKey '2' = " + tree.getNodesByRef("2"));
alert("refKey '2' below 'node3'' = " + tree.getNodesByRef("2", node3));
}
});
addSampleButton({
label: "remove",
newline: false,
code: function(){
var tree = $("#tree").fancytree("getTree"),
node = tree.getActiveNode();
node.remove();
}
});
});
</script>
<!-- End_Exclude -->
</head>
<body class="example">
<h1>Example: 'clones' extension</h1>
<div class="description">
<p>
Support linked nodes, i.e. multiple tree nodes representing the same
data instance.
</p>
<p>
</p>
<p>
<b>Status:</b> production.
<b>Details:</b>
<a href="https://github.com/mar10/fancytree/wiki/ExtClones"
target="_blank" class="external">ext-clones</a>.
</p>
</div>
<div>
<label for="skinswitcher">Skin:</label> <select id="skinswitcher"></select>
</div>
<p id="sampleButtons">
</p>
<!-- Add a <table> element where the tree should appear: -->
<div id="tree">
</div>
<!-- Start_Exclude: This block is not part of the sample code -->
<hr>
<p class="sample-links no_code">
<a class="hideInsideFS" href="https://github.com/mar10/fancytree">jquery.fancytree.js project home</a>
<a class="hideOutsideFS" href="#">Link to this page</a>
<a class="hideInsideFS" href="index.html">Example Browser</a>
<a href="#" id="codeExample">View source code</a>
</p>
<pre id="sourceCode" class="prettyprint" style="display:none"></pre>
<!-- End_Exclude -->
</body>
</html>