Skip to content
Snippets Groups Projects
sample-accordion.html 3.16 KiB
Newer Older
  • Learn to ignore specific revisions
  • Laura Cappelli's avatar
    Laura Cappelli committed
    <!DOCTYPE html>
    <html>
    <head>
    	<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
    	<title>Fancytree - Example: Accordion</title>
    
    	<script src="//code.jquery.com/jquery-3.2.1.min.js"></script>
    	<script src="//code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
    
    	<link href="../src/skin-win8/ui.fancytree.css" rel="stylesheet">
    	<script src="../src/jquery.fancytree.js"></script>
    
    	<!-- Themeroller switcher -->
    	<link href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet">
    	<script src="http://jqueryui.com/themeroller/themeswitchertool/"></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">
    
    ul.fancytree-container {
    	border: 1px solid gray;
    	width: 200px;
    }
    ul.fancytree-container >li {
    	width: 100%;
    }
    ul.fancytree-container >li >ul { /* don't indent level-2 nodes */
    	padding-left: 0;
    }
    ul.fancytree-container >li >.fancytree-node {
    	display: inline-block;
    	width: 100%;
    	background-color: #d0d0d0;
    }
    ul.fancytree-container >li >.fancytree-node .fancytree-title{
    	width: 100%;
    }
    /* Hide icons and expanders for top-level nodes*/
    ul.fancytree-container >li >.fancytree-node .fancytree-icon,
    ul.fancytree-container >li >.fancytree-node .fancytree-expander
    /*ul.fancytree-container >li >ul >li >span.fancytree-node span.fancytree-expander*/
    {
    	display: none;
    }
    </style>
    
    <!-- Add code to initialize the tree when the document is loaded: -->
    <script type="text/javascript">
    	$(function(){
    		// Attach the fancytree widget to an existing <div id="tree"> element
    		// and pass the tree options as an argument to the fancytree() function:
    		$("#tree").fancytree({
    			autoCollapse: true,
    			icon: false,
    			renderNode: function(event, data){
    				if(data.node.getLevel() === 1){
    					$(data.node.span).addClass("ui-accordion-header");
    				}
    			}
    		});
    	});
    </script>
    </head>
    <body class="example">
    	<h1>Example: accordion</h1>
    	<div class="description">
    		This sample skin that mimics an accordion.
    	</div>
    	<div>
    		<label for="skinswitcher">Skin:</label> <select id="skinswitcher"></select>
    	</div>
    	<!-- Add a <table> element where the tree should appear: -->
    	<div id="tree">
    	<ul>
    	<li class="folder">Foo
    		<ul>
    		<li>Node foo 1
    			<ul>
    			<li>Node foo 1.1
    			<li>Node foo 1.2
    			<li>Node foo 1.3
    			</ul>
    		<li>Node foo 2
    		<li>Node foo 3
    		</ul>
    	<li class="folder">Bar
    		<ul>
    		<li>Node bar 1
    		<li>Node bar 2
    		<li>Node bar 3
    		</ul>
    	<li class="folder">Baz
    		<ul>
    		<li>Node baz 1
    		<li>Node baz 2
    		<li>Node baz 3
    		</ul>
    	</ul>
    	</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>