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
|
const sphinx_code_tabs_onclick = function(clicked) {
const tabid = clicked.dataset.id;
const tabgroup = clicked.parentNode.parentNode.dataset.tabgroup;
const books = [];
if (tabgroup) {
for (const book of document.querySelectorAll("div.tabs")) {
if (book.dataset.tabgroup == tabgroup) {
books.push(book);
}
}
}
else {
books.push(clicked.parentNode.parentNode);
}
for (const book of books) {
const select = book.children[0];
for (const button of select.children) {
button.classList.toggle('selected', button.dataset.id == tabid);
}
for (const page of book.children) {
if (page.hasAttribute('data-id')) {
page.classList.toggle('selected', page.dataset.id == tabid);
}
}
}
};
|