| 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 /** | 9 /** |
| 10 * Helper function update element's state from pref change event. | 10 * Helper function update element's state from pref change event. |
| 11 * @private | 11 * @private |
| 12 * @param {!HTMLElement} el The element to update. | 12 * @param {!HTMLElement} el The element to update. |
| 13 * @param {!Event} event The pref change event. | 13 * @param {!Event} event The pref change event. |
| 14 */ | 14 */ |
| 15 function updateElementState_(el, event) { | 15 function updateElementState_(el, event) { |
| 16 el.managed = event.value && event.value['managed'] != undefined ? | 16 el.managed = false; |
| 17 event.value['managed'] : false; | |
| 18 | 17 |
| 19 // Managed UI elements can only be disabled as a result of being | 18 if (!event.value) |
| 20 // managed. They cannot be enabled as a result of a pref being | 19 return; |
| 21 // unmanaged. | |
| 22 if (el.managed) | |
| 23 el.disabled = true; | |
| 24 | 20 |
| 25 // Disable UI elements if backend says so. | 21 el.managed = event.value['managed']; |
| 26 if (!el.disabled && event.value && event.value['disabled']) | 22 |
| 27 el.disabled = true; | 23 // Disable UI elements if the backend says so. |
| 24 // |reenable| is a flag that tells us if the element is disabled because the |
| 25 // preference is not modifiable by the user. If the element is disabled but |
| 26 // the flag is not set, it means that the element has been disabled |
| 27 // somewhere else, so we don't do anything. |
| 28 if (el.disabled && !el.notUserModifiable) |
| 29 return; |
| 30 |
| 31 el.disabled = event.value['disabled']; |
| 32 el.notUserModifiable = event.value['disabled']; |
| 28 } | 33 } |
| 29 | 34 |
| 30 ///////////////////////////////////////////////////////////////////////////// | 35 ///////////////////////////////////////////////////////////////////////////// |
| 31 // PrefCheckbox class: | 36 // PrefCheckbox class: |
| 32 // TODO(jhawkins): Refactor all this copy-pasted code! | 37 // TODO(jhawkins): Refactor all this copy-pasted code! |
| 33 | 38 |
| 34 // Define a constructor that uses an input element as its underlying element. | 39 // Define a constructor that uses an input element as its underlying element. |
| 35 var PrefCheckbox = cr.ui.define('input'); | 40 var PrefCheckbox = cr.ui.define('input'); |
| 36 | 41 |
| 37 PrefCheckbox.prototype = { | 42 PrefCheckbox.prototype = { |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 PrefCheckbox: PrefCheckbox, | 526 PrefCheckbox: PrefCheckbox, |
| 522 PrefNumber: PrefNumber, | 527 PrefNumber: PrefNumber, |
| 523 PrefNumeric: PrefNumeric, | 528 PrefNumeric: PrefNumeric, |
| 524 PrefRadio: PrefRadio, | 529 PrefRadio: PrefRadio, |
| 525 PrefRange: PrefRange, | 530 PrefRange: PrefRange, |
| 526 PrefSelect: PrefSelect, | 531 PrefSelect: PrefSelect, |
| 527 PrefTextField: PrefTextField | 532 PrefTextField: PrefTextField |
| 528 }; | 533 }; |
| 529 | 534 |
| 530 }); | 535 }); |
| OLD | NEW |