elementor.js
1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* Elementor compatibility script
*/
( function() {
let gridFound, masonryFound;
const gridObserver = new MutationObserver( function( mutations ) {
mutations.forEach( function( mutationRecord ) {
const grid = mutationRecord.target.querySelector( '.learndash-course-grid' ),
skin = grid.dataset.skin,
display = mutationRecord.target.style.display;
if ( 'none' !== display ) {
if ( 'grid' === skin ) {
gridFound = true;
} else if ( 'masonry' === skin ) {
masonryFound = true;
}
}
} );
if ( gridFound && 'function' === typeof learndash_course_grid_init_grid_responsive_design ) {
learndash_course_grid_init_grid_responsive_design();
}
if ( masonryFound && 'function' === typeof learndash_course_grid_init_masonry_responsive_design ) {
learndash_course_grid_init_masonry_responsive_design();
}
} );
const grids = document.querySelectorAll( '.learndash-course-grid' );
grids.forEach( function( grid ) {
const target = grid.closest( '.elementor-tab-content' );
if ( target ) {
gridObserver.observe( target, { attributes : true, attributeFilter : [ 'style' ] } );
}
} );
} )();