File size: 1.37Kb
<div class="container user-posts__container">
<div class="user-posts explore-posts-container pg_grid_posts pg_grid_posts_tag">
<?php if ($context['favorite_posts'] > 0) {
foreach ($context['favorite_posts'] as $key => $post_data) {
include 'includes/fav.html';
}
} else{
include 'includes/no-posted.html';
} ?>
</div>
</div>
<script>
var ajax_url = '<?php echo($context['xhr_url']) ?>';
jQuery(document).ready(function($) {
var scrolled = 0;
var last_id = 0;
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() > $(document).height() - 100) {
if (scrolled == 0) {
scrolled = 1;
var list_ids = $("div.user-postset_fav[id]").map(function() {
return $(this).attr('id');
}).get();
if (!list_ids) {
return false;
}
var last_id = Math.min.apply(Math,list_ids);
$.ajax({
url: ajax_url + '/load-saved-posts',
type: 'GET',
dataType: 'json',
data: {
offset:last_id
},
}).done(function(data) {
if (data.status == 200) {
$(".user-posts").append(data.html);
scrolled = 0;
}
else{
$(window).unbind('scroll');
}
});
}
}
});
});
</script>