| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 cr.define('options', function() { | 5 cr.define('options', function() { |
| 6 | 6 |
| 7 var Preferences = options.Preferences; | 7 var Preferences = options.Preferences; |
| 8 ///////////////////////////////////////////////////////////////////////////// | 8 ///////////////////////////////////////////////////////////////////////////// |
| 9 // PrefCheckbox class: | 9 // PrefCheckbox class: |
| 10 // TODO(jhawkins): Refactor all this copy-pasted code! | 10 // TODO(jhawkins): Refactor all this copy-pasted code! |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 | 285 |
| 286 /** | 286 /** |
| 287 * onchange handler that sets the pref when the user changes the value of | 287 * onchange handler that sets the pref when the user changes the value of |
| 288 * the input element. | 288 * the input element. |
| 289 * @private | 289 * @private |
| 290 */ | 290 */ |
| 291 onChange_: function(event) { | 291 onChange_: function(event) { |
| 292 if (this.continuous) | 292 if (this.continuous) |
| 293 this.setRangePref_(); | 293 this.setRangePref_(); |
| 294 | 294 |
| 295 this.notifyChange(this, this.mapValueToRange_(this.value)); | 295 if (this.notifyChange) |
| 296 this.notifyChange(this, this.mapValueToRange_(this.value)); |
| 296 }, | 297 }, |
| 297 | 298 |
| 298 /** | 299 /** |
| 299 * Sets the integer value of |pref| to the value of this element. | 300 * Sets the integer value of |pref| to the value of this element. |
| 300 * @private | 301 * @private |
| 301 */ | 302 */ |
| 302 setRangePref_: function() { | 303 setRangePref_: function() { |
| 303 Preferences.setIntegerPref( | 304 Preferences.setIntegerPref( |
| 304 this.pref, this.mapValueToRange_(this.value), this.metric); | 305 this.pref, this.mapValueToRange_(this.value), this.metric); |
| 306 |
| 307 if (this.notifyPrefChange) |
| 308 this.notifyPrefChange(this, this.mapValueToRange_(this.value)); |
| 305 }, | 309 }, |
| 306 | 310 |
| 307 /** | 311 /** |
| 308 * onkeyup/onmouseup handler that modifies the pref if |continuous| is | 312 * onkeyup/onmouseup handler that modifies the pref if |continuous| is |
| 309 * false. | 313 * false. |
| 310 * @private | 314 * @private |
| 311 */ | 315 */ |
| 312 onInputUp_: function(event) { | 316 onInputUp_: function(event) { |
| 313 if (!this.continuous) | 317 if (!this.continuous) |
| 314 this.setRangePref_(); | 318 this.setRangePref_(); |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 PrefCheckbox: PrefCheckbox, | 515 PrefCheckbox: PrefCheckbox, |
| 512 PrefNumber: PrefNumber, | 516 PrefNumber: PrefNumber, |
| 513 PrefNumeric: PrefNumeric, | 517 PrefNumeric: PrefNumeric, |
| 514 PrefRadio: PrefRadio, | 518 PrefRadio: PrefRadio, |
| 515 PrefRange: PrefRange, | 519 PrefRange: PrefRange, |
| 516 PrefSelect: PrefSelect, | 520 PrefSelect: PrefSelect, |
| 517 PrefTextField: PrefTextField | 521 PrefTextField: PrefTextField |
| 518 }; | 522 }; |
| 519 | 523 |
| 520 }); | 524 }); |
| OLD | NEW |