diff options
Diffstat (limited to 'book.js')
-rw-r--r-- | book.js | 25 |
1 files changed, 9 insertions, 16 deletions
@@ -225,7 +225,7 @@ function playground_text(playground, hidden = true) { } var clipButton = document.createElement('button'); - clipButton.className = 'fa fa-copy clip-button'; + clipButton.className = 'clip-button'; clipButton.title = 'Copy to clipboard'; clipButton.setAttribute('aria-label', clipButton.title); clipButton.innerHTML = '<i class=\"tooltiptext\"></i>'; @@ -258,7 +258,7 @@ function playground_text(playground, hidden = true) { if (window.playground_copyable) { var copyCodeClipboardButton = document.createElement('button'); - copyCodeClipboardButton.className = 'fa fa-copy clip-button'; + copyCodeClipboardButton.className = 'clip-button'; copyCodeClipboardButton.innerHTML = '<i class="tooltiptext"></i>'; copyCodeClipboardButton.title = 'Copy to clipboard'; copyCodeClipboardButton.setAttribute('aria-label', copyCodeClipboardButton.title); @@ -289,6 +289,10 @@ function playground_text(playground, hidden = true) { var themeToggleButton = document.getElementById('theme-toggle'); var themePopup = document.getElementById('theme-list'); var themeColorMetaTag = document.querySelector('meta[name="theme-color"]'); + var themeIds = []; + themePopup.querySelectorAll('button.theme').forEach(function (el) { + themeIds.push(el.id); + }); var stylesheets = { ayuHighlight: document.querySelector("[href$='ayu-highlight.css']"), tomorrowNight: document.querySelector("[href$='tomorrow-night.css']"), @@ -317,7 +321,7 @@ function playground_text(playground, hidden = true) { function get_theme() { var theme; try { theme = localStorage.getItem('mdbook-theme'); } catch (e) { } - if (theme === null || theme === undefined) { + if (theme === null || theme === undefined || !themeIds.includes(theme)) { return default_theme; } else { return theme; @@ -459,17 +463,6 @@ function playground_text(playground, hidden = true) { try { localStorage.setItem('mdbook-sidebar', 'visible'); } catch (e) { } } - - var sidebarAnchorToggles = document.querySelectorAll('#sidebar a.toggle'); - - function toggleSection(ev) { - ev.currentTarget.parentElement.classList.toggle('expanded'); - } - - Array.from(sidebarAnchorToggles).forEach(function (el) { - el.addEventListener('click', toggleSection); - }); - function hideSidebar() { body.classList.remove('sidebar-visible') body.classList.add('sidebar-hidden'); @@ -597,12 +590,12 @@ function playground_text(playground, hidden = true) { function hideTooltip(elem) { elem.firstChild.innerText = ""; - elem.className = 'fa fa-copy clip-button'; + elem.className = 'clip-button'; } function showTooltip(elem, msg) { elem.firstChild.innerText = msg; - elem.className = 'fa fa-copy tooltipped'; + elem.className = 'clip-button tooltipped'; } var clipboardSnippets = new ClipboardJS('.clip-button', { |