File tree Expand file tree Collapse file tree 2 files changed +28
-4
lines changed Expand file tree Collapse file tree 2 files changed +28
-4
lines changed Original file line number Diff line number Diff line change 30
30
<!-- Scratchpad gets populated through call to .Inner -->
31
31
{{- .Inner -}}
32
32
33
- < ul class ="nav nav-tabs " id ="tabs-{{- $.Ordinal -}} " role ="tablist ">
33
+ < ul class ="nav nav-tabs{{ if $persistLang }} persist{{ end }} " id ="tabs-{{- $.Ordinal -}} " role ="tablist ">
34
34
{{- range $index, $element := $.Scratch.Get "tabs" -}}
35
35
36
36
{{- $lang := $langPane -}}
75
75
{{ $activeSet = false }}
76
76
77
77
<!-- Inner content -->
78
- < div class ="tab-content " id ="tabs-{{- $.Ordinal -}}-content ">
78
+ < div class ="tab-content{{ if $persistLang }} persist{{ end }} " id ="tabs-{{- $.Ordinal -}}-content ">
79
79
{{- range $index, $element := $.Scratch.Get "tabs" -}}
80
80
81
81
{{- $lang := $langPane -}}
Original file line number Diff line number Diff line change @@ -10,11 +10,35 @@ if (typeof Storage !== 'undefined') {
10
10
activeLanguage = params . language ;
11
11
localStorage . setItem ( 'active_language' , activeLanguage ) ;
12
12
}
13
- if ( activeLanguage ) {
13
+ var tabContents = document . querySelectorAll ( '.tab-content.persist' ) ;
14
+ if ( activeLanguage && tabContents . length > 1 ) {
15
+ const persistTab = document . querySelector ( 'ul.persist' ) . querySelectorAll ( '.nav-link' ) ;
16
+ var heightMap = { } ;
17
+
18
+ // select each persist tab and store calculated heights
19
+ persistTab . forEach ( ( langTab ) => {
20
+ langTab . click ( ) ;
21
+ tabContents . forEach ( ( tabContent ) => {
22
+ heightMap [ tabContent . id ] ||= [ ] ;
23
+ heightMap [ tabContent . id ] . push ( tabContent . clientHeight ) ;
24
+ } )
25
+ // everything ends up active unless classes removed
26
+ document . querySelectorAll ( '.active.show' ) . forEach ( ( activeTab ) => {
27
+ activeTab . classList . remove ( 'active' ) ;
28
+ activeTab . classList . remove ( 'show' ) ;
29
+ } )
30
+ } )
31
+ // need to make something active/shown again
32
+ persistTab [ 0 ] . click ( ) ;
33
+
34
+ tabContents . forEach ( ( tabContent ) => {
35
+ tabContent . style . height = Math . max . apply ( Math , heightMap [ tabContent . id ] ) . toString ( ) + 'px' ;
36
+ } )
37
+
14
38
document
15
39
. querySelectorAll ( '.persistLang-' + activeLanguage )
16
40
. forEach ( ( element ) => {
17
- $ ( '#' + element . id ) . tab ( 'show' ) ;
41
+ element . click ( ) ;
18
42
} ) ;
19
43
}
20
44
}
You can’t perform that action at this time.
0 commit comments