ec-confettieffect.js
6 months ago
ec-confettieffect.min.js
6 months ago
ecafe-accordion.js
6 months ago
ecafe-accordion.min.js
6 months ago
ecafe-assets.js
6 months ago
ecafe-assets.min.js
6 months ago
ecafe-back-to-top.js
6 months ago
ecafe-back-to-top.min.js
6 months ago
ecafe-changelog.js
6 months ago
ecafe-changelog.min.js
6 months ago
ecafe-chart.js
6 months ago
ecafe-chart.min.js
6 months ago
ecafe-countdown.js
6 months ago
ecafe-countdown.min.js
6 months ago
ecafe-coupon-code.js
6 months ago
ecafe-coupon-code.min.js
6 months ago
ecafe-hover-background.js
6 months ago
ecafe-hover-background.min.js
6 months ago
ecafe-image-accordion.js
6 months ago
ecafe-image-accordion.min.js
6 months ago
ecafe-image-scroll.js
6 months ago
ecafe-image-scroll.min.js
6 months ago
ecafe-infocircle.js
6 months ago
ecafe-infocircle.min.js
6 months ago
ecafe-infounfold.js
6 months ago
ecafe-infounfold.min.js
6 months ago
ecafe-lottie.js
6 months ago
ecafe-lottie.min.js
6 months ago
ecafe-marketing-link.js
6 months ago
ecafe-marketing-link.min.js
6 months ago
ecafe-page-piling.js
6 months ago
ecafe-page-piling.min.js
6 months ago
ecafe-page-scroll-to-id.js
6 months ago
ecafe-page-scroll-to-id.min.js
6 months ago
ecafe-pdf-viewer.js
6 months ago
ecafe-pdf-viewer.min.js
6 months ago
ecafe-post-image.js
6 months ago
ecafe-post-image.min.js
6 months ago
ecafe-post-listing.js
6 months ago
ecafe-post-listing.min.js
6 months ago
ecafe-qrcode.js
6 months ago
ecafe-qrcode.min.js
6 months ago
ecafe-scroll-progress.js
6 months ago
ecafe-scroll-progress.min.js
6 months ago
ecafe-sticky-video.js
6 months ago
ecafe-sticky-video.min.js
6 months ago
ecafe-tabs.js
6 months ago
ecafe-tabs.min.js
6 months ago
ecafe-tilt-custom.js
6 months ago
ecafe-tilt-custom.min.js
6 months ago
ecafe-tippy-custom.js
6 months ago
ecafe-tippy-custom.min.js
6 months ago
ecafe-toc.js
6 months ago
ecafe-toc.min.js
6 months ago
ecafe-whatsapp.js
6 months ago
ecafe-whatsapp.min.js
6 months ago
ecafe.js
6 months ago
ecafe.min.js
6 months ago
ecafe-post-listing.js
187 lines
| 1 | /*Load More Post*/ |
| 2 | ;( function($) { |
| 3 | 'use strict'; |
| 4 | $(document).ready(function(){ |
| 5 | if($(".eca-posts-load-more").length > 0){ |
| 6 | $(document).on("click", ".posts-load-more", function(e){ |
| 7 | e.preventDefault(); |
| 8 | var $this = $(this), |
| 9 | settings = $this.data('settings'), |
| 10 | postsoffset = settings.postsOffset, |
| 11 | numberOfPosts = settings.numberOfPosts, |
| 12 | totalPage = settings.totalPage, |
| 13 | page = $this.attr("data-page"), |
| 14 | loadMorePost = settings.loadMorePost, |
| 15 | loadMoreBtnText = settings.loadMoreBtnText, |
| 16 | loadingMoreText = settings.loadingMoreText, |
| 17 | loadedPostsText = settings.loadedPostsText, |
| 18 | ecrtl = settings.ecrtl; |
| 19 | |
| 20 | if(postsoffset === undefined || postsoffset === ""){ |
| 21 | postsoffset = 0; |
| 22 | } |
| 23 | |
| 24 | if(totalPage >= page){ |
| 25 | var offset = (parseInt(page - 1) * parseInt(loadMorePost)) + parseInt(numberOfPosts) + parseInt(postsoffset); |
| 26 | settings.offset = offset; |
| 27 | $.ajax({ |
| 28 | type: 'POST', |
| 29 | data: 'settings=' + JSON.stringify(settings) + '&action=eca_load_more_posts', |
| 30 | url: ecafe_data.eca_ajax_url, |
| 31 | beforeSend: function() { |
| 32 | $this.text(loadingMoreText); |
| 33 | }, success: function(data) { |
| 34 | if(data === ''){ |
| 35 | $this.addClass("hide"); |
| 36 | } else { |
| 37 | $("." + settings.id + ' .eca-post-listing-inner').append(data); |
| 38 | var $newItems = $(''); |
| 39 | $("." + settings.id + ' .eca-post-listing-inner').isotope('insert', $newItems); |
| 40 | $("." + settings.id + ' .eca-post-listing-inner').isotope('layout').isotope('reloadItems'); |
| 41 | } |
| 42 | |
| 43 | page++; |
| 44 | if(page === totalPage){ |
| 45 | $this.addClass("hide"); |
| 46 | $this.attr('data-page', page); |
| 47 | $this.parent(".eca-posts-load-more").append('<div class="eca-all-posts-loaded">' + loadedPostsText + '</div>'); |
| 48 | } else { |
| 49 | $this.text(loadMoreBtnText); |
| 50 | $this.attr('data-page', page); |
| 51 | } |
| 52 | }, complete: function() { |
| 53 | if($("." + settings.id + ' .terms-filters-wrap').length){ |
| 54 | $("." + settings.id + ' .terms-filters-wrap .terms-filters-lists > li > a').each(function(){ |
| 55 | var filter = $(this).data("filter"); |
| 56 | if(filter !== '' && filter !== undefined && filter === '*'){ |
| 57 | var totle_count = $("." + settings.id + ' .eca-post-listing-inner .ec-grid-wrap').length; |
| 58 | } else if(filter !== '' && filter !== undefined){ |
| 59 | var totle_count = $("." + settings.id + ' .eca-post-listing-inner .ec-grid-wrap' + filter).length; |
| 60 | } |
| 61 | if(totle_count){ |
| 62 | $(this).find(".term_count").text(totle_count); |
| 63 | } |
| 64 | }); |
| 65 | } |
| 66 | $("." + settings.id + ' .eca-post-listing-inner').isotope({ |
| 67 | itemSelector: '.ec-grid-wrap', |
| 68 | originLeft: ecrtl, |
| 69 | }); |
| 70 | } |
| 71 | }); |
| 72 | } else { |
| 73 | $this.addClass("hide"); |
| 74 | } |
| 75 | }); |
| 76 | } |
| 77 | }); |
| 78 | |
| 79 | $(window).on('load', function(){ |
| 80 | if($('body').find('.posts-lazy-load').length >= 1){ |
| 81 | var windowWidth, windowHeight, documentHeight, scrollTop, containerHeight, containerOffset, $window = $(window); |
| 82 | |
| 83 | var load_calc_Values = function() { |
| 84 | windowWidth = $window.width(); |
| 85 | windowHeight = $window.height(); |
| 86 | documentHeight = $('body').height(); |
| 87 | containerHeight = $('.eca-isotope').height(); |
| 88 | containerOffset = $('.eca-isotope').offset().top + 50; |
| 89 | setTimeout(function(){ |
| 90 | containerHeight = $('.eca-isotope').height(); |
| 91 | containerOffset = $('.eca-isotope').offset().top + 50; |
| 92 | }, 50); |
| 93 | }; |
| 94 | |
| 95 | load_calc_Values(); |
| 96 | $window.on('resize', load_calc_Values); // Updated from .resize() to .on('resize') |
| 97 | |
| 98 | $window.on('scroll', function(e) { // Updated from .bind() to .on() |
| 99 | e.preventDefault(); |
| 100 | load_calc_Values(); |
| 101 | scrollTop = $window.scrollTop(); |
| 102 | $('.eca-isotope').each(function() { |
| 103 | var $this = $(this); |
| 104 | containerHeight = $this.height(); |
| 105 | containerOffset = $this.offset().top + 50; |
| 106 | if($this.find(".posts-lazy-load").length && scrollTop < documentHeight && scrollTop > (containerHeight + containerOffset - windowHeight)){ |
| 107 | var load = $this.find(".posts-lazy-load"), |
| 108 | settings = load.data('settings'), |
| 109 | postsoffset = settings.postsOffset, |
| 110 | numberOfPosts = settings.numberOfPosts, |
| 111 | totalPage = settings.totalPage, |
| 112 | page = load.attr("data-page"), |
| 113 | loadMorePost = settings.loadMorePost, |
| 114 | loadingMoreText = settings.loadingMoreText, |
| 115 | loadedPostsText = settings.loadedPostsText, |
| 116 | ecrtl = settings.ecrtl; |
| 117 | |
| 118 | if (load.data('requestRunning')) { |
| 119 | return; |
| 120 | } |
| 121 | |
| 122 | if(postsoffset === undefined || postsoffset === ""){ |
| 123 | postsoffset = 0; |
| 124 | } |
| 125 | |
| 126 | if(totalPage >= page){ |
| 127 | load.data('requestRunning', true); |
| 128 | var offset = (parseInt(page) - 1) * parseInt(loadMorePost) + parseInt(numberOfPosts) + parseInt(postsoffset); |
| 129 | settings.offset = offset; |
| 130 | $.ajax({ |
| 131 | type: 'POST', |
| 132 | data: 'settings=' + JSON.stringify(settings) + '&action=eca_load_more_posts', |
| 133 | url: ecafe_data.eca_ajax_url, |
| 134 | beforeSend: function() { |
| 135 | load.find('.lazy-text').text(loadingMoreText); |
| 136 | load.addClass('post-loading'); |
| 137 | }, success: function(data) { |
| 138 | if(data === ''){ |
| 139 | load.addClass("hide"); |
| 140 | } else { |
| 141 | $("." + settings.id + ' .eca-post-listing-inner').append(data); |
| 142 | var $newItems = $(''); |
| 143 | $("." + settings.id + ' .eca-post-listing-inner').isotope('insert', $newItems); |
| 144 | $("." + settings.id + ' .eca-post-listing-inner').isotope('layout').isotope('reloadItems'); |
| 145 | } |
| 146 | |
| 147 | page++; |
| 148 | if(page === totalPage){ |
| 149 | load.addClass("hide"); |
| 150 | load.attr('data-page', page); |
| 151 | load.parent(".eca-posts-lazy-load").append('<div class="eca-all-posts-loaded">' + loadedPostsText + '</div>'); |
| 152 | } else { |
| 153 | load.find('.lazy-text').text('Lazy Load'); |
| 154 | load.attr('data-page', page); |
| 155 | } |
| 156 | load.removeClass('post-loading'); |
| 157 | }, complete: function() { |
| 158 | if($("." + settings.id + ' .terms-filters-wrap').length){ |
| 159 | $("." + settings.id + ' .terms-filters-wrap .terms-filters-lists > li > a').each(function(){ |
| 160 | var filter = $(this).data("filter"); |
| 161 | if(filter !== '' && filter !== undefined && filter === '*'){ |
| 162 | var totle_count = $("." + settings.id + ' .eca-post-listing-inner .ec-grid-wrap').length; |
| 163 | } else if(filter !== '' && filter !== undefined){ |
| 164 | var totle_count = $("." + settings.id + ' .eca-post-listing-inner .ec-grid-wrap' + filter).length; |
| 165 | } |
| 166 | if(totle_count){ |
| 167 | $(this).find(".term_count").text(totle_count); |
| 168 | } |
| 169 | }); |
| 170 | } |
| 171 | load.data('requestRunning', false); |
| 172 | $("." + settings.id + ' .eca-post-listing-inner').isotope({ |
| 173 | itemSelector: '.ec-grid-wrap', |
| 174 | originLeft: ecrtl, |
| 175 | }); |
| 176 | } |
| 177 | }); |
| 178 | } else { |
| 179 | load.addClass("hide"); |
| 180 | } |
| 181 | } |
| 182 | }); |
| 183 | }); |
| 184 | } |
| 185 | }); |
| 186 | })(jQuery); |
| 187 | /*Load More Post*/ |