~smagoun/whoopsie/whoopsie-lp1017637

« back to all changes in this revision

Viewing changes to backend/stats/static/js/yui/docs/button/button-plugin.html

  • Committer: Evan Dandrea
  • Date: 2012-05-09 05:53:45 UTC
  • Revision ID: evan.dandrea@canonical.com-20120509055345-z2j41tmcbf4as5uf
The backend now lives in lp:daisy and the website (errors.ubuntu.com) now lives in lp:errors.

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: Enhancing &lt;button&gt; nodes with button-plugin</title>
6
 
    <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Maven+Pro:400,700">
7
 
    <link rel="stylesheet" href="../../build/cssgrids/grids-min.css">
8
 
    <link rel="stylesheet" href="../assets/css/main.css">
9
 
    <link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
10
 
    <script src="../../build/yui/yui-min.js"></script>
11
 
</head>
12
 
<body>
13
 
 
14
 
<div id="doc">
15
 
    <h1>Example: Enhancing &lt;button&gt; nodes with button-plugin</h1>
16
 
 
17
 
    
18
 
        <a href="#toc" class="jump">Jump to Table of Contents</a>
19
 
    
20
 
 
21
 
    <div class="yui3-g">
22
 
        <div class="yui3-u-3-4">
23
 
            <div id="main">
24
 
                <div class="content"><div class="intro">
25
 
    <p>In this example, we'll look at a few ways to create buttons using the <code>&#x27;button-plugin&#x27;</code> module, and use the <code>&#x27;cssbutton&#x27;</code> module for basic styles.</p>
26
 
    <p>This example uses 3 different ways of creating plugged node elements.  Choose the one you are most comfortable with.</p>
27
 
</div>
28
 
 
29
 
<div class="example">
30
 
    <button id="myButton">A simple push button</button>
31
 
 
32
 
<button id="myEventButton">Toggle 'disabled' state of >></button>
33
 
 
34
 
<button id="myDisabledButton">Disabled</button>
35
 
 
36
 
    <script>
37
 
    YUI().use('button-plugin', 'cssbutton', function(Y){
38
 
    
39
 
    // A basic push button
40
 
    Y.one('#myButton').plug(Y.Plugin.Button);
41
 
    
42
 
    
43
 
    // A disabled button
44
 
    var disabledButton = Y.one('#myDisabledButton');
45
 
    disabledButton.plug(Y.Plugin.Button, {
46
 
        disabled: true
47
 
    });
48
 
    
49
 
    disabledButton.on('click', function(){
50
 
        var label = this.get('label');
51
 
        alert("My label is '"  + label + "'");
52
 
    });
53
 
    
54
 
    // An event button, listening for a click
55
 
    var eventButton = Y.Plugin.Button.createNode({
56
 
        srcNode:'#myEventButton'
57
 
    });
58
 
    
59
 
    eventButton.on('click', function(){
60
 
        var disabled = disabledButton.get('disabled'),
61
 
            newLabel = disabled ? 'Not disabled' : 'Disabled';
62
 
            
63
 
        disabledButton.set('label', newLabel).set('disabled', !disabled);
64
 
    });
65
 
});
66
 
    </script>
67
 
</div>
68
 
 
69
 
<h4 id="source-html">Source: HTML</h4>
70
 
<pre class="code prettyprint">&lt;button id=&quot;myButton&quot;&gt;A simple push button&lt;&#x2F;button&gt;
71
 
 
72
 
&lt;button id=&quot;myEventButton&quot;&gt;Toggle &#x27;disabled&#x27; state of &gt;&gt;&lt;&#x2F;button&gt;
73
 
 
74
 
&lt;button id=&quot;myDisabledButton&quot;&gt;Disabled&lt;&#x2F;button&gt;</pre>
75
 
 
76
 
 
77
 
<h4 id="source-javascript">Source: JavaScript</h4>
78
 
<pre class="code prettyprint">YUI().use(&#x27;button-plugin&#x27;, &#x27;cssbutton&#x27;, function(Y){
79
 
    
80
 
    &#x2F;&#x2F; A basic push button
81
 
    Y.one(&#x27;#myButton&#x27;).plug(Y.Plugin.Button);
82
 
    
83
 
    
84
 
    &#x2F;&#x2F; A disabled button
85
 
    var disabledButton = Y.one(&#x27;#myDisabledButton&#x27;);
86
 
    disabledButton.plug(Y.Plugin.Button, {
87
 
        disabled: true
88
 
    });
89
 
    
90
 
    disabledButton.on(&#x27;click&#x27;, function(){
91
 
        var label = this.get(&#x27;label&#x27;);
92
 
        alert(&quot;My label is &#x27;&quot;  + label + &quot;&#x27;&quot;);
93
 
    });
94
 
    
95
 
    &#x2F;&#x2F; An event button, listening for a click
96
 
    var eventButton = Y.Plugin.Button.createNode({
97
 
        srcNode:&#x27;#myEventButton&#x27;
98
 
    });
99
 
    
100
 
    eventButton.on(&#x27;click&#x27;, function(){
101
 
        var disabled = disabledButton.get(&#x27;disabled&#x27;),
102
 
            newLabel = disabled ? &#x27;Not disabled&#x27; : &#x27;Disabled&#x27;;
103
 
            
104
 
        disabledButton.set(&#x27;label&#x27;, newLabel).set(&#x27;disabled&#x27;, !disabled);
105
 
    });
106
 
});</pre>
107
 
 
108
 
</div>
109
 
            </div>
110
 
        </div>
111
 
 
112
 
        <div class="yui3-u-1-4">
113
 
            <div class="sidebar">
114
 
                
115
 
                    <div id="toc" class="sidebox">
116
 
                        <div class="hd">
117
 
                            <h2 class="no-toc">Table of Contents</h2>
118
 
                        </div>
119
 
 
120
 
                        <div class="bd">
121
 
                            <ul class="toc">
122
 
<li>
123
 
<a href="#source-html">Source: HTML</a>
124
 
</li>
125
 
<li>
126
 
<a href="#source-javascript">Source: JavaScript</a>
127
 
</li>
128
 
</ul>
129
 
                        </div>
130
 
                    </div>
131
 
                
132
 
 
133
 
                
134
 
                    <div class="sidebox">
135
 
                        <div class="hd">
136
 
                            <h2 class="no-toc">Examples</h2>
137
 
                        </div>
138
 
 
139
 
                        <div class="bd">
140
 
                            <ul class="examples">
141
 
                                
142
 
                                    
143
 
                                        <li data-description="This example shows how you can easily style button and non-button DOM elements to appear as buttons">
144
 
                                            <a href="cssbutton.html">Styling elements with cssbutton</a>
145
 
                                        </li>
146
 
                                    
147
 
                                
148
 
                                    
149
 
                                        <li data-description="This example shows a simple, light solution to enhance &lt;button&gt; nodes">
150
 
                                            <a href="button-plugin.html">Enhancing &lt;button&gt; nodes with button-plugin</a>
151
 
                                        </li>
152
 
                                    
153
 
                                
154
 
                                    
155
 
                                        <li data-description="This example demonstrates how to create button widgets">
156
 
                                            <a href="button.html">Basic button widgets</a>
157
 
                                        </li>
158
 
                                    
159
 
                                
160
 
                                    
161
 
                                        <li data-description="This example demonstrates how to create a widget containing a group of buttons">
162
 
                                            <a href="button-group.html">Managing groups of buttons with button-group</a>
163
 
                                        </li>
164
 
                                    
165
 
                                
166
 
                            </ul>
167
 
                        </div>
168
 
                    </div>
169
 
                
170
 
 
171
 
                
172
 
            </div>
173
 
        </div>
174
 
    </div>
175
 
</div>
176
 
 
177
 
<script src="../assets/vendor/prettify/prettify-min.js"></script>
178
 
<script>prettyPrint();</script>
179
 
 
180
 
</body>
181
 
</html>