You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
2.1 KiB
JavaScript
69 lines
2.1 KiB
JavaScript
function sort(e){
|
|
var el = (typeof e == "string")?$('#'+e):e;
|
|
var h1 = []; /*左边一列的开始座标*/
|
|
var h2 = []; /*右边一列的开始座标*/
|
|
var box = el.find("li");
|
|
/*求和*/
|
|
Array.prototype.sum = function (){for (var sum = i = 0; i < this.length; i++)sum += parseInt(this[i]);return sum};
|
|
var getMin = function(){ var a = h1.sum();var b = h2.sum(); return (a<=b)?[1,a]:[2,b];}
|
|
box.each(function(){
|
|
var o = $(this); /*获取当前高度*/
|
|
var h = o.outerHeight(true);
|
|
var p = getMin();
|
|
if(p[0] == 1){
|
|
o.css('position', 'absolute').css('top', p[1]).css('left',0).find('.arrow').removeClass().addClass('arrow arrow-left');
|
|
h1.push(h);
|
|
}else if(p[0] == 2){
|
|
o.css('position', 'absolute').css('top', p[1]).css('left','50%').find('.arrow').removeClass().addClass('arrow arrow-right');
|
|
h2.push(h);
|
|
}
|
|
tmph = el.outerHeight(true);
|
|
if( Number(tmph) < Number (p[1] + h ) ){
|
|
el.css('height', (p[1] + h +20));
|
|
}
|
|
});
|
|
};
|
|
//---------------------------------
|
|
function fetchComm(){
|
|
if(window.isFajax==true){return;}
|
|
var page = 1;
|
|
if(typeof window.pages=="undefined"){window.pages =1;}
|
|
var page = window.pages;
|
|
$.ajax({
|
|
url:'/api/api.asp?method=cht.comment.list&sn=0&w=cht&t=E&p='+page,
|
|
type:'GET',
|
|
dataType:'json',
|
|
beforeSend : function(){window.isFajax=true;},
|
|
success:function(o){
|
|
var content = $('#commonList ul');
|
|
if(o.data.length){
|
|
for(var i=0;i<o.data.length;i++){
|
|
var Item = o.data[i];
|
|
Str = '<li class="col-md-12"><div class="boxCont">';
|
|
Str += '<div class="arrow"><div class="img" ></div><div class="time">'+ Item.UserName + ' said on '+Item.PostTime +'</div></div>';
|
|
Str += '<div class="commonBody"><img src="http://data.chinahighlights.com/pic/quotation-left.png">'+ Item.commentbody +'</div></div></li>';
|
|
content.append(Str);
|
|
}
|
|
window.isFajax=false;
|
|
}else{
|
|
window.isFajax=true;
|
|
}
|
|
window.pages = page+1;
|
|
sort("commonList");
|
|
}
|
|
|
|
});
|
|
}
|
|
|
|
$(function(){
|
|
$(window).resize(function(){
|
|
sort("commonList");
|
|
});
|
|
$(window).scroll(function(){
|
|
if(jQuery(window).height()+jQuery(window).scrollTop() + 300 > jQuery(document).height() ){
|
|
fetchComm();
|
|
}
|
|
});
|
|
fetchComm();
|
|
});
|