OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 function toggleHelpBox() { | 5 function toggleHelpBox() { |
6 var helpBoxOuter = document.getElementById('details'); | 6 var helpBoxOuter = document.getElementById('details'); |
7 helpBoxOuter.classList.toggle('hidden'); | 7 helpBoxOuter.classList.toggle('hidden'); |
8 var detailsButton = document.getElementById('details-button'); | 8 var detailsButton = document.getElementById('details-button'); |
9 if (helpBoxOuter.classList.contains('hidden')) | 9 if (helpBoxOuter.classList.contains('hidden')) |
10 detailsButton.innerText = detailsButton.detailsText; | 10 detailsButton.innerText = detailsButton.detailsText; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 location = url; | 107 location = url; |
108 } | 108 } |
109 } | 109 } |
110 | 110 |
111 function showSavedCopyButtonClick() { | 111 function showSavedCopyButtonClick() { |
112 if (window.errorPageController) { | 112 if (window.errorPageController) { |
113 errorPageController.showSavedCopyButtonClick(); | 113 errorPageController.showSavedCopyButtonClick(); |
114 } | 114 } |
115 } | 115 } |
116 | 116 |
| 117 function showSavedPagesButtonClick() { |
| 118 if (window.errorPageController) { |
| 119 errorPageController.showSavedPagesButtonClick(); |
| 120 } |
| 121 } |
| 122 |
117 function detailsButtonClick() { | 123 function detailsButtonClick() { |
118 if (window.errorPageController) | 124 if (window.errorPageController) |
119 errorPageController.detailsButtonClick(); | 125 errorPageController.detailsButtonClick(); |
120 } | 126 } |
121 | 127 |
122 /** | 128 /** |
123 * Replace the reload button with the Google cached copy suggestion. | 129 * Replace the reload button with the Google cached copy suggestion. |
124 */ | 130 */ |
125 function setUpCachedButton(buttonStrings) { | 131 function setUpCachedButton(buttonStrings) { |
126 var reloadButton = document.getElementById('reload-button'); | 132 var reloadButton = document.getElementById('reload-button'); |
(...skipping 16 matching lines...) Expand all Loading... |
143 var primaryControlOnLeft = true; | 149 var primaryControlOnLeft = true; |
144 <if expr="is_macosx or is_ios or is_linux or is_android"> | 150 <if expr="is_macosx or is_ios or is_linux or is_android"> |
145 primaryControlOnLeft = false; | 151 primaryControlOnLeft = false; |
146 </if> | 152 </if> |
147 | 153 |
148 function onDocumentLoad() { | 154 function onDocumentLoad() { |
149 var controlButtonDiv = document.getElementById('control-buttons'); | 155 var controlButtonDiv = document.getElementById('control-buttons'); |
150 var reloadButton = document.getElementById('reload-button'); | 156 var reloadButton = document.getElementById('reload-button'); |
151 var detailsButton = document.getElementById('details-button'); | 157 var detailsButton = document.getElementById('details-button'); |
152 var showSavedCopyButton = document.getElementById('show-saved-copy-button'); | 158 var showSavedCopyButton = document.getElementById('show-saved-copy-button'); |
| 159 var showSavedPagesButton = document.getElementById('show-saved-pages-button'); |
| 160 |
| 161 // "Show save pages" button will only be provided in ERR_INTERNET_DISCONNECTED |
| 162 // page where "Reload" button will not be provided. |
| 163 var reloadButtonVisible = loadTimeData.valueExists('reloadButton') && |
| 164 loadTimeData.getValue('reloadButton').msg; |
| 165 var showSavedCopyButtonVisible = |
| 166 loadTimeData.valueExists('showSavedCopyButton') && |
| 167 loadTimeData.getValue('showSavedCopyButton').msg; |
| 168 var showSavedPagesButtonVisible = |
| 169 loadTimeData.valueExists('showSavedPagesButton') && |
| 170 loadTimeData.getValue('showSavedPagesButton').msg; |
153 | 171 |
154 var primaryButton, secondaryButton; | 172 var primaryButton, secondaryButton; |
155 if (showSavedCopyButton.primary) { | 173 if (showSavedCopyButton.primary) { |
156 primaryButton = showSavedCopyButton; | 174 primaryButton = showSavedCopyButton; |
157 secondaryButton = reloadButton; | 175 secondaryButton = |
| 176 showSavedPagesButtonVisible ? showSavedPagesButton : reloadButton; |
158 } else { | 177 } else { |
159 primaryButton = reloadButton; | 178 primaryButton = |
| 179 showSavedPagesButtonVisible ? showSavedPagesButton : reloadButton; |
160 secondaryButton = showSavedCopyButton; | 180 secondaryButton = showSavedCopyButton; |
161 } | 181 } |
162 | 182 |
163 // Sets up the proper button layout for the current platform. | 183 // Sets up the proper button layout for the current platform. |
164 if (primaryControlOnLeft) { | 184 if (primaryControlOnLeft) { |
165 buttons.classList.add('suggested-left'); | 185 buttons.classList.add('suggested-left'); |
166 controlButtonDiv.insertBefore(secondaryButton, primaryButton); | 186 controlButtonDiv.insertBefore(secondaryButton, primaryButton); |
167 } else { | 187 } else { |
168 buttons.classList.add('suggested-right'); | 188 buttons.classList.add('suggested-right'); |
169 controlButtonDiv.insertBefore(primaryButton, secondaryButton); | 189 controlButtonDiv.insertBefore(primaryButton, secondaryButton); |
170 } | 190 } |
171 | 191 |
172 // Check for Google cached copy suggestion. | 192 // Check for Google cached copy suggestion. |
173 if (loadTimeData.valueExists('cacheButton')) { | 193 if (loadTimeData.valueExists('cacheButton')) { |
174 setUpCachedButton(loadTimeData.getValue('cacheButton')); | 194 setUpCachedButton(loadTimeData.getValue('cacheButton')); |
175 } | 195 } |
176 | 196 |
177 if (reloadButton.style.display == 'none' && | 197 if (reloadButton.style.display == 'none' && |
178 showSavedCopyButton.style.display == 'none') { | 198 showSavedCopyButton.style.display == 'none' && |
| 199 showSavedPagesButton.style.display == 'none') { |
179 detailsButton.classList.add('singular'); | 200 detailsButton.classList.add('singular'); |
180 } | 201 } |
181 | 202 |
182 <if expr="not chromeos"> | 203 <if expr="not chromeos"> |
183 // Hide the details button if there are no details to show. | 204 // Hide the details button if there are no details to show. |
184 if (loadTimeData.valueExists('summary') && | 205 if (loadTimeData.valueExists('summary') && |
185 !loadTimeData.getValue('summary').msg) { | 206 !loadTimeData.getValue('summary').msg) { |
186 detailsButton.style.display = 'none'; | 207 detailsButton.style.display = 'none'; |
187 } | 208 } |
188 </if> | 209 </if> |
189 | 210 |
190 // Show control buttons. | 211 // Show control buttons. |
191 if (loadTimeData.valueExists('reloadButton') && | 212 if (reloadButtonVisible || showSavedCopyButtonVisible || |
192 loadTimeData.getValue('reloadButton').msg || | 213 showSavedPagesButtonVisible) { |
193 loadTimeData.valueExists('showSavedCopyButton') && | |
194 loadTimeData.getValue('showSavedCopyButton').msg) { | |
195 controlButtonDiv.hidden = false; | 214 controlButtonDiv.hidden = false; |
196 | 215 |
197 // Set the secondary button state in the cases of two call to actions. | 216 // Set the secondary button state in the cases of two call to actions. |
198 if (loadTimeData.valueExists('reloadButton') && | 217 if ((reloadButtonVisible || showSavedPagesButtonVisible) && |
199 loadTimeData.getValue('reloadButton').msg && | 218 showSavedCopyButtonVisible) { |
200 loadTimeData.valueExists('showSavedCopyButton') && | |
201 loadTimeData.getValue('showSavedCopyButton').msg) { | |
202 secondaryButton.classList.add('secondary-button'); | 219 secondaryButton.classList.add('secondary-button'); |
203 } | 220 } |
204 } | 221 } |
205 | 222 |
206 // Add a main message paragraph. | 223 // Add a main message paragraph. |
207 if (loadTimeData.valueExists('primaryParagraph')) { | 224 if (loadTimeData.valueExists('primaryParagraph')) { |
208 var p = document.querySelector('#main-message p'); | 225 var p = document.querySelector('#main-message p'); |
209 p.innerHTML = loadTimeData.getString('primaryParagraph'); | 226 p.innerHTML = loadTimeData.getString('primaryParagraph'); |
210 p.hidden = false; | 227 p.hidden = false; |
211 } | 228 } |
212 } | 229 } |
213 | 230 |
214 document.addEventListener('DOMContentLoaded', onDocumentLoad); | 231 document.addEventListener('DOMContentLoaded', onDocumentLoad); |
OLD | NEW |