File: code-tabs.js

package info (click to toggle)
sphinx-code-tabs 0.5.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 212 kB
  • sloc: python: 196; makefile: 32; javascript: 26
file content (29 lines) | stat: -rw-r--r-- 772 bytes parent folder | download
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);
      }
    }
  }

};