OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 /** @const */ var ControlledSettingIndicator = | 6 /** @const */ var ControlledSettingIndicator = |
7 options.ControlledSettingIndicator; | 7 options.ControlledSettingIndicator; |
8 | 8 |
9 /** | 9 /** |
10 * A variant of the {@link ControlledSettingIndicator} that shows the status | 10 * A variant of the {@link ControlledSettingIndicator} that shows the status |
(...skipping 19 matching lines...) Expand all Loading... |
30 /* Handle changes to the associated pref by hiding any currently visible | 30 /* Handle changes to the associated pref by hiding any currently visible |
31 * bubble. | 31 * bubble. |
32 * @param {Event} event Pref change event. | 32 * @param {Event} event Pref change event. |
33 * @override | 33 * @override |
34 */ | 34 */ |
35 handlePrefChange: function(event) { | 35 handlePrefChange: function(event) { |
36 PageManager.hideBubble(); | 36 PageManager.hideBubble(); |
37 }, | 37 }, |
38 | 38 |
39 /** | 39 /** |
40 * Sets the variable tracking thesection which becomes disabled if an | |
41 * error exists. | |
42 * @param {HTMLElement} section The section to disable. | |
43 */ | |
44 set disabledOnErrorSection(section) { | |
45 this.disabledOnErrorSection_ = section; | |
46 }, | |
47 | |
48 /** | |
49 * Returns the current error. | 40 * Returns the current error. |
50 * @return {string} The error message to be displayed. May be undefined if | 41 * @return {string} The error message to be displayed. May be undefined if |
51 * there is no error. | 42 * there is no error. |
52 */ | 43 */ |
53 get errorText() { | 44 get errorText() { |
54 return this.errorText_; | 45 return this.errorText_; |
55 }, | 46 }, |
56 | 47 |
57 /** | 48 /** |
58 * Checks for errors and records them. | 49 * Checks for errors and records them. |
59 * @param {string} errorMsg The error message to be displayed. May be | 50 * @param {string} errorMsg The error message to be displayed. May be |
60 * undefined if there is no error. | 51 * undefined if there is no error. |
61 */ | 52 */ |
62 setError: function(errorMsg) { | 53 setError: function(errorMsg) { |
63 this.setAttribute('controlled-by', 'policy'); | 54 this.setAttribute('controlled-by', 'policy'); |
64 this.errorText_ = errorMsg; | 55 this.errorText_ = errorMsg; |
65 }, | 56 }, |
66 | 57 |
67 /** | 58 /** |
68 * Changes the display to be visible if there are errors and disables | 59 * Changes the display to be visible if there are errors and disables |
69 * the section. | 60 * the section. |
70 */ | 61 */ |
71 updateBasedOnError: function() { | 62 updateBasedOnError: function() { |
72 if (this.errorText_) | 63 if (this.errorText_) |
73 this.hidden = false; | 64 this.hidden = false; |
74 if (this.disabledOnErrorSection_) | |
75 this.disabledOnErrorSection_.disabled = !!this.errorText_; | |
76 }, | 65 }, |
77 | 66 |
78 /** | 67 /** |
79 * Toggles showing and hiding the error message bubble. An empty | 68 * Toggles showing and hiding the error message bubble. An empty |
80 * |errorText_| indicates that there is no error message. So the bubble | 69 * |errorText_| indicates that there is no error message. So the bubble |
81 * only be shown if |errorText_| has a value. | 70 * only be shown if |errorText_| has a value. |
82 */ | 71 */ |
83 toggleBubble_: function() { | 72 toggleBubble_: function() { |
84 if (this.showingBubble) { | 73 if (this.showingBubble) { |
85 PageManager.hideBubble(); | 74 PageManager.hideBubble(); |
(...skipping 23 matching lines...) Expand all Loading... |
109 | 98 |
110 PageManager.showBubble(content, this.image, this, this.location); | 99 PageManager.showBubble(content, this.image, this, this.location); |
111 }, | 100 }, |
112 }; | 101 }; |
113 | 102 |
114 // Export | 103 // Export |
115 return { | 104 return { |
116 HotwordSearchSettingIndicator: HotwordSearchSettingIndicator | 105 HotwordSearchSettingIndicator: HotwordSearchSettingIndicator |
117 }; | 106 }; |
118 }); | 107 }); |
OLD | NEW |