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 } | 9 } |
10 | 10 |
11 function showLoadingIndicator(isLastPage) { | 11 function showLoadingIndicator(isLastPage) { |
12 document.getElementById('loadingIndicator').className = | 12 document.getElementById('loadingIndicator').className = |
13 isLastPage ? 'hidden' : 'visible'; | 13 isLastPage ? 'hidden' : 'visible'; |
14 updateLoadingIndicator(isLastPage); | 14 updateLoadingIndicator(isLastPage); |
15 } | 15 } |
16 | 16 |
| 17 // Maps JS Font Family to CSS class and then changes body class name. |
| 18 // CSS classes must agree with distilledpage.css. |
| 19 function useFontFamily(fontFamily) { |
| 20 var cssClass; |
| 21 if (fontFamily == "serif") { |
| 22 cssClass = "serif"; |
| 23 } else if (fontFamily == "monospace") { |
| 24 cssClass = "monospace"; |
| 25 } else { |
| 26 cssClass = "sans-serif"; |
| 27 } |
| 28 // Relies on the classname order of the body being Theme class, then Font |
| 29 // Family class. |
| 30 var themeClass = document.body.className.split(" ")[0]; |
| 31 document.body.className = themeClass + " " + cssClass; |
| 32 } |
| 33 |
17 // Maps JS theme to CSS class and then changes body class name. | 34 // Maps JS theme to CSS class and then changes body class name. |
18 // CSS classes must agree with distilledpage.css. | 35 // CSS classes must agree with distilledpage.css. |
19 function useTheme(theme) { | 36 function useTheme(theme) { |
20 var cssClass; | 37 var cssClass; |
21 if (theme == "sepia") { | 38 if (theme == "sepia") { |
22 cssClass = "sepia"; | 39 cssClass = "sepia"; |
23 } else if (theme == "dark") { | 40 } else if (theme == "dark") { |
24 cssClass = "dark"; | 41 cssClass = "dark"; |
25 } else { | 42 } else { |
26 cssClass = "light"; | 43 cssClass = "light"; |
27 } | 44 } |
28 document.body.className = cssClass; | 45 // Relies on the classname order of the body being Theme class, then Font |
| 46 // Family class. |
| 47 var fontFamilyClass = document.body.className.split(" ")[1]; |
| 48 document.body.className = cssClass + " " + fontFamilyClass; |
29 } | 49 } |
30 | 50 |
31 var updateLoadingIndicator = function() { | 51 var updateLoadingIndicator = function() { |
32 var colors = ["red", "yellow", "green", "blue"]; | 52 var colors = ["red", "yellow", "green", "blue"]; |
33 return function(isLastPage) { | 53 return function(isLastPage) { |
34 if (!isLastPage && typeof this.colorShuffle == "undefined") { | 54 if (!isLastPage && typeof this.colorShuffle == "undefined") { |
35 var loader = document.getElementById("loader"); | 55 var loader = document.getElementById("loader"); |
36 if (loader) { | 56 if (loader) { |
37 var colorIndex = -1; | 57 var colorIndex = -1; |
38 this.colorShuffle = setInterval(function() { | 58 this.colorShuffle = setInterval(function() { |
39 colorIndex = (colorIndex + 1) % colors.length; | 59 colorIndex = (colorIndex + 1) % colors.length; |
40 loader.className = colors[colorIndex]; | 60 loader.className = colors[colorIndex]; |
41 }, 600); | 61 }, 600); |
42 } | 62 } |
43 } else if (isLastPage && typeof this.colorShuffle != "undefined") { | 63 } else if (isLastPage && typeof this.colorShuffle != "undefined") { |
44 clearInterval(this.colorShuffle); | 64 clearInterval(this.colorShuffle); |
45 } | 65 } |
46 }; | 66 }; |
47 }(); | 67 }(); |
OLD | NEW |