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

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

Issue 1477773003: Use dom-if to hide settings pages and show explicitly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 * `settings-checkbox` is a checkbox that controls a supplied preference. 7 * `settings-checkbox` is a checkbox that controls a supplied preference.
8 * 8 *
9 * Example: 9 * Example:
10 * <settings-checkbox pref="{{prefs.settings.enableFoo}}" 10 * <settings-checkbox pref="{{prefs.settings.enableFoo}}"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 */ 80 */
81 prefValueChanged_: function(prefValue) { 81 prefValueChanged_: function(prefValue) {
82 this.checked = this.getNewValue_(prefValue); 82 this.checked = this.getNewValue_(prefValue);
83 }, 83 },
84 84
85 /** 85 /**
86 * Polymer observer for checked. 86 * Polymer observer for checked.
87 * @private 87 * @private
88 */ 88 */
89 checkedChanged_: function() { 89 checkedChanged_: function() {
90 this.set('pref.value', this.getNewValue_(this.checked)); 90 if (!this.pref)
91 return;
92 var newvalue = this.getNewValue_(this.checked);
93 if (this.pref.type == chrome.settingsPrivate.PrefType.NUMBER)
94 newvalue = newvalue ? 1 : 0;
95 this.set('pref.value', newvalue);
91 }, 96 },
92 97
93 /** 98 /**
94 * @param {*} value 99 * @param {*} value
95 * @return {boolean} The value as a boolean, inverted if |inverted| is true. 100 * @return {boolean} The value as a boolean, inverted if |inverted| is true.
96 * @private 101 * @private
97 */ 102 */
98 getNewValue_: function(value) { 103 getNewValue_: function(value) {
99 return this.inverted ? !value : !!value; 104 return this.inverted ? !value : !!value;
100 }, 105 },
101 106
102 /** 107 /**
103 * @param {boolean} disabled 108 * @param {boolean} disabled
104 * @param {!chrome.settingsPrivate.PrefObject} pref 109 * @param {!chrome.settingsPrivate.PrefObject} pref
105 * @return {boolean} Whether the checkbox should be disabled. 110 * @return {boolean} Whether the checkbox should be disabled.
106 * @private 111 * @private
107 */ 112 */
108 checkboxDisabled_: function(disabled, pref) { 113 checkboxDisabled_: function(disabled, pref) {
109 return disabled || this.isPrefPolicyControlled(pref); 114 return disabled || this.isPrefPolicyControlled(pref);
110 }, 115 },
111 }); 116 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698