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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 } else { | 104 } else { |
105 toolbarColor = "#F5F5F5"; | 105 toolbarColor = "#F5F5F5"; |
106 } | 106 } |
107 document.getElementById('theme-color').content = toolbarColor; | 107 document.getElementById('theme-color').content = toolbarColor; |
108 } | 108 } |
109 | 109 |
110 function useFontScaling(scaling) { | 110 function useFontScaling(scaling) { |
111 pincher.useFontScaling(scaling); | 111 pincher.useFontScaling(scaling); |
112 } | 112 } |
113 | 113 |
114 /** | |
115 * Show the distiller feedback form. | |
116 * @param questionText The i18n text for the feedback question. | |
117 * @param yesText The i18n text for the feedback answer 'YES'. | |
118 * @param noText The i18n text for the feedback answer 'NO'. | |
119 */ | |
120 function showFeedbackForm(questionText, yesText, noText) { | |
121 // If the distiller is running on iOS, do not show the feedback form. This | |
122 // variable is set in distiller_viewer.cc before this function is run. | |
123 if (distiller_on_ios) return; | |
124 | |
125 document.getElementById('feedbackYes').innerText = yesText; | |
126 document.getElementById('feedbackNo').innerText = noText; | |
127 document.getElementById('feedbackQuestion').innerText = questionText; | |
128 | |
129 document.getElementById('feedbackContainer').classList.remove("hidden"); | |
130 } | |
131 | |
132 // Add a listener to the "View Original" link to report opt-outs. | 114 // Add a listener to the "View Original" link to report opt-outs. |
133 document.getElementById('closeReaderView').addEventListener('click', | 115 document.getElementById('closeReaderView').addEventListener('click', |
134 function(e) { | 116 function(e) { |
135 if (distiller) { | 117 if (distiller) { |
136 distiller.closePanel(true); | 118 distiller.closePanel(true); |
137 } | 119 } |
138 }, true); | 120 }, true); |
139 | 121 |
140 document.getElementById('feedbackYes').addEventListener('click', function(e) { | |
141 if (distiller) { | |
142 distiller.sendFeedback(true); | |
143 } | |
144 document.getElementById('feedbackContainer').className += " fadeOut"; | |
145 }, true); | |
146 | |
147 document.getElementById('feedbackNo').addEventListener('click', function(e) { | |
148 if (distiller) { | |
149 distiller.sendFeedback(false); | |
150 } | |
151 document.getElementById('feedbackContainer').className += " fadeOut"; | |
152 }, true); | |
153 | |
154 document.getElementById('feedbackContainer').addEventListener('animationend', | |
155 function(e) { | |
156 var feedbackContainer = document.getElementById('feedbackContainer'); | |
157 feedbackContainer.classList.remove("fadeOut"); | |
158 document.getElementById('contentWrap').style.paddingBottom = | |
159 window.getComputedStyle(feedbackContainer).height; | |
160 feedbackContainer.className += " hidden"; | |
161 setTimeout(function() { | |
162 // Close the gap where the feedback form was. | |
163 var contentWrap = document.getElementById('contentWrap'); | |
164 contentWrap.style.transition = '0.5s'; | |
165 contentWrap.style.paddingBottom = ''; | |
166 }, 0); | |
167 }, true); | |
168 | |
169 document.getElementById('contentWrap').addEventListener('transitionend', | |
170 function(e) { | |
171 var contentWrap = document.getElementById('contentWrap'); | |
172 contentWrap.style.transition = ''; | |
173 }, true); | |
174 | |
175 updateToolbarColor(); | 122 updateToolbarColor(); |
176 | 123 |
177 var pincher = (function() { | 124 var pincher = (function() { |
178 'use strict'; | 125 'use strict'; |
179 // When users pinch in Reader Mode, the page would zoom in or out as if it | 126 // When users pinch in Reader Mode, the page would zoom in or out as if it |
180 // is a normal web page allowing user-zoom. At the end of pinch gesture, the | 127 // is a normal web page allowing user-zoom. At the end of pinch gesture, the |
181 // page would do text reflow. These pinch-to-zoom and text reflow effects | 128 // page would do text reflow. These pinch-to-zoom and text reflow effects |
182 // are not native, but are emulated using CSS and JavaScript. | 129 // are not native, but are emulated using CSS and JavaScript. |
183 // | 130 // |
184 // In order to achieve near-native zooming and panning frame rate, fake 3D | 131 // In order to achieve near-native zooming and panning frame rate, fake 3D |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 clampedScale = scaling; | 342 clampedScale = scaling; |
396 restoreCenter(); | 343 restoreCenter(); |
397 } | 344 } |
398 }; | 345 }; |
399 }()); | 346 }()); |
400 | 347 |
401 window.addEventListener('touchstart', pincher.handleTouchStart, false); | 348 window.addEventListener('touchstart', pincher.handleTouchStart, false); |
402 window.addEventListener('touchmove', pincher.handleTouchMove, false); | 349 window.addEventListener('touchmove', pincher.handleTouchMove, false); |
403 window.addEventListener('touchend', pincher.handleTouchEnd, false); | 350 window.addEventListener('touchend', pincher.handleTouchEnd, false); |
404 window.addEventListener('touchcancel', pincher.handleTouchCancel, false); | 351 window.addEventListener('touchcancel', pincher.handleTouchCancel, false); |
OLD | NEW |