@@ -290,7 +290,7 @@ function playground_text(playground, hidden = true) {
290290 }
291291
292292 var clipButton = document . createElement ( 'button' ) ;
293- clipButton . className = 'fa fa-copy clip-button' ;
293+ clipButton . className = 'clip-button' ;
294294 clipButton . title = 'Copy to clipboard' ;
295295 clipButton . setAttribute ( 'aria-label' , clipButton . title ) ;
296296 clipButton . innerHTML = '<i class=\"tooltiptext\"></i>' ;
@@ -323,7 +323,7 @@ function playground_text(playground, hidden = true) {
323323
324324 if ( window . playground_copyable ) {
325325 var copyCodeClipboardButton = document . createElement ( 'button' ) ;
326- copyCodeClipboardButton . className = 'fa fa-copy clip-button' ;
326+ copyCodeClipboardButton . className = 'clip-button' ;
327327 copyCodeClipboardButton . innerHTML = '<i class="tooltiptext"></i>' ;
328328 copyCodeClipboardButton . title = 'Copy to clipboard' ;
329329 copyCodeClipboardButton . setAttribute ( 'aria-label' , copyCodeClipboardButton . title ) ;
@@ -354,6 +354,10 @@ function playground_text(playground, hidden = true) {
354354 var themeToggleButton = document . getElementById ( 'theme-toggle' ) ;
355355 var themePopup = document . getElementById ( 'theme-list' ) ;
356356 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+ } ) ;
357361 var stylesheets = {
358362 ayuHighlight : document . querySelector ( "[href$='ayu-highlight.css']" ) ,
359363 tomorrowNight : document . querySelector ( "[href$='tomorrow-night.css']" ) ,
@@ -382,7 +386,7 @@ function playground_text(playground, hidden = true) {
382386 function get_theme ( ) {
383387 var theme ;
384388 try { theme = localStorage . getItem ( 'mdbook-theme' ) ; } catch ( e ) { }
385- if ( theme === null || theme === undefined ) {
389+ if ( theme === null || theme === undefined || ! themeIds . includes ( theme ) ) {
386390 return default_theme ;
387391 } else {
388392 return theme ;
@@ -510,6 +514,7 @@ function playground_text(playground, hidden = true) {
510514 var sidebar = document . getElementById ( "sidebar" ) ;
511515 var sidebarLinks = document . querySelectorAll ( '#sidebar a' ) ;
512516 var sidebarToggleButton = document . getElementById ( "sidebar-toggle" ) ;
517+ var sidebarToggleAnchor = document . getElementById ( "sidebar-toggle-anchor" ) ;
513518 var sidebarResizeHandle = document . getElementById ( "sidebar-resize-handle" ) ;
514519 var firstContact = null ;
515520
@@ -524,17 +529,6 @@ function playground_text(playground, hidden = true) {
524529 try { localStorage . setItem ( 'mdbook-sidebar' , 'visible' ) ; } catch ( e ) { }
525530 }
526531
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-
538532 function hideSidebar ( ) {
539533 body . classList . remove ( 'sidebar-visible' )
540534 body . classList . add ( 'sidebar-hidden' ) ;
@@ -547,22 +541,16 @@ function playground_text(playground, hidden = true) {
547541 }
548542
549543 // 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 ) {
552546 var current_width = parseInt (
553547 document . documentElement . style . getPropertyValue ( '--sidebar-width' ) , 10 ) ;
554548 if ( current_width < 150 ) {
555549 document . documentElement . style . setProperty ( '--sidebar-width' , '150px' ) ;
556550 }
557551 showSidebar ( ) ;
558- } else if ( body . classList . contains ( "sidebar-visible" ) ) {
559- hideSidebar ( ) ;
560552 } else {
561- if ( getComputedStyle ( sidebar ) [ 'transform' ] === 'none' ) {
562- hideSidebar ( ) ;
563- } else {
564- showSidebar ( ) ;
565- }
553+ hideSidebar ( ) ;
566554 }
567555 } ) ;
568556
@@ -662,12 +650,12 @@ function playground_text(playground, hidden = true) {
662650
663651 function hideTooltip ( elem ) {
664652 elem . firstChild . innerText = "" ;
665- elem . className = 'fa fa-copy clip-button' ;
653+ elem . className = 'clip-button' ;
666654 }
667655
668656 function showTooltip ( elem , msg ) {
669657 elem . firstChild . innerText = msg ;
670- elem . className = 'fa fa-copy tooltipped' ;
658+ elem . className = 'clip-button tooltipped' ;
671659 }
672660
673661 var clipboardSnippets = new ClipboardJS ( '.clip-button' , {
0 commit comments