1(function($){ 2 /** 3 * initializeSlide 4 * 5 * Adds custom JavaScript to the block HTML. 6 * 7 * @since 1.0.0 8 * 9 * @param object $block The block jQuery element. 10 * @param object attributes The block attributes (only available when editing). 11 * @return void 12 */ 13 var initializeSlide = function( $block ) { 14 var cols = $block.find('.cards-list__slide').attr('data-cols'); 15 16 cols = Number(cols); 17 18 if( !cols ) { 19 cols = 4; 20 } 21 22 var arrowLeft = $block.find('[class^="nav-prev"]'); 23 var arrowRight = $block.find('[class^="nav-next"]'); 24 25 $block.find('.cards-list__slide').slick({ 26 dots: false, 27 arrows: true, 28 prevArrow: arrowLeft, 29 nextArrow: arrowRight, 30 infinite: false, 31 speed: 500, 32 cssEase: 'linear', 33 slidesToShow: cols, 34 slidesToScroll: cols, 35 focusOnSelect: false, 36 responsive: [ 37 { 38 breakpoint: 992, 39 settings: { 40 slidesToShow: cols >= 4 ? 3 : cols, 41 slidesToScroll: cols >= 4 ? 3 : cols 42 } 43 }, 44 { 45 breakpoint: 768, 46 settings: { 47 slidesToShow: 2, 48 slidesToScroll: 2, 49 } 50 }, 51 { 52 breakpoint: 576, 53 settings: { 54 slidesToShow: 1, 55 slidesToScroll: 1, 56 centerMode: false 57 } 58 } 59 ] 60 }); 61 } 62 63 // Initialize each block on page load (front end). 64 $(document).ready(function(){ 65 $('.cards-list-block').each(function(){ 66 initializeSlide( $(this) ); 67 }); 68 }); 69 70 // Initialize dynamic block preview (editor). 71 if( window.acf ) { 72 window.acf.addAction( 'render_block_preview/type=cards', initializeSlide ); 73 } 74 })(jQuery);
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.