solo-skins/ease/js/ease.min.js
2015-06-20 14:41:19 +08:00

1 line
4.4 KiB
JavaScript

var goTranslate=function(){window.open("http://translate.google.com/translate?sl=auto&tl=auto&u="+location.href)},getNextPage=function(){var e=$(".article-next");currentPage+=1;var t="/articles/";if(1===$("#tag").length){var a=location.pathname.split("/");t="/articles/tags/"+a[a.length-1]+"/"}else if(1===$("#archive").length){var a=location.pathname.split("/");t="/articles/archives/"+a[a.length-2]+"/"+a[a.length-1]+"/"}else if(1===$("#author").length){var a=location.pathname.split("/");t="/articles/authors/"+a[a.length-1]+"/"}$.ajax({url:latkeConfig.servePath+t+currentPage,type:"GET",beforeSend:function(){e.css("background","url("+latkeConfig.staticServePath+"/skins/ease/images/ajax-loader.gif) no-repeat scroll center center #fefefe")},success:function(t,a){if(t.sc){for(var i="",r=t.rslts.pagination,n=0;n<t.rslts.articles.length;n++){var l=t.rslts.articles[n],s="";t.rslts.articles.length-1===n&&(s=" article-last"),i+='<li class="article'+s+'"><div class="article-title"><h2><a rel="bookmark" class="ft-gray" href="'+latkeConfig.servePath+l.articlePermalink+'">'+l.articleTitle+"</a>",l.hasUpdated&&(i+="<sup>"+Label.updatedLabel+"</sup>"),l.articlePutTop&&(i+="<sup>"+Label.topArticleLabel+"</sup>"),i+='</h2><div class="right"><a rel="nofollow" class="ft-gray" href="'+latkeConfig.servePath+l.articlePermalink+'#comments">'+ +l.articleCommentCount+"&nbsp;&nbsp;"+Label.commentLabel+'</a>&nbsp;&nbsp;<a rel="nofollow" class="ft-gray" href="'+latkeConfig.servePath+l.articlePermalink+'">'+l.articleViewCount+"&nbsp;&nbsp;"+Label.viewLabel+'</a></div><div class="clear"></div></div><div class="article-body"><div id="abstract'+l.oId+'">'+l.articleAbstract+'</div><div id="content'+l.oId+'" class="none"></div></div><div class="right ft-gray">',i+=l.hasUpdated?Util.toDate(l.articleUpdateTime,"yy-MM-dd HH:mm"):Util.toDate(l.articleCreateTime,"yy-MM-dd HH:mm"),i+=' <a href="'+latkeConfig.servePath+"/authors/"+l.authorId+'">'+l.authorName+'</a></div><div class="left ft-gray">'+Label.tag1Label+" ";for(var o=l.articleTags.split(","),c=0;c<o.length;c++)i+='<a rel="tag" href="'+latkeConfig.servePath+"/tags/"+encodeURIComponent(o[c])+'">'+o[c]+"</a>",c<o.length-1&&(i+=", ");i+='</div><div class="clear"></div></li>'}$(".article-last").removeClass("article-last"),$(".main>.wrapper>ul").append(i),r.paginationPageCount===currentPage?e.remove():e.css("background","none")}}})},ease={$header:$(".header"),headerH:103,$body:$(".main > .wrapper"),$nav:$(".nav"),getCurrentPage:function(){var e=$(".article-next");e.length>0&&(window.currentPage=e.data("page"))},setNavCurrent:function(){$(".nav ul a").each(function(){var e=$(this);e.attr("href")===location.href?e.addClass("current"):/\/[0-9]+$/.test(location.pathname)&&($(".nav ul li")[0].className="current")})},initCommon:function(){Util.init(),Util.replaceSideEm($(".recent-comments-content")),Util.buildTags("tagsSide")},initArchives:function(){var e=$(".archives");if(!(e.length<1)){$(".footer").css("marginTop","30px");for(var t=[],a=e.find("span").each(function(){for(var e=$(this).data("year"),a=!0,i=0;i<t.length;i++)if(e===t[i]){a=!1;break}a&&t.push(e)}),i="",r=0;r<t.length;r++){for(var n="",l=0;l<a.length;l++){var s=$(a[l]);s.data("year")===t[r]&&(n+=s.html())}i+="<div><h3 class='ft-gray'>"+t[r]+"</h3>"+n+"</div>"}e.html(i);for(var o=$(".archives>div"),c=0,h=0,g=[],d=0;d<o.length;d++){for(var f=0;3>f&&!(d>=o.length);f++)o[d].style.left=310*f+"px",c>0?(""!==o[d-3].style.top&&(h=parseInt(o[d-3].style.top)),o[d].style.top=$(o[d-3]).height()+60+h+"px",g[f]=parseInt(o[d].style.top)+$(o[d]).height()+60):g[f]=$(o[d]).height()+60,2>f&&(d+=1);c+=1}e.height(g.sort()[g.length-1])}},scrollEvent:function(){var e=this;$(window).scroll(function(){var t=$(window).scrollTop();if(t>e.headerH){var a=$(window).height(),i=t+a-21;$("body").height()-58<=t+a&&(i=$(".footer").offset().top-21),$("#goTop").fadeIn("slow").css("top",i)}else $("#goTop").hide()})},setDynamic:function(){var e=$(".dynamic");if(!($(".dynamic").length<1)){var t=e.find(".side-comments"),a=e.find(".side-tags"),i=e.find(".side-most-comment"),r=e.find(".side-most-view");t.height()>a.height()?a.height(t.height()):t.height(a.height()),i.height()>r.height()?r.height(i.height()):i.height(r.height()),$(".article-body").each(function(){this.innerHTML=Util.replaceEmString($(this).html())})}}};!function(){ease.getCurrentPage(),ease.initCommon(),ease.scrollEvent(),ease.setNavCurrent(),ease.initArchives(),ease.setDynamic()}();