Skip to content

Commit

Permalink
Merge pull request #30 from henryiii/henryiii/feat/tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
pradyunsg authored Mar 28, 2023
2 parents b37a295 + 821a172 commit 88b211e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/sphinx_inline_tabs/static/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ var labels_by_text = {};

function ready() {
var li = document.getElementsByClassName("tab-label");
const urlParams = new URLSearchParams(window.location.search);
const tabs = urlParams.getAll("tabs");

for (const label of li) {
label.onclick = onLabelClick;
const text = label.textContent;
Expand All @@ -10,6 +13,12 @@ function ready() {
}
labels_by_text[text].push(label);
}

for (const tab of tabs) {
for (label of labels_by_text[tab]) {
label.previousSibling.checked = true;
}
}
}

function onLabelClick() {
Expand Down

0 comments on commit 88b211e

Please sign in to comment.