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 function addToPage(html) { | 5 function addToPage(html) { |
6 var div = document.createElement('div'); | 6 var div = document.createElement('div'); |
7 div.innerHTML = html; | 7 div.innerHTML = html; |
8 document.getElementById('content').appendChild(div); | 8 document.getElementById('content').appendChild(div); |
| 9 fillYouTubePlaceholders(); |
| 10 } |
| 11 |
| 12 function fillYouTubePlaceholders() { |
| 13 var placeholders = document.getElementsByClassName('embed-placeholder'); |
| 14 for (var i = 0; i < placeholders.length; i++) { |
| 15 if (!placeholders[i].hasAttribute('data-type') || |
| 16 placeholders[i].getAttribute('data-type') != 'youtube' || |
| 17 !placeholders[i].hasAttribute('data-id')) { |
| 18 continue; |
| 19 } |
| 20 var embed = document.createElement('iframe'); |
| 21 var url = 'http://www.youtube.com/embed/' + |
| 22 placeholders[i].getAttribute('data-id'); |
| 23 embed.setAttribute('class', 'youtubeIframe'); |
| 24 embed.setAttribute('src', url); |
| 25 embed.setAttribute('type', 'text/html'); |
| 26 embed.setAttribute('frameborder', '0'); |
| 27 |
| 28 var parent = placeholders[i].parentElement; |
| 29 var container = document.createElement('div'); |
| 30 container.setAttribute('class', 'youtubeContainer'); |
| 31 container.appendChild(embed); |
| 32 |
| 33 parent.replaceChild(container, placeholders[i]); |
| 34 } |
9 } | 35 } |
10 | 36 |
11 function showLoadingIndicator(isLastPage) { | 37 function showLoadingIndicator(isLastPage) { |
12 document.getElementById('loadingIndicator').className = | 38 document.getElementById('loadingIndicator').className = |
13 isLastPage ? 'hidden' : 'visible'; | 39 isLastPage ? 'hidden' : 'visible'; |
14 updateLoadingIndicator(isLastPage); | 40 updateLoadingIndicator(isLastPage); |
15 } | 41 } |
16 | 42 |
17 // Maps JS Font Family to CSS class and then changes body class name. | 43 // Maps JS Font Family to CSS class and then changes body class name. |
18 // CSS classes must agree with distilledpage.css. | 44 // CSS classes must agree with distilledpage.css. |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 document.getElementById('feedbackNo').addEventListener('click', function(e) { | 137 document.getElementById('feedbackNo').addEventListener('click', function(e) { |
112 sendFeedback(false); | 138 sendFeedback(false); |
113 document.getElementById('feedbackContainer').className += " fadeOut"; | 139 document.getElementById('feedbackContainer').className += " fadeOut"; |
114 }, true); | 140 }, true); |
115 | 141 |
116 document.getElementById('feedbackContainer').addEventListener('animationend', | 142 document.getElementById('feedbackContainer').addEventListener('animationend', |
117 function(e) { | 143 function(e) { |
118 document.getElementById('feedbackContainer').style.display = "none"; | 144 document.getElementById('feedbackContainer').style.display = "none"; |
119 }, true); | 145 }, true); |
120 | 146 |
OLD | NEW |