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

Side by Side Diff: chrome/browser/resources/settings/controls/settings_radio_group.js

Issue 2052543002: MD Settings: disable <paper-radio-button>s inside of a <settings-radio-group> when controlled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: asdf Created 4 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * `cr-radio-group` wraps a radio-group and set of radio-buttons that control 7 * `cr-radio-group` wraps a radio-group and set of radio-buttons that control
8 * a supplied preference. 8 * a supplied preference.
9 * 9 *
10 * Example: 10 * Example:
11 * <settings-radio-group pref="{{prefs.settings.foo}}" 11 * <settings-radio-group pref="{{prefs.settings.foo}}"
12 * label="Foo Options." buttons="{{fooOptionsList}}"> 12 * label="Foo Options." buttons="{{fooOptionsList}}">
13 * </settings-radio-group> 13 * </settings-radio-group>
14 */ 14 */
15 Polymer({ 15 Polymer({
16 is: 'settings-radio-group', 16 is: 'settings-radio-group',
17 17
18 behaviors: [PrefControlBehavior], 18 behaviors: [CrPolicyPrefBehavior, PrefControlBehavior],
19 19
20 properties: { 20 properties: {
21 disabled_: {
22 observer: 'disabledChanged_',
23 type: Boolean,
24 value: false,
25 },
26
21 /** 27 /**
22 * IronSelectableBehavior selected attribute. 28 * IronSelectableBehavior selected attribute.
23 */ 29 */
24 selected: { 30 selected: {
25 type: String, 31 type: String,
26 notify: true, 32 notify: true,
27 observer: 'selectedChanged_' 33 observer: 'selectedChanged_'
28 }, 34 },
29 }, 35 },
30 36
31 observers: [ 37 observers: [
32 'prefChanged_(pref.*)', 38 'prefChanged_(pref.*)',
33 ], 39 ],
34 40
35 /** @private */ 41 /** @private */
36 prefChanged_: function() { 42 prefChanged_: function() {
37 this.selected = Settings.PrefUtil.prefToString( 43 var pref = /** @type {!chrome.settingsPrivate.PrefObject} */(this.pref);
38 /** @type {!chrome.settingsPrivate.PrefObject} */(this.pref)); 44 this.disabled_ = this.isPrefPolicyControlled(pref);
45 this.selected = Settings.PrefUtil.prefToString(pref);
39 }, 46 },
40 47
41 /** @private */ 48 /** @private */
49 disabledChanged_: function() {
50 var radioButtons = this.queryAllEffectiveChildren('paper-radio-button');
51 for (var i = 0; i < radioButtons.length; ++i) {
52 radioButtons[i].disabled = this.disabled_;
53 }
54 },
55
56 /** @private */
42 selectedChanged_: function(selected) { 57 selectedChanged_: function(selected) {
43 if (!this.pref) 58 if (!this.pref)
44 return; 59 return;
45 this.set('pref.value', 60 this.set('pref.value',
46 Settings.PrefUtil.stringToPrefValue(selected, this.pref)); 61 Settings.PrefUtil.stringToPrefValue(selected, this.pref));
47 }, 62 },
48 }); 63 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698