Last active
February 21, 2023 16:36
-
-
Save Preciousomonze/0636f53009511c400cbeb026a6244ca9 to your computer and use it in GitHub Desktop.
Fix for a site
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
jQuery( function($) { | |
$( document ).on( 'click', '.ld-expand-button', function( event ) { | |
// Get the clicked element section cover. | |
let $_ParentEl = $(this).closest( '.ld-item-lesson-item' ); | |
// Check if it's the parent expand all. | |
if ( $_ParentEl.length < 1 ) { // It's da big one. | |
let $_Expanded = $( '.ld-item-list .ld-item-list-item-expanded' ); // trigger all. | |
// Determine if it's expanded or collapsed. | |
if ( $_Expanded.hasClass( 'cx-ld-is-expanded' ) ) { | |
$_Expanded.css({ 'overflow' : 'hidden', 'max-height' : 0 }); | |
$_Expanded.removeClass( 'cx-ld-is-expanded' ); | |
} else { | |
$_Expanded.css({'overflow' : 'inherit', 'max-height' : 'fit-content' }); | |
$_Expanded.addClass( 'cx-ld-is-expanded' ); // Add Class to know it's expanded. | |
} | |
return; | |
} | |
// Now trigger the necessary for the clicked item. | |
let $_Expanded = $_ParentEl.find( '.ld-item-list-item-expanded' ); | |
// Determine if it's expand or collapse. | |
if ( $_Expanded.hasClass( 'cx-ld-is-expanded' ) ) { | |
$_Expanded.css({ 'overflow' : 'hidden', 'max-height' : 0 }); | |
$_Expanded.removeClass( 'cx-ld-is-expanded' ); | |
} else { | |
$_Expanded.css({'overflow' : 'inherit', 'max-height' : 'fit-content' }); | |
$_Expanded.addClass( 'cx-ld-is-expanded' ); // Add Class to know it's expanded. | |
} | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment