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

Side by Side Diff: third_party/polymer/v1_0/components-chromium/paper-radio-group/paper-radio-group-extracted.js

Issue 1401633002: Update Polymer from 1.1.4 -> 1.1.5 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: dzhioev@ review Created 5 years, 2 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
1 1 Polymer({
2 Polymer({
3 is: 'paper-radio-group', 2 is: 'paper-radio-group',
4 3
5 behaviors: [ 4 behaviors: [
6 Polymer.IronA11yKeysBehavior, 5 Polymer.IronA11yKeysBehavior,
7 Polymer.IronSelectableBehavior 6 Polymer.IronSelectableBehavior
8 ], 7 ],
9 8
10 hostAttributes: { 9 hostAttributes: {
11 role: 'radiogroup', 10 role: 'radiogroup',
12 tabindex: 0 11 tabindex: 0
13 }, 12 },
14 13
15 properties: { 14 properties: {
16 /** 15 /**
16 * Fired when the radio group selection changes.
17 *
18 * @event paper-radio-group-changed
19 */
20
21 /**
17 * Overriden from Polymer.IronSelectableBehavior 22 * Overriden from Polymer.IronSelectableBehavior
18 */ 23 */
19 attrForSelected: { 24 attrForSelected: {
20 type: String, 25 type: String,
21 value: 'name' 26 value: 'name'
22 }, 27 },
23 28
24 /** 29 /**
25 * Overriden from Polymer.IronSelectableBehavior 30 * Overriden from Polymer.IronSelectableBehavior
26 */ 31 */
27 selectedAttribute: { 32 selectedAttribute: {
28 type: String, 33 type: String,
29 value: 'checked' 34 value: 'checked'
30 }, 35 },
31 36
32 /** 37 /**
33 * Overriden from Polymer.IronSelectableBehavior 38 * Overriden from Polymer.IronSelectableBehavior
34 */ 39 */
35 selectable: { 40 selectable: {
36 type: String, 41 type: String,
37 value: 'paper-radio-button' 42 value: 'paper-radio-button'
43 },
44
45 /**
46 * If true, radio-buttons can be deselected
47 */
48 allowEmptySelection: {
49 type: Boolean,
50 value: false
38 } 51 }
39 }, 52 },
40 53
41 keyBindings: { 54 keyBindings: {
42 'left up': 'selectPrevious', 55 'left up': 'selectPrevious',
43 'right down': 'selectNext', 56 'right down': 'selectNext',
44 }, 57 },
45 58
46 /** 59 /**
47 * Selects the given value. 60 * Selects the given value.
48 */ 61 */
49 select: function(value) { 62 select: function(value) {
50 if (this.selected) { 63 if (this.selected) {
51 var oldItem = this._valueToItem(this.selected); 64 var oldItem = this._valueToItem(this.selected);
52 65
53 // Do not allow unchecking the selected item.
54 if (this.selected == value) { 66 if (this.selected == value) {
55 oldItem.checked = true; 67 // If deselecting is allowed we'll have to apply an empty selection.
56 return; 68 // Otherwise, we should force the selection to stay and make this
69 // action a no-op.
70 if (this.allowEmptySelection) {
71 value = '';
72 } else {
73 oldItem.checked = true;
74 return;
75 }
57 } 76 }
58 77
59 if (oldItem) 78 if (oldItem)
60 oldItem.checked = false; 79 oldItem.checked = false;
61 } 80 }
62 81
63 Polymer.IronSelectableBehavior.select.apply(this, [value]); 82 Polymer.IronSelectableBehavior.select.apply(this, [value]);
64 this.fire('paper-radio-group-changed'); 83 this.fire('paper-radio-group-changed');
65 }, 84 },
66 85
(...skipping 19 matching lines...) Expand all
86 selectNext: function() { 105 selectNext: function() {
87 var length = this.items.length; 106 var length = this.items.length;
88 var newIndex = Number(this._valueToIndex(this.selected)); 107 var newIndex = Number(this._valueToIndex(this.selected));
89 108
90 do { 109 do {
91 newIndex = (newIndex + 1 + length) % length; 110 newIndex = (newIndex + 1 + length) % length;
92 } while (this.items[newIndex].disabled) 111 } while (this.items[newIndex].disabled)
93 112
94 this.select(this._indexToValue(newIndex)); 113 this.select(this._indexToValue(newIndex));
95 }, 114 },
96 }); 115 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698