5
<title>Example: Basic Left Nav</title>
6
<link rel="stylesheet" href="http://yui.yahooapis.com/3.4.0pr3/build/cssgrids/grids-min.css">
7
<link rel="stylesheet" href="../assets/css/main.css">
8
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
9
<script src="../../build/yui/yui-min.js"></script>
14
<h1>Example: Basic Left Nav</h1>
19
<div id="main" class="yui3-u">
20
<div class="content"><div class="intro">
22
This example demonstrates how to create a traditional, two-column page layout
23
(<a href="../cssgrids/index.html">using Grids</a>) with a set of fly-out menu navigation
28
<div class="example newwindow">
29
<a href="menunav-leftnav-example.html" target="_blank" class="button">
30
View Example in New Window
34
<h2>Setting Up the HTML</h2>
37
Begin by including the <a href="../cssgrids/index.html#dependencies">CSS Grids dependencies</a> and grid
38
markup (this example uses a 2 column version of the
39
<a href="../cssgrids/cssgrids-fluid.html">Fluid Page Template</a> with a 160px left column).
40
Add the markup for the menu to the left column of the grid, and the class <code>yui3-skin-sam</code>
41
to the <code><body></code>.
45
The root menu of menus built using the MenuNav Node Plugin can have a verical or horizontal
46
orientation. The default orientation for menus is vertical, but can be easily switched to
47
horizontal by applying a class of <code>yui3-menu-horizontal</code> to the node representing the
48
root menu's bounding box, as illustrated below:
51
<pre class="code prettyprint"><div id="productsandservices" class="yui3-menu yui3-menu-horizontal"><!-- Bounding box -->
52
<div class="yui3-menu-content"><!-- Content box -->
54
<!-- Menu items -->
57
</div></pre>
60
<h2>Initializing the Menu</h2>
63
With the menu markup in place, retrieve the Node instance representing the root
64
menu (<code><div id="productsandservices"></code>) and call the
65
<a href="http://yuilibrary.com/yui/docs/api/classes/Node.html#method_plug"><code>plug</code></a>
66
passing in a reference to the MenuNav Node Plugin.
69
<pre class="code prettyprint">// Call the "use" method, passing in "node-menunav". This will load the
70
// script and CSS for the MenuNav Node Plugin and all of the required
71
// dependencies.
73
YUI().use('node-menunav', function(Y) {
75
// Retrieve the Node instance representing the root menu
76
// (<div id="productsandservices">) and call the "plug" method
77
// passing in a reference to the MenuNav Node Plugin.
79
var menu = Y.one("#productsandservices");
81
menu.plug(Y.Plugin.NodeMenuNav);
87
<em>Note:</em> In keeping with the
88
<a href="http://developer.yahoo.com/performance/">Exceptional Performance</a>
89
team's recommendation, the script block used to instantiate the menu will be
90
<a href="http://developer.yahoo.com/performance/rules.html#js_bottom">placed at the bottom of the page</a>.
91
This not only improves performance, it helps ensure that the DOM subtree of the
92
element representing the root menu
93
(<code><div id="productsandservices"></code>) is ready to be scripted.
98
<div id="sidebar" class="yui3-u">
102
<div class="sidebox">
104
<h2 class="no-toc">Examples</h2>
108
<ul class="examples">
111
<li data-description="Creating left navigation using the MenuNav Node Plugin.">
112
<a href="menunav-leftnav.html">Basic Left Nav</a>
117
<li data-description="Creating top navigation using the MenuNav Node Plugin">
118
<a href="node-menunav-2.html">Basic Top Nav</a>
123
<li data-description="Creating menu button navigation using the MenuNav Node Plugin">
124
<a href="node-menunav-3.html">Menu Button Top Nav</a>
129
<li data-description="Creating split button navigation using the MenuNav Node Plugin">
130
<a href="node-menunav-4.html">Split Button Top Nav</a>
135
<li data-description="Adding shadows to submenus of a left nav using the MenuNav Node Plugin">
136
<a href="node-menunav-5.html">Left Nav with Submenus with Shadows</a>
141
<li data-description="Adding rounded corners to submenus of a left nav using the MenuNav Node Plugin">
142
<a href="node-menunav-6.html">Left Nav With Submenus With Rounded Corners</a>
147
<li data-description="Skining a menu built using the MenuNav Node Plugin to look like the menus on Flickr">
148
<a href="node-menunav-7.html">Skinning Menus Created Using the MenuNav Node Plugin</a>
162
<script src="../assets/vendor/prettify/prettify-min.js"></script>
163
<script>prettyPrint();</script>