diff --git a/documentation/themes/beastie/assets/js/copy-clipboard.js b/documentation/themes/beastie/assets/js/copy-clipboard.js index 4b11058422..126f2bf8b1 100644 --- a/documentation/themes/beastie/assets/js/copy-clipboard.js +++ b/documentation/themes/beastie/assets/js/copy-clipboard.js @@ -1,66 +1,69 @@ /* BSD 2-Clause License Copyright (c) 2001-2022, The FreeBSD Documentation Project Copyright (c) 2021-2022, Sergio Carlavilla All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -(function () { +;(function () { + 'use strict' + document.querySelectorAll(".rouge, .highlight").forEach(function(codeItem) { var sourceCode = codeItem.textContent; var icon = document.createElement("i"); icon.className = "fa fa-clipboard"; var tooltip = document.createElement("span"); tooltip.className = "tooltip"; tooltip.innerHTML = "Copied!"; var button = document.createElement("button"); button.title = "Copy to clipboard"; button.appendChild(icon); button.appendChild(tooltip); var clipboardWrapper = document.createElement("div"); clipboardWrapper.className = "copy-to-clipboard-wrapper"; clipboardWrapper.appendChild(button); codeItem.appendChild(clipboardWrapper); button.addEventListener('click', copyToClipboard.bind(button, sourceCode)); }); -})(); -function copyToClipboard(text, item) { - const tooltip = item.target.nextElementSibling; - window.navigator.clipboard.writeText(text).then(function() { - if (tooltip) { - tooltip.classList.add("show-tooltip"); - setTimeout(function(){ - tooltip.classList.remove("show-tooltip"); - }, 1200); - } - }); -} + function copyToClipboard(text, item) { + const tooltip = item.target.nextElementSibling; + window.navigator.clipboard.writeText(text).then(function() { + if (tooltip) { + tooltip.classList.add("show-tooltip"); + setTimeout(function(){ + tooltip.classList.remove("show-tooltip"); + }, 1200); + } + }); + } + +})(); diff --git a/documentation/themes/beastie/assets/js/search.js b/documentation/themes/beastie/assets/js/search.js index cab7098d09..0cf9a29bb2 100644 --- a/documentation/themes/beastie/assets/js/search.js +++ b/documentation/themes/beastie/assets/js/search.js @@ -1,62 +1,65 @@ /* BSD 2-Clause License Copyright (c) 2001-2022, The FreeBSD Documentation Project Copyright (c) 2021-2022, Sergio Carlavilla All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ ;(function () { 'use strict' var searchBookInput = document.querySelector("#search-book"); var menuContents = document.querySelector("#MenuContents"); - searchBookInput.addEventListener('keyup', search); + + if (searchBookInput) { + searchBookInput.addEventListener('keyup', search); + } function search() { var menuElements = menuContents.children[0]; Array.from(menuElements.children).map(element => { var menuContent = element.textContent || element.innerText; var check = element.getElementsByTagName("input"); if (menuContent.toUpperCase().includes(searchBookInput.value.toUpperCase())) { element.classList.remove("hidden"); if (check && check[0]) { if (searchBookInput.value) { check[0].checked = true; } else { check[0].checked = false; } } } else { element.classList.add("hidden"); if (check && check[0]) { check[0].checked = false; } } }); } })(); diff --git a/documentation/themes/beastie/assets/js/theme-chooser.js b/documentation/themes/beastie/assets/js/theme-chooser.js index 9a48432dc5..cc52d7084b 100644 --- a/documentation/themes/beastie/assets/js/theme-chooser.js +++ b/documentation/themes/beastie/assets/js/theme-chooser.js @@ -1,65 +1,65 @@ /* BSD 2-Clause License Copyright (c) 2001-2022, The FreeBSD Documentation Project Copyright (c) 2021-2022, Sergio Carlavilla All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -(function () { +;(function () { + 'use strict' + var theme = localStorage.getItem('theme'); var themeChooser = document.querySelector('#theme-chooser'); var themeContainer = document.querySelector('.theme-container'); themeContainer.style.display = "block"; if (theme === "theme-dark") { setTheme('theme-dark'); themeChooser.value = 'theme-dark'; } else if (theme === "theme-high-contrast") { setTheme('theme-high-contrast'); themeChooser.value = 'theme-high-contrast'; } else { setTheme('theme-light'); themeChooser.value = 'theme-light'; } -})(); -var themeChooser = document.querySelector('#theme-chooser'); + themeChooser.addEventListener('change', function() { + var theme = this.value; -themeChooser.addEventListener('change', function() { - var theme = this.value; + if (theme === "theme-dark") { + setTheme('theme-dark'); + } else if (theme === "theme-high-contrast") { + setTheme('theme-high-contrast'); + } else { + setTheme('theme-light'); + } + }); - if (theme === "theme-dark") { - setTheme('theme-dark'); - } else if (theme === "theme-high-contrast") { - setTheme('theme-high-contrast'); - } else { - setTheme('theme-light'); + function setTheme(themeName) { + localStorage.setItem('theme', themeName); + document.documentElement.className = themeName; } -}); - -function setTheme(themeName) { - localStorage.setItem('theme', themeName); - document.documentElement.className = themeName; -} +})();