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 var Preferences = options.Preferences; | 6 var Preferences = options.Preferences; |
7 | 7 |
8 /** | 8 /** |
9 * A controlled setting indicator that can be placed on a setting as an | 9 * A controlled setting indicator that can be placed on a setting as an |
10 * indicator that the value is controlled by some external entity such as | 10 * indicator that the value is controlled by some external entity such as |
11 * policy or an extension. | 11 * policy or an extension. |
12 * @constructor | 12 * @constructor |
13 * @extends {HTMLSpanElement} | 13 * @extends {cr.ui.BubbleButton} |
14 */ | 14 */ |
15 var ControlledSettingIndicator = cr.ui.define('span'); | 15 var ControlledSettingIndicator = cr.ui.define('span'); |
16 | 16 |
17 ControlledSettingIndicator.prototype = { | 17 ControlledSettingIndicator.prototype = { |
18 __proto__: cr.ui.BubbleButton.prototype, | 18 __proto__: cr.ui.BubbleButton.prototype, |
19 | 19 |
20 /** | 20 /** |
21 * Decorates the base element to show the proper icon. | 21 * Decorates the base element to show the proper icon. |
22 */ | 22 */ |
23 decorate: function() { | 23 decorate: function() { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 this.controlledBy = | 73 this.controlledBy = |
74 !this.value || String(event.value.recommendedValue) == this.value ? | 74 !this.value || String(event.value.recommendedValue) == this.value ? |
75 'hasRecommendation' : null; | 75 'hasRecommendation' : null; |
76 } else { | 76 } else { |
77 this.controlledBy = null; | 77 this.controlledBy = null; |
78 } | 78 } |
79 }, | 79 }, |
80 | 80 |
81 /** | 81 /** |
82 * Open or close a bubble with further information about the pref. | 82 * Open or close a bubble with further information about the pref. |
83 * @private | 83 * @override |
84 */ | 84 */ |
85 toggleBubble_: function() { | 85 toggleBubble: function() { |
86 if (this.showingBubble) { | 86 if (this.showingBubble) { |
87 PageManager.hideBubble(); | 87 PageManager.hideBubble(); |
88 } else { | 88 } else { |
89 var self = this; | 89 var self = this; |
90 | 90 |
91 // Construct the bubble text. | 91 // Construct the bubble text. |
92 if (this.hasAttribute('plural')) { | 92 if (this.hasAttribute('plural')) { |
93 var defaultStrings = { | 93 var defaultStrings = { |
94 'policy': loadTimeData.getString('controlledSettingsPolicy'), | 94 'policy': loadTimeData.getString('controlledSettingsPolicy'), |
95 'extension': loadTimeData.getString('controlledSettingsExtension'), | 95 'extension': loadTimeData.getString('controlledSettingsExtension'), |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 content.appendChild(extensionContainer); | 180 content.appendChild(extensionContainer); |
181 } | 181 } |
182 | 182 |
183 PageManager.showBubble(content, this.image, this, this.location); | 183 PageManager.showBubble(content, this.image, this, this.location); |
184 } | 184 } |
185 }, | 185 }, |
186 }; | 186 }; |
187 | 187 |
188 /** | 188 /** |
189 * The name of the associated preference. | 189 * The name of the associated preference. |
190 * @type {string} | |
191 */ | 190 */ |
192 cr.defineProperty(ControlledSettingIndicator, 'pref', cr.PropertyKind.ATTR); | 191 cr.defineProperty(ControlledSettingIndicator, 'pref', cr.PropertyKind.ATTR); |
193 | 192 |
194 /** | 193 /** |
195 * Whether this indicator is part of a dialog. If so, changes made to the | 194 * Whether this indicator is part of a dialog. If so, changes made to the |
196 * associated preference take effect in the settings UI immediately but are | 195 * associated preference take effect in the settings UI immediately but are |
197 * only actually committed when the user confirms the dialog. If the user | 196 * only actually committed when the user confirms the dialog. If the user |
198 * cancels the dialog instead, the changes are rolled back in the settings UI | 197 * cancels the dialog instead, the changes are rolled back in the settings UI |
199 * and never committed. | 198 * and never committed. |
200 * @type {boolean} | |
201 */ | 199 */ |
202 cr.defineProperty(ControlledSettingIndicator, 'dialogPref', | 200 cr.defineProperty(ControlledSettingIndicator, 'dialogPref', |
203 cr.PropertyKind.BOOL_ATTR); | 201 cr.PropertyKind.BOOL_ATTR); |
204 | 202 |
205 /** | 203 /** |
206 * The value of the associated preference that the indicator represents. If | 204 * The value of the associated preference that the indicator represents. If |
207 * this is not set, the indicator will be visible whenever any value is | 205 * this is not set, the indicator will be visible whenever any value is |
208 * enforced or recommended. If it is set, the indicator will be visible only | 206 * enforced or recommended. If it is set, the indicator will be visible only |
209 * when the enforced or recommended value matches the value it represents. | 207 * when the enforced or recommended value matches the value it represents. |
210 * This allows multiple indicators to be created for a set of radio buttons, | 208 * This allows multiple indicators to be created for a set of radio buttons, |
211 * ensuring that only one of them is visible at a time. | 209 * ensuring that only one of them is visible at a time. |
212 */ | 210 */ |
213 cr.defineProperty(ControlledSettingIndicator, 'value', | 211 cr.defineProperty(ControlledSettingIndicator, 'value', |
214 cr.PropertyKind.ATTR); | 212 cr.PropertyKind.ATTR); |
215 | 213 |
216 /** | 214 /** |
217 * The status of the associated preference: | 215 * The status of the associated preference: |
218 * - 'policy': A specific value is enfoced by policy. | 216 * - 'policy': A specific value is enforced by policy. |
219 * - 'extension': A specific value is enforced by an extension. | 217 * - 'extension': A specific value is enforced by an extension. |
220 * - 'recommended': A value is recommended by policy. The user could | 218 * - 'recommended': A value is recommended by policy. The user could |
221 * override this recommendation but has not done so. | 219 * override this recommendation but has not done so. |
222 * - 'hasRecommendation': A value is recommended by policy. The user has | 220 * - 'hasRecommendation': A value is recommended by policy. The user has |
223 * overridden this recommendation. | 221 * overridden this recommendation. |
224 * - 'owner': A value is controlled by the owner of the device | 222 * - 'owner': A value is controlled by the owner of the device |
225 * (Chrome OS only). | 223 * (Chrome OS only). |
226 * - 'shared': A value belongs to the primary user but can be | 224 * - 'shared': A value belongs to the primary user but can be |
227 * modified (Chrome OS only). | 225 * modified (Chrome OS only). |
228 * - unset: The value is controlled by the user alone. | 226 * - unset: The value is controlled by the user alone. |
229 * @type {string} | |
230 */ | 227 */ |
231 cr.defineProperty(ControlledSettingIndicator, 'controlledBy', | 228 cr.defineProperty(ControlledSettingIndicator, 'controlledBy', |
232 cr.PropertyKind.ATTR); | 229 cr.PropertyKind.ATTR); |
233 | 230 |
234 // Export. | 231 // Export. |
235 return { | 232 return { |
236 ControlledSettingIndicator: ControlledSettingIndicator | 233 ControlledSettingIndicator: ControlledSettingIndicator |
237 }; | 234 }; |
238 }); | 235 }); |
OLD | NEW |