| 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() { | 117 function showOfflinePagesButtonClick() { |
| 118 if (window.errorPageController) { | 118 if (window.errorPageController) { |
| 119 errorPageController.showSavedPagesButtonClick(); | 119 errorPageController.showOfflinePagesButtonClick(); |
| 120 } | 120 } |
| 121 } | 121 } |
| 122 | 122 |
| 123 function showOfflineCopyButtonClick() { |
| 124 if (window.errorPageController) { |
| 125 errorPageController.showOfflineCopyButtonClick(); |
| 126 } |
| 127 } |
| 128 |
| 123 function detailsButtonClick() { | 129 function detailsButtonClick() { |
| 124 if (window.errorPageController) | 130 if (window.errorPageController) |
| 125 errorPageController.detailsButtonClick(); | 131 errorPageController.detailsButtonClick(); |
| 126 } | 132 } |
| 127 | 133 |
| 128 /** | 134 /** |
| 129 * Replace the reload button with the Google cached copy suggestion. | 135 * Replace the reload button with the Google cached copy suggestion. |
| 130 */ | 136 */ |
| 131 function setUpCachedButton(buttonStrings) { | 137 function setUpCachedButton(buttonStrings) { |
| 132 var reloadButton = document.getElementById('reload-button'); | 138 var reloadButton = document.getElementById('reload-button'); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 149 var primaryControlOnLeft = true; | 155 var primaryControlOnLeft = true; |
| 150 <if expr="is_macosx or is_ios or is_linux or is_android"> | 156 <if expr="is_macosx or is_ios or is_linux or is_android"> |
| 151 primaryControlOnLeft = false; | 157 primaryControlOnLeft = false; |
| 152 </if> | 158 </if> |
| 153 | 159 |
| 154 function onDocumentLoad() { | 160 function onDocumentLoad() { |
| 155 var controlButtonDiv = document.getElementById('control-buttons'); | 161 var controlButtonDiv = document.getElementById('control-buttons'); |
| 156 var reloadButton = document.getElementById('reload-button'); | 162 var reloadButton = document.getElementById('reload-button'); |
| 157 var detailsButton = document.getElementById('details-button'); | 163 var detailsButton = document.getElementById('details-button'); |
| 158 var showSavedCopyButton = document.getElementById('show-saved-copy-button'); | 164 var showSavedCopyButton = document.getElementById('show-saved-copy-button'); |
| 159 var showSavedPagesButton = document.getElementById('show-saved-pages-button'); | 165 var showOfflinePagesButton = |
| 166 document.getElementById('show-offline-pages-button'); |
| 167 var showOfflineCopyButton = |
| 168 document.getElementById('show-offline-copy-button'); |
| 160 | 169 |
| 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') && | 170 var reloadButtonVisible = loadTimeData.valueExists('reloadButton') && |
| 164 loadTimeData.getValue('reloadButton').msg; | 171 loadTimeData.getValue('reloadButton').msg; |
| 165 var showSavedCopyButtonVisible = | 172 var showSavedCopyButtonVisible = |
| 166 loadTimeData.valueExists('showSavedCopyButton') && | 173 loadTimeData.valueExists('showSavedCopyButton') && |
| 167 loadTimeData.getValue('showSavedCopyButton').msg; | 174 loadTimeData.getValue('showSavedCopyButton').msg; |
| 168 var showSavedPagesButtonVisible = | 175 var showOfflinePagesButtonVisible = |
| 169 loadTimeData.valueExists('showSavedPagesButton') && | 176 loadTimeData.valueExists('showOfflinePagesButton') && |
| 170 loadTimeData.getValue('showSavedPagesButton').msg; | 177 loadTimeData.getValue('showOfflinePagesButton').msg; |
| 178 var showOfflineCopyButtonVisible = |
| 179 loadTimeData.valueExists('showOfflineCopyButton') && |
| 180 loadTimeData.getValue('showOfflineCopyButton').msg; |
| 181 |
| 182 // "Show save pages" or "Show offline copy" button will only be provided in |
| 183 // ERR_INTERNET_DISCONNECTED page where "Reload" button will not be provided. |
| 184 var otherButton = reloadButton; |
| 185 if (showOfflinePagesButtonVisible) |
| 186 otherButton = showOfflinePagesButton; |
| 187 if (showOfflineCopyButtonVisible) |
| 188 otherButton = showOfflineCopyButton; |
| 171 | 189 |
| 172 var primaryButton, secondaryButton; | 190 var primaryButton, secondaryButton; |
| 173 if (showSavedCopyButton.primary) { | 191 if (showSavedCopyButton.primary) { |
| 174 primaryButton = showSavedCopyButton; | 192 primaryButton = showSavedCopyButton; |
| 175 secondaryButton = | 193 secondaryButton = otherButton; |
| 176 showSavedPagesButtonVisible ? showSavedPagesButton : reloadButton; | |
| 177 } else { | 194 } else { |
| 178 primaryButton = | 195 primaryButton = otherButton; |
| 179 showSavedPagesButtonVisible ? showSavedPagesButton : reloadButton; | |
| 180 secondaryButton = showSavedCopyButton; | 196 secondaryButton = showSavedCopyButton; |
| 181 } | 197 } |
| 182 | 198 |
| 183 // Sets up the proper button layout for the current platform. | 199 // Sets up the proper button layout for the current platform. |
| 184 if (primaryControlOnLeft) { | 200 if (primaryControlOnLeft) { |
| 185 buttons.classList.add('suggested-left'); | 201 buttons.classList.add('suggested-left'); |
| 186 controlButtonDiv.insertBefore(secondaryButton, primaryButton); | 202 controlButtonDiv.insertBefore(secondaryButton, primaryButton); |
| 187 } else { | 203 } else { |
| 188 buttons.classList.add('suggested-right'); | 204 buttons.classList.add('suggested-right'); |
| 189 controlButtonDiv.insertBefore(primaryButton, secondaryButton); | 205 controlButtonDiv.insertBefore(primaryButton, secondaryButton); |
| 190 } | 206 } |
| 191 | 207 |
| 192 // Check for Google cached copy suggestion. | 208 // Check for Google cached copy suggestion. |
| 193 if (loadTimeData.valueExists('cacheButton')) { | 209 if (loadTimeData.valueExists('cacheButton')) { |
| 194 setUpCachedButton(loadTimeData.getValue('cacheButton')); | 210 setUpCachedButton(loadTimeData.getValue('cacheButton')); |
| 195 } | 211 } |
| 196 | 212 |
| 197 if (reloadButton.style.display == 'none' && | 213 if (reloadButton.style.display == 'none' && |
| 198 showSavedCopyButton.style.display == 'none' && | 214 showSavedCopyButton.style.display == 'none' && |
| 199 showSavedPagesButton.style.display == 'none') { | 215 showOfflinePagesButton.style.display == 'none' && |
| 216 showOfflineCopyButton.style.display == 'none') { |
| 200 detailsButton.classList.add('singular'); | 217 detailsButton.classList.add('singular'); |
| 201 } | 218 } |
| 202 | 219 |
| 203 <if expr="not chromeos"> | 220 <if expr="not chromeos"> |
| 204 // Hide the details button if there are no details to show. | 221 // Hide the details button if there are no details to show. |
| 205 if (loadTimeData.valueExists('summary') && | 222 if (loadTimeData.valueExists('summary') && |
| 206 !loadTimeData.getValue('summary').msg) { | 223 !loadTimeData.getValue('summary').msg) { |
| 207 detailsButton.style.display = 'none'; | 224 detailsButton.style.display = 'none'; |
| 208 } | 225 } |
| 209 </if> | 226 </if> |
| 210 | 227 |
| 211 // Show control buttons. | 228 // Show control buttons. |
| 212 if (reloadButtonVisible || showSavedCopyButtonVisible || | 229 if (reloadButtonVisible || showSavedCopyButtonVisible || |
| 213 showSavedPagesButtonVisible) { | 230 showOfflinePagesButtonVisible || showOfflineCopyButton) { |
| 214 controlButtonDiv.hidden = false; | 231 controlButtonDiv.hidden = false; |
| 215 | 232 |
| 216 // Set the secondary button state in the cases of two call to actions. | 233 // Set the secondary button state in the cases of two call to actions. |
| 217 if ((reloadButtonVisible || showSavedPagesButtonVisible) && | 234 if ((reloadButtonVisible || showOfflinePagesButtonVisible || |
| 235 showOfflineCopyButton) && |
| 218 showSavedCopyButtonVisible) { | 236 showSavedCopyButtonVisible) { |
| 219 secondaryButton.classList.add('secondary-button'); | 237 secondaryButton.classList.add('secondary-button'); |
| 220 } | 238 } |
| 221 } | 239 } |
| 222 | 240 |
| 223 // Add a main message paragraph. | 241 // Add a main message paragraph. |
| 224 if (loadTimeData.valueExists('primaryParagraph')) { | 242 if (loadTimeData.valueExists('primaryParagraph')) { |
| 225 var p = document.querySelector('#main-message p'); | 243 var p = document.querySelector('#main-message p'); |
| 226 p.innerHTML = loadTimeData.getString('primaryParagraph'); | 244 p.innerHTML = loadTimeData.getString('primaryParagraph'); |
| 227 p.hidden = false; | 245 p.hidden = false; |
| 228 } | 246 } |
| 229 } | 247 } |
| 230 | 248 |
| 231 document.addEventListener('DOMContentLoaded', onDocumentLoad); | 249 document.addEventListener('DOMContentLoaded', onDocumentLoad); |
| OLD | NEW |