| 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(); | 9 fillYouTubePlaceholders(); |
| 10 } | 10 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 // Sets the title. The title will be exposed with a simple animation. This | 43 // Sets the title. The title will be exposed with a simple animation. This |
| 44 // should only be used when the title was not included in the initial html. | 44 // should only be used when the title was not included in the initial html. |
| 45 function setTitle(title) { | 45 function setTitle(title) { |
| 46 var holder = document.getElementById('titleHolder'); | 46 var holder = document.getElementById('titleHolder'); |
| 47 var collapse = document.getElementById('titleCollapse'); | 47 var collapse = document.getElementById('titleCollapse'); |
| 48 | 48 |
| 49 collapse.style.height = "0px"; | 49 collapse.style.height = "0px"; |
| 50 | 50 |
| 51 holder.textContent = title; | 51 holder.textContent = title; |
| 52 document.title = title; |
| 52 var newHeight = Math.max(90, holder.getBoundingClientRect().height); | 53 var newHeight = Math.max(90, holder.getBoundingClientRect().height); |
| 53 | 54 |
| 54 collapse.style.transition = "height 0.2s"; | 55 collapse.style.transition = "height 0.2s"; |
| 55 collapse.style.height = newHeight + "px"; | 56 collapse.style.height = newHeight + "px"; |
| 56 } | 57 } |
| 57 | 58 |
| 59 // Set the text direction of the document ('ltr', 'rtl', or 'auto'). |
| 60 function setTextDirection(direction) { |
| 61 document.body.setAttribute('dir', direction); |
| 62 } |
| 63 |
| 58 // Maps JS Font Family to CSS class and then changes body class name. | 64 // Maps JS Font Family to CSS class and then changes body class name. |
| 59 // CSS classes must agree with distilledpage.css. | 65 // CSS classes must agree with distilledpage.css. |
| 60 function useFontFamily(fontFamily) { | 66 function useFontFamily(fontFamily) { |
| 61 var cssClass; | 67 var cssClass; |
| 62 if (fontFamily == "serif") { | 68 if (fontFamily == "serif") { |
| 63 cssClass = "serif"; | 69 cssClass = "serif"; |
| 64 } else if (fontFamily == "monospace") { | 70 } else if (fontFamily == "monospace") { |
| 65 cssClass = "monospace"; | 71 cssClass = "monospace"; |
| 66 } else { | 72 } else { |
| 67 cssClass = "sans-serif"; | 73 cssClass = "sans-serif"; |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 shiftY: shiftY | 368 shiftY: shiftY |
| 363 }; | 369 }; |
| 364 } | 370 } |
| 365 }; | 371 }; |
| 366 }()); | 372 }()); |
| 367 | 373 |
| 368 window.addEventListener('touchstart', pincher.handleTouchStart, false); | 374 window.addEventListener('touchstart', pincher.handleTouchStart, false); |
| 369 window.addEventListener('touchmove', pincher.handleTouchMove, false); | 375 window.addEventListener('touchmove', pincher.handleTouchMove, false); |
| 370 window.addEventListener('touchend', pincher.handleTouchEnd, false); | 376 window.addEventListener('touchend', pincher.handleTouchEnd, false); |
| 371 window.addEventListener('touchcancel', pincher.handleTouchCancel, false); | 377 window.addEventListener('touchcancel', pincher.handleTouchCancel, false); |
| OLD | NEW |