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
3 // found in the LICENSE file.
5 cr
.define('options', function() {
6 /** @const */ var ControlledSettingIndicator
=
7 options
.ControlledSettingIndicator
;
10 * A variant of the {@link ControlledSettingIndicator} that shows the status
11 * of the hotword search setting, including a bubble to show setup errors
12 * (such as failures to download extension resources).
14 * @extends {options.ControlledSettingIndicator}
16 var HotwordSearchSettingIndicator
= cr
.ui
.define('span');
18 HotwordSearchSettingIndicator
.prototype = {
19 __proto__
: ControlledSettingIndicator
.prototype,
22 * Decorates the base element to show the proper icon.
25 decorate: function() {
26 ControlledSettingIndicator
.prototype.decorate
.call(this);
31 * Handle changes to the associated pref by hiding any currently visible
33 * @param {Event} event Pref change event.
36 handlePrefChange: function(event
) {
37 PageManager
.hideBubble();
41 * Returns the current error.
42 * @return {string} The error message to be displayed. May be undefined if
46 return this.errorText_
;
50 * Checks for errors and records them.
51 * @param {string} errorMsg The error message to be displayed. May be
52 * undefined if there is no error.
54 setError: function(errorMsg
) {
55 this.setAttribute('controlled-by', 'policy');
56 this.errorText_
= errorMsg
;
60 * Changes the display to be visible if there are errors and disables
63 updateBasedOnError: function() {
69 * Toggles showing and hiding the error message bubble. An empty
70 * |errorText_| indicates that there is no error message. So the bubble
71 * only be shown if |errorText_| has a value.
74 toggleBubble: function() {
75 if (this.showingBubble
) {
76 PageManager
.hideBubble();
84 // Create the DOM tree for the bubble content.
85 var closeButton
= document
.createElement('div');
86 closeButton
.classList
.add('close-button');
88 var text
= document
.createElement('p');
89 text
.innerHTML
= this.errorText_
;
91 var textDiv
= document
.createElement('div');
92 textDiv
.appendChild(text
);
94 var container
= document
.createElement('div');
95 container
.appendChild(closeButton
);
96 container
.appendChild(textDiv
);
98 var content
= document
.createElement('div');
99 content
.appendChild(container
);
101 PageManager
.showBubble(content
, this.image
, this, this.location
);
107 HotwordSearchSettingIndicator
: HotwordSearchSettingIndicator