[Ozone-Drm] Add support for async content protection
[chromium-blink-merge.git] / third_party / polymer / components / paper-radio-group / paper-radio-group.html
blob42a2260bde187326e32cbbaa7ced3873679aaee6
1 <!--
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
8 -->
10 <!--
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.
16 Example:
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>
22 </paper-radio-group>
24 See <a href="../paper-radio-button/">paper-radio-button</a> for more
25 information about `paper-radio-button`.
27 @group Paper Elements
28 @element paper-radio-group
29 @extends core-selector
30 @homepage github.io
31 -->
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">
39 <template>
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>
44 <style>
46 :host {
47 display: inline-block;
50 polyfill-next-selector { content: ':host > *'; }
51 ::content > * {
52 padding: 12px;
55 </style>
57 <shadow></shadow>
59 </template>
61 <script>
63 Polymer('paper-radio-group', {
64 nextIndex: function(index) {
65 var items = this.items;
66 var newIndex = index;
67 do {
68 newIndex = (newIndex + 1) % items.length;
69 if (newIndex === index) {
70 break;
72 } while (items[newIndex].disabled);
73 return newIndex;
75 previousIndex: function(index) {
76 var items = this.items;
77 var newIndex = index;
78 do {
79 newIndex = (newIndex || items.length) - 1;
80 if (newIndex === index) {
81 break;
83 } while (items[newIndex].disabled);
84 return newIndex;
86 selectNext: function() {
87 var node = this.selectIndex(this.nextIndex(this.selectedIndex));
88 node.focus();
90 selectPrevious: function() {
91 var node = this.selectIndex(this.previousIndex(this.selectedIndex));
92 node.focus();
94 selectedAttribute: 'checked',
95 activateEvent: 'change'
97 });
99 </script>
101 </polymer-element>