Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: chrome/renderer/resources/neterror.js

Issue 1442433003: Add "Show saved copy" button in dino page when there's offline copy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update button color for "Show all saved pages" per UI review Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/renderer/resources/neterror.html ('k') | components/error_page.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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;
171 181
172 var primaryButton, secondaryButton; 182 var primaryButton, secondaryButton;
173 if (showSavedCopyButton.primary) { 183 if (showSavedCopyButton.primary) {
174 primaryButton = showSavedCopyButton; 184 primaryButton = showSavedCopyButton;
175 secondaryButton = 185 secondaryButton = reloadButton;
176 showSavedPagesButtonVisible ? showSavedPagesButton : reloadButton;
177 } else { 186 } else {
178 primaryButton = 187 primaryButton = reloadButton;
179 showSavedPagesButtonVisible ? showSavedPagesButton : reloadButton;
180 secondaryButton = showSavedCopyButton; 188 secondaryButton = showSavedCopyButton;
181 } 189 }
182 190
183 // Sets up the proper button layout for the current platform. 191 // Sets up the proper button layout for the current platform.
184 if (primaryControlOnLeft) { 192 if (primaryControlOnLeft) {
185 buttons.classList.add('suggested-left'); 193 buttons.classList.add('suggested-left');
186 controlButtonDiv.insertBefore(secondaryButton, primaryButton); 194 controlButtonDiv.insertBefore(secondaryButton, primaryButton);
187 } else { 195 } else {
188 buttons.classList.add('suggested-right'); 196 buttons.classList.add('suggested-right');
189 controlButtonDiv.insertBefore(primaryButton, secondaryButton); 197 controlButtonDiv.insertBefore(primaryButton, secondaryButton);
190 } 198 }
191 199
192 // Check for Google cached copy suggestion. 200 // Check for Google cached copy suggestion.
193 if (loadTimeData.valueExists('cacheButton')) { 201 if (loadTimeData.valueExists('cacheButton')) {
194 setUpCachedButton(loadTimeData.getValue('cacheButton')); 202 setUpCachedButton(loadTimeData.getValue('cacheButton'));
195 } 203 }
196 204
197 if (reloadButton.style.display == 'none' && 205 if (reloadButton.style.display == 'none' &&
198 showSavedCopyButton.style.display == 'none' && 206 showSavedCopyButton.style.display == 'none' &&
199 showSavedPagesButton.style.display == 'none') { 207 showOfflinePagesButton.style.display == 'none' &&
208 showOfflineCopyButton.style.display == 'none') {
200 detailsButton.classList.add('singular'); 209 detailsButton.classList.add('singular');
201 } 210 }
202 211
203 <if expr="not chromeos"> 212 <if expr="not chromeos">
204 // Hide the details button if there are no details to show. 213 // Hide the details button if there are no details to show.
205 if (loadTimeData.valueExists('summary') && 214 if (loadTimeData.valueExists('summary') &&
206 !loadTimeData.getValue('summary').msg) { 215 !loadTimeData.getValue('summary').msg) {
207 detailsButton.style.display = 'none'; 216 detailsButton.style.display = 'none';
208 } 217 }
209 </if> 218 </if>
210 219
211 // Show control buttons. 220 // Show control buttons.
212 if (reloadButtonVisible || showSavedCopyButtonVisible || 221 if (reloadButtonVisible || showSavedCopyButtonVisible ||
213 showSavedPagesButtonVisible) { 222 showOfflinePagesButtonVisible || showOfflineCopyButton) {
214 controlButtonDiv.hidden = false; 223 controlButtonDiv.hidden = false;
215 224
216 // Set the secondary button state in the cases of two call to actions. 225 // Set the secondary button state in the cases of two call to actions.
217 if ((reloadButtonVisible || showSavedPagesButtonVisible) && 226 if ((reloadButtonVisible || showOfflinePagesButtonVisible ||
227 showOfflineCopyButton) &&
218 showSavedCopyButtonVisible) { 228 showSavedCopyButtonVisible) {
219 secondaryButton.classList.add('secondary-button'); 229 secondaryButton.classList.add('secondary-button');
220 } 230 }
221 } 231 }
222 232
223 // Add a main message paragraph. 233 // Add a main message paragraph.
224 if (loadTimeData.valueExists('primaryParagraph')) { 234 if (loadTimeData.valueExists('primaryParagraph')) {
225 var p = document.querySelector('#main-message p'); 235 var p = document.querySelector('#main-message p');
226 p.innerHTML = loadTimeData.getString('primaryParagraph'); 236 p.innerHTML = loadTimeData.getString('primaryParagraph');
227 p.hidden = false; 237 p.hidden = false;
228 } 238 }
229 } 239 }
230 240
231 document.addEventListener('DOMContentLoaded', onDocumentLoad); 241 document.addEventListener('DOMContentLoaded', onDocumentLoad);
OLDNEW
« no previous file with comments | « chrome/renderer/resources/neterror.html ('k') | components/error_page.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698