| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 Polymer({ | 5 Polymer({ |
| 6 is: 'controlled-radio-button', | 6 is: 'controlled-radio-button', |
| 7 | 7 |
| 8 behaviors: [CrPolicyPrefBehavior, PrefControlBehavior], | 8 behaviors: [CrPolicyPrefBehavior, PrefControlBehavior], |
| 9 | 9 |
| 10 properties: { | 10 properties: { |
| 11 name: { | 11 name: { |
| 12 type: String, | 12 type: String, |
| 13 notify: true, | 13 notify: true, |
| 14 }, | 14 }, |
| 15 | 15 |
| 16 /** @private */ | 16 /** @private */ |
| 17 controlled_: { | 17 controlled_: { |
| 18 type: Boolean, | 18 type: Boolean, |
| 19 computed: 'computeControlled_(pref.*)', | 19 computed: 'computeControlled_(pref.*)', |
| 20 reflectToAttribute: true, | 20 reflectToAttribute: true, |
| 21 }, | 21 }, |
| 22 }, | 22 }, |
| 23 | 23 |
| 24 listeners: { |
| 25 'focus': 'onFocus_', |
| 26 }, |
| 27 |
| 24 /** | 28 /** |
| 25 * @return {boolean} Whether the button is disabled. | 29 * @return {boolean} Whether the button is disabled. |
| 26 * @private | 30 * @private |
| 27 */ | 31 */ |
| 28 computeControlled_: function() { | 32 computeControlled_: function() { |
| 29 return this.isPrefPolicyControlled(assert(this.pref)); | 33 return this.isPrefPolicyControlled(assert(this.pref)); |
| 30 }, | 34 }, |
| 31 | 35 |
| 32 /** | 36 /** |
| 33 * @param {boolean} controlled | 37 * @param {boolean} controlled |
| 34 * @param {string} name | 38 * @param {string} name |
| 35 * @param {chrome.settingsPrivate.PrefObject} pref | 39 * @param {chrome.settingsPrivate.PrefObject} pref |
| 36 * @return {boolean} | 40 * @return {boolean} |
| 37 * @private | 41 * @private |
| 38 */ | 42 */ |
| 39 showIndicator_: function(controlled, name, pref) { | 43 showIndicator_: function(controlled, name, pref) { |
| 40 return controlled && name == Settings.PrefUtil.prefToString(pref); | 44 return controlled && name == Settings.PrefUtil.prefToString(pref); |
| 41 }, | 45 }, |
| 42 | 46 |
| 43 /** | 47 /** |
| 44 * @param {!Event} e | 48 * @param {!Event} e |
| 45 * @private | 49 * @private |
| 46 */ | 50 */ |
| 47 onIndicatorTap_: function(e) { | 51 onIndicatorTap_: function(e) { |
| 48 // Disallow <controlled-radio-button on-tap="..."> when controlled. | 52 // Disallow <controlled-radio-button on-tap="..."> when controlled. |
| 49 e.preventDefault(); | 53 e.preventDefault(); |
| 50 e.stopPropagation(); | 54 e.stopPropagation(); |
| 51 }, | 55 }, |
| 56 |
| 57 /** Focuses the internal radio button when the row is selected. */ |
| 58 onFocus_: function() { |
| 59 this.$.radioButton.focus(); |
| 60 }, |
| 52 }); | 61 }); |
| OLD | NEW |