GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — python-docs-theme/python_docs_theme/static/menu.js at 2024.6 · python/python-docs-theme

Expand file tree

/

menu.js

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
57 lines (53 loc) · 2.09 KB
/

menu.js

Copy path

File metadata and controls

57 lines (53 loc) · 2.09 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
document.addEventListener("DOMContentLoaded", function () {
// Make tables responsive by wrapping them in a div and making them scrollable
const tables = document.querySelectorAll("table.docutils")
tables.forEach(function(table){
table.outerHTML = '<div class="responsive-table__container">' + table.outerHTML + "</div>"
})
const togglerInput = document.querySelector(".toggler__input")
const togglerLabel = document.querySelector(".toggler__label")
const sideMenu = document.querySelector(".menu-wrapper")
const menuItems = document.querySelectorAll(".menu")
const doc = document.querySelector(".document")
const body = document.querySelector("body")
function closeMenu() {
togglerInput.checked = false
sideMenu.setAttribute("aria-expanded", "false")
sideMenu.setAttribute("aria-hidden", "true")
togglerLabel.setAttribute("aria-pressed", "false")
body.style.overflow = "visible"
}
function openMenu() {
togglerInput.checked = true
sideMenu.setAttribute("aria-expanded", "true")
sideMenu.setAttribute("aria-hidden", "false")
togglerLabel.setAttribute("aria-pressed", "true")
body.style.overflow = "hidden"
}
// Close menu when link on the sideMenu is clicked
sideMenu.addEventListener("click", function (event) {
let target = event.target
if (target.tagName.toLowerCase() !== "a") {
return
}
closeMenu()
})
// Add accessibility data when sideMenu is opened/closed
togglerInput.addEventListener("change", function (_event) {
togglerInput.checked ? openMenu() : closeMenu()
})
// Make sideMenu links tabbable only when visible
for(let menuItem of menuItems) {
if(togglerInput.checked) {
menuItem.setAttribute("tabindex", "0")
} else {
menuItem.setAttribute("tabindex", "-1")
}
}
// Close sideMenu when document body is clicked
doc.addEventListener("click", function () {
if (togglerInput.checked) {
closeMenu()
}
})
})
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.