|
525
|
1 |
<!DOCTYPE html> |
|
|
2 |
<html lang="en"> |
|
|
3 |
<head> |
|
|
4 |
<meta charset="utf-8"> |
|
|
5 |
<title>Example: TabView from Existing Markup</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: TabView from Existing Markup</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>This example shows how to create a <code>TabView</code> widget from existing HTML on the page.</p> |
|
|
30 |
</div> |
|
|
31 |
|
|
|
32 |
<div class="example yui3-skin-sam"> |
|
|
33 |
<div id="demo"> |
|
|
34 |
<ul> |
|
|
35 |
<li><a href="#foo">foo</a></li> |
|
|
36 |
<li><a href="#bar">bar</a></li> |
|
|
37 |
<li><a href="#baz">baz</a></li> |
|
|
38 |
</ul> |
|
|
39 |
<div> |
|
|
40 |
<div id="foo"> |
|
|
41 |
<p>foo content</p> |
|
|
42 |
</div> |
|
|
43 |
<div id="bar"> |
|
|
44 |
<p>bar content</p> |
|
|
45 |
</div> |
|
|
46 |
<div id="baz"> |
|
|
47 |
<p>baz content</p> |
|
|
48 |
</div> |
|
|
49 |
</div> |
|
|
50 |
</div> |
|
|
51 |
|
|
|
52 |
<script type="text/javascript"> |
|
|
53 |
YUI().use('tabview', function(Y) { |
|
|
54 |
var tabview = new Y.TabView({srcNode:'#demo'}); |
|
|
55 |
tabview.render(); |
|
|
56 |
}); |
|
|
57 |
</script> |
|
|
58 |
|
|
|
59 |
</div> |
|
|
60 |
|
|
|
61 |
<h2>Creating A TabView From Existing Markup</h2> |
|
|
62 |
|
|
|
63 |
<p>A <code>TabView</code> can be created easily from existing markup, supporting a progressive enhancement approach to development.</p> |
|
|
64 |
|
|
|
65 |
<h3>The Markup</h3> |
|
|
66 |
|
|
|
67 |
<p>The only markup requirements are an unordered list of items and a corresponding group of divs.</p> |
|
|
68 |
|
|
|
69 |
<pre class="code prettyprint"><div id="demo"> |
|
|
70 |
<ul> |
|
|
71 |
<li><a href="#foo">foo</a></li> |
|
|
72 |
<li><a href="#bar">bar</a></li> |
|
|
73 |
<li><a href="#baz">baz</a></li> |
|
|
74 |
</ul> |
|
|
75 |
<div> |
|
|
76 |
<div id="foo"> |
|
|
77 |
<p>foo content</p> |
|
|
78 |
</div> |
|
|
79 |
<div id="bar"> |
|
|
80 |
<p>bar content</p> |
|
|
81 |
</div> |
|
|
82 |
<div id="baz"> |
|
|
83 |
<p>baz content</p> |
|
|
84 |
</div> |
|
|
85 |
</div> |
|
|
86 |
</div></pre> |
|
|
87 |
|
|
|
88 |
|
|
|
89 |
<h3>The JavaScript</h3> |
|
|
90 |
|
|
|
91 |
<p><code>TabView</code> extends <code>Widget</code>, and the <code>srcNode</code> |
|
|
92 |
becomes the <code>contentBox</code>. This is the |
|
|
93 |
minimal requirement to create a <code>Tabview</code> instance for the markup, |
|
|
94 |
and can be assigned using a selector. Calling render enlivens the <code>TabView |
|
|
95 |
</code> making it usable.</p> |
|
|
96 |
|
|
|
97 |
<pre class="code prettyprint">var tabview = new Y.TabView({srcNode:'#demo'}); |
|
|
98 |
tabview.render();</pre> |
|
|
99 |
|
|
|
100 |
|
|
|
101 |
|
|
|
102 |
<h2>Complete Example Source</h2> |
|
|
103 |
<pre class="code prettyprint"><div id="demo"> |
|
|
104 |
<ul> |
|
|
105 |
<li><a href="#foo">foo</a></li> |
|
|
106 |
<li><a href="#bar">bar</a></li> |
|
|
107 |
<li><a href="#baz">baz</a></li> |
|
|
108 |
</ul> |
|
|
109 |
<div> |
|
|
110 |
<div id="foo"> |
|
|
111 |
<p>foo content</p> |
|
|
112 |
</div> |
|
|
113 |
<div id="bar"> |
|
|
114 |
<p>bar content</p> |
|
|
115 |
</div> |
|
|
116 |
<div id="baz"> |
|
|
117 |
<p>baz content</p> |
|
|
118 |
</div> |
|
|
119 |
</div> |
|
|
120 |
</div> |
|
|
121 |
|
|
|
122 |
<script type="text/javascript"> |
|
|
123 |
YUI().use('tabview', function(Y) { |
|
|
124 |
var tabview = new Y.TabView({srcNode:'#demo'}); |
|
|
125 |
tabview.render(); |
|
|
126 |
}); |
|
|
127 |
</script></pre> |
|
|
128 |
|
|
|
129 |
</div> |
|
|
130 |
</div> |
|
|
131 |
</div> |
|
|
132 |
|
|
|
133 |
<div class="yui3-u-1-4"> |
|
|
134 |
<div class="sidebar"> |
|
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
|
138 |
<div class="sidebox"> |
|
|
139 |
<div class="hd"> |
|
|
140 |
<h2 class="no-toc">Examples</h2> |
|
|
141 |
</div> |
|
|
142 |
|
|
|
143 |
<div class="bd"> |
|
|
144 |
<ul class="examples"> |
|
|
145 |
|
|
|
146 |
|
|
|
147 |
<li data-description="This example shows how to create a TabView wigdet from existing HTML."> |
|
|
148 |
<a href="tabview-basic.html">TabView from Existing Markup</a> |
|
|
149 |
</li> |
|
|
150 |
|
|
|
151 |
|
|
|
152 |
|
|
|
153 |
<li data-description="This example shows how to create a TabView wigdet from JavaScript."> |
|
|
154 |
<a href="tabview-fromjs.html">Dynamic TabView from JavaScript</a> |
|
|
155 |
</li> |
|
|
156 |
|
|
|
157 |
|
|
|
158 |
|
|
|
159 |
<li data-description="This example shows how to add and remove Tabs."> |
|
|
160 |
<a href="tabview-add-remove.html">Adding and Removing Tabs</a> |
|
|
161 |
</li> |
|
|
162 |
|
|
|
163 |
|
|
|
164 |
|
|
|
165 |
<li data-description="This example shows how to load tab content remotely using a YQL plugin."> |
|
|
166 |
<a href="tabview-yql.html">Loading Tab Content</a> |
|
|
167 |
</li> |
|
|
168 |
|
|
|
169 |
|
|
|
170 |
|
|
|
171 |
|
|
|
172 |
</ul> |
|
|
173 |
</div> |
|
|
174 |
</div> |
|
|
175 |
|
|
|
176 |
|
|
|
177 |
|
|
|
178 |
<div class="sidebox"> |
|
|
179 |
<div class="hd"> |
|
|
180 |
<h2 class="no-toc">Examples That Use This Component</h2> |
|
|
181 |
</div> |
|
|
182 |
|
|
|
183 |
<div class="bd"> |
|
|
184 |
<ul class="examples"> |
|
|
185 |
|
|
|
186 |
|
|
|
187 |
|
|
|
188 |
|
|
|
189 |
|
|
|
190 |
|
|
|
191 |
|
|
|
192 |
|
|
|
193 |
|
|
|
194 |
|
|
|
195 |
<li data-description="Demonstrates how to add browser history support to a TabView widget using the History Utility."> |
|
|
196 |
<a href="../history/history-tabview.html">History + TabView</a> |
|
|
197 |
</li> |
|
|
198 |
|
|
|
199 |
|
|
|
200 |
</ul> |
|
|
201 |
</div> |
|
|
202 |
</div> |
|
|
203 |
|
|
|
204 |
</div> |
|
|
205 |
</div> |
|
|
206 |
</div> |
|
|
207 |
</div> |
|
|
208 |
|
|
|
209 |
<script src="../assets/vendor/prettify/prettify-min.js"></script> |
|
|
210 |
<script>prettyPrint();</script> |
|
|
211 |
|
|
|
212 |
<script> |
|
|
213 |
YUI.Env.Tests = { |
|
|
214 |
examples: [], |
|
|
215 |
project: '../assets', |
|
|
216 |
assets: '../assets/tabview', |
|
|
217 |
name: 'tabview-basic', |
|
|
218 |
title: 'TabView from Existing Markup', |
|
|
219 |
newWindow: '', |
|
|
220 |
auto: false |
|
|
221 |
}; |
|
|
222 |
YUI.Env.Tests.examples.push('tabview-basic'); |
|
|
223 |
YUI.Env.Tests.examples.push('tabview-fromjs'); |
|
|
224 |
YUI.Env.Tests.examples.push('tabview-add-remove'); |
|
|
225 |
YUI.Env.Tests.examples.push('tabview-yql'); |
|
|
226 |
YUI.Env.Tests.examples.push('history-tabview'); |
|
|
227 |
|
|
|
228 |
</script> |
|
|
229 |
<script src="../assets/yui/test-runner.js"></script> |
|
|
230 |
|
|
|
231 |
|
|
|
232 |
|
|
|
233 |
</body> |
|
|
234 |
</html> |