/
index.mustache
323 lines (276 loc) · 10.3 KB
/
index.mustache
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
<div class='intro'>
<p>{{description}}</p>
</div>
{{>getting-started}}
<h2>Using Button - Quick Start</h2>
<h3>Button Widgets</h3>
<h4>HTML</h4>
{{>need-skin-note}}
```
<body class="yui3-skin-sam"> {{>need-skin-comment}}
<button id="myButton">One</button>
```
<h4>JavaScript</h4>
```
// Create some button widgets
YUI().use('button', function(Y){
// A push button widget
var button = new Y.Button({
srcNode: '#myButton'
});
// A toggle button widget
var toggleButton = new Y.ToggleButton({
srcNode: '#myToggleButton'
});
});
```
<h3>Node Plugin</h3>
```
// If you want something a little more light-weight than a widget...
YUI().use('button-plugin', function(Y){
var button = new Y.Plugin.Button.createNode("#testButton", {
label: "I'm a disabled button",
disabled: true
});
});
```
<h3>Button Groups</h3>
<h4>HTML</h4>
{{>need-skin-note}}
```
<body class="yui3-skin-sam"> {{>need-skin-comment}}
<div id="container">
<button class='yui3-button'>One</button>
<button class='yui3-button'>Two</button>
<button class='yui3-button'>Three</button>
```
<h4>JavaScript</h4>
```
// And if you want to manage a group of buttons
YUI().use('button-group', function(Y){
var buttonGroup = new Y.ButtonGroup({
srcNode: '#container' // Should contain <button> children
});
});
```
<h2>Modules</h2>
<p>YUI's Button component introduces 5 modules:</p>
<ul>
<li><a href="#cssbutton">`cssbutton`</a> - Includes various `yui3-button` styles to provide a normalized CSS base for buttons.</li>
<li><a href="#button">`button`</a> - Exports the `Y.Button` & `Y.ToggleButton` widgets.</li>
<li><a href="#buttongroup">`button-group`</a> - Exports the `Y.ButtonGroup` widget.</li>
<li><a href="#buttonplugin">`button-plugin`</a> - Exports the `Y.Plugin.Button.createNode` factory.</li>
<li>`button-core` - Exports `Y.ButtonCore`, a base used by all other Button component modules.</li>
</ul>
<h3>Which one to use?</h3>
<ul>
<li>`use('cssbutton')` if you only want a CSS stylesheet to enhance button(-like) nodes</li>
<li>`use('button-plugin')` if you only need to enhance a DOM node with button functionality</li>
<li>`use('button')` if you want a button widget</li>
<li>`use('button-group')` if you want a widget to manage a group of buttons</li>
<li>`button-core` is not intended to be used stand-alone</li>
</ul>
<div id="cssbutton">
<h3>use('cssbutton')</h3>
<p>YUI's Button component was designed with the idea in mind that sometimes you may only want button styles, without the need for any JavaScript functionality. Instead of `use('button', ...)`, you can just include the `cssbutton` module. This can be done dynamically with `use('cssbutton')`, or statically with a `link` tag.</p>
```
<link rel="stylesheet" href="http://yui.yahooapis.com/{{yuiVersion}}/build/cssbutton/cssbutton.css">
```
<p>Loading this stylesheet will include the following classes:</p>
<ul>
<li>yui3-button</li>
<li>yui3-button-disabled</li>
<li>yui3-button-hover, yui3-button:hover</li>
<li>yui3-button-active, yui3-button:active</li>
<li>yui3-button-primary, yui3-button-selected</li>
</ul>
<p>These styles are designed to progressively enhance. In legacy browsers, you'll get styles that appear as basic buttons, and in new browsers you'll get buttons using modern styles. cssbutton is intended to provide a base and be overridable with custom styles. Such as `background-color`.</p>
<h5>Background Color</h5>
<p>A feature of cssbutton is that it uses transparent gradients to create a colored effect. So if you would like a button that has a light to dark red gradient, you do not need to specify all the styles for proper cross-browser gradients, you only need to specify a single `background-color` style to your buttons.</p>
</div>
<div id="buttonplugin">
<h3>use('button-core')</h3>
<p>This module serves as the foundation for all Button component JavaScript modules and exports `Y.ButtonCore`. While you can use it stand-alone if you like, it is typically a foundational building block for all other Button classes.</p>
</div>
<div id="buttonplugin">
<h3>use('button-plugin')</h3>
<p>This module exports the `Y.Plugin.Node.createNode` factory, which simplifies the process of plugging nodes with `Y.ButtonCore`.</p>
</div>
<div id="button">
<h3>use('button')</h3>
<h4>Y.Button</h4>
<p>`Y.Button` combines `Y.ButtonCore` with `Y.Widget`, to give you basic button functionality, but with the benefits of having a <a href='/yui/docs/widget/'>Widget</a> instance. This can be used as a building block for different types of advanced buttons.</p>
<h4>Y.ToggleButton</h4>
<p>`Y.ToggleButton` does everything that `Y.Button` does (by extending it), and adds the concept of a selected state, which is referred to as either 'pressed' or 'checked', depending on the `type` attribute of the instance. This distinction is made for proper ARIA support.</p>
<h4>Benefits</h4>
<p>So what do you get from `Y.Button`/`Y.ToggleButton` over just creating or plugging a `<button>` node?</p>
<ul>
<li><strong>Accessibility</strong> - Your buttons automatically create and manage their own ARIA <a href='http://www.w3.org/TR/wai-aria/states_and_properties'>states</a> & <a href='http://www.w3.org/TR/wai-aria/roles'>roles</a>. This includes states like `aria-pressed` & `aria-checked`, also appropriate roles like `button`, `checked`, `radio`, etc...</li>
<li><strong>State management</strong> - Instances automatically apply classes, such as `yui3-button-selected` and `yui3-button-disabled` which are useful for styling purposes. Also, `Y.ToggleButton` will fire a 'pressedChange' or 'checkedChange' event (depending on `type`) when the button's state changes from selected to unselected, or vice-versa. This event eliminates the typical case of listening for all 'click' events and then verifying a state changed actually did occur.</li>
</ul>
</div>
<div id="buttongroup">
<h3>use('button-group')</h3>
<p>`Y.ButtonGroup` is a constructor that is used to generate widgets containing a group of buttons.</p>
</div>
<h2>Reference</h2>
<p><strong>Note</strong>: This is not an exhaustive list. See the API documentation for a complete listing.</p>
<h3>Attributes</h3>
<h4>Y.ButtonCore</h4>
<table>
<thead>
<tr>
<th>Attribute</th>
<th>Data type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>label</td>
<td>string</td>
<td>
Sets the button's `innerHTML` or `value` attribute depending on node type
</td>
</tr>
<tr>
<td>disabled</td>
<td>boolean</td>
<td>
Sets the button's disabled state to true/false
</td>
</tr>
</tbody>
</table>
<h4>Node Plugin</h4>
<p>Inherited from `Y.ButtonCore`</p>
<h4>Y.Button</h4>
<p>Identical to `Y.ButtonCore`</p>
<h4>Y.ToggleButton</h4>
<p>In addition to the inherited `Y.Button` attributes...</p>
<table>
<thead>
<tr>
<th>Attribute</th>
<th>Data type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>type</td>
<td>string</td>
<td>
<p>Sets the type of a toggleable button.</p>
<p>Possible values:
<ul>
<li>'toggle' (default)</li>
<li>'checkbox' </li>
</ul>
</p>
<p>The difference is that a 'toggle' button will use <a href='http://www.w3.org/TR/wai-aria/states_and_properties#aria-pressed'>aria-pressed</a>, and a 'checkbox' button will use <a href='http://www.w3.org/TR/wai-aria/states_and_properties#aria-checked'>aria-checked</a>.</p> </td>
</tr>
</tbody>
</table>
<h4>Y.ButtonGroup</h4>
<p>In addition to the inherited `Y.Widget` attributes...</p>
<table>
<thead>
<tr>
<th>Attribute</th>
<th>Data type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>type</td>
<td>string</td>
<td>
<p>Sets the type of button group</p>
<p>Possible values:
<ul>
<li>'push' (default) - No buttons have a selectable state</li>
<li>'radio' - Only one button is selectable at a time</li>
<li>'checkbox' - Multiple buttons can be selected at a time</li>
</ul>
</p>
</td>
</tr>
</tbody>
</table>
<h3>Change Events</h3>
<h4>Y.ButtonCore</h4>
<table>
<thead>
<tr>
<th>Event</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>labelChange</td>
<td>
Fires to inform the subscriber that the button's label is about to be, or has been updated.
</td>
</tr>
<tr>
<td>disabledChange</td>
<td>
Fires to notify the subscriber the disabled state is about to be, or has been updated.
</td>
</tr>
</tbody>
</table>
<h4>Node Plugin</h4>
<p>Inherited from `Y.ButtonCore`</p>
<h4>Y.Button</h4>
<p>Identical to `Y.ButtonCore`</p>
<h4>Y.ToggleButton</h4>
<p>In addition to the inherited `Y.Button` events...</p>
<table>
<thead>
<tr>
<th>Event</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>pressedChange</td>
<td>
Fires for toggle buttons to notify the subscriber the selected state is about to be, or has been updated.
</td>
</tr>
<tr>
<td>checkedChange</td>
<td>
Identical to `"pressedChange"`, but only applicable for buttons with a configuration attribute `"type: 'checkbox'"`.
</td>
</tr>
</tbody>
</table>
<h4>Y.ButtonGroup</h4>
<p>In addition to the inherited `Y.Widget` events...</p>
<table>
<thead>
<tr>
<th>Event</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>selectionChange</td>
<td>
Fires when a button within the group is either selected or unselected. The event payload contains a reference `'originEvent'` to the original event, which can be used to obtain the target button.
</td>
</tr>
</tbody>
</table>
<p>
Note:
<br>`.on('eventName', fn)` will fire <strong>before</strong> the attribute & UI are updated.
<br>`.after('eventName', fn)` will fire <strong>after</strong> the attribute & UI are updated.
</p>