jQuery(document).ready(function ($) { var ajaxurl = dolpa_pagination.ajax_url; function dolpa_is_on_screen(elem) { if ($(elem)[0]) { var themewindow = jQuery(window); var viewport_top = themewindow.scrollTop(); var viewport_height = themewindow.height(); var viewport_bottom = viewport_top + viewport_height; var themeelem = jQuery(elem); var top = themeelem.offset().top; var height = themeelem.height(); var bottom = top + height; return (top >= viewport_top && top < viewport_bottom) || (bottom > viewport_top && bottom <= viewport_bottom) || (height > viewport_height && top <= viewport_top && bottom >= viewport_bottom); } } var n = window.TWP_JS || {}; var paged = parseInt(dolpa_pagination.paged) + 1; var maxpage = dolpa_pagination.maxpage; var nextLink = dolpa_pagination.nextLink; var loadmore = dolpa_pagination.loadmore; var loading = dolpa_pagination.loading; var nomore = dolpa_pagination.nomore; var pagination_layout = dolpa_pagination.pagination_layout; function dolpa_load_content_ajax(){ if ((!$('.theme-no-posts').hasClass('theme-no-posts'))) { $('.theme-loading-button .loading-text').text(loading); $('.theme-loading-status').addClass('theme-ajax-loading'); $('.theme-loaded-content').load(nextLink + ' .post', function () { if (paged < 10) { var newlink = nextLink.substring(0, nextLink.length - 2); } else { var newlink = nextLink.substring(0, nextLink.length - 3); } paged++; nextLink = newlink + paged + '/'; if (paged > maxpage) { $('.theme-loading-button').addClass('theme-no-posts'); $('.theme-loading-button .loading-text').text(nomore); } else { $('.theme-loading-button .loading-text').text(loadmore); } var lodedContent = $('.theme-loaded-content').html(); $('.theme-loaded-content').html(''); if ($('.article-wraper').hasClass('archive-layout-masonry')) { if ($('.archive-layout-masonry').length > 0) { var content = $(lodedContent); content.hide(); grid = $('.archive-layout-masonry'); grid.append(content); grid.imagesLoaded(function () { content.show(); var winwidth = $(window).width(); $(window).resize(function () { winwidth = $(window).width(); }); if (winwidth > 990) { grid.masonry('appended', content).masonry(); } else { grid.masonry('appended', content); } }); } } else { $('.content-area .article-wraper').append(lodedContent); } $('.theme-loading-status').removeClass('theme-ajax-loading'); $('.theme-article.post').each(function () { if (!$(this).hasClass('theme-article-loaded')) { $(this).addClass(paged + '-theme-article-ajax'); $(this).addClass('theme-article-loaded'); } }); // Background var pageSection = $(".data-bg"); pageSection.each(function (indx) { if ($(this).attr("data-background")) { $(this).css("background-image", "url(" + $(this).data("background") + ")"); } }); }); } } $('.theme-loading-button').click(function () { dolpa_load_content_ajax(); }); if (pagination_layout == 'auto-load') { $(window).scroll(function () { if (!$('.theme-loading-status').hasClass('theme-ajax-loading') && !$('.theme-loading-button').hasClass('theme-no-posts') && maxpage > 1 && dolpa_is_on_screen('.theme-loading-button')) { dolpa_load_content_ajax(); } }); } $(window).scroll(function () { if (!$('.theme-single-infinity').hasClass('theme-single-loading') && $('.theme-single-infinity').attr('loop-count') <= 3 && dolpa_is_on_screen('.theme-single-infinity')) { $('.theme-single-infinity').addClass('theme-single-loading'); var loopcount = $('.theme-single-infinity').attr('loop-count'); var postid = $('.theme-single-infinity').attr('next-post'); var data = { 'action': 'dolpa_single_infinity', '_wpnonce': dolpa_pagination.ajax_nonce, 'postid': postid, }; $.post(ajaxurl, data, function (response) { if (response) { var content = response.data.content.join(''); var content = $(content); $('.theme-single-infinity').before(content); var newpostid = response.data.postid.join(''); var newpostid = $(newpostid); $('.theme-single-infinity').attr('next-post', newpostid['selector']); if ($('body').hasClass('booster-extension')) { likedislike('after-load-ajax'); booster_extension_post_reaction('after-load-ajax'); } $('article#post-' + postid + ' ul.wp-block-gallery.columns-1, article#post-' + postid + ' .wp-block-gallery.columns-1 .blocks-gallery-grid, article#post-' + postid + ' .gallery-columns-1').each(function () { $(this).slick({ slidesToShow: 1, slidesToScroll: 1, fade: true, autoplay: true, autoplaySpeed: 8000, infinite: true, nextArrow: '', prevArrow: '', dots: false }); }); var i = 1; $('article#post-' + postid + ' .entry-content .wp-block-gallery ').each(function () { $(this).attr('gallery-data', 'gallery-num-' + i); $(this).addClass('gallery-data-slick'); $(this).addClass('gallery-data-gallery-num-' + i); i++; var k = 0; $(this).find('.blocks-gallery-item').each(function () { $(this).attr('gallery-index', k); k++; }); }); var j = 1; $('article#post-' + postid + ' .footer-galleries .wp-block-gallery ').each(function () { $(this).append(''); $(this).append(''); $(this).addClass('gallery-num-' + j); j++; $(this).addClass('dolpa-slick-dactivated'); }); $('article#post-' + postid + ' .gallery-data-slick .blocks-gallery-item a').click(function (event) { event.preventDefault(); }); $('article#post-' + postid + ' .gallery-data-slick .blocks-gallery-item').click(function () { if (!$(this).closest('article#post-' + postid + ' .gallery-data-slick').hasClass('columns-1')) { $('html').attr('style', 'margin: 0; height: 100%; overflow: hidden'); var galid = $(this).closest('.gallery-data-slick').attr('gallery-data'); $('article#post-' + postid + ' .' + galid).addClass('gallery-show fullscreen'); if ($('article#post-' + postid + ' .' + galid).hasClass('dolpa-slick-dactivated')) { $('article#post-' + postid + ' .' + galid + ' .blocks-gallery-grid').slick({ slidesToShow: 1, slidesToScroll: 1, fade: true, autoplay: false, autoplaySpeed: 8000, infinite: true, nextArrow: '', prevArrow: '', dots: false, }); } var galindex = $(this).attr('gallery-index'); $('article#post-' + postid + ' .' + galid + ' .blocks-gallery-grid').slick('slickGoTo', galindex); $('article#post-' + postid + ' .' + galid).removeClass('dolpa-slick-dactivated'); } }); $('article#post-' + postid + ' .wp-block-gallery.columns-1').append(''); $('article#post-' + postid + ' .wp-block-gallery.columns-1').append(''); $('article#post-' + postid + ' .gallery-popup').click(function () { $(this).closest('article#post-' + postid + ' .wp-block-gallery').addClass('fullscreen'); $('html').attr('style', 'margin: 0; height: 100%; overflow: hidden'); $('article#post-' + postid + ' .wp-block-gallery.columns-1 .blocks-gallery-grid').slick("slickSetOption", "speed", 500, !0); }); $('article#post-' + postid + ' .gallery-popup-close').click(function () { $(this).closest('article#post-' + postid + ' .wp-block-gallery').removeClass('fullscreen gallery-show'); $('html').attr('style', ''); $('article#post-' + postid + ' .wp-block-gallery.columns-1 .blocks-gallery-grid').slick("slickSetOption", "speed", 500, !0); }); $('article').each(function () { $(this).removeClass('after-load-ajax'); }); } $('.theme-single-infinity').removeClass('theme-single-loading'); loopcount++; $('.theme-single-infinity').attr('loop-count', loopcount); }); } }); });