1
|
<!DOCTYPE html
|
2
|
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
3
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
5
|
<head>
|
6
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
7
|
<title>jsTree v.1.0 - types documentation</title>
|
8
|
<script type="text/javascript" src="../_lib/jquery.js"></script>
|
9
|
<script type="text/javascript" src="../_lib/jquery.cookie.js"></script>
|
10
|
<script type="text/javascript" src="../_lib/jquery.hotkeys.js"></script>
|
11
|
<script type="text/javascript" src="../jquery.jstree.js"></script>
|
12
|
|
13
|
<link type="text/css" rel="stylesheet" href="syntax/!style.css"/>
|
14
|
<link type="text/css" rel="stylesheet" href="!style.css"/>
|
15
|
<script type="text/javascript" src="syntax/!script.js"></script>
|
16
|
</head>
|
17
|
<body>
|
18
|
<div id="container">
|
19
|
|
20
|
<h1>jsTree v.1.0 - types plugin</h1>
|
21
|
<h2>Description</h2>
|
22
|
<div id="description">
|
23
|
<p>The <code>types</code> enables node types - each node can have a type, and you can define rules on how that type should behave - maximum children count, maximum depth, valid children types, selectable or not, etc.</p>
|
24
|
</div>
|
25
|
|
26
|
<h2 id="configuration">Configuration</h2>
|
27
|
<div class="panel configuration">
|
28
|
|
29
|
<h3>max_children</h3>
|
30
|
<p class="meta">A number. Default is <code>-1</code>.</p>
|
31
|
<p>Defines maximum number of root nodes (<code>-1</code> means unlimited, <code>-2</code> means disable max_children checking in the tree).</p>
|
32
|
|
33
|
<h3>max_depth</h3>
|
34
|
<p class="meta">A number. Default is <code>-1</code>.</p>
|
35
|
<p>Defines maximum depth of the tree (<code>-1</code> means unlimited, <code>-2</code> means disable max_depth checking in the tree).</p>
|
36
|
|
37
|
<h3>valid_children</h3>
|
38
|
<p class="meta">A string or array. Default is <code>"all"</code>.</p>
|
39
|
<p>Defines valid root node types (could be <code>"all"</code>, <code>"none"</code>, or an array of type strings).</p>
|
40
|
|
41
|
<h3>type_attr</h3>
|
42
|
<p class="meta">A string. Default is <code>"rel"</code>.</p>
|
43
|
<p>Defines the attribute on each <code>li</code> node, where the type attribute will be stored.</p>
|
44
|
|
45
|
<h3>types</h3>
|
46
|
<p class="meta">An object.</p>
|
47
|
<p>Defines all the active types in the tree. Each key is the type name, and each value represents the rules for this type. A <code>default</code> type is defined - all nodes with no explicit type set are treated as if they were of the <code>default</code> type.</p>
|
48
|
<div style="border:1px solid gray;">
|
49
|
<pre class="brush:js">
|
50
|
types : {
|
51
|
// the default type
|
52
|
"default" : {
|
53
|
"max_children" : -1,
|
54
|
"max_depth" : -1,
|
55
|
"valid_children": "all"
|
56
|
|
57
|
// Bound functions - you can bind any other function here (using boolean or function)
|
58
|
//"select_node" : true,
|
59
|
//"open_node" : true,
|
60
|
//"close_node" : true,
|
61
|
//"create_node" : true,
|
62
|
//"delete_node" : true
|
63
|
}
|
64
|
}
|
65
|
</pre>
|
66
|
</div>
|
67
|
<p>For <code>max_children</code>, <code>max_depth</code> & <code>valid_children</code> use the same values as for the tree, but the value you set will only apply for that node type.</p>
|
68
|
<p>You can set an <code>icon</code> key - it should be an object consisting of two keys - <code>image</code> (string - location of the image to be used as an icon) & <code>position</code> (string - left and top pixels of the image - 10px 40px, only useful when using sprites - omit otherwise).</p>
|
69
|
<p>You can set more keys in that object - each key should be a function name, and each value - either a boolean (in order to allow or disallow that operation, on that node type) or a function. If you supply a function - your function will be called with two arguments - the name of the called function (the key) and the arguments passed to that function - you can then decide whether to return <code>true</code> or <code>false</code>.</p>
|
70
|
<p class="note">For any type - for now you can control only functions that take the node being manipulated as the first argument.</p>
|
71
|
|
72
|
</div>
|
73
|
|
74
|
<h2 id="demos">Demos</h2>
|
75
|
<div class="panel">
|
76
|
<h3>Using the types plugin</h3>
|
77
|
|
78
|
<div id="demo1" class="demo">
|
79
|
<ul>
|
80
|
<li id="phtml_1" rel="root">
|
81
|
<a href="#">Root node 1</a>
|
82
|
<ul>
|
83
|
<li id="phtml_2">
|
84
|
<a href="#">Child node 1</a>
|
85
|
</li>
|
86
|
<li id="phtml_3">
|
87
|
<a href="#">Child node 2</a>
|
88
|
</li>
|
89
|
</ul>
|
90
|
</li>
|
91
|
<li id="phtml_4" rel="root">
|
92
|
<a href="#">Root node 2</a>
|
93
|
</li>
|
94
|
</ul>
|
95
|
</div>
|
96
|
<script type="text/javascript" class="source">
|
97
|
$(function () {
|
98
|
$("#demo1").jstree({
|
99
|
"types" : {
|
100
|
"valid_children" : [ "root" ],
|
101
|
"types" : {
|
102
|
"root" : {
|
103
|
"icon" : {
|
104
|
"image" : "http://static.jstree.com/v.1.0rc/_docs/_drive.png"
|
105
|
},
|
106
|
"valid_children" : [ "default" ],
|
107
|
"max_depth" : 2,
|
108
|
"hover_node" : false,
|
109
|
"select_node" : function () {return false;}
|
110
|
},
|
111
|
"default" : {
|
112
|
"valid_children" : [ "default" ]
|
113
|
}
|
114
|
}
|
115
|
},
|
116
|
"plugins" : ["themes","html_data","dnd","ui","types"]
|
117
|
});
|
118
|
});
|
119
|
</script>
|
120
|
|
121
|
</div>
|
122
|
|
123
|
<h2 id="api">API</h2>
|
124
|
<div class="panel api">
|
125
|
|
126
|
<h3 id="_get_type">._get_type ( node )</h3>
|
127
|
<p>Get the type of a node.</p>
|
128
|
<ul class="arguments">
|
129
|
<li>
|
130
|
<code class="tp">mixed</code> <strong>node</strong>
|
131
|
<p>This can be a DOM node, jQuery node or selector pointing to the element.</p>
|
132
|
</li>
|
133
|
</ul>
|
134
|
|
135
|
<h3 id="set_type">.set_type ( type , node )</h3>
|
136
|
<p>Set the type of a node.</p>
|
137
|
<ul class="arguments">
|
138
|
<li>
|
139
|
<code class="tp">string</code> <strong>type</strong>
|
140
|
<p>The new type.</p>
|
141
|
</li>
|
142
|
<li>
|
143
|
<code class="tp">mixed</code> <strong>node</strong>
|
144
|
<p>This can be a DOM node, jQuery node or selector pointing to the element.</p>
|
145
|
</li>
|
146
|
</ul>
|
147
|
|
148
|
<h3 id="_check">._check ( rule , node , opts )</h3>
|
149
|
<p>Checks a rule on a give node. Used mostly internally.</p>
|
150
|
<ul class="arguments">
|
151
|
<li>
|
152
|
<code class="tp">string</code> <strong>rule</strong>
|
153
|
<p>The rule to check.</p>
|
154
|
</li>
|
155
|
<li>
|
156
|
<code class="tp">mixed</code> <strong>node</strong>
|
157
|
<p>This can be a DOM node, jQuery node or selector pointing to the element.</p>
|
158
|
</li>
|
159
|
<li>
|
160
|
<code class="tp">mixed</code> <strong>opts</strong>
|
161
|
<p>Any additional options regarding the rule. Used internally.</p>
|
162
|
</li>
|
163
|
</ul>
|
164
|
|
165
|
<div style="height:1px; visibility:hidden;"><span id="check_move"> </span></div>
|
166
|
<h3 id="create_node">.create_node ( ), .check_move ( )</h3>
|
167
|
<p>Both functions are overwritten to accomodate the new functionality presented by the plugin.</p>
|
168
|
|
169
|
</div>
|
170
|
|
171
|
</div>
|
172
|
</body>
|
173
|
</html>
|