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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 if (window.errorPageController) { | 106 if (window.errorPageController) { |
107 errorPageController.showSavedCopyButtonClick(); | 107 errorPageController.showSavedCopyButtonClick(); |
108 } | 108 } |
109 } | 109 } |
110 | 110 |
111 function detailsButtonClick() { | 111 function detailsButtonClick() { |
112 if (window.errorPageController) | 112 if (window.errorPageController) |
113 errorPageController.detailsButtonClick(); | 113 errorPageController.detailsButtonClick(); |
114 } | 114 } |
115 | 115 |
116 /** | |
117 * Replace the reload button with the Google cached copy suggestion. | |
118 */ | |
119 function setupCachedButton(buttonStrings) { | |
mmenke
2015/05/13 14:58:40
nit: setUp ("setup" is a noun, want "set up" here
edwardjung
2015/05/13 17:34:34
Done.
| |
120 var reloadButton = document.getElementById('reload-button'); | |
121 | |
122 reloadButton.textContent = buttonStrings.msg; | |
123 reloadButton.url = buttonStrings.cacheUrl; | |
arv (Not doing code reviews)
2015/05/13 14:26:22
No need to add expandos here and below.
| |
124 reloadButton.trackingid = buttonStrings.trackingId; | |
arv (Not doing code reviews)
2015/05/13 14:26:22
trackingid -> trackingId
edwardjung
2015/05/13 17:34:34
Done.
| |
125 reloadButton.removeAttribute('onclick'); | |
arv (Not doing code reviews)
2015/05/13 14:26:22
Why? Instead of using addEventListener on the next
edwardjung
2015/05/13 17:34:34
Good point.
| |
126 reloadButton.addEventListener('click', function(e) { | |
127 e.preventDefault(); | |
arv (Not doing code reviews)
2015/05/13 14:26:22
wrong indentation
edwardjung
2015/05/13 17:34:34
Done.
| |
128 var el = e.currentTarget; | |
129 trackClick(el.trackingid); | |
130 location = el.url; | |
131 }); | |
arv (Not doing code reviews)
2015/05/13 14:26:22
OK. Here is what you will end up with:
var url =
edwardjung
2015/05/13 17:34:34
Done.
| |
132 reloadButton.style.display = ''; | |
133 document.getElementById('control-buttons').hidden = false; | |
134 } | |
135 | |
116 var primaryControlOnLeft = true; | 136 var primaryControlOnLeft = true; |
117 <if expr="is_macosx or is_ios or is_linux or is_android"> | 137 <if expr="is_macosx or is_ios or is_linux or is_android"> |
118 primaryControlOnLeft = false; | 138 primaryControlOnLeft = false; |
119 </if> | 139 </if> |
120 | 140 |
121 function onDocumentLoad() { | 141 function onDocumentLoad() { |
122 var buttonsDiv = document.getElementById('buttons'); | |
123 var controlButtonDiv = document.getElementById('control-buttons'); | 142 var controlButtonDiv = document.getElementById('control-buttons'); |
124 var reloadButton = document.getElementById('reload-button'); | 143 var reloadButton = document.getElementById('reload-button'); |
125 var detailsButton = document.getElementById('details-button'); | 144 var detailsButton = document.getElementById('details-button'); |
126 var showSavedCopyButton = document.getElementById('show-saved-copy-button'); | 145 var showSavedCopyButton = document.getElementById('show-saved-copy-button'); |
127 | 146 |
128 var primaryButton, secondaryButton; | 147 var primaryButton, secondaryButton; |
129 if (showSavedCopyButton.primary) { | 148 if (showSavedCopyButton.primary) { |
130 primaryButton = showSavedCopyButton; | 149 primaryButton = showSavedCopyButton; |
131 secondaryButton = reloadButton; | 150 secondaryButton = reloadButton; |
132 } else { | 151 } else { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 secondaryButton.classList.add('secondary-button'); | 190 secondaryButton.classList.add('secondary-button'); |
172 } | 191 } |
173 } | 192 } |
174 | 193 |
175 // Add a main message paragraph. | 194 // Add a main message paragraph. |
176 if (loadTimeData.valueExists('primaryParagraph')) { | 195 if (loadTimeData.valueExists('primaryParagraph')) { |
177 var p = document.querySelector('#main-message p'); | 196 var p = document.querySelector('#main-message p'); |
178 p.innerHTML = loadTimeData.getString('primaryParagraph'); | 197 p.innerHTML = loadTimeData.getString('primaryParagraph'); |
179 p.hidden = false; | 198 p.hidden = false; |
180 } | 199 } |
200 | |
201 // Check for Google cached copy suggestion. | |
202 if (loadTimeData.valueExists('cacheButton')) { | |
203 setupCachedButton(loadTimeData.getValue('cacheButton')); | |
204 } | |
181 } | 205 } |
182 | 206 |
183 document.addEventListener('DOMContentLoaded', onDocumentLoad); | 207 document.addEventListener('DOMContentLoaded', onDocumentLoad); |
OLD | NEW |