diff --git a/docs/reST/_static/sections.js b/docs/reST/_static/sections.js new file mode 100644 index 0000000000..d58547382f --- /dev/null +++ b/docs/reST/_static/sections.js @@ -0,0 +1,37 @@ +function toggleSectionVisibility(section){ + document.getElementById(section).hidden = ! document.getElementById(section).hidden; + if (document.getElementById(section).hidden === true){ // show + items = sessionStorage.getItem('hidden'); + if (items !== null){ + if (!(items.includes(section))){ + items = items + section + '|'; + } + sessionStorage.setItem('hidden', items); + } else { + sessionStorage.setItem('hidden', section + '|'); + } + document.getElementById(section[0]).innerHTML = document.getElementById(section[0]).innerHTML.replace('▼', '▶'); + } else { // hide + items = sessionStorage.getItem('hidden'); + if (items !== null){ + if (items.includes(section)){ + items = items.replace(section + '|', ''); + } + sessionStorage.setItem('hidden', items); + } + document.getElementById(section[0]).innerHTML = document.getElementById(section[0]).innerHTML.replace('▶', '▼'); + } +} + +function toggleChecked(classname){ + if (window.innerWidth <= 1100) { + el = document.getElementsByClassName(classname)[0]; + if (el.id !== 'clicked') { + el.id = 'clicked'; + htmlElement.classList.add('clicked'); + } else { + el.id = null; + htmlElement.classList.remove('clicked'); + } + } +} diff --git a/docs/reST/_static/script.js b/docs/reST/_static/theme.js similarity index 68% rename from docs/reST/_static/script.js rename to docs/reST/_static/theme.js index 0986d830e1..95a172d010 100644 --- a/docs/reST/_static/script.js +++ b/docs/reST/_static/theme.js @@ -10,6 +10,7 @@ if (localStorage.getItem('theme') === null) { // Execute once the DOM is loaded document.addEventListener('DOMContentLoaded', () => { + document.body.className = localStorage.getItem('theme'); const search_buttons = document.querySelectorAll('.searchbar-button'); const search_submit = document.querySelector('.searchbar-submit'); @@ -24,9 +25,14 @@ document.addEventListener('DOMContentLoaded', () => { theme_icons.forEach((icon) => { icon.addEventListener('click', () => { const theme = icon.getAttribute('data-theme'); - htmlElement.classList.add('light-theme', 'dark-theme'); - htmlElement.classList.remove(theme); - localStorage.setItem('theme', htmlElement.classList[0]); - }); + if (theme === 'light-theme'){ + new_theme = 'dark-theme'; + } else { + new_theme = 'light-theme'; + } + htmlElement.classList.replace(theme, new_theme); + localStorage.setItem('theme', new_theme); + document.body.className = localStorage.getItem('theme'); + }); }); }); diff --git a/docs/reST/_static/three_lines.svg b/docs/reST/_static/three_lines.svg new file mode 100644 index 0000000000..8fba225c49 --- /dev/null +++ b/docs/reST/_static/three_lines.svg @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/docs/reST/ext/boilerplate.py b/docs/reST/ext/boilerplate.py index ad5089d5ed..c7acc95370 100644 --- a/docs/reST/ext/boilerplate.py +++ b/docs/reST/ext/boilerplate.py @@ -46,7 +46,8 @@ def setup(app): app.setup_extension("ext.indexer") # Add js files for theme changing in docs. - app.add_js_file("script.js") + app.add_js_file("theme.js") + app.add_js_file("sections.js") # Documents to leave untransformed by boilerplate app.add_config_value("boilerplate_skip_transform", [], "") diff --git a/docs/reST/themes/classic/elements.html b/docs/reST/themes/classic/elements.html index 1dfa0bee5f..f17336602d 100644 --- a/docs/reST/themes/classic/elements.html +++ b/docs/reST/themes/classic/elements.html @@ -4,12 +4,13 @@ {%- block relbar1 %}{# Do not want bar across the top #}{% endblock %} {%- endif %} -{#- Classic header with Snakey on the left, page links on the right. +{#- Classic header with Snakey on the left, page links on the sidebar. #} {%- macro header() %}
Most useful stuff: -{% set sep = joiner(" | \n") %} + +
▼Window
Advanced stuff: -{% set sep = joiner(" | \n") %} +
▼Drawing / Surface
Other: -{% set sep = joiner(" | \n") %} +
▼Events/Input
▼Collisions
▼Music
▼Other