Skip to content
This repository was archived by the owner on Sep 23, 2021. It is now read-only.

Commit 2b53943

Browse files
committed
Theme ctrl
1 parent 33b85d8 commit 2b53943

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

static/js/slides.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ function isPreview() {
55
function initializeReveal() {
66
// Full list of configuration options available at:
77
// https://github.com/hakimel/reveal.js#configuration
8+
89
Reveal.initialize({
910
controls: true,
1011
progress: true,
@@ -70,6 +71,8 @@ function initializeReveal() {
7071
}
7172
]
7273
});
74+
75+
themesCtrl();
7376
}
7477

7578
function highlightAnyCodeBlocks() {
@@ -112,6 +115,47 @@ function externalLinksInNewWindow() {
112115
insertMarkdownReference();
113116
initializeReveal();
114117

118+
function themesCtrl() {
119+
var defaultTheme = "black.css",
120+
currentTheme = localStorage.getItem('theme?') ||
121+
defaultTheme;
122+
123+
function setTheme(theme) {
124+
cssEl = $("#theme");
125+
cssEl.attr("href", "/static/reveal.js/css/theme/" + theme);
126+
localStorage.setItem('theme?', theme);
127+
}
128+
setTheme(currentTheme);
129+
130+
if (!isPreview()) {
131+
return
132+
}
133+
var availableThemes = [
134+
"black.css",
135+
"beige.css",
136+
"blood.css",
137+
"league.css",
138+
"moon.css",
139+
"night.css",
140+
"serif.css",
141+
"simple.css",
142+
"sky.css",
143+
"solarized.css",
144+
"white.css",
145+
];
146+
themeEl = $("#themes");
147+
availableThemes.forEach(function(theme) {
148+
elem = $("<option value=" + theme + ">" + theme + "</option>");
149+
themeEl.append(elem);
150+
})
151+
themeEl.val(currentTheme);
152+
themeEl.change(function() {
153+
val = themeEl.val()
154+
setTheme(val);
155+
});
156+
themeEl.attr("hidden", false);
157+
}
158+
115159
// Monkey patch Reveal so we can reload markdown through an
116160
// inter window message (using the reveal rpc api)
117161
// (yes, reveal has an rpc api!)

0 commit comments

Comments
 (0)