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; |
11 document.getElementById('content').appendChild(div); | 11 document.getElementById('content').appendChild(div); |
12 fillYouTubePlaceholders(); | 12 fillYouTubePlaceholders(); |
13 | |
14 if (typeof navigate_on_initial_content_load !== 'undefined' && | |
15 navigate_on_initial_content_load) { | |
16 navigate_on_initial_content_load = false; | |
17 setTimeout(function() { | |
18 window.location = window.location + "#loaded"; | |
19 }, 0); | |
20 } | |
21 } | 13 } |
22 | 14 |
23 function fillYouTubePlaceholders() { | 15 function fillYouTubePlaceholders() { |
24 var placeholders = document.getElementsByClassName('embed-placeholder'); | 16 var placeholders = document.getElementsByClassName('embed-placeholder'); |
25 for (var i = 0; i < placeholders.length; i++) { | 17 for (var i = 0; i < placeholders.length; i++) { |
26 if (!placeholders[i].hasAttribute('data-type') || | 18 if (!placeholders[i].hasAttribute('data-type') || |
27 placeholders[i].getAttribute('data-type') != 'youtube' || | 19 placeholders[i].getAttribute('data-type') != 'youtube' || |
28 !placeholders[i].hasAttribute('data-id')) { | 20 !placeholders[i].hasAttribute('data-id')) { |
29 continue; | 21 continue; |
30 } | 22 } |
(...skipping 10 matching lines...) Expand all Loading... |
41 container.setAttribute('class', 'youtubeContainer'); | 33 container.setAttribute('class', 'youtubeContainer'); |
42 container.appendChild(embed); | 34 container.appendChild(embed); |
43 | 35 |
44 parent.replaceChild(container, placeholders[i]); | 36 parent.replaceChild(container, placeholders[i]); |
45 } | 37 } |
46 } | 38 } |
47 | 39 |
48 function showLoadingIndicator(isLastPage) { | 40 function showLoadingIndicator(isLastPage) { |
49 document.getElementById('loadingIndicator').className = | 41 document.getElementById('loadingIndicator').className = |
50 isLastPage ? 'hidden' : 'visible'; | 42 isLastPage ? 'hidden' : 'visible'; |
| 43 // This function will be one of the last things to occur when a page is |
| 44 // loaded. This is temporarily used to signal print preview to generate |
| 45 // a PDF. |
| 46 if (isLastPage) { |
| 47 setTimeout(function() { |
| 48 window.location = window.location + "#loaded"; |
| 49 }, 0); |
| 50 } |
51 } | 51 } |
52 | 52 |
53 // Sets the title. | 53 // Sets the title. |
54 function setTitle(title) { | 54 function setTitle(title) { |
55 var holder = document.getElementById('titleHolder'); | 55 var holder = document.getElementById('titleHolder'); |
56 | 56 |
57 holder.textContent = title; | 57 holder.textContent = title; |
58 document.title = title; | 58 document.title = title; |
59 } | 59 } |
60 | 60 |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 clampedScale = scaling; | 403 clampedScale = scaling; |
404 restoreCenter(); | 404 restoreCenter(); |
405 } | 405 } |
406 }; | 406 }; |
407 }()); | 407 }()); |
408 | 408 |
409 window.addEventListener('touchstart', pincher.handleTouchStart, false); | 409 window.addEventListener('touchstart', pincher.handleTouchStart, false); |
410 window.addEventListener('touchmove', pincher.handleTouchMove, false); | 410 window.addEventListener('touchmove', pincher.handleTouchMove, false); |
411 window.addEventListener('touchend', pincher.handleTouchEnd, false); | 411 window.addEventListener('touchend', pincher.handleTouchEnd, false); |
412 window.addEventListener('touchcancel', pincher.handleTouchCancel, false); | 412 window.addEventListener('touchcancel', pincher.handleTouchCancel, false); |
OLD | NEW |