@@ -290,7 +290,7 @@ function playground_text(playground, hidden = true) {
290
290
}
291
291
292
292
var clipButton = document . createElement ( 'button' ) ;
293
- clipButton . className = 'fa fa-copy clip-button' ;
293
+ clipButton . className = 'clip-button' ;
294
294
clipButton . title = 'Copy to clipboard' ;
295
295
clipButton . setAttribute ( 'aria-label' , clipButton . title ) ;
296
296
clipButton . innerHTML = '<i class=\"tooltiptext\"></i>' ;
@@ -323,7 +323,7 @@ function playground_text(playground, hidden = true) {
323
323
324
324
if ( window . playground_copyable ) {
325
325
var copyCodeClipboardButton = document . createElement ( 'button' ) ;
326
- copyCodeClipboardButton . className = 'fa fa-copy clip-button' ;
326
+ copyCodeClipboardButton . className = 'clip-button' ;
327
327
copyCodeClipboardButton . innerHTML = '<i class="tooltiptext"></i>' ;
328
328
copyCodeClipboardButton . title = 'Copy to clipboard' ;
329
329
copyCodeClipboardButton . setAttribute ( 'aria-label' , copyCodeClipboardButton . title ) ;
@@ -354,6 +354,10 @@ function playground_text(playground, hidden = true) {
354
354
var themeToggleButton = document . getElementById ( 'theme-toggle' ) ;
355
355
var themePopup = document . getElementById ( 'theme-list' ) ;
356
356
var themeColorMetaTag = document . querySelector ( 'meta[name="theme-color"]' ) ;
357
+ var themeIds = [ ] ;
358
+ themePopup . querySelectorAll ( 'button.theme' ) . forEach ( function ( el ) {
359
+ themeIds . push ( el . id ) ;
360
+ } ) ;
357
361
var stylesheets = {
358
362
ayuHighlight : document . querySelector ( "[href$='ayu-highlight.css']" ) ,
359
363
tomorrowNight : document . querySelector ( "[href$='tomorrow-night.css']" ) ,
@@ -382,7 +386,7 @@ function playground_text(playground, hidden = true) {
382
386
function get_theme ( ) {
383
387
var theme ;
384
388
try { theme = localStorage . getItem ( 'mdbook-theme' ) ; } catch ( e ) { }
385
- if ( theme === null || theme === undefined ) {
389
+ if ( theme === null || theme === undefined || ! themeIds . includes ( theme ) ) {
386
390
return default_theme ;
387
391
} else {
388
392
return theme ;
@@ -510,6 +514,7 @@ function playground_text(playground, hidden = true) {
510
514
var sidebar = document . getElementById ( "sidebar" ) ;
511
515
var sidebarLinks = document . querySelectorAll ( '#sidebar a' ) ;
512
516
var sidebarToggleButton = document . getElementById ( "sidebar-toggle" ) ;
517
+ var sidebarToggleAnchor = document . getElementById ( "sidebar-toggle-anchor" ) ;
513
518
var sidebarResizeHandle = document . getElementById ( "sidebar-resize-handle" ) ;
514
519
var firstContact = null ;
515
520
@@ -524,17 +529,6 @@ function playground_text(playground, hidden = true) {
524
529
try { localStorage . setItem ( 'mdbook-sidebar' , 'visible' ) ; } catch ( e ) { }
525
530
}
526
531
527
-
528
- var sidebarAnchorToggles = document . querySelectorAll ( '#sidebar a.toggle' ) ;
529
-
530
- function toggleSection ( ev ) {
531
- ev . currentTarget . parentElement . classList . toggle ( 'expanded' ) ;
532
- }
533
-
534
- Array . from ( sidebarAnchorToggles ) . forEach ( function ( el ) {
535
- el . addEventListener ( 'click' , toggleSection ) ;
536
- } ) ;
537
-
538
532
function hideSidebar ( ) {
539
533
body . classList . remove ( 'sidebar-visible' )
540
534
body . classList . add ( 'sidebar-hidden' ) ;
@@ -547,22 +541,16 @@ function playground_text(playground, hidden = true) {
547
541
}
548
542
549
543
// Toggle sidebar
550
- sidebarToggleButton . addEventListener ( 'click ' , function sidebarToggle ( ) {
551
- if ( body . classList . contains ( "sidebar-hidden" ) ) {
544
+ sidebarToggleAnchor . addEventListener ( 'change ' , function sidebarToggle ( ) {
545
+ if ( sidebarToggleAnchor . checked ) {
552
546
var current_width = parseInt (
553
547
document . documentElement . style . getPropertyValue ( '--sidebar-width' ) , 10 ) ;
554
548
if ( current_width < 150 ) {
555
549
document . documentElement . style . setProperty ( '--sidebar-width' , '150px' ) ;
556
550
}
557
551
showSidebar ( ) ;
558
- } else if ( body . classList . contains ( "sidebar-visible" ) ) {
559
- hideSidebar ( ) ;
560
552
} else {
561
- if ( getComputedStyle ( sidebar ) [ 'transform' ] === 'none' ) {
562
- hideSidebar ( ) ;
563
- } else {
564
- showSidebar ( ) ;
565
- }
553
+ hideSidebar ( ) ;
566
554
}
567
555
} ) ;
568
556
@@ -662,12 +650,12 @@ function playground_text(playground, hidden = true) {
662
650
663
651
function hideTooltip ( elem ) {
664
652
elem . firstChild . innerText = "" ;
665
- elem . className = 'fa fa-copy clip-button' ;
653
+ elem . className = 'clip-button' ;
666
654
}
667
655
668
656
function showTooltip ( elem , msg ) {
669
657
elem . firstChild . innerText = msg ;
670
- elem . className = 'fa fa-copy tooltipped' ;
658
+ elem . className = 'clip-button tooltipped' ;
671
659
}
672
660
673
661
var clipboardSnippets = new ClipboardJS ( '.clip-button' , {
0 commit comments