jquery.fancytree
Version: 
jQuery tree view / tree grid plugin with support for keyboard, inline editing, filtering, checkboxes, drag'n'drop, and lazy loading
153 lines (135 loc) • 4 kB
HTML
<html>
<head>
	<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
	<title>Test Extensions - Fancytree</title>
	<!--
	<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css">
	<script src="//code.jquery.com/jquery-1.12.1.min.js"></script>
	<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
	<script src="../src/jquery.fancytree.childcounter.js"></script>
	<script src="../src/jquery.fancytree.childcounter2.js"></script>
	-->
	<script src="../lib/jquery.js"></script>
	<script src="../lib/jquery-ui.custom.js"></script>
	<link href="../src/skin-win8/ui.fancytree.css" rel="stylesheet">
	<script src="../src/jquery.fancytree.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="../demo/sample.css" rel="stylesheet">
	<script src="../demo/sample.js"></script>
	<!-- End_Exclude -->
<style type="text/css">
span.fancytree-icon {
	position: relative;
}
span.fancytree-childcounter {
	color:#800;
/*	background:#8ee; */
/*	border: 1px solid gray; */
	position: absolute;
	top: -6px;
	right: -6px;
	min-width:10px;
	height: 10px;
	border-radius: 50%;
	padding: 2px;
	text-align: center;
	font-size: 9px;
}
</style>
<!-- Add code to initialize the tree when the document is loaded: -->
<script type="text/javascript">
$(function(){
	;(function($, undefined) {
		"use strict";
		var CNT = 0;
		$.ui.fancytree.registerExtension({
			name: "sampleExt1",
			version: "1.0.0",
			options: {
				opt1: true
			},
			treeInit: function(ctx){
				var tree = this, // same as ctx.tree,
					opts = ctx.options,
					extOpts = ctx.options.sampleExt1;
				this.debug("sampleExt1.treeInit start...");
				if( CNT++ > 3 ) $.error("recursion");
				this._superApply(arguments);
				this.debug("sampleExt1.treeInit done.");
			}
		});
	}(jQuery)); // End of namespace closure
	;(function($, undefined) {
		"use strict";
		$.ui.fancytree.registerExtension({
			name: "sampleExt2",
			version: "1.0.0",
			options: {
				opt1: true,
			},
			treeInit: function(ctx){
				var tree = this, // same as ctx.tree,
					opts = ctx.options,
					extOpts = ctx.options.sampleExt2;
				this.debug("sampleExt2.treeInit start...");
				this._superApply(arguments);
				this.debug("sampleExt2.treeInit done.");
			}
		});
	}(jQuery)); // End of namespace closure
	/* The tree uses both exetensions */
	$("#tree").fancytree({
		extensions: ["sampleExt1", "sampleExt2"],
		source: {
			url: "../demo/ajax-tree-plain.json"
		},
		sampleExt1: {
			opt1: "set by tree"
		},
		sampleExt2: {
			opt1: "set by tree (2)"
		},
		lazyLoad: function(event, data) {
			data.result = {url: "ajax-sub2.json"}
		}
	});
});
</script>
</head>
<body class="example">
	<h1>Example: 'childcounter' extension</h1>
	<div class="description">
		<p>
			Display count of children at parent node.
		</p>
		<p>
			The main puropse of this extension is to serve as an example for
			Fanytree's the general extension concept:
			<br>
			See the
			<a class="external" href="../doc/annotated-src/src/jquery.fancytree.childcounter.html">annotated source</a>
			to learn how to write a Fancytree extension.<br>
			Click the [View source code] link below, to see how an extension is used.
		</p>
		<p>
			<b>Status</b>: pre-alpha
		</p>
	</div>
	<!-- 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>