| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 set errorText(errorMsg) { | 54 set errorText(errorMsg) { |
| 55 this.setAttribute('controlled-by', 'policy'); | 55 this.setAttribute('controlled-by', 'policy'); |
| 56 this.errorText_ = errorMsg; | 56 this.errorText_ = errorMsg; |
| 57 if (errorMsg) | 57 if (errorMsg) |
| 58 this.hidden = false; | 58 this.hidden = false; |
| 59 if (this.disabledOnErrorSection_) | 59 if (this.disabledOnErrorSection_) |
| 60 this.disabledOnErrorSection_.disabled = (errorMsg ? true : false); | 60 this.disabledOnErrorSection_.disabled = (errorMsg ? true : false); |
| 61 }, | 61 }, |
| 62 | 62 |
| 63 /** | 63 /** |
| 64 * Assigns a value to the help link variable. |
| 65 * @param {string} helpLink The text that links to a troubleshooting page. |
| 66 */ |
| 67 set helpLink(helpLinkText) { |
| 68 this.helpLink_ = helpLinkText; |
| 69 }, |
| 70 |
| 71 /** |
| 64 * Toggles showing and hiding the error message bubble. An empty | 72 * Toggles showing and hiding the error message bubble. An empty |
| 65 * |errorText_| indicates that there is no error message. So the bubble | 73 * |errorText_| indicates that there is no error message. So the bubble |
| 66 * only be shown if |errorText_| has a value. | 74 * only be shown if |errorText_| has a value. |
| 67 */ | 75 */ |
| 68 toggleBubble_: function() { | 76 toggleBubble_: function() { |
| 69 if (this.showingBubble) { | 77 if (this.showingBubble) { |
| 70 OptionsPage.hideBubble(); | 78 OptionsPage.hideBubble(); |
| 71 return; | 79 return; |
| 72 } | 80 } |
| 73 | 81 |
| 74 if (!this.errorText_) | 82 if (!this.errorText_) |
| 75 return; | 83 return; |
| 76 | 84 |
| 77 var self = this; | 85 var self = this; |
| 78 // Create the DOM tree for the bubble content. | 86 // Create the DOM tree for the bubble content. |
| 79 var action = document.createElement('button'); | |
| 80 action.classList.add('default-button'); | |
| 81 action.classList.add('controlled-setting-bubble-action'); | |
| 82 action.textContent = loadTimeData.getString('hotwordRetryDownloadButton'); | |
| 83 action.addEventListener('click', function(event) { | |
| 84 self.retryDownload_(); | |
| 85 }); | |
| 86 | |
| 87 var buttonStrip = document.createElement('div'); | |
| 88 buttonStrip.classList.add('button-strip'); | |
| 89 buttonStrip.reversed = true; | |
| 90 buttonStrip.appendChild(action); | |
| 91 | |
| 92 var actionContainer = document.createElement('div'); | |
| 93 actionContainer.classList.add('action-area'); | |
| 94 actionContainer.appendChild(buttonStrip); | |
| 95 | |
| 96 var closeButton = document.createElement('div'); | 87 var closeButton = document.createElement('div'); |
| 97 closeButton.classList.add('close-button'); | 88 closeButton.classList.add('close-button'); |
| 98 | 89 |
| 99 var text = document.createElement('p'); | 90 var text = document.createElement('p'); |
| 100 text.textContent = this.errorText_; | 91 text.textContent = this.errorText_; |
| 101 | 92 |
| 93 var help = document.createElement('p'); |
| 94 help.textContent = this.helpLink_; |
| 95 |
| 96 var textDiv = document.createElement('div'); |
| 97 textDiv.appendChild(text); |
| 98 textDiv.appendChild(help); |
| 99 |
| 102 var container = document.createElement('div'); | 100 var container = document.createElement('div'); |
| 103 container.appendChild(closeButton); | 101 container.appendChild(closeButton); |
| 104 container.appendChild(text); | 102 container.appendChild(textDiv); |
| 105 container.appendChild(actionContainer); | |
| 106 | 103 |
| 107 var content = document.createElement('div'); | 104 var content = document.createElement('div'); |
| 108 content.appendChild(container); | 105 content.appendChild(container); |
| 109 | 106 |
| 110 OptionsPage.showBubble(content, this.image, this, this.location); | 107 OptionsPage.showBubble(content, this.image, this, this.location); |
| 111 }, | 108 }, |
| 112 | |
| 113 retryDownload_: function() { | |
| 114 chrome.send('requestHotwordSetupRetry'); | |
| 115 OptionsPage.hideBubble(); | |
| 116 }, | |
| 117 }; | 109 }; |
| 118 | 110 |
| 119 // Export | 111 // Export |
| 120 return { | 112 return { |
| 121 HotwordSearchSettingIndicator: HotwordSearchSettingIndicator | 113 HotwordSearchSettingIndicator: HotwordSearchSettingIndicator |
| 122 }; | 114 }; |
| 123 }); | 115 }); |
| OLD | NEW |