Project

General

Profile

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 Testing</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 - Core</h1>
21
<h2>Description</h2>
22
<div id="description">
23
<h3>Including the files</h3>
24
<p>First of all, as jsTree is a jQuery component, you need to include jQuery itself. jsTree v.1.0 requires jQuery version 1.4.2</p>
25

    
26
<div class="code_f"><pre class="brush:xml;">
27
&lt;script type="text/javascript" src="_lib/jquery.js"&gt;&lt;/script&gt;
28
</pre></div>
29

    
30
<p>Then you need to include jsTree:</p>
31

    
32
<div class="code_f"><pre class="brush:xml;">
33
&lt;script type="text/javascript" src="jquery.jstree.js"&gt;&lt;/script&gt;
34
</pre></div>
35

    
36
<p>Or you could use the minified version:</p>
37

    
38
<div class="code_f"><pre class="brush:xml;">
39
&lt;script type="text/javascript" src="jquery.jstree.min.js"&gt;&lt/script&gt;
40
</pre></div>
41

    
42
<p>You may change the path to whatever you like, but it is recommended not to rename <code>jquery.tree.js</code> or <code>jquery.tree.min.js</code> as the filenames may be used for path autodetection (for example in the <code>themes</code> plugin, but if you really need to rename the file most plugins will give you the option to set the path manually).</p>
43

    
44
<p>Additionally some plugins have dependencies - plugins that detect a dependency is missing will throw an error.</p>
45

    
46
<h3>Creating and configuring an instance</h3>
47
<p>You can create a tree in the following manner:</p>
48

    
49
<div class="code_f"><pre class="brush:js;">
50
jQuery("some-selector-to-container-node-here").jstree([ config_object ]);
51
</pre></div>
52

    
53
<p>In the optional config object you specify all the options that you want to set. Each plugin will describe its configuration and defaults. In the <a href="#configuration">configuration section</a> below you will find the options defined by the core. Each plugin's options (even the core) are set in their own subobject, which is named after the plugin. For example all of the core's options are set in the <code>core</code> key of the config object:</p>
54
<div class="code_f"><pre class="brush:js;">
55
jQuery("some-selector-to-container-node-here")
56
	.jstree({
57
		core : {
58
			/* core options go here */
59
		}
60
	});
61
</pre></div>
62

    
63
<p class="note">Please note that if your options for a given plugin are the same as the defaults you may omit those options or omit the subobject completely (if you do not need to modify the defaults).</p>
64

    
65
<p>There is only one special config option that is not a part of any plugin - this is the <code>plugins</code> option, which defines a list of active plugins for the instance being created. Although many plugins may be included, only the ones listed in this option will be active. The only autoincluded "plugin" is the jstree core.</p>
66

    
67
<div class="code_f"><pre class="brush:js;">
68
jQuery("some-selector-to-container-node-here")
69
	.jstree({
70
		core : { /* core options go here */ },
71
		plugins : [ "themes", "html_data", "some-other-plugin" ]
72
	});
73
</pre></div>
74

    
75
<h3>Interacting with the tree</h3>
76

    
77
<p>To perform an operation programatically on a given instance you can use two methods:</p>
78
<div class="code_f"><pre class="brush:js;">
79
/* METHOD ONE */
80
jQuery("some-selector-to-container-node-here")
81
	.jstree("operation_name" [, argument_1, argument_2, ...]);
82

    
83
/* METHOD TWO */
84
jQuery.jstree._reference(needle) 
85
	/* NEEDLE can be a DOM node or selector for the container or a node within the container */
86
	.operation_name([ argument_1, argument_2, ...]);
87
</pre></div>
88
<p class="note">NOTE: Functions prefixed with <code>_</code> can not be called with method one.</p>
89

    
90
<p>jsTree uses events to notify of any changes happening in the tree. All events fire on the tree container in the <code>jstree</code> namespace and are named after the function that triggered them. Please note that for some events it is best to bind before creating the instance. For example:</p>
91
<div class="code_f"><pre class="brush:js;">
92
jQuery("some-container")
93
	.bind("loaded.jstree", function (event, data) {
94
		alert("TREE IS LOADED");
95
	})
96
	.jstree({ /* configuration here */ });
97
</pre></div>
98
<p>Please note the second parameter <code>data</code>. Its structure is as follows:</p>
99
<div class="code_f"><pre class="brush:js;">
100
{ 
101
	"inst" : /* the actual tree instance */, 
102
	"args" : /* arguments passed to the function */, 
103
	"rslt" : /* any data the function passed to the event */, 
104
	"rlbk" : /* an optional rollback object - it is not always present */
105
}
106
</pre></div>
107
<p>There is also one special event - <code>before.jstree</code>. This events enables you to prevent an operation from executing. Look at the <a href="#demos">demo</a> below.</p>
108

    
109
</div>
110

    
111
<h2 id="configuration">Configuration</h2>
112
<div class="panel configuration">
113

    
114
<h3>html_titles</h3>
115
<p class="meta">Boolean. Default is <code>false</code>.</p>
116
<p>Defines whether titles can contain HTML code.</p>
117

    
118
<h3>animation</h3>
119
<p class="meta">A number. Default is <code>500</code>.</p>
120
<p>Defines the duration of open/close animations. <code>0</code> means no animation.</p>
121

    
122
<h3>initially_open</h3>
123
<p class="meta">An array. Default is <code>[]</code>.</p>
124
<p>Defines which nodes are to be automatically opened when the tree finishes loading - a list of IDs is expected.</p>
125

    
126
<h3>rtl</h3>
127
<p class="meta">Boolean. Default is <code>false</code>.</p>
128
<p>Defines whether the tree is in right-to-left mode (also make sure you are using a RTL theme - for example the included <code>default-rtl</code>).</p>
129

    
130
<h3>strings</h3>
131
<p class="meta">Object. Default is <code>{ loading : "Loading ...", new_node : "New node" }</code>.</p>
132
<p>Contains strings needed for the operation of the tree so that you can localize.</p>
133

    
134

    
135
</div>
136

    
137
<h2 id="demos">Demos</h2>
138
<div class="panel">
139

    
140
<h3>Binding to an event and executing an action</h3>
141
<input type="button" class="button" value="toggle_node" id="toggle_node" style="clear:both;" />
142
<div id="demo1" class="demo">
143
	<ul>
144
		<li id="phtml_1">
145
			<a href="#">Root node 1</a>
146
			<ul>
147
				<li id="phtml_2">
148
					<a href="#">Child node 1</a>
149
				</li>
150
				<li id="phtml_3">
151
					<a href="#">Child node 2</a>
152
				</li>
153
			</ul>
154
		</li>
155
		<li id="phtml_4">
156
			<a href="#">Root node 2</a>
157
		</li>
158
	</ul>
159
</div>
160
<script type="text/javascript" class="source">
161
$(function () {
162
	$("#toggle_node").click(function () { 
163
		$("#demo1").jstree("toggle_node","#phtml_1");
164
	});
165
	$("#demo1")
166
		.bind("open_node.jstree close_node.jstree", function (e) {
167
			$("#log1").html("Last operation: " + e.type);
168
		})
169
		.jstree({ "plugins" : [ "themes", "html_data" ] });
170
	});
171
</script>
172
<p class="log" id="log1" style="clear:both;">&#160;</p>
173

    
174
<h3>Preventing an action</h3>
175
<p>This is the same demo as above, but this time the operation will be prevented.</p>
176
<input type="button" class="button" value="toggle_node" id="toggle_node2" style="clear:both;" />
177
<div id="demo2" class="demo">
178
	<ul>
179
		<li id="html_1">
180
			<a href="#">Root node 1</a>
181
			<ul>
182
				<li id="html_2">
183
					<a href="#">Child node 1</a>
184
				</li>
185
				<li id="html_3">
186
					<a href="#">Child node 2</a>
187
				</li>
188
			</ul>
189
		</li>
190
		<li id="html_4">
191
			<a href="#">Root node 2</a>
192
		</li>
193
	</ul>
194
</div>
195
<script type="text/javascript">
196
$(function () {
197
	$("#toggle_node2").click(function () { 
198
		$("#demo2").jstree("toggle_node","#html_1");
199
	});
200
	$("#demo2")
201
		.bind("open_node.jstree close_node.jstree", function (e) {
202
			$("#log2").html("Last operation: " + e.type);
203
		})
204
		.jstree({ "plugins" : [ "themes", "html_data" ] });
205
	});
206
</script>
207
<script type="text/javascript" class="source">
208
$(function () {
209
	$("#demo2").bind("before.jstree", function (e, data) {
210
		if(data.func === "open_node") {
211
			$("#log2").html(data.args[0].attr("id"));
212
			e.stopImmediatePropagation();
213
			return false;
214
		}
215
	});
216
});
217
</script>
218
<p class="log" id="log2" style="clear:both;">&#160;</p>
219
<p>The important part is <code>e.stopImmediatePropagation(); return false</code>.</p>
220
</div>
221

    
222
<h2 id="api">API</h2>
223
<div class="panel api">
224
<p class="note">Use extra caution when working with functions prefixed with an underscore - <code>_</code>!<br />Those functions are probably for internal usage only.</p>
225

    
226

    
227
<h3 id="jstree.defaults">jQuery.jstree.defaults</h3>
228
<p class="meta">An object. Default is a collection of all included plugin's defaults.</p>
229
<p>This object is exposed so that you can apply standart settings to all future instances</p>
230

    
231
<h3 id="jstree.plugin">jQuery.jstree.plugin ( plugin_name , plugin_data )</h3>
232
<p>This function is used by developers to extend jstree (add "plugins").</p>
233
<ul class="arguments">
234
	<li>
235
		<code class="tp">string</code> <strong>plugin_name</strong>
236
		<p>The plugin name - it should be unique.</p>
237
	</li>
238
	<li>
239
		<code class="tp">object</code> <strong>plugin_data</strong>
240
		<p>The plugin itself. It consists of <code>__init</code> &amp; <code>__destroy</code> functions, <code>defaults</code> object (that of course could be an array or a simple value) and a <code>_fn</code> object, whose keys are all the functions you are extending jstree with. You can overwrite functions (but you can in your function call the overriden old function), and you are responsible for triggering events and setting rollback points. You can omit any of the elements in the <code>plugin_data</code> param. Keep in mind jstree will automatically clear classes prepended with <code>jstree-</code> and all events in the <code>jstree</code> namespace when destroying a tree, so you do not need to worry about those.</p>
241
		<p>Read jstree's code for examples on how to develop plugins.</p>
242
	</li>
243
</ul>
244

    
245
<h3 id="jstree.rollback">jQuery.jstree.rollback ( rollback_object )</h3>
246
<p>This function will roll the tree back to the state specified by the rollback object</p>
247
<ul class="arguments">
248
	<li>
249
		<code class="tp">string</code> <strong>rollback_object</strong>
250
		<p>Normally you will get this object from the event you are handling. You can of course use <code>.get_rollback()</code> to get the current state of the tree as a rollback object.</p>
251
		<div class="code_f"><pre class="brush:js;">
252
$("some-container").bind("some-event.jstree", function (e, data) {
253
	$.jstree.rollback(data.rlbk);
254
});</pre></div>
255
		<p>Keep in mind that not all events will give you a rollback object - sometimes <code>data.rlbk</code> will be <code>false</code>.</p>
256
	</li>
257
</ul>
258

    
259
<h3 id="jstree._focused">jQuery.jstree._focused ()</h3>
260
<p>Returns the currently focused tree instance on the page. If not interaction has been made - it is the last one to be created.</p>
261

    
262
<h3 id="jstree._reference">jQuery.jstree._reference ( needle )</h3>
263
<p>Returns the tree instance for the specified <code>needle</code>.</p>
264
<ul class="arguments">
265
	<li>
266
		<code class="tp">mixed</code> <strong>needle</strong>
267
		<p>This can be a DOM node, jQuery node or selector pointing to the tree container, or an element within the tree.</p>
268
	</li>
269
</ul>
270

    
271
<h3 id="jstree._instance">jQuery.jstree._instance ( index , container , settings )</h3>
272
<p>This function is used internally when creating new tree instances. Calling this function by itself is not enough to create a new instance. To create a tree use the documented method <code>$("selector").jstree([ options ])</code>.</p>
273

    
274
<h3 id="jstree._fn">jQuery.jstree._fn</h3>
275
<p>This object stores all functions included by plugins. It is used internally as a prototype for all instances - do not modify manually.</p>
276

    
277
<h3 id="data">.data</h3>
278
<p>An object where all plugins store instance specific data. Do not modify manually.</p>
279

    
280
<h3 id="get_settings">.get_settings ()</h3>
281
<p>Returns a copy of the instance's settings object - the defaults, extended by your own config object.</p>
282

    
283
<h3 id="_get_settings">._get_settings ()</h3>
284
<p>Returns the instance's settings object - the defaults, extended by your own config object.</p>
285

    
286
<h3 id="get_index">.get_index ()</h3>
287
<p>Returns the internal instance index.</p>
288

    
289
<h3 id="get_container">.get_container ()</h3>
290
<p>Returns the jQuery extended container node of the tree.</p>
291

    
292
<h3 id="_set_settings">._set_settings ( settings )</h3>
293
<p>Replace the settings object with the <code>settings</code> param. Please note that not all plugins will react to the change. Unless you know exactly what you are doing you'd be better off recreating the tree with the new settings.</p>
294

    
295
<h3 id="init">.init ()</h3>
296
<p>This function is used internally when creating a new instance. Triggers an event, which fires after the tree is initialized, but not yet loaded.</p>
297

    
298
<h3 id="destroy">.destroy ()</h3>
299
<p>Destroys the instance - it will automatically remove all bound events in the <code>jstree</code> namespace &amp; remove all classes starting with <code>jstree-</code>. Triggers an event.</p>
300

    
301
<h3 id="save_opened">.save_opened ()</h3>
302
<p>Stores the currently open nodes before refreshing. Used internally. Triggers an event.</p>
303

    
304
<h3 id="reopen">.reopen ( is_callback )</h3>
305
<p>Reopens all the nodes stored by <code>save_opened</code> or set in the <code>initially_open</code> config option on first load. It is called multiple times while reopening nodes - the <code>is_callback</code> param determines if this is the first call (<code>false</code>) or not. Used internally. Triggers an event.</p>
306

    
307
<h3 id="refresh">.refresh ( node )</h3>
308
<p>Refreshes the tree. Saves all open nodes, and reloads and then reopens all saved nodes. Triggers an event.</p>
309
<ul class="arguments">
310
	<li>
311
		<code class="tp">mixed</code> <strong>node</strong>
312
		<p>This can be a DOM node, jQuery node or selector pointing to an element within the tree. If set this will reload only the given node - otherwise - the whole tree. Passing <code>-1</code> also reloads the whole tree.</p>
313
	</li>
314
</ul>
315

    
316
<h3 id="loaded">.loaded ()</h3>
317
<p>A dummy function, whose purpose is only to trigger the loaded event. This event is triggered once after the tree's root nodes are loaded, but before any nodes set in <code>initially_open</code> are opened.</p>
318

    
319
<h3 id="set_focus">.set_focus ()</h3>
320
<p>Makes the current instance the focused one on the page. Triggers an event.</p>
321

    
322
<h3 id="is_focused">.is_focused ()</h3>
323
<p>Returns <code>true</code> if the current instance is the focused one, otherwise returns <code>false</code>.</p>
324

    
325
<h3 id="_get_node">._get_node ( node )</h3>
326
<p>Return the jQuery extended <code>LI</code> element of the node, <code>-1</code> if the container node is passed, or <code>false</code> otherwise.</p>
327
<ul class="arguments">
328
	<li>
329
		<code class="tp">mixed</code> <strong>node</strong>
330
		<p>This can be a DOM node, jQuery node or selector pointing to an element within the tree.</p>
331
	</li>
332
</ul>
333

    
334
<h3 id="_get_next">._get_next ( node , strict )</h3>
335
<p>Gets the <code>LI</code> element representing the node next to the passed <code>node</code>. Returns <code>false</code> on failure.</p>
336
<ul class="arguments">
337
	<li>
338
		<code class="tp">mixed</code> <strong>node</strong>
339
		<p>This can be a DOM node, jQuery node or selector pointing to an element within the tree, whose next sibling we want.</p>
340
	</li>
341
	<li>
342
		<code class="tp">bool</code> <strong>strict</strong>
343
		<p>If set to <code>true</code> only immediate siblings are calculated. Otherwise if the <code>node</code> is the last child of its parent this function will "jump out" and return the parent's next sibling, etc. Default is <code>false</code>.</p>
344
	</li>
345
</ul>
346

    
347
<h3 id="_get_prev">._get_prev ( node , strict )</h3>
348
<p>Gets the <code>LI</code> element representing the node previous to the passed <code>node</code>. Returns <code>false</code> on failure.</p>
349
<ul class="arguments">
350
	<li>
351
		<code class="tp">mixed</code> <strong>node</strong>
352
		<p>This can be a DOM node, jQuery node or selector pointing to an element within the tree, whose previous sibling we want.</p>
353
	</li>
354
	<li>
355
		<code class="tp">bool</code> <strong>strict</strong>
356
		<p>If set to <code>true</code> only immediate siblings are calculated. Otherwise if the <code>node</code> is the first child of its parent this function will "jump out" and return the parent itself. Default is <code>false</code>.</p>
357
	</li>
358
</ul>
359

    
360
<h3 id="_get_parent">._get_parent ( node )</h3>
361
<p>Gets the <code>LI</code> element representing the parent of the passed <code>node</code>. Returns <code>false</code> on failure.</p>
362
<ul class="arguments">
363
	<li>
364
		<code class="tp">mixed</code> <strong>node</strong>
365
		<p>This can be a DOM node, jQuery node or selector pointing to an element within the tree, whose parent we want.</p>
366
	</li>
367
</ul>
368

    
369
<h3 id="_get_children">._get_children ( node )</h3>
370
<p>Gets the <code>LI</code> elements representing the children of the passed <code>node</code>. Returns <code>false</code> on failure (or if the node has no children).</p>
371
<ul class="arguments">
372
	<li>
373
		<code class="tp">mixed</code> <strong>node</strong>
374
		<p>This can be a DOM node, jQuery node or selector pointing to an element within the tree, whose children we want. Use <code>-1</code> to return all root nodes.</p>
375
	</li>
376
</ul>
377

    
378
<h3 id="get_path">.get_path ( node , id_mode )</h3>
379
<p>Return the path to a node, either as an array of IDs or as an array of node names.</p>
380
<ul class="arguments">
381
	<li>
382
		<code class="tp">mixed</code> <strong>node</strong>
383
		<p>This can be a DOM node, jQuery node or selector pointing to an element within the tree, whose path we want.</p>
384
	</li>
385
	<li>
386
		<code class="tp">bool</code> <strong>id_mode</strong>
387
		<p>If set to <code>true</code> IDs are returned instead of the names of the parents. Default is <code>false</code>.</p>
388
	</li>
389
</ul>
390

    
391
<h3 id="open_node">.open_node ( node , callback , skip_animation )</h3>
392
<p>Opens a closed node, so that its children are visible. If the <code>animation</code> config option is greater than <code>0</code> the children are revealed using a slide down animation, whose duration is the value of the <code>animation</code> config option in milliseconds. Triggers an event.</p>
393
<ul class="arguments">
394
	<li>
395
		<code class="tp">mixed</code> <strong>node</strong>
396
		<p>This can be a DOM node, jQuery node or selector pointing to an element we want opened.</p>
397
	</li>
398
	<li>
399
		<code class="tp">function</code> <strong>callback</strong>
400
		<p>A callback function executed once the node is opened. Used mostly internally, you'd be better of waiting for the event. You can skip this, by not specifying it, or by passing <code>false</code>.</p>
401
	</li>
402
	<li>
403
		<code class="tp">bool</code> <strong>skip_animation</strong>
404
		<p>If set to <code>true</code> the animation set in the <code>animation</code> config option is skipped. Default is <code>false</code>.</p>
405
	</li>
406
</ul>
407

    
408
<h3 id="close_node">.close_node ( node , skip_animation )</h3>
409
<p>Closes an open node, so that its children are not visible. If the <code>animation</code> config option is greater than <code>0</code> the children are hidden using a slide up animation, whose duration is the value of the <code>animation</code> config option in milliseconds. Triggers an event.</p>
410
<ul class="arguments">
411
	<li>
412
		<code class="tp">mixed</code> <strong>node</strong>
413
		<p>This can be a DOM node, jQuery node or selector pointing to an element we want closed.</p>
414
	</li>
415
	<li>
416
		<code class="tp">bool</code> <strong>skip_animation</strong>
417
		<p>If set to <code>true</code> the animation set in the <code>animation</code> config option is skipped. Default is <code>false</code>.</p>
418
	</li>
419
</ul>
420

    
421
<h3 id="toggle_node">.toggle_node ( node )</h3>
422
<p>If a node is closed - this function opens it, if it is open - calling this function will close it.</p>
423
<ul class="arguments">
424
	<li>
425
		<code class="tp">mixed</code> <strong>node</strong>
426
		<p>This can be a DOM node, jQuery node or selector pointing to an element we want toggled.</p>
427
	</li>
428
</ul>
429

    
430
<h3 id="open_all">.open_all ( node , original_obj )</h3>
431
<p>Opens all descendants of the <code>node</code> node.</p>
432
<ul class="arguments">
433
	<li>
434
		<code class="tp">mixed</code> <strong>node</strong>
435
		<p>This can be a DOM node, jQuery node or selector pointing to an element whose descendants you want opened. If this param is omitted or set to <code>-1</code> all nodes in the tree are opened.</p>
436
	</li>
437
	<li>
438
		<code class="tp">mixed</code> <strong>original_obj</strong>
439
		<p>Used internally when recursively calling the same function - do not pass this param.</p>
440
	</li>
441
</ul>
442

    
443
<h3 id="close_all">.close_all ( node )</h3>
444
<p>Closes all descendants of the <code>node</code> node.</p>
445
<ul class="arguments">
446
	<li>
447
		<code class="tp">mixed</code> <strong>node</strong>
448
		<p>This can be a DOM node, jQuery node or selector pointing to an element whose descendants you want closed. If this param is omitted or set to <code>-1</code> all nodes in the tree are closed.</p>
449
	</li>
450
</ul>
451

    
452
<div style="height:1px; visibility:hidden;"><span id="is_leaf">&nbsp;</span><span id="is_closed">&nbsp;</span></div>
453
<h3 id="is_open">.is_open ( node ), .is_closed ( node ), .is_leaf ( node )</h3>
454
<p>Those function check if the <code>node</code> is in a state.</p>
455
<ul class="arguments">
456
	<li>
457
		<code class="tp">mixed</code> <strong>node</strong>
458
		<p>This can be a DOM node, jQuery node or selector pointing to an element you want checked.</p>
459
	</li>
460
</ul>
461

    
462
<h3 id="clean_node">.clean_node ( node )</h3>
463
<p>Applies all necessary classes to the <code>node</code> and its descendants. Used internally. Triggers an event.</p>
464
<ul class="arguments">
465
	<li>
466
		<code class="tp">mixed</code> <strong>node</strong>
467
		<p>This can be a DOM node, jQuery node or selector pointing to an element you want cleaned. If this param is omitted or set to <code>-1</code> all nodes in the tree are cleaned.</p>
468
	</li>
469
</ul>
470

    
471
<h3 id="get_rollback">.get_rollback ()</h3>
472
<p>Get the current tree's state in the rollback format. Used mainly internally by plugins.</p>
473

    
474
<h3 id="set_rollback">.set_rollback ( html , data )</h3>
475
<p>Rollback the tree. Used ONLY internally! Both arguments are part of the rollback object. If you need to rollback - take a look at <a href="#jstree.rollback">jQuery.jstree.rollback()</a>. Triggers event.</p>
476

    
477
<h3 id="load_node">.load_node ( node , success_callback , error_callback )</h3>
478
<p>A dummy function that is overwritten by data plugins. Triggers event.</p>
479
<ul class="arguments">
480
	<li>
481
		<code class="tp">mixed</code> <strong>node</strong>
482
		<p>This can be a DOM node, jQuery node or selector pointing to an element you want loaded. Use <code>-1</code> for root nodes.</p>
483
	</li>
484
	<li>
485
		<code class="tp">function</code> <strong>success_callback</strong>
486
		<p>A function to be executed once the node is loaded successfully - used internally. You should wait for the event.</p>
487
	</li>
488
	<li>
489
		<code class="tp">function</code> <strong>error_callback</strong>
490
		<p>A function to be executed if the node is not loaded due to an error - used internally. You should wait for the event.</p>
491
	</li>
492
</ul>
493

    
494
<h3 id="_is_loaded">._is_loaded ( node )</h3>
495
<p>A dummy function that should return <code>true</code> if the node's children are loaded or <code>false</code> otherwise.</p>
496
<ul class="arguments">
497
	<li>
498
		<code class="tp">mixed</code> <strong>node</strong>
499
		<p>This can be a DOM node, jQuery node or selector pointing to an element you want to check.</p>
500
	</li>
501
</ul>
502

    
503
<h3 id="create_node">.create_node ( node , position , js , callback , is_loaded )</h3>
504
<p>Creates the DOM structure necessary for a new node. Triggers an event.</p>
505
<ul class="arguments">
506
	<li>
507
		<code class="tp">mixed</code> <strong>node</strong>
508
		<p>This can be a DOM node, jQuery node or selector pointing to the element you want to create in (or next to).</p>
509
	</li>
510
	<li>
511
		<code class="tp">mixed</code> <strong>position</strong>
512
		<p>The position of the newly created node. This can be a zero based index to position the element at a specific point among the current children. You can also pass in one of those strings: <code>"before"</code>, <code>"after"</code>, <code>"inside"</code>, <code>"first"</code>, <code>"last"</code>.</p>
513
	</li>
514
	<li>
515
		<code class="tp">object</code> <strong>js</strong>
516
		<p>The data for the newly created node. Consists of three keys:</p><p style="margin-left:25px;"><code class="tp">attr</code> - an object of attributes (same used for <code>jQuery.attr()</code>. You can omit this key;<br /><code class="tp">state</code> - a string - either <code>"open"</code> or <code>"closed"</code>, for a leaf node - omit this key;<br /><code class="tp">data</code> - a string or an object - if a string is passed it is used for the title of the node, if an object is passed there are two keys you can specify: <code>attr</code> and <code>title</code>;</p>
517
	</li>
518
	<li>
519
		<code class="tp">function</code> <strong>callback</strong>
520
		<p>A function to be executed once the node is created - used internally. You should wait for the event.</p>
521
	</li>
522
	<li>
523
		<code class="tp">bool</code> <strong>is_loaded</strong>
524
		<p>Specifies if the parent of the node is loaded or not - used ONLY internally.</p>
525
	</li>
526
</ul>
527

    
528
<h3 id="get_text">.get_text ( node )</h3>
529
<p>Returns the title of a node.</p>
530
<ul class="arguments">
531
	<li>
532
		<code class="tp">mixed</code> <strong>node</strong>
533
		<p>This can be a DOM node, jQuery node or selector pointing to the element whose title you need.</p>
534
	</li>
535
</ul>
536

    
537
<h3 id="set_text">.set_text ( node , text )</h3>
538
<p>Sets the title of a node. Triggers an event. This is used mostly internally - wait for a <a href="#rename_node">.rename_node event</a> to avoid confusion.</p>
539
<ul class="arguments">
540
	<li>
541
		<code class="tp">mixed</code> <strong>node</strong>
542
		<p>This can be a DOM node, jQuery node or selector pointing to the element whose title you want to change.</p>
543
	</li>
544
	<li>
545
		<code class="tp">string</code> <strong>text</strong>
546
		<p>The new title.</p>
547
	</li>
548
</ul>
549

    
550
<h3 id="rename_node">.rename_node ( node , text )</h3>
551
<p>Sets the title of a node. Triggers an event.</p>
552
<ul class="arguments">
553
	<li>
554
		<code class="tp">mixed</code> <strong>node</strong>
555
		<p>This can be a DOM node, jQuery node or selector pointing to the element whose title you want to change.</p>
556
	</li>
557
	<li>
558
		<code class="tp">string</code> <strong>text</strong>
559
		<p>The new title.</p>
560
	</li>
561
</ul>
562

    
563
<h3 id="delete_node">.delete_node ( node )</h3>
564
<p>Removes a node. Triggers an event.</p>
565
<ul class="arguments">
566
	<li>
567
		<code class="tp">mixed</code> <strong>node</strong>
568
		<p>This can be a DOM node, jQuery node or selector pointing to the element you want to remove.</p>
569
	</li>
570
</ul>
571

    
572
<h3 id="prepare_move">.prepare_move ( o , r , pos , cb , is_cb )</h3>
573
<p>This function is used internally to prepare all necessary variables and nodes when moving a node around. It is automatically called as needed - you do not need to call it manually. Triggers an event.</p>
574

    
575
<h3 id="check_move">.check_move ()</h3>
576
<p>Checks if the prepared move is a valid one.</p>
577

    
578
<h3 id="move_node">.move_node ( node , ref , position , is_copy , is_prepared , skip_check )</h3>
579
<p>Moves a node to a new place. Triggers an event.</p>
580
<ul class="arguments">
581
	<li>
582
		<code class="tp">mixed</code> <strong>node</strong>
583
		<p>This can be a DOM node, jQuery node or selector pointing to the element you want to move.</p>
584
	</li>
585
	<li>
586
		<code class="tp">mixed</code> <strong>ref</strong>
587
		<p>This can be a DOM node, jQuery node or selector pointing to the element which will be the reference element in the move. <code>-1</code> may be used too (to indicate the container node).</p>
588
	</li>
589
	<li>
590
		<code class="tp">mixed</code> <strong>position</strong>
591
		<p>The new position of the moved node. This can be a zero based index to position the element at a specific point among the reference node's current children. You can also use one of these strings: <code>"before"</code>, <code>"after"</code>, <code>"inside"</code>, <code>"first"</code>, <code>"last"</code>.</p>
592
	</li>
593
	<li>
594
		<code class="tp">bool</code> <strong>is_copy</strong>
595
		<p>Should this be a copy or a move operation.</p>
596
	</li>
597
	<li>
598
		<code class="tp">bool</code> <strong>is_prepared</strong>
599
		<p>Used internally when this function is called recursively.</p>
600
	</li>
601
	<li>
602
		<code class="tp">bool</code> <strong>skip_check</strong>
603
		<p>If this is set to <code>true</code> <a href="#check_move">check_move</a> is not called.</p>
604
	</li>
605
</ul>
606

    
607
<h3 id="_get_move">._get_move ()</h3>
608
<p>Returns the lastly prepared move. The returned object contains:<br />
609
<code>.o</code> - the node being moved<br />
610
<code>.r</code> - the reference node in the move<br />
611
<code>.ot</code> - the origin tree instance<br />
612
<code>.rt</code> - the reference tree instance<br />
613
<code>.p</code> - the position to move to (may be a string - <code>"last"</code>, <code>"first"</code>, etc)<br />
614
<code>.cp</code> - the calculated position to move to (always a number)<br />
615
<code>.np</code> - the new parent<br />
616
</p>
617

    
618
</div>
619

    
620
</div>
621
</body>
622
</html>
(12-12/27)