1function learndash_course_grid_init_masonry( items_wrapper ) { 2 const course_grid = items_wrapper.closest( '.learndash-course-grid' ); 3 const columns = parseInt( course_grid.dataset.columns ); 4 const min_width = parseInt( course_grid.dataset.min_column_width ); 5 6 const width = items_wrapper.offsetWidth; 7 const items = items_wrapper.querySelectorAll( '.item' ); 8 9 if ( items.length < 1 ) { 10 return; 11 } 12 13 const padding = 10; 14 15 let max_columns = Math.floor( width / min_width ); 16 max_columns = max_columns > columns ? columns : max_columns; 17 18 items.forEach( function( item ) { 19 item.style.padding = padding + 'px'; 20 item.style.maxWidth = ( width / max_columns ) + 'px'; 21 item.style.width = ( width / max_columns ) + 'px'; 22 23 item.style.visibility = 'visible'; 24 } ); 25 26 const masonry = new Masonry( items_wrapper, { 27 itemSelector: '.item', 28 fitWidth: true, 29 horizontalOrder: true, 30 } ); 31} 32 33function learndash_course_grid_init_masonry_responsive_design() { 34 const wrappers = document.querySelectorAll( '.learndash-course-grid[data-skin="masonry"]' ); 35 wrappers.forEach( function( wrapper ) { 36 const items_wrapper = wrapper.querySelector( '.items-wrapper.masonry' ); 37 38 learndash_course_grid_init_masonry( items_wrapper ); 39 } ); 40} 41 42( function() { 43 window.addEventListener( 'resize', function() { 44 learndash_course_grid_init_masonry_responsive_design(); 45 } ); 46 47 window.addEventListener( 'load', function() { 48 learndash_course_grid_init_masonry_responsive_design(); 49 } ); 50} )();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.