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 // This variable will be changed by iOS scripts. | 5 // This variable will be changed by iOS scripts. |
6 var distiller_on_ios = false; | 6 var distiller_on_ios = false; |
7 | 7 |
8 function addToPage(html) { | 8 function addToPage(html) { |
9 var div = document.createElement('div'); | 9 var div = document.createElement('div'); |
10 div.innerHTML = html; | 10 div.innerHTML = html; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 */ | 130 */ |
131 function showFeedbackForm(questionText, yesText, noText) { | 131 function showFeedbackForm(questionText, yesText, noText) { |
132 // If the distiller is running on iOS, do not show the feedback form. This | 132 // If the distiller is running on iOS, do not show the feedback form. This |
133 // variable is set in distiller_viewer.cc before this function is run. | 133 // variable is set in distiller_viewer.cc before this function is run. |
134 if (distiller_on_ios) return; | 134 if (distiller_on_ios) return; |
135 | 135 |
136 document.getElementById('feedbackYes').innerText = yesText; | 136 document.getElementById('feedbackYes').innerText = yesText; |
137 document.getElementById('feedbackNo').innerText = noText; | 137 document.getElementById('feedbackNo').innerText = noText; |
138 document.getElementById('feedbackQuestion').innerText = questionText; | 138 document.getElementById('feedbackQuestion').innerText = questionText; |
139 | 139 |
140 document.getElementById('contentWrap').style.paddingBottom = '120px'; | 140 document.getElementById('feedbackContainer').classList.remove("hidden"); |
141 document.getElementById('feedbackContainer').style.display = 'block'; | |
142 var mediaQuery = window.matchMedia("print"); | |
143 mediaQuery.addListener(function (query) { | |
144 if (query.matches) { | |
145 document.getElementById('contentWrap').style.paddingBottom = '0px'; | |
146 document.getElementById('feedbackContainer').style.display = 'none'; | |
147 } else { | |
148 document.getElementById('contentWrap').style.paddingBottom = '120px'; | |
149 document.getElementById('feedbackContainer').style.display = 'block'; | |
150 } | |
151 }); | |
152 } | 141 } |
153 | 142 |
154 /** | 143 /** |
155 * Send feedback about this distilled article. | 144 * Send feedback about this distilled article. |
156 * @param good True if the feedback was positive, false if negative. | 145 * @param good True if the feedback was positive, false if negative. |
157 */ | 146 */ |
158 function sendFeedback(good) { | 147 function sendFeedback(good) { |
159 var img = document.createElement('img'); | 148 var img = document.createElement('img'); |
160 if (good) { | 149 if (good) { |
161 img.src = '/feedbackgood'; | 150 img.src = '/feedbackgood'; |
(...skipping 18 matching lines...) Expand all Loading... |
180 document.getElementById('feedbackContainer').className += " fadeOut"; | 169 document.getElementById('feedbackContainer').className += " fadeOut"; |
181 }, true); | 170 }, true); |
182 | 171 |
183 document.getElementById('feedbackNo').addEventListener('click', function(e) { | 172 document.getElementById('feedbackNo').addEventListener('click', function(e) { |
184 sendFeedback(false); | 173 sendFeedback(false); |
185 document.getElementById('feedbackContainer').className += " fadeOut"; | 174 document.getElementById('feedbackContainer').className += " fadeOut"; |
186 }, true); | 175 }, true); |
187 | 176 |
188 document.getElementById('feedbackContainer').addEventListener('animationend', | 177 document.getElementById('feedbackContainer').addEventListener('animationend', |
189 function(e) { | 178 function(e) { |
190 document.getElementById('feedbackContainer').style.display = 'none'; | 179 var feedbackContainer = document.getElementById('feedbackContainer'); |
191 // Close the gap where the feedback form was. | 180 feedbackContainer.classList.remove("fadeOut"); |
192 var contentWrap = document.getElementById('contentWrap'); | 181 feedbackContainer.className += " hidden"; |
193 contentWrap.style.transition = '0.5s'; | 182 document.getElementById('contentWrap').style.paddingBottom = '120px'; |
194 contentWrap.style.paddingBottom = '0px'; | 183 setTimeout(function() { |
| 184 // Close the gap where the feedback form was. |
| 185 var contentWrap = document.getElementById('contentWrap'); |
| 186 contentWrap.style.transition = '0.5s'; |
| 187 contentWrap.style.paddingBottom = ''; |
| 188 }, 0); |
195 }, true); | 189 }, true); |
196 | 190 |
197 document.getElementById('contentWrap').addEventListener('transitionend', | 191 document.getElementById('contentWrap').addEventListener('transitionend', |
198 function(e) { | 192 function(e) { |
199 var contentWrap = document.getElementById('contentWrap'); | 193 var contentWrap = document.getElementById('contentWrap'); |
200 contentWrap.style.transition = ''; | 194 contentWrap.style.transition = ''; |
201 }, true); | 195 }, true); |
202 | 196 |
203 var pincher = (function() { | 197 var pincher = (function() { |
204 'use strict'; | 198 'use strict'; |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 shiftY: shiftY | 387 shiftY: shiftY |
394 }; | 388 }; |
395 } | 389 } |
396 }; | 390 }; |
397 }()); | 391 }()); |
398 | 392 |
399 window.addEventListener('touchstart', pincher.handleTouchStart, false); | 393 window.addEventListener('touchstart', pincher.handleTouchStart, false); |
400 window.addEventListener('touchmove', pincher.handleTouchMove, false); | 394 window.addEventListener('touchmove', pincher.handleTouchMove, false); |
401 window.addEventListener('touchend', pincher.handleTouchEnd, false); | 395 window.addEventListener('touchend', pincher.handleTouchEnd, false); |
402 window.addEventListener('touchcancel', pincher.handleTouchCancel, false); | 396 window.addEventListener('touchcancel', pincher.handleTouchCancel, false); |
OLD | NEW |