(function($) { $(function() { var slider = $('.fl-node- .fl-content-slider-wrapper').bxSlider({ adaptiveHeight: true, auto: false, autoHover: true, autoControls: false, pause: 0, mode: '', speed: 0, controls: false, infiniteLoop: , pager: false, video: true, onSliderLoad: function(currentIndex) { $('.fl-node- .fl-content-slider-wrapper').addClass('fl-content-slider-loaded'); // Remove autoplay video sources $('.fl-node- iframe[src*="autoplay"]').each( function(){ var src = $( this ).attr( 'src' ); $( this ).attr( 'data-url', src ); if ( ! $( this ).is( ':visible' ) || 0 === $( this ).parents( '.fl-slide-0:not(.bx-clone)' ).length ) { $( this ).attr( 'src', '' ); } }); }, onSlideBefore: function(ele, oldIndex, newIndex) { $('.fl-node- .fl-content-slider-navigation a').addClass('disabled'); $('.fl-node- .bx-viewport > .bx-controls .bx-pager-link').addClass('disabled'); }, onSlideAfter: function( ele, oldIndex, newIndex ) { // Swap autoplay video sources $( '.fl-node- .fl-slide-' + newIndex + ':not(.bx-clone) iframe[data-url*="autoplay"]:visible' ).each( function(){ var src = $( this ).attr( 'data-url' ); $( this ).attr( 'src', src ); } ); $( '.fl-node- .fl-slide-' + oldIndex + ':not(.bx-clone) iframe[src*="autoplay"]:visible' ).each( function(){ var src = $( this ).attr( 'src' ); $( this ).attr( 'src', '' ); } ); $('.fl-node- .fl-content-slider-navigation a').removeClass('disabled'); $('.fl-node- .bx-viewport > .bx-controls .bx-pager-link').removeClass('disabled'); } }); // Store a reference to the slider. slider.data('bxSlider', slider); }); })(jQuery);