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-settings-checkbox` is a checkbox that controls a supplied preference.
10 * <cr-settings-checkbox pref="{{prefs.settings.enableFoo}}"
11 * label="Enable foo setting." subLabel="(bar also)">
12 * </cr-settings-checkbox>
14 * @element cr-settings-checkbox
17 is: 'cr-settings-checkbox',
21 * The boolean preference object to control.
37 observer: 'checkedChanged_'
52 'prefValueChanged_(pref.value)'
57 this.$.events.forward(this.$.checkbox, ['change']);
61 prefValueChanged_: function(prefValue) {
62 // prefValue is initially undefined when Polymer initializes pref.
63 if (prefValue !== undefined) {
64 this.checked = this.getNewValue_(prefValue);
69 checkedChanged_: function() {
71 this.pref.value = this.getNewValue_(this.checked);
76 getNewValue_: function(val) {
77 return this.inverted ? !val : val;