diff --git a/install-mdbook.sh b/install-mdbook.sh index 04e690d6a1ff..abd812585fc2 100755 --- a/install-mdbook.sh +++ b/install-mdbook.sh @@ -1,10 +1,10 @@ #!/bin/bash # The --locked flag is important for reproducible builds. It also # avoids breakage due to skews between mdbook and mdbook-svgbob. -cargo install mdbook --locked --version 0.4.37 +cargo install mdbook --locked --version 0.4.44 cargo install mdbook-svgbob --locked --version 0.2.1 cargo install mdbook-pandoc --locked --version 0.9.3 -cargo install mdbook-i18n-helpers --locked --version 0.3.3 +cargo install mdbook-i18n-helpers --locked --version 0.3.5 cargo install i18n-report --locked --version 0.2.0 # these packages are located in this repository cargo install --path mdbook-exerciser --locked diff --git a/theme/book.js b/theme/book.js index 38ca7068ab04..69a0fc67a337 100644 --- a/theme/book.js +++ b/theme/book.js @@ -290,7 +290,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 = ''; @@ -323,7 +323,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 = ''; copyCodeClipboardButton.title = 'Copy to clipboard'; copyCodeClipboardButton.setAttribute('aria-label', copyCodeClipboardButton.title); @@ -354,6 +354,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']"), @@ -382,7 +386,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; @@ -510,6 +514,7 @@ function playground_text(playground, hidden = true) { var sidebar = document.getElementById("sidebar"); var sidebarLinks = document.querySelectorAll('#sidebar a'); var sidebarToggleButton = document.getElementById("sidebar-toggle"); + var sidebarToggleAnchor = document.getElementById("sidebar-toggle-anchor"); var sidebarResizeHandle = document.getElementById("sidebar-resize-handle"); var firstContact = null; @@ -524,17 +529,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'); @@ -547,22 +541,16 @@ function playground_text(playground, hidden = true) { } // Toggle sidebar - sidebarToggleButton.addEventListener('click', function sidebarToggle() { - if (body.classList.contains("sidebar-hidden")) { + sidebarToggleAnchor.addEventListener('change', function sidebarToggle() { + if (sidebarToggleAnchor.checked) { var current_width = parseInt( document.documentElement.style.getPropertyValue('--sidebar-width'), 10); if (current_width < 150) { document.documentElement.style.setProperty('--sidebar-width', '150px'); } showSidebar(); - } else if (body.classList.contains("sidebar-visible")) { - hideSidebar(); } else { - if (getComputedStyle(sidebar)['transform'] === 'none') { - hideSidebar(); - } else { - showSidebar(); - } + hideSidebar(); } }); @@ -662,12 +650,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', { diff --git a/theme/index.hbs b/theme/index.hbs index 625d6443be66..bbbdc3bdc3e0 100644 --- a/theme/index.hbs +++ b/theme/index.hbs @@ -1,5 +1,5 @@ - + @@ -52,15 +52,17 @@ {{/if}} - - -
+ - + + + + +
- - -