~ubuntu-branches/ubuntu/raring/maas/raring-updates

« back to all changes in this revision

Viewing changes to src/maasserver/static/jslibs/yui/3.4.1/docs/tabview/tabview-fromjs.html

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2012-07-03 17:42:37 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20120703174237-p8l0keuuznfg721k
Tags: 0.1+bzr709+dfsg-0ubuntu1
* New Upstream release
* debian/control:
  - Depends on python-celery, python-tempita, libjs-yui3-{full,min},
    libjs-raphael
* debian/maas.install:
  - Install apiclient, celeryconfig.py, maas-import-pxe-files, preseeds_v2.
  - Update to install various files from chroot, rather tha manually copy
    them from the source.
* debian/maas.links: symlink celeryconfig.py
* debian/maas.maas-celery.upstart: Add job.
* debian/rules:
  - Install celery upstart job.
  - Do not install jslibs as packages are now used.
  - Drop copying of maas_local_settings_sample.py as source now ships
    a maas_local_settings.py
* debian/patches:
  - 04-maas-http-fix.patch: Drop. Merged upstream.
  - 01-fix-database-settings.patch: Refreshed.
  - 99_enums_js.patch: Added until creation of enum.js / build process
    is fixed.
* debian/maas.postinst: Update bzr version to correctly handle upgrades.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!DOCTYPE html>
2
 
<html lang="en">
3
 
<head>
4
 
    <meta charset="utf-8">
5
 
    <title>Example: Dynamic TabView from JavaScript</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>
10
 
</head>
11
 
<body>
12
 
 
13
 
<div id="doc">
14
 
    <h1>Example: Dynamic TabView from JavaScript</h1>
15
 
 
16
 
    
17
 
 
18
 
    <div class="yui3-g">
19
 
        <div id="main" class="yui3-u">
20
 
            <div class="content"><div class="intro">
21
 
    <p>This example shows how to create a <code>TabView</code> widget dynamically and insert it into the page.</p>
22
 
</div>
23
 
 
24
 
<div class="example yui3-skin-sam">
25
 
<div id="demo">
26
 
</div>
27
 
 
28
 
<script type="text/javascript">
29
 
YUI().use('tabview', function(Y) {
30
 
    var tabview = new Y.TabView({
31
 
        children: [{
32
 
            label: 'foo',
33
 
            content: '<p>foo content</p>'
34
 
        }, {
35
 
            label: 'bar',
36
 
            content: '<p>bar content</p>'
37
 
        }, {
38
 
            label: 'baz',
39
 
            content: '<p>baz content</p>'
40
 
        }]
41
 
    });
42
 
 
43
 
    tabview.render('#demo');
44
 
    tabview.selectChild(2);
45
 
});
46
 
</script>
47
 
 
48
 
</div>
49
 
 
50
 
<h2>Creating a TabView From JavaScript</h2>
51
 
 
52
 
<p>A <code>TabView</code> can be created dynamically using a small amount of JavaScript.</p>
53
 
 
54
 
<h3>The Markup</h3>
55
 
 
56
 
<p>There are no markup requirements in this case, although you may want to have a placeholder to render the tabview into, which is what this example does.</p>
57
 
 
58
 
<pre class="code prettyprint">&lt;div id=&quot;demo&quot;&gt;
59
 
&lt;&#x2F;div&gt;</pre>
60
 
 
61
 
 
62
 
<h3>The JavaScript</h3>
63
 
 
64
 
<p>The minimal requirement for creating a <code>TabView</code> from scratch are the labels and content for each tab.
65
 
These are added as the <code>children</code> attribute when creating the <code>TabView</code>.</p>
66
 
 
67
 
<pre class="code prettyprint">var tabview = new Y.TabView({
68
 
    children: [{
69
 
        label: &#x27;foo&#x27;,
70
 
        content: &#x27;&lt;p&gt;foo content&lt;&#x2F;p&gt;&#x27;
71
 
    }, {
72
 
        label: &#x27;bar&#x27;,
73
 
        content: &#x27;&lt;p&gt;bar content&lt;&#x2F;p&gt;&#x27;
74
 
    }, {
75
 
        label: &#x27;baz&#x27;,
76
 
        content: &#x27;&lt;p&gt;baz content&lt;&#x2F;p&gt;&#x27;
77
 
    }]
78
 
});</pre>
79
 
 
80
 
 
81
 
<h3>Rendering</h3>
82
 
 
83
 
<p>Calling render creates the <code>TabView</code>, inserting into the node
84
 
passed to render.
85
 
</p>
86
 
 
87
 
<pre class="code prettyprint">tabview.render(&#x27;#demo&#x27;);</pre>
88
 
 
89
 
 
90
 
<h3>Changing the Selected Tab</h3>
91
 
 
92
 
<p>By default, clicking a tab makes it selected and shows its content.  You can also do this programmatically
93
 
by calling the <code>selectChild</code> method on the <code>TabView</code>, passing it the index of the
94
 
tab to be selected.
95
 
</p>
96
 
 
97
 
<pre class="code prettyprint">tabview.selectChild(2);</pre>
98
 
 
99
 
 
100
 
<h2>Complete Example Source</h2>
101
 
<pre class="code prettyprint">&lt;div id=&quot;demo&quot;&gt;
102
 
&lt;&#x2F;div&gt;
103
 
 
104
 
&lt;script type=&quot;text&#x2F;javascript&quot;&gt;
105
 
YUI().use(&#x27;tabview&#x27;, function(Y) {
106
 
    var tabview = new Y.TabView({
107
 
        children: [{
108
 
            label: &#x27;foo&#x27;,
109
 
            content: &#x27;&lt;p&gt;foo content&lt;&#x2F;p&gt;&#x27;
110
 
        }, {
111
 
            label: &#x27;bar&#x27;,
112
 
            content: &#x27;&lt;p&gt;bar content&lt;&#x2F;p&gt;&#x27;
113
 
        }, {
114
 
            label: &#x27;baz&#x27;,
115
 
            content: &#x27;&lt;p&gt;baz content&lt;&#x2F;p&gt;&#x27;
116
 
        }]
117
 
    });
118
 
 
119
 
    tabview.render(&#x27;#demo&#x27;);
120
 
    tabview.selectChild(2);
121
 
});
122
 
&lt;&#x2F;script&gt;</pre>
123
 
 
124
 
</div>
125
 
        </div>
126
 
 
127
 
        <div id="sidebar" class="yui3-u">
128
 
            
129
 
 
130
 
            
131
 
                <div class="sidebox">
132
 
                    <div class="hd">
133
 
                        <h2 class="no-toc">Examples</h2>
134
 
                    </div>
135
 
 
136
 
                    <div class="bd">
137
 
                        <ul class="examples">
138
 
                            
139
 
                                
140
 
                                    <li data-description="This example shows how to create a TabView wigdet from existing HTML.">
141
 
                                        <a href="tabview-basic.html">TabView from Existing Markup</a>
142
 
                                    </li>
143
 
                                
144
 
                            
145
 
                                
146
 
                                    <li data-description="This example shows how to create a TabView wigdet from JavaScript.">
147
 
                                        <a href="tabview-fromjs.html">Dynamic TabView from JavaScript</a>
148
 
                                    </li>
149
 
                                
150
 
                            
151
 
                                
152
 
                                    <li data-description="This example shows how to add and remove Tabs.">
153
 
                                        <a href="tabview-add-remove.html">Adding and Removing Tabs</a>
154
 
                                    </li>
155
 
                                
156
 
                            
157
 
                                
158
 
                                    <li data-description="This example shows how to load tab content remotely using a YQL plugin.">
159
 
                                        <a href="tabview-yql.html">Loading Tab Content</a>
160
 
                                    </li>
161
 
                                
162
 
                            
163
 
                                
164
 
                            
165
 
                        </ul>
166
 
                    </div>
167
 
                </div>
168
 
            
169
 
 
170
 
            
171
 
                <div class="sidebox">
172
 
                    <div class="hd">
173
 
                        <h2 class="no-toc">Examples That Use This Component</h2>
174
 
                    </div>
175
 
 
176
 
                    <div class="bd">
177
 
                        <ul class="examples">
178
 
                            
179
 
                                
180
 
                            
181
 
                                
182
 
                            
183
 
                                
184
 
                            
185
 
                                
186
 
                            
187
 
                                
188
 
                                    <li data-description="Demonstrates how to add browser history support to a TabView widget using the History Utility.">
189
 
                                        <a href="../history/history-tabview.html">History + TabView</a>
190
 
                                    </li>
191
 
                                
192
 
                            
193
 
                        </ul>
194
 
                    </div>
195
 
                </div>
196
 
            
197
 
        </div>
198
 
    </div>
199
 
</div>
200
 
 
201
 
<script src="../assets/vendor/prettify/prettify-min.js"></script>
202
 
<script>prettyPrint();</script>
203
 
 
204
 
</body>
205
 
</html>