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 // This variable allows the page to signal the BrowserProcess |
| 9 // when the first bit of content is loaded. |
| 10 var navigate_on_initial_content_load = false; |
| 11 |
| 12 function setNavigateOnInitialContentLoad(navigate) { |
| 13 navigate_on_initial_content_load = navigate; |
| 14 } |
| 15 |
8 function addToPage(html) { | 16 function addToPage(html) { |
9 var div = document.createElement('div'); | 17 var div = document.createElement('div'); |
10 div.innerHTML = html; | 18 div.innerHTML = html; |
11 document.getElementById('content').appendChild(div); | 19 document.getElementById('content').appendChild(div); |
12 fillYouTubePlaceholders(); | 20 fillYouTubePlaceholders(); |
| 21 |
| 22 if (navigate_on_initial_content_load) { |
| 23 navigate_on_initial_content_load = false; |
| 24 setTimeout(function() { |
| 25 window.location = window.location + "#loaded"; |
| 26 }, 0); |
| 27 } |
13 } | 28 } |
14 | 29 |
15 function fillYouTubePlaceholders() { | 30 function fillYouTubePlaceholders() { |
16 var placeholders = document.getElementsByClassName('embed-placeholder'); | 31 var placeholders = document.getElementsByClassName('embed-placeholder'); |
17 for (var i = 0; i < placeholders.length; i++) { | 32 for (var i = 0; i < placeholders.length; i++) { |
18 if (!placeholders[i].hasAttribute('data-type') || | 33 if (!placeholders[i].hasAttribute('data-type') || |
19 placeholders[i].getAttribute('data-type') != 'youtube' || | 34 placeholders[i].getAttribute('data-type') != 'youtube' || |
20 !placeholders[i].hasAttribute('data-id')) { | 35 !placeholders[i].hasAttribute('data-id')) { |
21 continue; | 36 continue; |
22 } | 37 } |
(...skipping 27 matching lines...) Expand all Loading... |
50 var collapse = document.getElementById('titleCollapse'); | 65 var collapse = document.getElementById('titleCollapse'); |
51 | 66 |
52 collapse.style.height = "0px"; | 67 collapse.style.height = "0px"; |
53 | 68 |
54 holder.textContent = title; | 69 holder.textContent = title; |
55 document.title = title; | 70 document.title = title; |
56 var newHeight = Math.max(90, holder.getBoundingClientRect().height); | 71 var newHeight = Math.max(90, holder.getBoundingClientRect().height); |
57 | 72 |
58 collapse.style.transition = "height 0.2s"; | 73 collapse.style.transition = "height 0.2s"; |
59 collapse.style.height = newHeight + "px"; | 74 collapse.style.height = newHeight + "px"; |
| 75 |
| 76 var mediaQuery = window.matchMedia("print"); |
| 77 mediaQuery.addListener(function (query) { |
| 78 if (query.matches) |
| 79 collapse.style.transition = ''; |
| 80 }); |
60 } | 81 } |
61 | 82 |
62 // Set the text direction of the document ('ltr', 'rtl', or 'auto'). | 83 // Set the text direction of the document ('ltr', 'rtl', or 'auto'). |
63 function setTextDirection(direction) { | 84 function setTextDirection(direction) { |
64 document.body.setAttribute('dir', direction); | 85 document.body.setAttribute('dir', direction); |
65 } | 86 } |
66 | 87 |
67 // Maps JS Font Family to CSS class and then changes body class name. | 88 // Maps JS Font Family to CSS class and then changes body class name. |
68 // CSS classes must agree with distilledpage.css. | 89 // CSS classes must agree with distilledpage.css. |
69 function useFontFamily(fontFamily) { | 90 function useFontFamily(fontFamily) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 // If the distiller is running on iOS, do not show the feedback form. This | 147 // If the distiller is running on iOS, do not show the feedback form. This |
127 // variable is set in distiller_viewer.cc before this function is run. | 148 // variable is set in distiller_viewer.cc before this function is run. |
128 if (distiller_on_ios) return; | 149 if (distiller_on_ios) return; |
129 | 150 |
130 document.getElementById('feedbackYes').innerText = yesText; | 151 document.getElementById('feedbackYes').innerText = yesText; |
131 document.getElementById('feedbackNo').innerText = noText; | 152 document.getElementById('feedbackNo').innerText = noText; |
132 document.getElementById('feedbackQuestion').innerText = questionText; | 153 document.getElementById('feedbackQuestion').innerText = questionText; |
133 | 154 |
134 document.getElementById('contentWrap').style.paddingBottom = '120px'; | 155 document.getElementById('contentWrap').style.paddingBottom = '120px'; |
135 document.getElementById('feedbackContainer').style.display = 'block'; | 156 document.getElementById('feedbackContainer').style.display = 'block'; |
| 157 var mediaQuery = window.matchMedia("print"); |
| 158 mediaQuery.addListener(function (query) { |
| 159 if (query.matches) { |
| 160 document.getElementById('contentWrap').style.paddingBottom = '0px'; |
| 161 document.getElementById('feedbackContainer').style.display = 'none'; |
| 162 } |
| 163 }); |
136 } | 164 } |
137 | 165 |
138 /** | 166 /** |
139 * Send feedback about this distilled article. | 167 * Send feedback about this distilled article. |
140 * @param good True if the feedback was positive, false if negative. | 168 * @param good True if the feedback was positive, false if negative. |
141 */ | 169 */ |
142 function sendFeedback(good) { | 170 function sendFeedback(good) { |
143 var img = document.createElement('img'); | 171 var img = document.createElement('img'); |
144 if (good) { | 172 if (good) { |
145 img.src = '/feedbackgood'; | 173 img.src = '/feedbackgood'; |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 shiftY: shiftY | 405 shiftY: shiftY |
378 }; | 406 }; |
379 } | 407 } |
380 }; | 408 }; |
381 }()); | 409 }()); |
382 | 410 |
383 window.addEventListener('touchstart', pincher.handleTouchStart, false); | 411 window.addEventListener('touchstart', pincher.handleTouchStart, false); |
384 window.addEventListener('touchmove', pincher.handleTouchMove, false); | 412 window.addEventListener('touchmove', pincher.handleTouchMove, false); |
385 window.addEventListener('touchend', pincher.handleTouchEnd, false); | 413 window.addEventListener('touchend', pincher.handleTouchEnd, false); |
386 window.addEventListener('touchcancel', pincher.handleTouchCancel, false); | 414 window.addEventListener('touchcancel', pincher.handleTouchCancel, false); |
OLD | NEW |