Debian Codegraph @

sphinx_code_tabs/code-tabs.js

raw
1 const sphinx_code_tabs_onclick = function(clicked) {
2 const tabid = clicked.dataset.id;
3 const tabgroup = clicked.parentNode.parentNode.dataset.tabgroup;
4 const books = [];
5
6 if (tabgroup) {
7 for (const book of document.querySelectorAll("div.tabs")) {
8 if (book.dataset.tabgroup == tabgroup) {
9 books.push(book);
10 }
11 }
12 }
13 else {
14 books.push(clicked.parentNode.parentNode);
15 }
16
17 for (const book of books) {
18 const select = book.children[0];
19 for (const button of select.children) {
20 button.classList.toggle('selected', button.dataset.id == tabid);
21 }
22 for (const page of book.children) {
23 if (page.hasAttribute('data-id')) {
24 page.classList.toggle('selected', page.dataset.id == tabid);
25 }
26 }
27 }
28
29 };