Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: polymer_1.0.4/bower_components/paper-radio-group/paper-radio-group.html

Issue 1205703007: Add polymer 1.0 to npm_modules (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Renamed folder to 1.0.4 Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!--
2 @license
3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
4 This code may only be used under the BSD style license found at http://polymer.g ithub.io/LICENSE.txt
5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6 The complete set of contributors may be found at http://polymer.github.io/CONTRI BUTORS.txt
7 Code distributed by Google as part of the polymer project is also
8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN TS.txt
9 -->
10
11 <link rel="import" href="../polymer/polymer.html">
12 <link rel="import" href="../iron-selector/iron-selectable.html">
13 <link rel="import" href="../paper-radio-button/paper-radio-button.html">
14 <link rel="import" href="../iron-a11y-keys-behavior/iron-a11y-keys-behavior.html ">
15
16 <!--
17 `paper-radio-group` allows user to select only one radio button from a set.
18 Checking one radio button that belongs to a radio group unchecks any
19 previously checked radio button within the same group. Use
20 `selected` to get or set the selected radio button.
21
22 Example:
23
24 <paper-radio-group selected="small">
25 <paper-radio-button name="small">Small</paper-radio-button>
26 <paper-radio-button name="medium">Medium</paper-radio-button>
27 <paper-radio-button name="large">Large</paper-radio-button>
28 </paper-radio-group>
29
30 See <a href="paper-radio-button.html">paper-radio-button</a> for more
31 information about `paper-radio-button`.
32
33 @group Paper Elements
34 @element paper-radio-group
35 @hero hero.svg
36 @demo demo/index.html
37 -->
38
39 <dom-module name="paper-radio-group">
40 <style>
41 :host {
42 display: inline-block;
43 }
44
45 :host ::content > * {
46 padding: 12px;
47 }
48 </style>
49
50 <template>
51 <content id="items" select="*"></content>
52 </template>
53
54 </dom-module>
55
56 <script>
57 Polymer({
58 is: 'paper-radio-group',
59
60 behaviors: [
61 Polymer.IronA11yKeysBehavior,
62 Polymer.IronSelectableBehavior
63 ],
64
65 hostAttributes: {
66 role: 'radiogroup',
67 tabindex: 0
68 },
69
70 properties: {
71 /**
72 * Overriden from Polymer.IronSelectableBehavior
73 */
74 attrForSelected: {
75 type: String,
76 value: 'name'
77 },
78
79 /**
80 * Overriden from Polymer.IronSelectableBehavior
81 */
82 selectedAttribute: {
83 type: String,
84 value: 'checked'
85 }
86 },
87
88 keyBindings: {
89 'left up': 'selectPrevious',
90 'right down': 'selectNext',
91 },
92
93 /**
94 * Selects the given value.
95 */
96 select: function(value) {
97 if (this.selected) {
98 var oldItem = this._valueToItem(this.selected);
99
100 // Do not allow unchecking the selected item.
101 if (this.selected == value) {
102 oldItem.checked = true;
103 return;
104 }
105
106 if (oldItem)
107 oldItem.checked = false;
108 }
109
110 Polymer.IronSelectableBehavior.select.apply(this, [value]);
111 this.fire('paper-radio-group-changed');
112 },
113
114 /**
115 * Selects the previous item. If the previous item is disabled, then it is
116 * skipped, and its previous item is selected
117 */
118 selectPrevious: function() {
119 var length = this.items.length;
120 var newIndex = Number(this._valueToIndex(this.selected));
121
122 do {
123 newIndex = (newIndex - 1 + length) % length;
124 } while (this.items[newIndex].disabled)
125
126 this.select(this._indexToValue(newIndex));
127 },
128
129 /**
130 * Selects the next item. If the next item is disabled, then it is
131 * skipped, and its nexy item is selected
132 */
133 selectNext: function() {
134 var length = this.items.length;
135 var newIndex = Number(this._valueToIndex(this.selected));
136
137 do {
138 newIndex = (newIndex + 1 + length) % length;
139 } while (this.items[newIndex].disabled)
140
141 this.select(this._indexToValue(newIndex));
142 },
143 });
144 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698