123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
-
-
- const initialiseSidebar = () => {
-
- const bodyWrapper = document.getElementsByClassName("bodywrapper")[0]
- const sidebar = document.getElementsByClassName("sphinxsidebar")[0]
- const sidebarWrapper = document.getElementsByClassName("sphinxsidebarwrapper")[0]
-
-
- if (typeof sidebar === "undefined") {
- return
- }
-
-
-
- const sidebarButton = document.getElementById("sidebarbutton")
- const sidebarArrow = sidebarButton.querySelector('span')
-
-
- const collapse_sidebar = () => {
- bodyWrapper.style.marginLeft = ".8em"
- sidebar.style.width = ".8em"
- sidebarWrapper.style.display = "none"
- sidebarArrow.innerText = "»"
- sidebarButton.title = _("Expand sidebar")
- window.localStorage.setItem("sidebar", "collapsed")
- }
-
- const expand_sidebar = () => {
- bodyWrapper.style.marginLeft = ""
- sidebar.style.removeProperty("width")
- sidebarWrapper.style.display = ""
- sidebarArrow.innerText = "«"
- sidebarButton.title = _("Collapse sidebar")
- window.localStorage.setItem("sidebar", "expanded")
- }
-
- sidebarButton.addEventListener("click", () => {
- (sidebarWrapper.style.display === "none") ? expand_sidebar() : collapse_sidebar()
- })
-
- const sidebar_state = window.localStorage.getItem("sidebar")
- if (sidebar_state === "collapsed") {
- collapse_sidebar()
- }
- else if (sidebar_state === "expanded") {
- expand_sidebar()
- }
- }
-
- if (document.readyState !== "loading") {
- initialiseSidebar()
- }
- else {
- document.addEventListener("DOMContentLoaded", initialiseSidebar)
- }
|