|
525
|
1 |
<!DOCTYPE html> |
|
|
2 |
<html lang="en"> |
|
|
3 |
<head> |
|
|
4 |
<meta charset="utf-8"> |
|
|
5 |
<title>TabView</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 |
<a href="#toc" class="jump">Jump to Table of Contents</a> |
|
|
24 |
|
|
|
25 |
|
|
|
26 |
<h1>TabView</h1> |
|
|
27 |
<div class="yui3-g"> |
|
|
28 |
<div class="yui3-u-3-4"> |
|
|
29 |
<div id="main"> |
|
|
30 |
<div class="content"><div class="intro"> |
|
|
31 |
<p>The TabView widget is a UI control that enables the user switch between content panels.</p> |
|
|
32 |
|
|
|
33 |
</div> |
|
|
34 |
<h2 id="getting-started">Getting Started</h2> |
|
|
35 |
|
|
|
36 |
<p> |
|
|
37 |
To include the source files for TabView and its dependencies, first load |
|
|
38 |
the YUI seed file if you haven't already loaded it. |
|
|
39 |
</p> |
|
|
40 |
|
|
|
41 |
<pre class="code prettyprint"><script src="http://yui.yahooapis.com/3.10.3/build/yui/yui-min.js"></script></pre> |
|
|
42 |
|
|
|
43 |
|
|
|
44 |
<p> |
|
|
45 |
Next, create a new YUI instance for your application and populate it with the |
|
|
46 |
modules you need by specifying them as arguments to the <code>YUI().use()</code> method. |
|
|
47 |
YUI will automatically load any dependencies required by the modules you |
|
|
48 |
specify. |
|
|
49 |
</p> |
|
|
50 |
|
|
|
51 |
<pre class="code prettyprint"><script> |
|
|
52 |
// Create a new YUI instance and populate it with the required modules. |
|
|
53 |
YUI().use('tabview', function (Y) { |
|
|
54 |
// TabView is available and ready for use. Add implementation |
|
|
55 |
// code here. |
|
|
56 |
}); |
|
|
57 |
</script></pre> |
|
|
58 |
|
|
|
59 |
|
|
|
60 |
<p> |
|
|
61 |
For more information on creating YUI instances and on the |
|
|
62 |
<a href="http://yuilibrary.com/yui/docs/api/classes/YUI.html#method_use"><code>use()</code> method</a>, see the |
|
|
63 |
documentation for the <a href="../yui/index.html">YUI Global Object</a>. |
|
|
64 |
</p> |
|
|
65 |
|
|
|
66 |
<h2 id="anatomy">Anatomy of a TabView</h2> |
|
|
67 |
|
|
|
68 |
<h3 id="minimum-markup-requirement">Minimum Markup Requirement</h3> |
|
|
69 |
|
|
|
70 |
<p> |
|
|
71 |
<strong>Note:</strong> be sure to add the <code>yui3-skin-sam</code> classname to the |
|
|
72 |
page's <code><body></code> element or to a parent element of the widget in order to apply |
|
|
73 |
the default CSS skin. See <a href="http://yuilibrary.com/yui/docs/tutorials/skins/">Understanding Skinning</a>. |
|
|
74 |
</p> |
|
|
75 |
<pre class="code prettyprint"><body class="yui3-skin-sam"> <!-- You need this skin class --></pre> |
|
|
76 |
|
|
|
77 |
|
|
|
78 |
<p>A <code>TabView</code> consists of a list of links that target a content element.</p> |
|
|
79 |
<p>The basic markup needed to create from HTML is the following:</p> |
|
|
80 |
|
|
|
81 |
<pre class="code prettyprint"><div id="demo"> |
|
|
82 |
<ul> |
|
|
83 |
<li><a href="#foo">foo</a></li> |
|
|
84 |
<li><a href="#bar">bar</a></li> |
|
|
85 |
<li><a href="#baz">baz</a></li> |
|
|
86 |
</ul> |
|
|
87 |
<div> |
|
|
88 |
<div id="foo">foo content</div> |
|
|
89 |
<div id="bar">bar content</div> |
|
|
90 |
<div id="baz">baz content</div> |
|
|
91 |
</div> |
|
|
92 |
</div></pre> |
|
|
93 |
|
|
|
94 |
|
|
|
95 |
<h3 id="rendered-markup">Rendered Markup</h3> |
|
|
96 |
<p>After a <code>TabView</code> is rendered, the final markup becomes: |
|
|
97 |
|
|
|
98 |
<pre class="code prettyprint"><div class="yui3-widget yui3-tabview"> |
|
|
99 |
<div id="demo" class="yui3-tabview-content"> |
|
|
100 |
<ul class="yui3-tabview-list"> |
|
|
101 |
<li class="yui3-tab yui3-widget yui3-tab-selected"> |
|
|
102 |
<a href="#foo" class="yui3-tab-label yui3-tab-content">foo</a> |
|
|
103 |
</li> |
|
|
104 |
<li class="yui3-tab yui3-widget"> |
|
|
105 |
<a href="#bar" class="yui3-tab-label yui3-tab-content">bar</a> |
|
|
106 |
</li> |
|
|
107 |
<li class="yui3-tab yui3-widget"> |
|
|
108 |
<a href="#baz" class="yui3-tab-label yui3-tab-content">baz</a> |
|
|
109 |
</li> |
|
|
110 |
</ul> |
|
|
111 |
<div class="yui3-tabview-panel"> |
|
|
112 |
<div id="foo" class="yui3-tab-panel">foo content</div> |
|
|
113 |
<div id="bar" class="yui3-tab-panel">bar content</div> |
|
|
114 |
<div id="baz" class="yui3-tab-panel">baz content</div> |
|
|
115 |
</div> |
|
|
116 |
</div> |
|
|
117 |
</div></pre> |
|
|
118 |
|
|
|
119 |
|
|
|
120 |
<h2 id="instantiating">Creating and Configuring a TabView</h2> |
|
|
121 |
<p>A <code>TabView</code> instance can be created from existing markup on the page, or dynamically |
|
|
122 |
using JavaScript.</p> |
|
|
123 |
|
|
|
124 |
<h3 id="from-markup">From Existing Markup</h3> |
|
|
125 |
<p>To create from existing markup, first conform to the basic markup pattern, then create a |
|
|
126 |
new <code>TabView</code> instance, pointing to the existing <code>srcNode</code>, and render.</p> |
|
|
127 |
|
|
|
128 |
<pre class="code prettyprint"><div id="demo"> |
|
|
129 |
<ul> |
|
|
130 |
<li><a href="#foo">foo</a></li> |
|
|
131 |
<li><a href="#bar">bar</a></li> |
|
|
132 |
<li><a href="#baz">baz</a></li> |
|
|
133 |
</ul> |
|
|
134 |
<div> |
|
|
135 |
<div id="foo">foo content</div> |
|
|
136 |
<div id="bar">bar content</div> |
|
|
137 |
<div id="baz">baz content</div> |
|
|
138 |
</div> |
|
|
139 |
</div> |
|
|
140 |
|
|
|
141 |
<script> |
|
|
142 |
YUI().use('tabview', function(Y) { |
|
|
143 |
var tabview = new Y.TabView({ |
|
|
144 |
srcNode: '#demo' |
|
|
145 |
}); |
|
|
146 |
|
|
|
147 |
tabview.render(); |
|
|
148 |
}); |
|
|
149 |
</script></pre> |
|
|
150 |
|
|
|
151 |
|
|
|
152 |
<h3 id="from-js">From JavaScript</h3> |
|
|
153 |
<p>To create purely from JavaScript, all that is required is passing the <code>TabView</code> |
|
|
154 |
constructor a list of <code>children</code> containing their respective <code>label</code> |
|
|
155 |
and <content> attributes, and call render. As with all YUI <code>Widget</code>s, |
|
|
156 |
render takes an optional container to render into, or defaults to the <code>body</code> element.</p> |
|
|
157 |
|
|
|
158 |
<pre class="code prettyprint"><div id="demo"></div> |
|
|
159 |
<script> |
|
|
160 |
YUI().use('tabview', function(Y) { |
|
|
161 |
var tabview = new Y.TabView({ |
|
|
162 |
children: [{ |
|
|
163 |
label: 'foo', |
|
|
164 |
content: '<p>foo content</p>' |
|
|
165 |
}, { |
|
|
166 |
label: 'bar', |
|
|
167 |
content: '<p>bar content</p>' |
|
|
168 |
}, { |
|
|
169 |
label: 'baz', |
|
|
170 |
content: '<p>baz content</p>' |
|
|
171 |
}] |
|
|
172 |
}); |
|
|
173 |
|
|
|
174 |
tabview.render('#demo'); |
|
|
175 |
}); |
|
|
176 |
</script></pre> |
|
|
177 |
|
|
|
178 |
|
|
|
179 |
<h2 id="skinning">Skinning TabView</h2> |
|
|
180 |
<p>The <code>TabView</code> comes with a basic skin by default. This can be easily |
|
|
181 |
customized using the rich set of <a href="#rendered-markup">classNames</a>.</p> |
|
|
182 |
<p>For a more polished look and feel, we also ship with the "sam skin", which can |
|
|
183 |
be applied by adding the <code>yui3-skin-sam</code> className to some ancestor:</p> |
|
|
184 |
|
|
|
185 |
<pre class="code prettyprint"><body class="yui3-skin-sam"> |
|
|
186 |
... |
|
|
187 |
<div id="demo"> |
|
|
188 |
<ul> |
|
|
189 |
<li><a href="#foo">foo</a></li> |
|
|
190 |
<li><a href="#bar">bar</a></li> |
|
|
191 |
<li><a href="#baz">baz</a></li> |
|
|
192 |
</ul> |
|
|
193 |
<div> |
|
|
194 |
<div id="foo">foo content</div> |
|
|
195 |
<div id="bar">bar content</div> |
|
|
196 |
<div id="baz">baz content</div> |
|
|
197 |
</div> |
|
|
198 |
</div> |
|
|
199 |
... |
|
|
200 |
</body></pre> |
|
|
201 |
|
|
|
202 |
|
|
|
203 |
<h2 id="events">TabView Events</h2> |
|
|
204 |
<p>TabViews fire the following events during operation:</p> |
|
|
205 |
<table> |
|
|
206 |
<thead> |
|
|
207 |
<tr> |
|
|
208 |
<th>Event</th> |
|
|
209 |
<th>When</th> |
|
|
210 |
<th>Payload</th> |
|
|
211 |
</tr> |
|
|
212 |
</thead> |
|
|
213 |
<tbody> |
|
|
214 |
<tr> |
|
|
215 |
<td><code>addChild</code></td> |
|
|
216 |
<td>a Tab is added to the TabView</td> |
|
|
217 |
<td><code>child, index</code></td> |
|
|
218 |
</tr> |
|
|
219 |
<tr> |
|
|
220 |
<td><code>removeChild</code></td> |
|
|
221 |
<td>a Tab is removed from the TabView</td> |
|
|
222 |
<td><code>child, index</code></td> |
|
|
223 |
</tr> |
|
|
224 |
<tr> |
|
|
225 |
<td><code>selectionChange</code></td> |
|
|
226 |
<td>the selected tab changes</td> |
|
|
227 |
<td><code>prevVal, newVal</code></td> |
|
|
228 |
</tr> |
|
|
229 |
<tr> |
|
|
230 |
<td><code>render</code></td> |
|
|
231 |
<td>a Tabview is rendered</td> |
|
|
232 |
<td>Normal change event signature (<code>newVal</code>, <code>prevVal</code>, etc). When dragging, extra event property <code>ddEvent : (drag:drag event)</code> is added</td> |
|
|
233 |
</tr> |
|
|
234 |
</tbody> |
|
|
235 |
</table> |
|
|
236 |
|
|
|
237 |
<p>This is not an exhaustive list. See the <a href="http://yuilibrary.com/yui/docs/api/module_tabview.html">API docs</a> for a complete listing.</p> |
|
|
238 |
|
|
|
239 |
</div> |
|
|
240 |
</div> |
|
|
241 |
</div> |
|
|
242 |
|
|
|
243 |
<div class="yui3-u-1-4"> |
|
|
244 |
<div class="sidebar"> |
|
|
245 |
|
|
|
246 |
<div id="toc" class="sidebox"> |
|
|
247 |
<div class="hd"> |
|
|
248 |
<h2 class="no-toc">Table of Contents</h2> |
|
|
249 |
</div> |
|
|
250 |
|
|
|
251 |
<div class="bd"> |
|
|
252 |
<ul class="toc"> |
|
|
253 |
<li> |
|
|
254 |
<a href="#getting-started">Getting Started</a> |
|
|
255 |
</li> |
|
|
256 |
<li> |
|
|
257 |
<a href="#anatomy">Anatomy of a TabView</a> |
|
|
258 |
<ul class="toc"> |
|
|
259 |
<li> |
|
|
260 |
<a href="#minimum-markup-requirement">Minimum Markup Requirement</a> |
|
|
261 |
</li> |
|
|
262 |
<li> |
|
|
263 |
<a href="#rendered-markup">Rendered Markup</a> |
|
|
264 |
</li> |
|
|
265 |
</ul> |
|
|
266 |
</li> |
|
|
267 |
<li> |
|
|
268 |
<a href="#instantiating">Creating and Configuring a TabView</a> |
|
|
269 |
<ul class="toc"> |
|
|
270 |
<li> |
|
|
271 |
<a href="#from-markup">From Existing Markup</a> |
|
|
272 |
</li> |
|
|
273 |
<li> |
|
|
274 |
<a href="#from-js">From JavaScript</a> |
|
|
275 |
</li> |
|
|
276 |
</ul> |
|
|
277 |
</li> |
|
|
278 |
<li> |
|
|
279 |
<a href="#skinning">Skinning TabView</a> |
|
|
280 |
</li> |
|
|
281 |
<li> |
|
|
282 |
<a href="#events">TabView Events</a> |
|
|
283 |
</li> |
|
|
284 |
</ul> |
|
|
285 |
</div> |
|
|
286 |
</div> |
|
|
287 |
|
|
|
288 |
|
|
|
289 |
|
|
|
290 |
<div class="sidebox"> |
|
|
291 |
<div class="hd"> |
|
|
292 |
<h2 class="no-toc">Examples</h2> |
|
|
293 |
</div> |
|
|
294 |
|
|
|
295 |
<div class="bd"> |
|
|
296 |
<ul class="examples"> |
|
|
297 |
|
|
|
298 |
|
|
|
299 |
<li data-description="This example shows how to create a TabView wigdet from existing HTML."> |
|
|
300 |
<a href="tabview-basic.html">TabView from Existing Markup</a> |
|
|
301 |
</li> |
|
|
302 |
|
|
|
303 |
|
|
|
304 |
|
|
|
305 |
<li data-description="This example shows how to create a TabView wigdet from JavaScript."> |
|
|
306 |
<a href="tabview-fromjs.html">Dynamic TabView from JavaScript</a> |
|
|
307 |
</li> |
|
|
308 |
|
|
|
309 |
|
|
|
310 |
|
|
|
311 |
<li data-description="This example shows how to add and remove Tabs."> |
|
|
312 |
<a href="tabview-add-remove.html">Adding and Removing Tabs</a> |
|
|
313 |
</li> |
|
|
314 |
|
|
|
315 |
|
|
|
316 |
|
|
|
317 |
<li data-description="This example shows how to load tab content remotely using a YQL plugin."> |
|
|
318 |
<a href="tabview-yql.html">Loading Tab Content</a> |
|
|
319 |
</li> |
|
|
320 |
|
|
|
321 |
|
|
|
322 |
|
|
|
323 |
|
|
|
324 |
</ul> |
|
|
325 |
</div> |
|
|
326 |
</div> |
|
|
327 |
|
|
|
328 |
|
|
|
329 |
|
|
|
330 |
<div class="sidebox"> |
|
|
331 |
<div class="hd"> |
|
|
332 |
<h2 class="no-toc">Examples That Use This Component</h2> |
|
|
333 |
</div> |
|
|
334 |
|
|
|
335 |
<div class="bd"> |
|
|
336 |
<ul class="examples"> |
|
|
337 |
|
|
|
338 |
|
|
|
339 |
|
|
|
340 |
|
|
|
341 |
|
|
|
342 |
|
|
|
343 |
|
|
|
344 |
|
|
|
345 |
|
|
|
346 |
|
|
|
347 |
<li data-description="Demonstrates how to add browser history support to a TabView widget using the History Utility."> |
|
|
348 |
<a href="../history/history-tabview.html">History + TabView</a> |
|
|
349 |
</li> |
|
|
350 |
|
|
|
351 |
|
|
|
352 |
</ul> |
|
|
353 |
</div> |
|
|
354 |
</div> |
|
|
355 |
|
|
|
356 |
</div> |
|
|
357 |
</div> |
|
|
358 |
</div> |
|
|
359 |
</div> |
|
|
360 |
|
|
|
361 |
<script src="../assets/vendor/prettify/prettify-min.js"></script> |
|
|
362 |
<script>prettyPrint();</script> |
|
|
363 |
|
|
|
364 |
<script> |
|
|
365 |
YUI.Env.Tests = { |
|
|
366 |
examples: [], |
|
|
367 |
project: '../assets', |
|
|
368 |
assets: '../assets/tabview', |
|
|
369 |
name: 'tabview', |
|
|
370 |
title: 'TabView', |
|
|
371 |
newWindow: '', |
|
|
372 |
auto: false |
|
|
373 |
}; |
|
|
374 |
YUI.Env.Tests.examples.push('tabview-basic'); |
|
|
375 |
YUI.Env.Tests.examples.push('tabview-fromjs'); |
|
|
376 |
YUI.Env.Tests.examples.push('tabview-add-remove'); |
|
|
377 |
YUI.Env.Tests.examples.push('tabview-yql'); |
|
|
378 |
YUI.Env.Tests.examples.push('history-tabview'); |
|
|
379 |
|
|
|
380 |
</script> |
|
|
381 |
<script src="../assets/yui/test-runner.js"></script> |
|
|
382 |
|
|
|
383 |
|
|
|
384 |
|
|
|
385 |
</body> |
|
|
386 |
</html> |