Add code to auto select tabs
This commit is contained in:
@@ -2,6 +2,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Pattern</title>
|
||||
<script>
|
||||
let u = document.location.href.substring(0, document.location.href.search(/patterns/i));
|
||||
let p = document.location.pathname.substring(document.location.pathname.search(/patterns/i));
|
||||
p = p.replace(/\/$|\/index\.html/i, "").substring(9);
|
||||
window.location = u + "?p=" + p;
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body data-prismjs-copy-timeout="1500">
|
||||
<h2>What is it</h2>
|
||||
@@ -170,6 +177,7 @@ const click = new MouseEvent('click', {
|
||||
});
|
||||
|
||||
export function init(p = document, s = true) {
|
||||
|
||||
p.querySelectorAll(".tab-group, tabset").forEach(tabGroup => {
|
||||
|
||||
if (tabGroup.querySelector("[role=tablist]") === null) {
|
||||
@@ -222,6 +230,10 @@ export function init(p = document, s = true) {
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
if (document.location.hash != "" && document.location.hash.substring(0,5) == "#tab-") {
|
||||
document.querySelector(document.location.hash).dispatchEvent(click);
|
||||
}
|
||||
});
|
||||
}
|
||||
</pre>
|
||||
|
Reference in New Issue
Block a user