Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / third_party / polymer / v1_0 / components-chromium / paper-radio-group / paper-radio-group-extracted.js
blob6c13939d7dd6431ee19146fea8beb0576571f3fe
2   Polymer({
3     is: 'paper-radio-group',
5     behaviors: [
6       Polymer.IronA11yKeysBehavior,
7       Polymer.IronSelectableBehavior
8     ],
10     hostAttributes: {
11       role: 'radiogroup',
12       tabindex: 0
13     },
15     properties: {
16       /**
17        * Overriden from Polymer.IronSelectableBehavior
18        */
19       attrForSelected: {
20         type: String,
21         value: 'name'
22       },
24       /**
25        * Overriden from Polymer.IronSelectableBehavior
26        */
27       selectedAttribute: {
28         type: String,
29         value: 'checked'
30       },
32       /**
33        * Overriden from Polymer.IronSelectableBehavior
34        */
35       selectable: {
36         type: String,
37         value: 'paper-radio-button'
38       }
39     },
41     keyBindings: {
42       'left up': 'selectPrevious',
43       'right down': 'selectNext',
44     },
46     /**
47      * Selects the given value.
48      */
49      select: function(value) {
50       if (this.selected) {
51         var oldItem = this._valueToItem(this.selected);
53         // Do not allow unchecking the selected item.
54         if (this.selected == value) {
55           oldItem.checked = true;
56           return;
57         }
59         if (oldItem)
60           oldItem.checked = false;
61       }
63       Polymer.IronSelectableBehavior.select.apply(this, [value]);
64       this.fire('paper-radio-group-changed');
65     },
67     /**
68      * Selects the previous item. If the previous item is disabled, then it is
69      * skipped, and its previous item is selected
70      */
71     selectPrevious: function() {
72       var length = this.items.length;
73       var newIndex = Number(this._valueToIndex(this.selected));
75       do {
76         newIndex = (newIndex - 1 + length) % length;
77       } while (this.items[newIndex].disabled)
79       this.select(this._indexToValue(newIndex));
80     },
82     /**
83      * Selects the next item. If the next item is disabled, then it is
84      * skipped, and the next item after it is selected.
85      */
86     selectNext: function() {
87       var length = this.items.length;
88       var newIndex = Number(this._valueToIndex(this.selected));
90       do {
91         newIndex = (newIndex + 1 + length) % length;
92       } while (this.items[newIndex].disabled)
94       this.select(this._indexToValue(newIndex));
95     },
96   });