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 25 matching lines...) Expand all Loading... |
36 parent.replaceChild(container, placeholders[i]); | 36 parent.replaceChild(container, placeholders[i]); |
37 } | 37 } |
38 } | 38 } |
39 | 39 |
40 function showLoadingIndicator(isLastPage) { | 40 function showLoadingIndicator(isLastPage) { |
41 document.getElementById('loadingIndicator').className = | 41 document.getElementById('loadingIndicator').className = |
42 isLastPage ? 'hidden' : 'visible'; | 42 isLastPage ? 'hidden' : 'visible'; |
43 updateLoadingIndicator(isLastPage); | 43 updateLoadingIndicator(isLastPage); |
44 } | 44 } |
45 | 45 |
46 // Sets the title. The title will be exposed with a simple animation. This | 46 // Sets the title. |
47 // should only be used when the title was not included in the initial html. | |
48 function setTitle(title) { | 47 function setTitle(title) { |
49 var holder = document.getElementById('titleHolder'); | 48 var holder = document.getElementById('titleHolder'); |
50 var collapse = document.getElementById('titleCollapse'); | |
51 | |
52 collapse.style.height = "0px"; | |
53 | 49 |
54 holder.textContent = title; | 50 holder.textContent = title; |
55 document.title = title; | 51 document.title = title; |
56 var newHeight = Math.max(90, holder.getBoundingClientRect().height); | |
57 | |
58 collapse.style.transition = "height 0.2s"; | |
59 collapse.style.height = newHeight + "px"; | |
60 } | 52 } |
61 | 53 |
62 // Set the text direction of the document ('ltr', 'rtl', or 'auto'). | 54 // Set the text direction of the document ('ltr', 'rtl', or 'auto'). |
63 function setTextDirection(direction) { | 55 function setTextDirection(direction) { |
64 document.body.setAttribute('dir', direction); | 56 document.body.setAttribute('dir', direction); |
65 } | 57 } |
66 | 58 |
67 // Maps JS Font Family to CSS class and then changes body class name. | 59 // Maps JS Font Family to CSS class and then changes body class name. |
68 // CSS classes must agree with distilledpage.css. | 60 // CSS classes must agree with distilledpage.css. |
69 function useFontFamily(fontFamily) { | 61 function useFontFamily(fontFamily) { |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 shiftY: shiftY | 369 shiftY: shiftY |
378 }; | 370 }; |
379 } | 371 } |
380 }; | 372 }; |
381 }()); | 373 }()); |
382 | 374 |
383 window.addEventListener('touchstart', pincher.handleTouchStart, false); | 375 window.addEventListener('touchstart', pincher.handleTouchStart, false); |
384 window.addEventListener('touchmove', pincher.handleTouchMove, false); | 376 window.addEventListener('touchmove', pincher.handleTouchMove, false); |
385 window.addEventListener('touchend', pincher.handleTouchEnd, false); | 377 window.addEventListener('touchend', pincher.handleTouchEnd, false); |
386 window.addEventListener('touchcancel', pincher.handleTouchCancel, false); | 378 window.addEventListener('touchcancel', pincher.handleTouchCancel, false); |
OLD | NEW |