<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>jsTree v.1.0 - CRRM documentation</title>
	<script type="text/javascript" src="../_lib/jquery.js"></script>
	<script type="text/javascript" src="../_lib/jquery.cookie.js"></script>
	<script type="text/javascript" src="../_lib/jquery.hotkeys.js"></script>
	<script type="text/javascript" src="../jquery.jstree.js"></script>

	<link type="text/css" rel="stylesheet" href="syntax/!style.css"/>
	<link type="text/css" rel="stylesheet" href="!style.css"/>
	<script type="text/javascript" src="syntax/!script.js"></script>
</head>
<body>
<div id="container">

<h1 id="dhead">jsTree v.1.0</h1>
<h1>crrm plugin</h1>
<h2>Description</h2>
<div id="description">
<p>The <code>CRRM</code> plugin handles creating, renaming, removing and moving nodes by the user.</p>
</div>

<h2 id="configuration">Configuration</h2>
<div class="panel configuration">
<h3>input_width_limit</h3>
<p class="meta">A number. Default is <code>200</code>.</p>
<p>When renaming (or creating) nodes the input for the text will autosize - this number sets the maximum size for the input.</p>

<h3>move</h3>
<p class="meta">An object, containing various settings - see below for more.</p>

<h3>move.always_copy</h3>
<p class="meta"><code>true</code>, <code>false</code> or <code>"multitree"</code>. Default is <code>false</code>.</p>
<p>Defines how moves are handled - if set to <code>true</code> every move will be forced to a copy (leaving the original node in place). If set to <code>"multitree"</code> only moves between trees will be forced to a copy.</p>

<h3>move.open_onmove</h3>
<p class="meta">A Boolean. Default is <code>true</code>.</p>
<p>If set to true, when moving a node to a new, closed parent, the parent node will be opened when the move completes.</p>

<h3>move.default_position</h3>
<p class="meta">A string or a number. Default is <code>"last"</code>.</p>
<p>The default position to move to if no position is specified. This can be a zero based index to position the element at a specific point among the new parent'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>

<h3>move.check_move</h3>
<p class="meta">A function. Default is <code>function (m) { return true; }</code>.</p>
<p>The callback function enabling you to prevent some moves - just return <code>false</code>. The <code>m</code> parameter is the move object generated by jstree. The object follows the structure described in <a href="core.html#_get_move">._get_move</a>.</p>

</div>

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

<h3>Creating nodes</h3>
<input type="button" class="button" value="create_1" id="create_1" style="float:left;" />
<input type="button" class="button" value="create_2" id="create_2" style="float:left;" />
<input type="button" class="button" value="create_3" id="create_3" style="" />
<div id="demo1" class="demo">
	<ul>
		<li id="phtml_1">
			<a href="#">Root node 1</a>
			<ul>
				<li id="phtml_2">
					<a href="#">Child node 1</a>
				</li>
				<li id="phtml_3">
					<a href="#">Child node 2</a>
				</li>
			</ul>
		</li>
		<li id="phtml_4">
			<a href="#">Root node 2</a>
		</li>
	</ul>
</div>
<script type="text/javascript" class="source">
$(function () {
	$("#create_1").click(function () { 
		$("#demo1").jstree("create"); 
	});
	$("#create_2").click(function () { 
		$("#demo1").jstree("create","#phtml_1","first","Enter a new name"); 
	});
	$("#create_3").click(function () { 
		$("#demo1").jstree("create",-1,false,"No rename",false,true); 
	});
	$("#demo1").jstree({ 
		"ui" : {
			"initially_select" : [ "phtml_2" ]
		},
		"core" : { "initially_open" : [ "phtml_1" ] },
		"plugins" : [ "themes", "html_data", "ui", "crrm" ]
	});
});
</script>

<h3>Removing nodes</h3>
<input type="button" class="button" value="remove_1" id="remove_1" style="float:left;" />
<input type="button" class="button" value="remove_2" id="remove_2" style="" />
<div id="demo2" class="demo">
	<ul>
		<li id="rhtml_1">
			<a href="#">Root node 1</a>
			<ul>
				<li id="rhtml_2">
					<a href="#">Child node 1</a>
				</li>
				<li id="rhtml_3">
					<a href="#">Child node 2</a>
				</li>
			</ul>
		</li>
		<li id="rhtml_4">
			<a href="#">Root node 2</a>
		</li>
	</ul>
</div>
<script type="text/javascript" class="source">
$(function () {
	$("#remove_1").click(function () { 
		$("#demo2").jstree("remove"); 
	});
	$("#remove_2").click(function () { 
		$("#demo2").jstree("remove","#rhtml_1"); 
	});
	$("#demo2").jstree({ 
		"ui" : {
			"initially_select" : [ "rhtml_2" ]
		},
		"core" : { "initially_open" : [ "rhtml_1" ] },
		"plugins" : [ "themes", "html_data", "ui", "crrm" ]
	});
});
</script>

<h3>Renaming nodes</h3>
<input type="button" class="button" value="rename_1" id="rename_1" style="float:left;" />
<input type="button" class="button" value="rename_2" id="rename_2" style="" />
<div id="demo3" class="demo">
	<ul>
		<li id="shtml_1">
			<a href="#">Root node 1</a>
			<ul>
				<li id="shtml_2">
					<a href="#">Child node 1</a>
				</li>
				<li id="shtml_3">
					<a href="#">Child node 2</a>
				</li>
			</ul>
		</li>
		<li id="shtml_4">
			<a href="#">Root node 2</a>
		</li>
	</ul>
</div>
<script type="text/javascript" class="source">
$(function () {
	$("#rename_1").click(function () { 
		$("#demo3").jstree("rename"); 
	});
	$("#rename_2").click(function () { 
		$("#demo3").jstree("rename","#shtml_1"); 
	});
	$("#demo3").jstree({ 
		"ui" : {
			"initially_select" : [ "shtml_2" ]
		},
		"core" : { "initially_open" : [ "shtml_1" ] },
		"plugins" : [ "themes", "html_data", "ui", "crrm" ]
	});
});
</script>

<h3>Moving nodes</h3>
<p><strong>move_1</strong> uses the default position - <code>"first"</code></p>
<p><strong>move_2</strong> specifies a position - <code>"before"</code> - meaning that the node specified as a first argument will come above the node specified as the second argument</p>
<p><strong>move_3</strong> will never work, because of the specified <code>check_move</code> function which prevents the first root node from being moved</p>
<input type="button" class="button" value="move_1" id="move_1" style="float:left;" />
<input type="button" class="button" value="move_2" id="move_2" style="float:left;" />
<input type="button" class="button" value="move_3" id="move_3" style="" />
<div id="demo4" class="demo">
	<ul>
		<li id="thtml_1">
			<a href="#">Root node 1</a>
			<ul>
				<li id="thtml_2">
					<a href="#">Child node 1</a>
				</li>
				<li id="thtml_3">
					<a href="#">Child node 2</a>
				</li>
			</ul>
		</li>
		<li id="thtml_4">
			<a href="#">Root node 2</a>
		</li>
	</ul>
</div>
<script type="text/javascript" class="source">
$(function () {
	$("#move_1").click(function () { 
		$("#demo4").jstree("move_node","#thtml_4","#thtml_1"); 
	});
	$("#move_2").click(function () { 
		$("#demo4").jstree("move_node","#thtml_4","#thtml_1", "before"); 
	});
	$("#move_3").click(function () { 
		$("#demo4").jstree("move_node","#thtml_1","#thtml_4"); 
	});
	$("#demo4").jstree({ 
		"crrm" : {
			"move" : {
				"default_position" : "first",
				"check_move" : function (m) { return (m.o[0].id === "thtml_1") ? false : true;  }
			}
		},
		"ui" : {
			"initially_select" : [ "thtml_2" ]
		},
		"core" : { "initially_open" : [ "thtml_1" ] },
		"plugins" : [ "themes", "html_data", "ui", "crrm" ]
	});
});
</script>

</div>

<h2 id="api">API</h2>
<div class="panel api">

<h3 id="_show_input">._show_input ( node , callback )</h3>
<p>Renders an input field in a node. Used only internally.</p>

<h3 id="rename">.rename ( node )</h3>
<p>Sets a node in rename mode and when the user has entered changes, an event is triggered.</p>
<ul class="arguments">
	<li>
		<code class="tp">mixed</code> <strong>node</strong>
		<p>This can be a DOM node, jQuery node or selector pointing to an element within the tree. If you use the UI plugin - pass <code>null</code> to use the currently selected item.</p>
	</li>
</ul>

<h3 id="create">.create ( node , position , js , callback , skip_rename )</h3>
<p>Creates a new node. Triggers an event.</p>
<ul class="arguments">
	<li>
		<code class="tp">mixed</code> <strong>node</strong>
		<p>This can be a DOM node, jQuery node or selector pointing to the element you want to create in (or next to). If you use the UI plugin - pass <code>null</code> to use the currently selected item.</p>
	</li>
	<li>
		<code class="tp">mixed</code> <strong>position</strong>
		<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>
	</li>
	<li>
		<code class="tp">object</code> <strong>js</strong>
		<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>
	</li>
	<li>
		<code class="tp">function</code> <strong>callback</strong>
		<p>A function to be executed once the node is created. You'd be better off waiting for the event.</p>
	</li>
	<li>
		<code class="tp">bool</code> <strong>skip_rename</strong>
		<p>Skips the user input step. The node is created with the data you have supplied.</p>
	</li>
</ul>

<h3 id="remove">.remove ( node )</h3>
<p>Removes a node. Triggers an event.</p>
<ul class="arguments">
	<li>
		<code class="tp">mixed</code> <strong>node</strong>
		<p>This can be a DOM node, jQuery node or selector pointing to an element within the tree. If you use the UI plugin - pass <code>null</code> to use the currently selected items.</p>
	</li>
</ul>

<div style="height:1px; visibility:hidden; overflow:hidden;"><span id="check_move">&#160;</span></div>
<h3 id="move_node">.check_move ( ), .move_node ( )</h3>
<p>Both functions are overwritten from the <a href="core.html#check_move">core</a> in order to implement the new functionality.</p>

<h3 id="cut">.cut ( node )</h3>
<p>Cuts a node (prepares it for pasting).</p>
<ul class="arguments">
	<li>
		<code class="tp">mixed</code> <strong>node</strong>
		<p>This can be a DOM node, jQuery node or selector pointing to an element within the tree. If you use the UI plugin - pass <code>null</code> to use the currently selected item.</p>
	</li>
</ul>

<h3 id="copy">.copy ( node )</h3>
<p>Copies a node (prepares it for pasting).</p>
<ul class="arguments">
	<li>
		<code class="tp">mixed</code> <strong>node</strong>
		<p>This can be a DOM node, jQuery node or selector pointing to an element within the tree. If you use the UI plugin - pass <code>null</code> to use the currently selected item.</p>
	</li>
</ul>

<h3 id="paste">.paste ( node )</h3>
<p>Pastes copied or cut nodes inside a node.</p>
<ul class="arguments">
	<li>
		<code class="tp">mixed</code> <strong>node</strong>
		<p>This can be a DOM node, jQuery node or selector pointing to an element within the tree. If you use the UI plugin - pass <code>null</code> to use the currently selected item.</p>
	</li>
</ul>

</div>

</div>
</body>
</html>