| OLD | NEW |
| 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-settings-checkbox` is a checkbox that controls a supplied preference. | 7 * `cr-settings-checkbox` is a checkbox that controls a supplied preference. |
| 8 * | 8 * |
| 9 * Example: | 9 * Example: |
| 10 * <cr-settings-checkbox pref="{{prefs.settings.enableFoo}}" | 10 * <cr-settings-checkbox pref="{{prefs.settings.enableFoo}}" |
| 11 * label="Enable foo setting." subLabel="(bar also)"> | 11 * label="Enable foo setting." subLabel="(bar also)"> |
| 12 * </cr-settings-checkbox> | 12 * </cr-settings-checkbox> |
| 13 * | 13 * |
| 14 * @element cr-settings-checkbox | 14 * @element cr-settings-checkbox |
| 15 */ | 15 */ |
| 16 Polymer({ | 16 Polymer({ |
| 17 is: 'cr-settings-checkbox', | 17 is: 'cr-settings-checkbox', |
| 18 | 18 |
| 19 properties: { | 19 properties: { |
| 20 /** | 20 /** |
| 21 * The boolean preference object to control. | 21 * The boolean preference object to control. |
| 22 * @type {?PrefObject} | 22 * @type {?chrome.settingsPrivate.PrefObject} |
| 23 */ | 23 */ |
| 24 pref: { | 24 pref: { |
| 25 type: Object, | 25 type: Object, |
| 26 notify: true | 26 notify: true, |
| 27 value: null |
| 27 }, | 28 }, |
| 28 | 29 |
| 29 inverted: { | 30 inverted: { |
| 30 type: Boolean, | 31 type: Boolean, |
| 31 value: false | 32 value: false |
| 32 }, | 33 }, |
| 33 | 34 |
| 34 checked: { | 35 checked: { |
| 35 type: Boolean, | 36 type: Boolean, |
| 36 value: false, | 37 value: false, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 if (this.pref) { | 71 if (this.pref) { |
| 71 this.pref.value = this.getNewValue_(this.checked); | 72 this.pref.value = this.getNewValue_(this.checked); |
| 72 } | 73 } |
| 73 }, | 74 }, |
| 74 | 75 |
| 75 /** @private */ | 76 /** @private */ |
| 76 getNewValue_: function(val) { | 77 getNewValue_: function(val) { |
| 77 return this.inverted ? !val : val; | 78 return this.inverted ? !val : val; |
| 78 } | 79 } |
| 79 }); | 80 }); |
| OLD | NEW |