mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 07:47:54 +00:00
tabs: fix false codify detection if only contained in subtabs #550
This commit is contained in:
parent
efce383939
commit
5a2ffac7fc
2 changed files with 11 additions and 11 deletions
|
@ -1952,7 +1952,7 @@ html[dir="rtl"] #sidebar ul.collapsible-menu > li > label > i.fa-chevron-right {
|
|||
}
|
||||
|
||||
/* remove margin if only a single code block is contained in the tab (FF without :has using .codify style) */
|
||||
#body .tab-content.tab-panel-style.codify > .tab-content-text{
|
||||
#body .tab-content.codify > .tab-content-text{
|
||||
padding: 0;
|
||||
}
|
||||
#body .tab-content-text:has(> div.highlight:only-child){
|
||||
|
|
|
@ -67,22 +67,22 @@ function adjustContentWidth(){
|
|||
|
||||
function fixCodeTabs(){
|
||||
/* if only a single code block is contained in the tab and no style was selected, treat it like style=code */
|
||||
var codeTabPanels = Array.from( document.querySelectorAll( '.tab-content.tab-panel-style' ) ).filter( function( tabPanel ){
|
||||
return tabPanel.querySelector( '.tab-content-text > div.highlight:only-child, .tab-content-text > pre.pre-code:only-child');
|
||||
var codeTabContents = Array.from( document.querySelectorAll( '.tab-content.tab-panel-style' ) ).filter( function( tabContent ){
|
||||
return tabContent.querySelector( '*:scope > .tab-content-text > div.highlight:only-child, *:scope > .tab-content-text > pre.pre-code:only-child');
|
||||
});
|
||||
|
||||
codeTabPanels.forEach( function( tabPanel ){
|
||||
var p = tabPanel.parentNode.parentNode;
|
||||
var tabId = tabPanel.dataset.tabItem;
|
||||
var tabButton = p.querySelector( '.tab-nav-button.tab-panel-style[data-tab-item="'+tabId+'"]' );
|
||||
if( tabPanel.classList.contains( 'initial' ) ){
|
||||
codeTabContents.forEach( function( tabContent ){
|
||||
var tabId = tabContent.dataset.tabItem;
|
||||
var tabPanel = tabContent.parentNode.parentNode;
|
||||
var tabButton = tabPanel.querySelector( '.tab-nav-button.tab-panel-style[data-tab-item="'+tabId+'"]' );
|
||||
if( tabContent.classList.contains( 'initial' ) ){
|
||||
tabButton.classList.remove( 'initial' );
|
||||
tabButton.classList.add( 'code' );
|
||||
tabPanel.classList.remove( 'initial' );
|
||||
tabPanel.classList.add( 'code' );
|
||||
tabContent.classList.remove( 'initial' );
|
||||
tabContent.classList.add( 'code' );
|
||||
}
|
||||
// mark code blocks for FF without :has()
|
||||
tabPanel.classList.add( 'codify' );
|
||||
tabContent.classList.add( 'codify' );
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue