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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 // Listen for user events. | 58 // Listen for user events. |
59 this.addEventListener('change', this.handleChange_.bind(this)); | 59 this.addEventListener('change', this.handleChange_.bind(this)); |
60 | 60 |
61 // Listen for pref changes. | 61 // Listen for pref changes. |
62 Preferences.getInstance().addEventListener(this.pref, function(event) { | 62 Preferences.getInstance().addEventListener(this.pref, function(event) { |
63 if (event.value.uncommitted && !self.dialogPref) | 63 if (event.value.uncommitted && !self.dialogPref) |
64 return; | 64 return; |
65 self.updateStateFromPref_(event); | 65 self.updateStateFromPref_(event); |
66 updateDisabledState_(self, 'notUserModifiable', event.value.disabled); | 66 updateDisabledState_(self, 'notUserModifiable', event.value.disabled); |
67 self.controlledBy = event.value.controlledBy; | 67 self.controlledBy = event.value.controlledBy; |
68 OptionsPage.updateManagedBannerVisibility(); | |
69 }); | 68 }); |
70 }, | 69 }, |
71 | 70 |
72 /** | 71 /** |
73 * Handle changes to the input element's state made by the user. If a custom | 72 * Handle changes to the input element's state made by the user. If a custom |
74 * change handler does not suppress it, a default handler is invoked that | 73 * change handler does not suppress it, a default handler is invoked that |
75 * updates the associated pref. | 74 * updates the associated pref. |
76 * @param {Event} event Change event. | 75 * @param {Event} event Change event. |
77 * @private | 76 * @private |
78 */ | 77 */ |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 // Listen for pref changes. | 481 // Listen for pref changes. |
483 // This element behaves like a normal button and does not affect the | 482 // This element behaves like a normal button and does not affect the |
484 // underlying preference; it just becomes disabled when the preference is | 483 // underlying preference; it just becomes disabled when the preference is |
485 // managed, and its value is false. This is useful for buttons that should | 484 // managed, and its value is false. This is useful for buttons that should |
486 // be disabled when the underlying Boolean preference is set to false by a | 485 // be disabled when the underlying Boolean preference is set to false by a |
487 // policy or extension. | 486 // policy or extension. |
488 Preferences.getInstance().addEventListener(this.pref, function(event) { | 487 Preferences.getInstance().addEventListener(this.pref, function(event) { |
489 updateDisabledState_(self, 'notUserModifiable', | 488 updateDisabledState_(self, 'notUserModifiable', |
490 event.value.disabled && !event.value.value); | 489 event.value.disabled && !event.value.value); |
491 self.controlledBy = event.value.controlledBy; | 490 self.controlledBy = event.value.controlledBy; |
492 OptionsPage.updateManagedBannerVisibility(); | |
493 }); | 491 }); |
494 }, | 492 }, |
495 | 493 |
496 /** | 494 /** |
497 * See |updateDisabledState_| above. | 495 * See |updateDisabledState_| above. |
498 */ | 496 */ |
499 setDisabled: function(reason, disabled) { | 497 setDisabled: function(reason, disabled) { |
500 updateDisabledState_(this, reason, disabled); | 498 updateDisabledState_(this, reason, disabled); |
501 }, | 499 }, |
502 }; | 500 }; |
(...skipping 16 matching lines...) Expand all Loading... |
519 PrefCheckbox: PrefCheckbox, | 517 PrefCheckbox: PrefCheckbox, |
520 PrefNumber: PrefNumber, | 518 PrefNumber: PrefNumber, |
521 PrefRadio: PrefRadio, | 519 PrefRadio: PrefRadio, |
522 PrefRange: PrefRange, | 520 PrefRange: PrefRange, |
523 PrefSelect: PrefSelect, | 521 PrefSelect: PrefSelect, |
524 PrefTextField: PrefTextField, | 522 PrefTextField: PrefTextField, |
525 PrefButton: PrefButton | 523 PrefButton: PrefButton |
526 }; | 524 }; |
527 | 525 |
528 }); | 526 }); |
OLD | NEW |