2 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
3 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
5 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
6 Code distributed by Google as part of the polymer project is also
7 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
11 `paper-radio-group` allows user to select only one radio button from a set.
12 Checking one radio button that belongs to a radio group unchecks any
13 previously checked radio button within the same group. Use
14 `selected` to get or set the selected radio button.
18 <paper-radio-group selected="small">
19 <paper-radio-button name="small" label="Small"></paper-radio-button>
20 <paper-radio-button name="medium" label="Medium"></paper-radio-button>
21 <paper-radio-button name="large" label="Large"></paper-radio-button>
24 See <a href="../paper-radio-button/">paper-radio-button</a> for more
25 information about `paper-radio-button`.
28 @element paper-radio-group
29 @extends core-selector
33 <link rel=
"import" href=
"../core-a11y-keys/core-a11y-keys.html">
34 <link rel=
"import" href=
"../core-selector/core-selector.html">
35 <link rel=
"import" href=
"../paper-radio-button/paper-radio-button.html">
37 <polymer-element name=
"paper-radio-group" extends=
"core-selector" role=
"radiogroup">
41 <core-a11y-keys target=
"{{}}" keys=
"up left" on-keys-pressed=
"{{selectPrevious}}"></core-a11y-keys>
42 <core-a11y-keys target=
"{{}}" keys=
"down right" on-keys-pressed=
"{{selectNext}}"></core-a11y-keys>
47 display: inline-block;
50 polyfill-next-selector { content: ':host
> *'; }
63 Polymer('paper-radio-group', {
64 nextIndex: function(index
) {
65 var items
= this.items
;
68 newIndex
= (newIndex
+ 1) % items
.length
;
69 if (newIndex
=== index
) {
72 } while (items
[newIndex
].disabled
);
75 previousIndex: function(index
) {
76 var items
= this.items
;
79 newIndex
= (newIndex
|| items
.length
) - 1;
80 if (newIndex
=== index
) {
83 } while (items
[newIndex
].disabled
);
86 selectNext: function() {
87 var node
= this.selectIndex(this.nextIndex(this.selectedIndex
));
90 selectPrevious: function() {
91 var node
= this.selectIndex(this.previousIndex(this.selectedIndex
));
94 selectedAttribute
: 'checked',
95 activateEvent
: 'change'