File tree 1 file changed +13
-7
lines changed
1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -285,7 +285,7 @@ function playpen_text(playpen) {
285
285
function showThemes ( ) {
286
286
themePopup . style . display = 'block' ;
287
287
themeToggleButton . setAttribute ( 'aria-expanded' , true ) ;
288
- themePopup . querySelector ( "button#" + document . body . className ) . focus ( ) ;
288
+ themePopup . querySelector ( "button#" + get_theme ( ) ) . focus ( ) ;
289
289
}
290
290
291
291
function hideThemes ( ) {
@@ -294,6 +294,16 @@ function playpen_text(playpen) {
294
294
themeToggleButton . focus ( ) ;
295
295
}
296
296
297
+ function get_theme ( ) {
298
+ var theme ;
299
+ try { theme = localStorage . getItem ( 'mdbook-theme' ) ; } catch ( e ) { }
300
+ if ( theme === null || theme === undefined ) {
301
+ return default_theme ;
302
+ } else {
303
+ return theme ;
304
+ }
305
+ }
306
+
297
307
function set_theme ( theme , store = true ) {
298
308
let ace_theme ;
299
309
@@ -325,9 +335,7 @@ function playpen_text(playpen) {
325
335
} ) ;
326
336
}
327
337
328
- var previousTheme ;
329
- try { previousTheme = localStorage . getItem ( 'mdbook-theme' ) ; } catch ( e ) { }
330
- if ( previousTheme === null || previousTheme === undefined ) { previousTheme = default_theme ; }
338
+ var previousTheme = get_theme ( ) ;
331
339
332
340
if ( store ) {
333
341
try { localStorage . setItem ( 'mdbook-theme' , theme ) ; } catch ( e ) { }
@@ -338,9 +346,7 @@ function playpen_text(playpen) {
338
346
}
339
347
340
348
// Set theme
341
- var theme ;
342
- try { theme = localStorage . getItem ( 'mdbook-theme' ) ; } catch ( e ) { }
343
- if ( theme === null || theme === undefined ) { theme = default_theme ; }
349
+ var theme = get_theme ( ) ;
344
350
345
351
set_theme ( theme , false ) ;
346
352
You can’t perform that action at this time.
0 commit comments