2018-10-16 16:28:42 +00:00
|
|
|
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({
|
2018-10-17 11:56:22 +00:00
|
|
|
url: "/main/getPosts",
|
2018-10-16 16:28:42 +00:00
|
|
|
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('<div class="alert alert-warning">' + $('#social-post-container').attr('data-error-msg') + '</div>');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function autoHeight() {
|
|
|
|
$('.sort-list-item').each(function () {
|
|
|
|
$(this).css('height', $('.item-inner', this).outerHeight() + 40);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#main-slider').on('swiperight', function () {
|
|
|
|
$('#main-slider').carousel('prev');
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#main-slider').on('swipeleft', function () {
|
|
|
|
$('#main-slider').carousel('next');
|
|
|
|
});
|
|
|
|
|
|
|
|
addReadMoreBtns();
|