const amount = 18; let offset = 0; let category = $('#social-post-container .sort-list-filter > li > a.active').attr('data-filter'); $(window).load(function () { $portfolio_selectors = $('#social-post-container .sort-list-filter >li>a'); if ($portfolio_selectors != 'undefined') { $portfolio = $('.sort-list-items'); $portfolio.isotope({ itemSelector: 'li', layoutMode: 'masonry' }); $portfolio_selectors.on('click', function () { $portfolio_selectors.removeClass('active'); $(this).addClass('active'); const selector = $(this).attr('data-filter'); // if(selector === '*') { offset = 0; $('#load-more-button').fadeOut(); $portfolio.isotope('remove', $('#social-posts > li')); category = selector; loadPosts(true); // autoHeight(); // } else if(selector === 'twitter') { // // } $portfolio.isotope({filter: selector}).isotope('layout'); return false; }); } loadPosts(true); }); $(document).ready(function () { }); function loadPosts(onLoad) { // const category = $('#social-post-container .sort-list-filter > li > a.active').attr('data-filter'); $.ajax({ url: "/main/getPosts", data: { amount: amount, offset: offset, category: category }, beforeSend: function () { $('#load-more-button').html($('#load-more-button').attr('data-loading')); }, success: function (data) { const $items = $(data); if(onLoad) { $('#social-posts').append($items) .isotope('appended', $items); $('#load-more-button').fadeIn(); } else { $('#social-posts').append($items) .isotope('appended', $items); } $('#load-more-button').html($('#load-more-button').attr('data-load')); autoHeight(); $('#social-posts').isotope({filter: '*'}).isotope('layout'); offset += 1; if(data === ' ') { $('#load-more-button').fadeOut().delay(1000).remove(); $('#social-post-container').parent().append('