Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions website_and_docs/layouts/shortcodes/tabpane.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<!-- Scratchpad gets populated through call to .Inner -->
{{- .Inner -}}

<ul class="nav nav-tabs" id="tabs-{{- $.Ordinal -}}" role="tablist">
<ul class="nav nav-tabs{{ if $persistLang }} persist{{ end }}" id="tabs-{{- $.Ordinal -}}" role="tablist">
{{- range $index, $element := $.Scratch.Get "tabs" -}}

{{- $lang := $langPane -}}
Expand Down Expand Up @@ -75,7 +75,7 @@
{{ $activeSet = false }}

<!-- Inner content -->
<div class="tab-content" id="tabs-{{- $.Ordinal -}}-content">
<div class="tab-content{{ if $persistLang }} persist{{ end }}" id="tabs-{{- $.Ordinal -}}-content">
{{- range $index, $element := $.Scratch.Get "tabs" -}}

{{- $lang := $langPane -}}
Expand Down
26 changes: 26 additions & 0 deletions website_and_docs/static/js/tabpane-persist.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
<!-- Upstream docsy commit — ecd4be87ea48e8e94684e32c925049e9bdf7f127-->
var tabContents = document.querySelectorAll('.tab-content.persist');
if (tabContents.length > 1) {
const persistTab = document.querySelector('ul.persist').querySelectorAll('.nav-link');
var heightMap = {};

// select each persist tab and store calculated heights
persistTab.forEach((langTab) => {
langTab.click();
tabContents.forEach((tabContent) => {
heightMap[tabContent.id] ||= [];
heightMap[tabContent.id].push(tabContent.clientHeight);
})
// everything ends up active unless classes removed
document.querySelectorAll('.active.show').forEach((activeTab) => {
activeTab.classList.remove('active');
activeTab.classList.remove('show');
})
})
// need to make something active/shown again
persistTab[0].click();

tabContents.forEach((tabContent) => {
tabContent.style.height = Math.max.apply(Math, heightMap[tabContent.id]).toString() + 'px';
})
}

if (typeof Storage !== 'undefined') {
let activeLanguage = localStorage.getItem('active_language');

Expand Down