| 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( |
| 327 !this.dialogPref, this.metric); | 331 this.pref, |
| 332 this.mapPositionToPref(parseInt(this.value, 10)), |
| 333 !this.dialogPref, |
| 334 this.metric); |
| 328 }, | 335 }, |
| 329 | 336 |
| 330 /** | 337 /** |
| 331 * Ignore changes to the slider position made by the user while the slider | 338 * Ignore changes to the slider position made by the user while the slider |
| 332 * has not been released. | 339 * has not been released. |
| 333 * @private | 340 * @private |
| 334 */ | 341 */ |
| 335 handleChange_: function() { | 342 handleChange_: function() { |
| 336 }, | 343 }, |
| 337 | 344 |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 | 575 |
| 569 /** | 576 /** |
| 570 * Whether the associated preference is controlled by a source other than the | 577 * Whether the associated preference is controlled by a source other than the |
| 571 * user's setting (can be 'policy', 'extension', 'recommended' or unset). | 578 * user's setting (can be 'policy', 'extension', 'recommended' or unset). |
| 572 */ | 579 */ |
| 573 cr.defineProperty(PrefButton, 'controlledBy', cr.PropertyKind.ATTR); | 580 cr.defineProperty(PrefButton, 'controlledBy', cr.PropertyKind.ATTR); |
| 574 | 581 |
| 575 // Export | 582 // Export |
| 576 return { | 583 return { |
| 577 PrefCheckbox: PrefCheckbox, | 584 PrefCheckbox: PrefCheckbox, |
| 585 PrefInputElement: PrefInputElement, |
| 578 PrefNumber: PrefNumber, | 586 PrefNumber: PrefNumber, |
| 579 PrefRadio: PrefRadio, | 587 PrefRadio: PrefRadio, |
| 580 PrefRange: PrefRange, | 588 PrefRange: PrefRange, |
| 581 PrefSelect: PrefSelect, | 589 PrefSelect: PrefSelect, |
| 582 PrefTextField: PrefTextField, | 590 PrefTextField: PrefTextField, |
| 583 PrefPortNumber: PrefPortNumber, | 591 PrefPortNumber: PrefPortNumber, |
| 584 PrefButton: PrefButton | 592 PrefButton: PrefButton |
| 585 }; | 593 }; |
| 586 | 594 |
| 587 }); | 595 }); |
| OLD | NEW |