if (jQuery("#infinity_init_data")[0]) {
// infinit scroll
var $post_type = jQuery("#infinity_init_data").val();
var $last_index = jQuery("#infinity_init_data").attr('lastIndex');
var $amount_of_post = jQuery("#infinity_init_data").attr('num_of_post');
var $max_post_count = parseInt(jQuery("#infinity_init_data").attr('max_post_count'));
var Wait = false;
var Stop = false;
$( window ).scroll(function() {
infinity_scroll_trigger();
});
function infinity_scroll_trigger() {
if ( ($('.thumbInfo .treeWrap').last().offset().top) < ($( window ).scrollTop() + $( window ).innerHeight()) && !Wait && !Stop ) {
Wait = true;
$('.loading').fadeIn();
infinity_scroll($post_type, $last_index, $amount_of_post);
}
};
function infinity_scroll($post_type, $last_index, $amount_of_post){ //get the data
var pram = {post_type:$post_type,last_index:$last_index,amount_of_post:$amount_of_post};
var arr, obj = new Array();
var index = 0;
$.ajax({
type: "POST",
dataType: "json",
context: this,
url: ajaxurl,
data:({pram:pram,action: 'get_more_post_to_scroll'}),
success: function (data) {
more_news_callbck(data);
}
});
return false;
}
function more_news_callbck(data){ // push the data to the doc
debugger;
if ((data.new_index != false) && ( $last_index < $max_post_count )) {
$last_index = data.new_index;
var num = 3;
for (var i = 0; i < data.post.length; i++) {
var video_class = '';
var author_name = '';
var photo_agency = '';
var tags = '';
if (data.post[i].vid != '') {
var video_class = video;
};
if (data.post[i].author_name != '') {
var author_name = '
' + data.post[i].author_name + '
'
};
if (data.post[i].photo_agency != '') {
var photo_agency = '