").replaceAll("\n", "
") + `
`; } if ( youtube ) { $( '.gallery-slides' ).append( `
` + description_html + `
` ); } else if(imageTypes.indexOf(extension) !== -1) { $( '.gallery-slides' ).append( ` ` ); } else { $( '.gallery-slides' ).append( ` ` ); } } ); if ( $items.length > 1 ) { $( '.gallery-next, .gallery-prev' ).show(); } else { $( '.gallery-next, .gallery-prev' ).hide(); } $( 'body' ).addClass( 'gallery-open' ); $('.gallery-content .owl-carousel').owlCarousel({ center: false, autoplay: false, items: 1, loop: false, margin: 0, nav: true, dots: false, }); $('.gallery-content .owl-carousel').trigger('to.owl.carousel', index); }); function pause_youtube() { var yt_player = $( '.gallery-content .owl-carousel .active' ).find( 'iframe' ); if ( yt_player.length ) { yt_player.each(function(){ this.contentWindow.postMessage('{"event":"command","func":"stopVideo","args":""}', '*'); }); } } $( document ).on( 'click', '.gallery-close', function(e) { $( 'body' ).removeClass( 'gallery-open' ); $( '.gallery-slides' ).html( '' ); $('.gallery-content .owl-carousel').trigger('destroy.owl.carousel'); $('.gallery-content .owl-carousel').find('.owl-stage-outer').children().unwrap(); $('.gallery-content .owl-carousel').removeClass("owl-center owl-loaded owl-text-select-on"); }); $( document ).on( 'click', '.gallery-next', function(e) { pause_youtube(); document.querySelectorAll('video').forEach(vid => vid.pause()); $('.gallery-content .owl-carousel').trigger('next.owl.carousel'); var video = $('.gallery-content .owl-carousel .active').find( 'video' ); if ( video.length ) { video.get(0).play(); } } ); $( document ).on( 'click', '.gallery-prev', function(e) { pause_youtube(); document.querySelectorAll('video').forEach(vid => vid.pause()); $('.gallery-content .owl-carousel').trigger('prev.owl.carousel'); var video = $('.gallery-content .owl-carousel .active').find( 'video' ); if ( video.length ) { video.get(0).play(); } } );