Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 /** | 9 /** |
| 10 * Allows an element to be disabled for several reasons. | 10 * Allows an element to be disabled for several reasons. |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 el.disabledReasons[reason] = true; | 35 el.disabledReasons[reason] = true; |
| 36 } else { | 36 } else { |
| 37 delete el.disabledReasons[reason]; | 37 delete el.disabledReasons[reason]; |
| 38 } | 38 } |
| 39 el.disabled = Object.keys(el.disabledReasons).length > 0; | 39 el.disabled = Object.keys(el.disabledReasons).length > 0; |
| 40 } | 40 } |
| 41 | 41 |
| 42 ///////////////////////////////////////////////////////////////////////////// | 42 ///////////////////////////////////////////////////////////////////////////// |
| 43 // PrefInputElement class: | 43 // PrefInputElement class: |
| 44 | 44 |
| 45 // Define a constructor that uses an input element as its underlying element. | 45 /** |
| 46 * Define a constructor that uses an input element as its underlying element. | |
| 47 * @constructor | |
| 48 * @extends {HTMLInputElement} | |
| 49 */ | |
| 46 var PrefInputElement = cr.ui.define('input'); | 50 var PrefInputElement = cr.ui.define('input'); |
| 47 | 51 |
| 48 PrefInputElement.prototype = { | 52 PrefInputElement.prototype = { |
| 49 // Set up the prototype chain | 53 // Set up the prototype chain |
| 50 __proto__: HTMLInputElement.prototype, | 54 __proto__: HTMLInputElement.prototype, |
| 51 | 55 |
| 52 /** | 56 /** |
| 53 * Initialization function for the cr.ui framework. | 57 * Initialization function for the cr.ui framework. |
| 54 */ | 58 */ |
| 55 decorate: function() { | 59 decorate: function() { |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 316 this.addEventListener('mouseup', this.handleRelease_.bind(this)); | 320 this.addEventListener('mouseup', this.handleRelease_.bind(this)); |
| 317 this.addEventListener('touchcancel', this.handleRelease_.bind(this)); | 321 this.addEventListener('touchcancel', this.handleRelease_.bind(this)); |
| 318 this.addEventListener('touchend', this.handleRelease_.bind(this)); | 322 this.addEventListener('touchend', this.handleRelease_.bind(this)); |
| 319 }, | 323 }, |
| 320 | 324 |
| 321 /** | 325 /** |
| 322 * Update the associated pref when when the user releases the slider. | 326 * Update the associated pref when when the user releases the slider. |
| 323 * @private | 327 * @private |
| 324 */ | 328 */ |
| 325 updatePrefFromState_: function() { | 329 updatePrefFromState_: function() { |
| 326 Preferences.setIntegerPref(this.pref, this.mapPositionToPref(this.value), | 330 Preferences.setIntegerPref(this.pref, |
| 327 !this.dialogPref, this.metric); | 331 this.mapPositionToPref(parseInt(this.value, 10)), !this.dialogPref, |
| 332 this.metric); | |
|
Dan Beam
2014/09/12 03:25:20
Preferences.setIntegerPref(
this.pref,
thi
Vitaly Pavlenko
2014/09/12 19:16:23
Done.
| |
| 328 }, | 333 }, |
| 329 | 334 |
| 330 /** | 335 /** |
| 331 * Ignore changes to the slider position made by the user while the slider | 336 * Ignore changes to the slider position made by the user while the slider |
| 332 * has not been released. | 337 * has not been released. |
| 333 * @private | 338 * @private |
| 334 */ | 339 */ |
| 335 handleChange_: function() { | 340 handleChange_: function() { |
| 336 }, | 341 }, |
| 337 | 342 |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 568 | 573 |
| 569 /** | 574 /** |
| 570 * Whether the associated preference is controlled by a source other than the | 575 * Whether the associated preference is controlled by a source other than the |
| 571 * user's setting (can be 'policy', 'extension', 'recommended' or unset). | 576 * user's setting (can be 'policy', 'extension', 'recommended' or unset). |
| 572 */ | 577 */ |
| 573 cr.defineProperty(PrefButton, 'controlledBy', cr.PropertyKind.ATTR); | 578 cr.defineProperty(PrefButton, 'controlledBy', cr.PropertyKind.ATTR); |
| 574 | 579 |
| 575 // Export | 580 // Export |
| 576 return { | 581 return { |
| 577 PrefCheckbox: PrefCheckbox, | 582 PrefCheckbox: PrefCheckbox, |
| 583 PrefInputElement: PrefInputElement, | |
| 578 PrefNumber: PrefNumber, | 584 PrefNumber: PrefNumber, |
| 579 PrefRadio: PrefRadio, | 585 PrefRadio: PrefRadio, |
| 580 PrefRange: PrefRange, | 586 PrefRange: PrefRange, |
| 581 PrefSelect: PrefSelect, | 587 PrefSelect: PrefSelect, |
| 582 PrefTextField: PrefTextField, | 588 PrefTextField: PrefTextField, |
| 583 PrefPortNumber: PrefPortNumber, | 589 PrefPortNumber: PrefPortNumber, |
| 584 PrefButton: PrefButton | 590 PrefButton: PrefButton |
| 585 }; | 591 }; |
| 586 | 592 |
| 587 }); | 593 }); |
| OLD | NEW |