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
3 // found in the LICENSE file.
7 * `cr-radio-group` wraps a radio-group and set of radio-buttons that control
8 * a supplied preference.
11 * <cr-settings-radio-group pref="{{prefs.settings.foo}}"
12 * label="Foo Options." buttons="{{fooOptionsList}}">
13 * </cr-settings-radio-group>
15 * @element cr-settings-radio-group
18 is: 'cr-settings-radio-group',
22 * The preference object to control.
23 * @type {chrome.settingsPrivate.PrefObject|undefined}
28 observer: 'prefChanged_'
32 * IronSelectableBehavior selected attribute
36 observer: 'selectedChanged_'
41 prefChanged_: function() {
44 if (this.pref.type == chrome.settingsPrivate.PrefType.NUMBER ||
45 this.pref.type == chrome.settingsPrivate.PrefType.BOOLEAN) {
46 this.selected = this.pref.value.toString();
48 assert(this.pref.type != chrome.settingsPrivate.PrefType.LIST);
49 this.selected = /** @type {string} */(this.pref.value);
54 selectedChanged_: function() {
57 if (this.pref.type == chrome.settingsPrivate.PrefType.NUMBER) {
58 var n = parseInt(this.selected, 10);
60 console.error('Bad selected name for numerical pref: ' + this.selected);
63 this.set('pref.value', n);
64 } else if (this.pref.type == chrome.settingsPrivate.PrefType.BOOLEAN) {
65 this.set('pref.value', this.selected == 'true');
67 assert(this.pref.type != chrome.settingsPrivate.PrefType.LIST);
68 this.set('pref.value', this.selected);