|
525
|
1 |
<!DOCTYPE html> |
|
|
2 |
<html lang="en"> |
|
|
3 |
<head> |
|
|
4 |
<meta charset="utf-8"> |
|
|
5 |
<title>Example: Basic Top Nav</title> |
|
|
6 |
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=PT+Sans:400,700,400italic,700italic"> |
|
|
7 |
<link rel="stylesheet" href="../../build/cssgrids/cssgrids-min.css"> |
|
|
8 |
<link rel="stylesheet" href="../assets/css/main.css"> |
|
|
9 |
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css"> |
|
|
10 |
<link rel="shortcut icon" type="image/png" href="../assets/favicon.png"> |
|
|
11 |
<script src="../../build/yui/yui-min.js"></script> |
|
|
12 |
|
|
|
13 |
</head> |
|
|
14 |
<body> |
|
|
15 |
<!-- |
|
|
16 |
<a href="https://github.com/yui/yui3"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a> |
|
|
17 |
--> |
|
|
18 |
<div id="doc"> |
|
|
19 |
<div id="hd"> |
|
|
20 |
<h1><img src="http://yuilibrary.com/img/yui-logo.png"></h1> |
|
|
21 |
</div> |
|
|
22 |
|
|
|
23 |
|
|
|
24 |
<h1>Example: Basic Top Nav</h1> |
|
|
25 |
<div class="yui3-g"> |
|
|
26 |
<div class="yui3-u-3-4"> |
|
|
27 |
<div id="main"> |
|
|
28 |
<div class="content"><div class="intro"> |
|
|
29 |
<p> |
|
|
30 |
This example demonstrates how to create a traditional, two-column page layout (<a href="../cssgrids/index.html">using Grids</a>) with top navigation featuring drop-down menus. |
|
|
31 |
</p> |
|
|
32 |
</div> |
|
|
33 |
|
|
|
34 |
<div class="example newwindow"> |
|
|
35 |
<a href="node-menunav-2-example.html" target="_blank" class="button"> |
|
|
36 |
View Example in New Window |
|
|
37 |
</a> |
|
|
38 |
</div> |
|
|
39 |
|
|
|
40 |
<h2>Setting Up the HTML</h2> |
|
|
41 |
|
|
|
42 |
<p> |
|
|
43 |
Begin by including the <a href="../cssgrids/index.html#dependencies">CSS Grids dependencies</a> and grid |
|
|
44 |
markup (this example uses a 2 column version of the |
|
|
45 |
<a href="../cssgrids/cssgrids-fluid.html">Fluid Page Template</a> with a 160px left column). |
|
|
46 |
Add the markup for the menu to the left column of the grid. |
|
|
47 |
</p> |
|
|
48 |
<p> |
|
|
49 |
<strong>Note:</strong> be sure to add the <code>yui3-skin-sam</code> classname to the |
|
|
50 |
page's <code><body></code> element or to a parent element of the widget in order to apply |
|
|
51 |
the default CSS skin. See <a href="http://yuilibrary.com/yui/docs/tutorials/skins/">Understanding Skinning</a>. |
|
|
52 |
</p> |
|
|
53 |
<pre class="code prettyprint"><body class="yui3-skin-sam"> <!-- You need this skin class --></pre> |
|
|
54 |
|
|
|
55 |
|
|
|
56 |
|
|
|
57 |
<p> |
|
|
58 |
The root menu of menus built using the MenuNav Node Plugin can have a verical or horizontal |
|
|
59 |
orientation. The default orientation for menus is vertical, but can be easily switched to |
|
|
60 |
horizontal by applying a class of <code>yui3-menu-horizontal</code> to the node representing the |
|
|
61 |
root menu's bounding box, as illustrated below: |
|
|
62 |
</p> |
|
|
63 |
|
|
|
64 |
<pre class="code prettyprint"><div id="productsandservices" class="yui3-menu yui3-menu-horizontal"><!-- Bounding box --> |
|
|
65 |
<div class="yui3-menu-content"><!-- Content box --> |
|
|
66 |
<ul> |
|
|
67 |
<!-- Menu items --> |
|
|
68 |
</ul> |
|
|
69 |
</div> |
|
|
70 |
</div></pre> |
|
|
71 |
|
|
|
72 |
|
|
|
73 |
|
|
|
74 |
<h2>Initializing the Menu</h2> |
|
|
75 |
<p> |
|
|
76 |
With the menu markup in place, retrieve the Node instance representing the root |
|
|
77 |
menu (<code><div id="productsandservices"></code>) and call the |
|
|
78 |
<a href="http://yuilibrary.com/yui/docs/api/classes/Node.html#method_plug"><code>plug</code></a> |
|
|
79 |
passing in a reference to the MenuNav Node Plugin. |
|
|
80 |
</p> |
|
|
81 |
|
|
|
82 |
<pre class="code prettyprint">// Call the "use" method, passing in "node-menunav". This will load the |
|
|
83 |
// script and CSS for the MenuNav Node Plugin and all of the required |
|
|
84 |
// dependencies. |
|
|
85 |
|
|
|
86 |
YUI().use('node-menunav', function(Y) { |
|
|
87 |
|
|
|
88 |
// Retrieve the Node instance representing the root menu |
|
|
89 |
// (<div id="productsandservices">) and call the "plug" method |
|
|
90 |
// passing in a reference to the MenuNav Node Plugin. |
|
|
91 |
|
|
|
92 |
var menu = Y.one("#productsandservices"); |
|
|
93 |
|
|
|
94 |
menu.plug(Y.Plugin.NodeMenuNav); |
|
|
95 |
|
|
|
96 |
});</pre> |
|
|
97 |
|
|
|
98 |
|
|
|
99 |
<p> |
|
|
100 |
<em>Note:</em> In keeping with the |
|
|
101 |
<a href="http://developer.yahoo.com/performance/">Exceptional Performance</a> |
|
|
102 |
team's recommendation, the script block used to instantiate the menu will be |
|
|
103 |
<a href="http://developer.yahoo.com/performance/rules.html#js_bottom">placed at the bottom of the page</a>. |
|
|
104 |
This not only improves performance, it helps ensure that the DOM subtree of the |
|
|
105 |
element representing the root menu |
|
|
106 |
(<code><div id="productsandservices"></code>) is ready to be scripted. |
|
|
107 |
</p> |
|
|
108 |
</div> |
|
|
109 |
</div> |
|
|
110 |
</div> |
|
|
111 |
|
|
|
112 |
<div class="yui3-u-1-4"> |
|
|
113 |
<div class="sidebar"> |
|
|
114 |
|
|
|
115 |
|
|
|
116 |
|
|
|
117 |
<div class="sidebox"> |
|
|
118 |
<div class="hd"> |
|
|
119 |
<h2 class="no-toc">Examples</h2> |
|
|
120 |
</div> |
|
|
121 |
|
|
|
122 |
<div class="bd"> |
|
|
123 |
<ul class="examples"> |
|
|
124 |
|
|
|
125 |
|
|
|
126 |
<li data-description="Creating left navigation using the MenuNav Node Plugin."> |
|
|
127 |
<a href="menunav-leftnav.html">Basic Left Nav</a> |
|
|
128 |
</li> |
|
|
129 |
|
|
|
130 |
|
|
|
131 |
|
|
|
132 |
<li data-description="Creating top navigation using the MenuNav Node Plugin"> |
|
|
133 |
<a href="node-menunav-2.html">Basic Top Nav</a> |
|
|
134 |
</li> |
|
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
|
138 |
<li data-description="Creating menu button navigation using the MenuNav Node Plugin"> |
|
|
139 |
<a href="node-menunav-3.html">Menu Button Top Nav</a> |
|
|
140 |
</li> |
|
|
141 |
|
|
|
142 |
|
|
|
143 |
|
|
|
144 |
<li data-description="Creating split button navigation using the MenuNav Node Plugin"> |
|
|
145 |
<a href="node-menunav-4.html">Split Button Top Nav</a> |
|
|
146 |
</li> |
|
|
147 |
|
|
|
148 |
|
|
|
149 |
|
|
|
150 |
<li data-description="Adding shadows to submenus of a left nav using the MenuNav Node Plugin"> |
|
|
151 |
<a href="node-menunav-5.html">Left Nav with Submenus with Shadows</a> |
|
|
152 |
</li> |
|
|
153 |
|
|
|
154 |
|
|
|
155 |
|
|
|
156 |
<li data-description="Adding rounded corners to submenus of a left nav using the MenuNav Node Plugin"> |
|
|
157 |
<a href="node-menunav-6.html">Left Nav With Submenus With Rounded Corners</a> |
|
|
158 |
</li> |
|
|
159 |
|
|
|
160 |
|
|
|
161 |
|
|
|
162 |
<li data-description="Skining a menu built using the MenuNav Node Plugin to look like the menus on Flickr"> |
|
|
163 |
<a href="node-menunav-7.html">Skinning Menus Created Using the MenuNav Node Plugin</a> |
|
|
164 |
</li> |
|
|
165 |
|
|
|
166 |
|
|
|
167 |
</ul> |
|
|
168 |
</div> |
|
|
169 |
</div> |
|
|
170 |
|
|
|
171 |
|
|
|
172 |
|
|
|
173 |
</div> |
|
|
174 |
</div> |
|
|
175 |
</div> |
|
|
176 |
</div> |
|
|
177 |
|
|
|
178 |
<script src="../assets/vendor/prettify/prettify-min.js"></script> |
|
|
179 |
<script>prettyPrint();</script> |
|
|
180 |
|
|
|
181 |
<script> |
|
|
182 |
YUI.Env.Tests = { |
|
|
183 |
examples: [], |
|
|
184 |
project: '../assets', |
|
|
185 |
assets: '../assets/node-menunav', |
|
|
186 |
name: 'node-menunav-2', |
|
|
187 |
title: 'Basic Top Nav', |
|
|
188 |
newWindow: 'true', |
|
|
189 |
auto: false |
|
|
190 |
}; |
|
|
191 |
YUI.Env.Tests.examples.push('menunav-leftnav'); |
|
|
192 |
YUI.Env.Tests.examples.push('node-menunav-2'); |
|
|
193 |
YUI.Env.Tests.examples.push('node-menunav-3'); |
|
|
194 |
YUI.Env.Tests.examples.push('node-menunav-4'); |
|
|
195 |
YUI.Env.Tests.examples.push('node-menunav-5'); |
|
|
196 |
YUI.Env.Tests.examples.push('node-menunav-6'); |
|
|
197 |
YUI.Env.Tests.examples.push('node-menunav-7'); |
|
|
198 |
|
|
|
199 |
</script> |
|
|
200 |
<script src="../assets/yui/test-runner.js"></script> |
|
|
201 |
|
|
|
202 |
|
|
|
203 |
|
|
|
204 |
</body> |
|
|
205 |
</html> |