mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2025-06-13 20:30:32 +00:00
shortcodes: add style option to mimic code box color scheme #551
This commit is contained in:
parent
d39c0fb402
commit
67fe76a99c
10 changed files with 41 additions and 10 deletions
static/js
|
@ -65,6 +65,23 @@ function adjustContentWidth(){
|
|||
elc.style[ dir_padding_end ] = '' + end + 'px';
|
||||
}
|
||||
|
||||
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.initial' ) ).filter( function( tabPanel ){
|
||||
return tabPanel.querySelector( '.tab-content-text > div.highlight:only-child');
|
||||
});
|
||||
|
||||
codeTabPanels.forEach( function( tabPanel ){
|
||||
tabPanel.classList.remove( 'initial' );
|
||||
tabPanel.classList.add( 'code' );
|
||||
tabId = tabPanel.dataset.tabItem;
|
||||
var p = tabPanel.parentNode.parentNode;
|
||||
var tabButton = p.querySelector( '.tab-nav-button.tab-panel-style[data-tab-item="'+tabId+'"]' );
|
||||
tabButton.classList.remove( 'initial' );
|
||||
tabButton.classList.add( 'code' );
|
||||
});
|
||||
}
|
||||
|
||||
function switchTab(tabGroup, tabId) {
|
||||
var tabs = Array.from( document.querySelectorAll( '.tab-panel[data-tab-group="'+tabGroup+'"]' ) ).filter( function( e ){
|
||||
return !!e.querySelector( '[data-tab-item="'+tabId+'"]' );
|
||||
|
@ -1251,6 +1268,7 @@ ready( function(){
|
|||
initToc();
|
||||
initAnchorClipboard();
|
||||
initCodeClipboard();
|
||||
fixCodeTabs();
|
||||
restoreTabSelections();
|
||||
initSwipeHandler();
|
||||
initHistory();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue