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