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

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

Issue 2437183002: [MD settings] content site list toggles (Closed)
Patch Set: review changes Created 4 years, 2 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 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 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * `settings-checkbox` is a checkbox that controls a supplied preference. 7 * A behavior to help controls that handle a boolean preference, such as
8 * 8 * checkbox and toggle button.
9 * Example:
10 * <settings-checkbox pref="{{prefs.settings.enableFoo}}"
11 * label="Enable foo setting." subLabel="(bar also)">
12 * </settings-checkbox>
13 */ 9 */
14 Polymer({
15 is: 'settings-checkbox',
16 10
17 behaviors: [CrPolicyPrefBehavior, PrefControlBehavior], 11 /** @polymerBehavior SettingsBooleanControlBehavior */
18 12 var SettingsBooleanControlBehaviorImpl = {
19 properties: { 13 properties: {
20 /** Whether the checkbox should represent the inverted value. */ 14 /** Whether the control should represent the inverted value. */
21 inverted: { 15 inverted: {
22 type: Boolean, 16 type: Boolean,
23 value: false, 17 value: false,
24 }, 18 },
25 19
26 /** Whether the checkbox is checked. */ 20 /** Whether the control is checked. */
27 checked: { 21 checked: {
28 type: Boolean, 22 type: Boolean,
29 value: false, 23 value: false,
30 notify: true, 24 notify: true,
31 observer: 'checkedChanged_', 25 observer: 'checkedChanged_',
32 reflectToAttribute: true 26 reflectToAttribute: true
33 }, 27 },
34 28
35 /** Disabled property for the element. */ 29 /** Disabled property for the element. */
36 disabled: { 30 disabled: {
37 type: Boolean, 31 type: Boolean,
38 value: false, 32 value: false,
39 notify: true, 33 notify: true,
40 reflectToAttribute: true 34 reflectToAttribute: true
41 }, 35 },
42 36
43 /** Checkbox label. */ 37 /** The main label. */
44 label: { 38 label: {
45 type: String, 39 type: String,
46 value: '', 40 value: '',
47 }, 41 },
48 42
49 /** Additional sub-label for the checkbox. */ 43 /** Additional (optional) sub-label. */
50 subLabel: { 44 subLabel: {
51 type: String, 45 type: String,
52 value: '', 46 value: '',
53 }, 47 },
54 }, 48 },
55 49
56 observers: [ 50 observers: [
57 'prefValueChanged_(pref.value)' 51 'prefValueChanged_(pref.value)'
58 ], 52 ],
59 53
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 getNewValue_: function(value) { 85 getNewValue_: function(value) {
92 return this.inverted ? !value : !!value; 86 return this.inverted ? !value : !!value;
93 }, 87 },
94 88
95 /** 89 /**
96 * @param {boolean} disabled 90 * @param {boolean} disabled
97 * @param {!chrome.settingsPrivate.PrefObject} pref 91 * @param {!chrome.settingsPrivate.PrefObject} pref
98 * @return {boolean} Whether the checkbox should be disabled. 92 * @return {boolean} Whether the checkbox should be disabled.
99 * @private 93 * @private
100 */ 94 */
101 checkboxDisabled_: function(disabled, pref) { 95 controlDisabled_: function(disabled, pref) {
102 return disabled || this.isPrefPolicyControlled(pref); 96 return disabled || this.isPrefPolicyControlled(pref);
103 }, 97 },
104 }); 98 };
99
100 /** @polymerBehavior */
101 var SettingsBooleanControlBehavior = [
102 CrPolicyPrefBehavior,
103 PrefControlBehavior,
104 SettingsBooleanControlBehaviorImpl,
105 ];
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698