<div class="page-margin">
	<div class="row">
		<div class="col-md-2 leftcol"><?php echo Wo_LoadPage("sidebar/left-sidebar"); ?></div>
		<div class="col-md-7 profile-lists middlecol">
			<div class="page-margin wow_content mt-0">
				<div class="wo_page_hdng pag_neg_padd pag_alone">
					<div class="wo_page_hdng_menu">
						<ul class="list-unstyled">
							<li class="active"><a href="<?php echo Wo_SeoLink('index.php?link1=most_liked'); ?>" data-ajax="?link1=most_liked"><?php echo $wo['lang']['popular_posts_comments'] ?></a></li>
						</ul>
					</div>
				</div>
			</div>
			<div id="mlposts">
				<?php
					$most_liked = $wo['most_liked'];
					if (count($most_liked) <= 0) {
						echo '<div class="empty_state"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M20 22H4a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1h16a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1zm-1-2V4H5v16h14zM7 6h4v4H7V6zm0 6h10v2H7v-2zm0 4h10v2H7v-2zm6-9h4v2h-4V7z" fill="currentColor"></path></svg>' . $wo['lang']['no_posts_found'] . '</div>';
					} else {
						foreach ($most_liked as $wo['story']) {
							if( is_array($wo['story']) && isset( $wo['story']['id']) ){
								echo Wo_LoadPage('story/content');
							}
						}
					}
				?>
			</div>
			<?php if (count($most_liked) > 0) { ?>
				<div class="load-more pointer" id="load-more-posts" onclick="Wo_GetMoreMostLiked();"></div>
			<?php } ?>
			<!-- .load-more pointer -->
			<div id="load-more-filter"><span class="filter-by-more hidden" data-filter-by="most_liked"></span></div>
			<!-- #load-more-filter -->
			<div class="clear"></div>
		</div>
		<?php echo Wo_LoadPage('sidebar/content');?>
	</div>
</div>
<script>
$(function () {
	xscrolled = 0;
	var api = $('#api').val();
	current_width = $(window).width();
	if(current_width > 900 || api) {
    	$(window).scroll(function () {
			if($('.footer-wrapper').scrollTop() > 500) {
				$('.footer-wrapper .dropdown-menu').css('bottom', 'auto');
			} else {
				$('.footer-wrapper .dropdown-menu').css('bottom', '100%');
			}
			if($(document).scrollTop() > 200) {
				$('.sidebar-sticky').addClass('Stick');
			} else {
				$('.sidebar-sticky').removeClass('Stick');
			}
			var nearToBottom = 100;
			if($('#mlposts').length > 0) {
				if ($(window).scrollTop() + $(window).height() > $(document).height() - nearToBottom) {
					if (xscrolled == 0) {
						xscrolled = 1;
						Wo_GetMoreMostLiked();
					}
				}
			}
		});
  	}
});

function Wo_GetMoreMostLiked() {
  var more_posts = $('#load-more-posts');
  var after_post_id = $('div.post:last').attr('data-post-id');
  var after_last_id = $('div.post:last').attr('data-post-id');
  var lasttotal = $('div.post:last').attr('data-post-total');
  var ids = $('div.post:last').attr('data-post-ids');
  var dt = $('div.post:last').attr('data-post-dt');
  $('#mlposts').append('<div class="hidden loading-status loading-single"></div>');
  $('#load-more-posts').hide();
  $('.loading-status').hide().html('<div class="wo_loading_post"><div class="wo_loading_post_child2"></div></div>').removeClass('hidden').show();
  Wo_progressIconLoader($('#load-more-posts'));
  posts_count = 0;
  if ($('.post').length > 0) {
    posts_count = $('.post').length;
  }
  $.get(Wo_Ajax_Requests_File(), {
	f: 'get_more_most_liked',
	after_last_id: after_last_id,
	lasttotal: lasttotal,
	ids:ids,
	dt: dt
  }, function (data) {
	  console.log( data );
	if(data.status == 200) {
		if(data.html == "") {
			console.log('empty')
			xscrolled = 1;
			$('#load-more-posts').show().html('<div class="white-loading list-group"><div class="cs-loader"><div class="no-more-posts-to-show"><?php echo $wo['lang']['no_more_posts_to_show']; ?></div></div>');
		} else {
			$('#mlposts').append(data.html);
			xscrolled = 0;
		}
	}
    
	$('.loading-status').remove();
	$('#load-more-posts').show();
    Wo_progressIconLoader($('#load-more-posts'));
    
  });
}
</script>