diff options
author | johannst <johannst@users.noreply.github.com> | 2024-11-07 22:05:24 +0000 |
---|---|---|
committer | johannst <johannst@users.noreply.github.com> | 2024-11-07 22:05:24 +0000 |
commit | 76d0ea3113933da30c1251e8c8b7016a677dfa42 (patch) | |
tree | fcb211abbf7073b679e3e1a54aff52daf53236d0 /book.js | |
parent | eeadf0599a4b8a92dc0f5475e011435e752feddb (diff) | |
download | notes-76d0ea3113933da30c1251e8c8b7016a677dfa42.tar.gz notes-76d0ea3113933da30c1251e8c8b7016a677dfa42.zip |
deploy: 8c7f8b75acf4eb4fc0e8d606cffa4bcdae865606
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', { |