Commit 2a3d386e authored by Vanessa's avatar Vanessa

compress

parent 508eb8d2
......@@ -18,7 +18,7 @@
* @fileoverview ease js.
*
* @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a>
* @version 1.0.1.4, Aug 29, 2012
* @version 1.0.1.5, Jan 29, 2013
*/
var goTranslate = function () {
window.open("http://translate.google.com/translate?sl=auto&tl=auto&u=" + location.href);
......@@ -28,14 +28,16 @@ var getNextPage = function () {
var $more = $(".article-next");
currentPage += 1;
var path = "/articles/";
if(location.pathname.indexOf("tags") > -1) {
var tagsPathnaem = location.pathname.split("/tags/");
var tags = tagsPathnaem[1].split("/");
path = "/articles/tags/" + tags[0] + "/";
if(location.pathname.indexOf("tags") === 1) {
var pathnames = location.pathname.split("/tags/");
path = "/articles/tags/" + pathnames[1].split("/")[0] + "/";
} else if (location.pathname.indexOf("archives") > -1) {
var archivesPathname = location.pathname.split("/archives/");
var archives = archivesPathname[1].split("/");
path = "/articles/archives/" + archives[0] + "/" + archives[1] + "/";
} else if (location.pathname.indexOf("authors") === 1) {
var pathnames = location.pathname.split("/authors/");
path = "/articles/authors/" + pathnames[1].split("/")[0] + "/";
}
$.ajax({
......
/*
* Copyright (c) 2009, 2010, 2011, 2012, B3log Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*//**
* @fileoverview ease js.
*
* @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a>
* @version 1.0.1.4, Aug 29, 2012
*/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(location.pathname.indexOf("tags")>-1){var n=location.pathname.split("/tags/"),r=n[1].split("/");t="/articles/tags/"+r[0]+"/"}else if(location.pathname.indexOf("archives")>-1){var i=location.pathname.split("/archives/"),s=i[1].split("/");t="/articles/archives/"+s[0]+"/"+s[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,n){if(!t.sc)return;var r="",i=t.rslts.pagination;for(var s=0;s<t.rslts.articles.length;s++){var o=t.rslts.articles[s],u="";t.rslts.articles.length-1===s&&(u=" article-last"),r+='<li class="article'+u+'">'+'<div class="article-title">'+"<h2>"+'<a rel="bookmark" class="ft-gray" href="'+latkeConfig.servePath+o.articlePermalink+'">'+o.articleTitle+"</a>",o.hasUpdated&&(r+="<sup>"+Label.updatedLabel+"</sup>"),o.articlePutTop&&(r+="<sup>"+Label.topArticleLabel+"</sup>"),r+='</h2><div class="right"><a rel="nofollow" class="ft-gray" href="'+latkeConfig.servePath+o.articlePermalink+'#comments">'+ +o.articleCommentCount+"&nbsp;&nbsp;"+Label.commentLabel+"</a>&nbsp;&nbsp;"+'<a rel="nofollow" class="ft-gray" href="'+latkeConfig.servePath+o.articlePermalink+'">'+o.articleViewCount+"&nbsp;&nbsp;"+Label.viewLabel+"</a>"+"</div>"+'<div class="clear"></div>'+"</div>"+'<div class="article-body">'+'<div id="abstract'+o.oId+'">'+o.articleAbstract+"</div>"+'<div id="content'+o.oId+'" class="none"></div>'+"</div>"+'<div class="right ft-gray">',o.hasUpdated?r+=Util.toDate(o.articleUpdateTime,"yy-MM-dd HH:mm"):r+=Util.toDate(o.articleCreateTime,"yy-MM-dd HH:mm"),r+=' <a href="'+latkeConfig.servePath+"/authors/"+o.authorId+'">'+o.authorName+"</a>"+"</div>"+'<div class="left ft-gray">'+Label.tag1Label+" ";var a=o.articleTags.split(",");for(var f=0;f<a.length;f++)r+='<a rel="tag" href="'+latkeConfig.servePath+"/tags/"+encodeURIComponent(a[f])+'">'+a[f]+"</a>",f<a.length-1&&(r+=", ");r+='</div><div class="clear"></div></li>'}$(".article-last").removeClass("article-last"),$(".main>.wrapper>ul").append(r),i.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")===latkeConfig.servePath+location.pathname?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)return;$(".footer").css("marginTop","30px");var t=[],n=e.find("span").each(function(){var e=$(this).data("year"),n=!0;for(var r=0;r<t.length;r++)if(e===t[r]){n=!1;break}n&&t.push(e)}),r="";for(var i=0;i<t.length;i++){var s="";for(var o=0;o<n.length;o++){var u=$(n[o]);u.data("year")===t[i]&&(s+=u.html())}r+="<div><h3 class='ft-gray'>"+t[i]+"</h3>"+s+"</div>"}e.html(r);var a=$(".archives>div"),f=0,l=0,c=[];for(var h=0;h<a.length;h++){for(var p=0;p<3;p++){if(h>=a.length)break;a[h].style.left=p*310+"px",f>0?(a[h-3].style.top!==""&&(l=parseInt(a[h-3].style.top)),a[h].style.top=$(a[h-3]).height()+60+l+"px",c[p]=parseInt(a[h].style.top)+$(a[h]).height()+60):c[p]=$(a[h]).height()+60,p<2&&(h+=1)}f+=1}e.height(c.sort()[c.length-1])},scrollEvent:function(){var e=this;$(window).scroll(function(){var t=$(window).scrollTop(),n=0;$("#top").css("display")==="block"&&(n=$("#top").height()),t>=e.headerH+n?(e.$nav.css("position","fixed"),e.$body.css("marginTop","55px")):(e.$nav.css("position","inherit"),e.$body.css("marginTop","0"));if(t>e.headerH){var r=$(window).height(),i=t+r-21;$("body").height()-58<=t+r&&(i=$(".footer").offset().top-21),$("#goTop").fadeIn("slow").css("top",i)}else $("#goTop").hide()})},setDynamic:function(){var e=$(".dynamic");if($(".dynamic").length<1)return;var t=e.find(".side-comments"),n=e.find(".side-tags"),r=e.find(".side-most-comment"),i=e.find(".side-most-view");t.height()>n.height()?n.height(t.height()):t.height(n.height()),r.height()>i.height()?i.height(r.height()):r.height(i.height()),$(".article-body").each(function(){this.innerHTML=Util.replaceEmString($(this).html())})},scrollToCmt:function(){$(window.location.hash).length==1&&$(window).scrollTop($(window.location.hash).offset().top-60)}};(function(){ease.getCurrentPage(),ease.initCommon(),ease.scrollEvent(),ease.setNavCurrent(),ease.initArchives(),ease.setDynamic()})();
\ No newline at end of file
/*
* Copyright (c) 2009, 2010, 2011, 2012, B3log Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*//**
* @fileoverview ease js.
*
* @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a>
* @version 1.0.1.5, Jan 29, 2013
*/
var goTranslate=function(){window.open("http://translate.google.com/translate?sl=auto&tl=auto&u="+location.href)};var getNextPage=function(){var $more=$(".article-next");currentPage+=1;var path="/articles/";if(location.pathname.indexOf("tags")===1){var pathnames=location.pathname.split("/tags/");path="/articles/tags/"+pathnames[1].split("/")[0]+"/"}else if(location.pathname.indexOf("archives")>-1){var archivesPathname=location.pathname.split("/archives/");var archives=archivesPathname[1].split("/");path="/articles/archives/"+archives[0]+"/"+archives[1]+"/"}else if(location.pathname.indexOf("authors")===1){var pathnames=location.pathname.split("/authors/");path="/articles/authors/"+pathnames[1].split("/")[0]+"/"}$.ajax({url:latkeConfig.servePath+path+currentPage,type:"GET",beforeSend:function(){$more.css("background","url("+latkeConfig.staticServePath+"/skins/ease/images/ajax-loader.gif) no-repeat scroll center center #fefefe")},success:function(result,textStatus){if(!result.sc){return}var articlesHTML="",pagination=result.rslts.pagination;for(var i=0;i<result.rslts.articles.length;i++){var article=result.rslts.articles[i],lastClass="";if(result.rslts.articles.length-1===i){lastClass=" article-last"}articlesHTML+='<li class="article'+lastClass+'">'+'<div class="article-title">'+'<h2>'+'<a rel="bookmark" class="ft-gray" href="'+latkeConfig.servePath+article.articlePermalink+'">'+article.articleTitle+'</a>';if(article.hasUpdated){articlesHTML+='<sup>'+Label.updatedLabel+'</sup>'}if(article.articlePutTop){articlesHTML+='<sup>'+Label.topArticleLabel+'</sup>'}articlesHTML+='</h2>'+'<div class="right">'+'<a rel="nofollow" class="ft-gray" href="'+latkeConfig.servePath+article.articlePermalink+'#comments">'+ +article.articleCommentCount+'&nbsp;&nbsp;'+Label.commentLabel+'</a>&nbsp;&nbsp;'+'<a rel="nofollow" class="ft-gray" href="'+latkeConfig.servePath+article.articlePermalink+'">'+article.articleViewCount+'&nbsp;&nbsp;'+Label.viewLabel+'</a>'+'</div>'+'<div class="clear"></div>'+'</div>'+'<div class="article-body">'+'<div id="abstract'+article.oId+'">'+article.articleAbstract+'</div>'+'<div id="content'+article.oId+'" class="none"></div>'+'</div>'+'<div class="right ft-gray">';if(article.hasUpdated){articlesHTML+=Util.toDate(article.articleUpdateTime,'yy-MM-dd HH:mm')}else{articlesHTML+=Util.toDate(article.articleCreateTime,'yy-MM-dd HH:mm')}articlesHTML+=' <a href="'+latkeConfig.servePath+'/authors/'+article.authorId+'">'+article.authorName+'</a>'+'</div>'+'<div class="left ft-gray">'+Label.tag1Label+" ";var articleTags=article.articleTags.split(",");for(var j=0;j<articleTags.length;j++){articlesHTML+='<a rel="tag" href="'+latkeConfig.servePath+'/tags/'+encodeURIComponent(articleTags[j])+'">'+articleTags[j]+'</a>';if(j<articleTags.length-1){articlesHTML+=", "}}articlesHTML+='</div>'+'<div class="clear"></div>'+'</li>'}$(".article-last").removeClass("article-last");$(".main>.wrapper>ul").append(articlesHTML);if(pagination.paginationPageCount===currentPage){$more.remove()}else{$more.css("background","none")}}})};var ease={$header:$(".header"),headerH:103,$body:$(".main > .wrapper"),$nav:$(".nav"),getCurrentPage:function(){var $next=$(".article-next");if($next.length>0){window.currentPage=$next.data("page")}},setNavCurrent:function(){$(".nav ul a").each(function(){var $this=$(this);if($this.attr("href")===latkeConfig.servePath+location.pathname){$this.addClass("current")}else if(/\/[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 $archives=$(".archives");if($archives.length<1){return}$(".footer").css("marginTop","30px");var years=[],$archiveList=$archives.find("span").each(function(){var year=$(this).data("year"),tag=true;for(var i=0;i<years.length;i++){if(year===years[i]){tag=false;break}}if(tag){years.push(year)}});var yearsHTML="";for(var j=0;j<years.length;j++){var monthsHTML="";for(var l=0;l<$archiveList.length;l++){var $month=$($archiveList[l]);if($month.data("year")===years[j]){monthsHTML+=$month.html()}}yearsHTML+="<div><h3 class='ft-gray'>"+years[j]+"</h3>"+monthsHTML+"</div>"}$archives.html(yearsHTML);var $items=$(".archives>div"),line=0,top=0,heights=[];for(var m=0;m<$items.length;m++){for(var n=0;n<3;n++){if(m>=$items.length){break}$items[m].style.left=(n*310)+"px";if(line>0){if($items[m-3].style.top!==""){top=parseInt($items[m-3].style.top)}$items[m].style.top=$($items[m-3]).height()+60+top+"px";heights[n]=parseInt($items[m].style.top)+$($items[m]).height()+60}else{heights[n]=$($items[m]).height()+60}if(n<2){m+=1}}line+=1}$archives.height(heights.sort()[heights.length-1])},scrollEvent:function(){var _it=this;$(window).scroll(function(){var y=$(window).scrollTop(),topH=0;if($("#top").css("display")==="block"){topH=$("#top").height()}if(y>=_it.headerH+topH){_it.$nav.css("position","fixed");_it.$body.css("marginTop","55px")}else{_it.$nav.css("position","inherit");_it.$body.css("marginTop","0")}if(y>_it.headerH){var bodyH=$(window).height();var top=y+bodyH-21;if($("body").height()-58<=y+bodyH){top=$(".footer").offset().top-21}$("#goTop").fadeIn("slow").css("top",top)}else{$("#goTop").hide()}})},setDynamic:function(){var $dynamic=$(".dynamic");if($(".dynamic").length<1){return}var $comments=$dynamic.find(".side-comments"),$tags=$dynamic.find(".side-tags"),$mostComment=$dynamic.find(".side-most-comment"),$mostView=$dynamic.find(".side-most-view");if($comments.height()>$tags.height()){$tags.height($comments.height())}else{$comments.height($tags.height())}if($mostComment.height()>$mostView.height()){$mostView.height($mostComment.height())}else{$mostComment.height($mostView.height())}$(".article-body").each(function(){this.innerHTML=Util.replaceEmString($(this).html())})},scrollToCmt:function(){if($(window.location.hash).length==1){$(window).scrollTop($(window.location.hash).offset().top-60)}}};(function(){ease.getCurrentPage();ease.initCommon();ease.scrollEvent();ease.setNavCurrent();ease.initArchives();ease.setDynamic()})();
\ No newline at end of file
......@@ -143,7 +143,7 @@ var timeline = {
+ '<div class="article-more" onclick="timeline.getNextPage(this, \''
+ archive + '\')" data-page="0">' + Label.moreLabel + '</div>';
$("#" + archiveDate).html(archiveHTML)
$("#" + archiveDate).html(archiveHTML);
timeline.getNextPage($("#" + archiveDate).find(".article-more")[0], archive);
}
},
......
......@@ -20,255 +20,4 @@
* @author <a href="mailto:LLY219@gmail.com">Liyuan Li</a>
* @version 1.0.0.1, Jan 14, 2013
*/
var timeline = {
_COLHA: 0,
_COLHB: 20,
_initArticleList: function () {
var $articles = $(".articles");
if ($articles.length === 0 || $(".articles > .fn-clear").length > 0) {
return;
}
$(window).resize(function () {
var colH = [timeline._COLHA, timeline._COLHB];
$articles.find("article").each(function () {
var $it = $(this),
isLeft = colH[1] > colH[0],
top = isLeft ? colH[0] : colH[1];
$it.css({
"top": top + "px",
"position": "absolute"
});
if (isLeft) {
$it.addClass("l");
} else {
$it.addClass("r");
}
colH[( isLeft ? '0' : '1' )] += parseInt($it.outerHeight(true));
});
$articles.height(colH[0] > colH[1] ? colH[0] : colH[1]);
});
$(window).resize();
},
_initIndexList: function () {
var $archives = $(".articles > .fn-clear");
if ($archives.length === 0) {
return;
}
// 如果为 index 页面,重构 archives 结构,使其可收缩
var year = 0;
$(".nav-abs li").each(function (i) {
var $this = $(this);
$this.hide();
if (year !== $this.data("year")) {
year = $this.data("year");
$this.before("<li class='year' onclick='timeline.toggleArchives(" +
year + ")'>" + year + "</div></li>");
}
});
$(window).resize(function () {
$archives.each(function () {
var colH = [timeline._COLHA + 60, timeline._COLHB * 4];
var $articles = $(this).find("article");
if ($articles.length === 0) {
$(this).find("h2").remove();
} else {
$articles.each(function () {
var $it = $(this),
isLeft = colH[1] > colH[0],
top = isLeft ? colH[0] : colH[1];
$it.css({
"top": top + "px",
"position": "absolute"
});
if (isLeft) {
$it.addClass("l");
} else {
$it.addClass("r");
}
colH[( isLeft ? '0' : '1' )] += parseInt($it.outerHeight(true));
});
$(this).height(colH[0] > colH[1] ? colH[0] : colH[1]);
}
});
});
$(window).resize();
},
_setNavCurrent: function () {
$(".header li a").each(function () {
if($(this).attr("href") === location.href.split("#")[0]) {
this.className = "current";
} else {
this.className = "";
}
})
},
init: function () {
$(window).scroll(function () {
if ($(window).scrollTop() > 60) {
$(".ico-top").show();
} else {
$(".ico-top").hide();
}
});
timeline._initIndexList();
timeline._initArticleList();
timeline._setNavCurrent();
},
translate: function () {
window.open("http://translate.google.com/translate?sl=auto&tl=auto&u=" + location.href);
},
getArchive: function (archive) {
var archiveDate = archive.replace("/", "");
if ($("#" + archiveDate + " > article").length > 0) {
window.location.hash = "#" + archiveDate;
} else {
var archiveHTML = '<h2><span class="article-archive">' + archiveDate + '</span></h2>'
+ '<div class="article-more" onclick="timeline.getNextPage(this, \''
+ archive + '\')" data-page="0">' + Label.moreLabel + '</div>';
$("#" + archiveDate).html(archiveHTML)
timeline.getNextPage($("#" + archiveDate).find(".article-more")[0], archive);
}
},
getNextPage: function (it, archive) {
var $more = $(it),
currentPage = $more.data("page") + 1,
path = "/articles/";
if(location.pathname.indexOf("tags") === 1) {
var pathnames = location.pathname.split("/tags/");
path = "/articles/tags/" + pathnames[1].split("/")[0] + "/";
} else if (location.pathname.indexOf("authors") === 1) {
var pathnames = location.pathname.split("/authors/");
path = "/articles/authors/" + pathnames[1].split("/")[0] + "/";
} else if (archive) {
path = "/articles/archives/" + archive + "/";
}
$.ajax({
url: latkeConfig.servePath + path + currentPage,
type: "GET",
beforeSend: function () {
$more.css("background",
"url(" + latkeConfig.staticServePath
+ "/skins/timeline/images/ajax-loader.gif) no-repeat scroll center center #60829F").text("");
},
success: function(result, textStatus){
if (!result.sc) {
return;
}
var articlesHTML = "",
pagination = result.rslts.pagination;
// append articles
for (var i = 0; i < result.rslts.articles.length; i++) {
var article = result.rslts.articles[i];
articlesHTML += '<article><div class="module"><div class="dot"></div>'
+ '<div class="arrow"></div><time class="article-time"><span>'
+ Util.toDate(article.articleCreateTime, 'yy-MM-dd HH:mm')
+ '</span></time><h3 class="article-title"><a rel="bookmark" href="'
+ latkeConfig.servePath + article.articlePermalink + '">'
+article.articleTitle + '</a>';
if (article.hasUpdated) {
articlesHTML += '<sup>' + Label.updatedLabel + '</sup>';
}
if (article.articlePutTop) {
articlesHTML += '<sup>' + Label.topArticleLabel + '</sup>';
}
articlesHTML += '</h3><p>' + article.articleAbstract + '</p>'
+ '<span class="ico-tags ico" title="' + Label.tagLabel + '">';
var articleTags = article.articleTags.split(",");
for (var j = 0; j < articleTags.length; j++) {
articlesHTML += '<a rel="category tag" href="' + latkeConfig.servePath
+ '/tags/' + encodeURIComponent(articleTags[j]) + '">' + articleTags[j] + '</a>';
if (j < articleTags.length - 1) {
articlesHTML += ",";
}
}
articlesHTML += '</span>&nbsp;<span class="ico-author ico" title="' + Label.authorLabel + '">'
+ '<a rel="author" href="' + latkeConfig.servePath + '/authors/' + article.authorId + '">'
+ article.authorName + '</a></span>&nbsp;<span class="ico-comment ico" title="'
+ Label.commentLabel + '"><a rel="nofollow" href="' + latkeConfig.servePath + article.articlePermalink
+ '#comments">' + (article.articleCommentCount === 0 ? Label.noCommentLabel : article.articleCommentCount)
+ '</a></span>&nbsp;<span class="ico-view ico" title="' + Label.viewLabel + '">'
+ '<a rel="nofollow" href="${servePath}${article.articlePermalink}">' + article.articleViewCount
+ '</a></span></div></article>';
}
var colH = [parseInt($(".article-more").prev().prev().css("top")) + $(".article-more").prev().prev().outerHeight(true),
parseInt($(".article-more").prev().css("top")) + $(".article-more").prev().outerHeight(true)];
$more.before(articlesHTML).data("page", currentPage);
// 最后一页处理
if (pagination.paginationPageCount === currentPage) {
$more.remove();
} else {
$more.css("background", "none #60829F").text(Label.moreLabel);
}
$((archive ? "#" + archive.replace("/", "") : ".articles") + " article").each(function () {
if (this.className !== "r" && this.className !== "l") {
var $it = $(this),
isLeft = colH[1] > colH[0],
top = isLeft ? colH[0] : colH[1];
$it.css({
"top": top + "px",
"position": "absolute"
});
if (isLeft) {
$it.addClass("l");
} else {
$it.addClass("r");
}
colH[( isLeft ? '0' : '1' )] += parseInt($it.outerHeight(true));
}
});
$(archive ? "#" + archive.replace("/", "") : ".articles").height(colH[0] > colH[1] ? colH[0] : colH[1]);
}
});
},
toggleArchives: function (year) {
$(".nav-abs li").each(function (i) {
var $this = $(this);
if (year === $this.data("year")) {
$this.toggle();
}
});
}
};
(function () {
Util.init();
Util.replaceSideEm($(".recent-comments-content"));
Util.buildTags("tagsSide");
timeline.init();
})();
\ No newline at end of file
var timeline={_COLHA:0,_COLHB:20,_initArticleList:function(){var $articles=$(".articles");if($articles.length===0||$(".articles > .fn-clear").length>0){return}$(window).resize(function(){var colH=[timeline._COLHA,timeline._COLHB];$articles.find("article").each(function(){var $it=$(this),isLeft=colH[1]>colH[0],top=isLeft?colH[0]:colH[1];$it.css({"top":top+"px","position":"absolute"});if(isLeft){$it.addClass("l")}else{$it.addClass("r")}colH[(isLeft?'0':'1')]+=parseInt($it.outerHeight(true))});$articles.height(colH[0]>colH[1]?colH[0]:colH[1])});$(window).resize()},_initIndexList:function(){var $archives=$(".articles > .fn-clear");if($archives.length===0){return}var year=0;$(".nav-abs li").each(function(i){var $this=$(this);$this.hide();if(year!==$this.data("year")){year=$this.data("year");$this.before("<li class='year' onclick='timeline.toggleArchives("+year+")'>"+year+"</div></li>")}});$(window).resize(function(){$archives.each(function(){var colH=[timeline._COLHA+60,timeline._COLHB*4];var $articles=$(this).find("article");if($articles.length===0){$(this).find("h2").remove()}else{$articles.each(function(){var $it=$(this),isLeft=colH[1]>colH[0],top=isLeft?colH[0]:colH[1];$it.css({"top":top+"px","position":"absolute"});if(isLeft){$it.addClass("l")}else{$it.addClass("r")}colH[(isLeft?'0':'1')]+=parseInt($it.outerHeight(true))});$(this).height(colH[0]>colH[1]?colH[0]:colH[1])}})});$(window).resize()},_setNavCurrent:function(){$(".header li a").each(function(){if($(this).attr("href")===location.href.split("#")[0]){this.className="current"}else{this.className=""}})},init:function(){$(window).scroll(function(){if($(window).scrollTop()>60){$(".ico-top").show()}else{$(".ico-top").hide()}});timeline._initIndexList();timeline._initArticleList();timeline._setNavCurrent()},translate:function(){window.open("http://translate.google.com/translate?sl=auto&tl=auto&u="+location.href)},getArchive:function(archive){var archiveDate=archive.replace("/","");if($("#"+archiveDate+" > article").length>0){window.location.hash="#"+archiveDate}else{var archiveHTML='<h2><span class="article-archive">'+archiveDate+'</span></h2>'+'<div class="article-more" onclick="timeline.getNextPage(this, \''+archive+'\')" data-page="0">'+Label.moreLabel+'</div>';$("#"+archiveDate).html(archiveHTML);timeline.getNextPage($("#"+archiveDate).find(".article-more")[0],archive)}},getNextPage:function(it,archive){var $more=$(it),currentPage=$more.data("page")+1,path="/articles/";if(location.pathname.indexOf("tags")===1){var pathnames=location.pathname.split("/tags/");path="/articles/tags/"+pathnames[1].split("/")[0]+"/"}else if(location.pathname.indexOf("authors")===1){var pathnames=location.pathname.split("/authors/");path="/articles/authors/"+pathnames[1].split("/")[0]+"/"}else if(archive){path="/articles/archives/"+archive+"/"}$.ajax({url:latkeConfig.servePath+path+currentPage,type:"GET",beforeSend:function(){$more.css("background","url("+latkeConfig.staticServePath+"/skins/timeline/images/ajax-loader.gif) no-repeat scroll center center #60829F").text("")},success:function(result,textStatus){if(!result.sc){return}var articlesHTML="",pagination=result.rslts.pagination;for(var i=0;i<result.rslts.articles.length;i++){var article=result.rslts.articles[i];articlesHTML+='<article><div class="module"><div class="dot"></div>'+'<div class="arrow"></div><time class="article-time"><span>'+Util.toDate(article.articleCreateTime,'yy-MM-dd HH:mm')+'</span></time><h3 class="article-title"><a rel="bookmark" href="'+latkeConfig.servePath+article.articlePermalink+'">'+article.articleTitle+'</a>';if(article.hasUpdated){articlesHTML+='<sup>'+Label.updatedLabel+'</sup>'}if(article.articlePutTop){articlesHTML+='<sup>'+Label.topArticleLabel+'</sup>'}articlesHTML+='</h3><p>'+article.articleAbstract+'</p>'+'<span class="ico-tags ico" title="'+Label.tagLabel+'">';var articleTags=article.articleTags.split(",");for(var j=0;j<articleTags.length;j++){articlesHTML+='<a rel="category tag" href="'+latkeConfig.servePath+'/tags/'+encodeURIComponent(articleTags[j])+'">'+articleTags[j]+'</a>';if(j<articleTags.length-1){articlesHTML+=","}}articlesHTML+='</span>&nbsp;<span class="ico-author ico" title="'+Label.authorLabel+'">'+'<a rel="author" href="'+latkeConfig.servePath+'/authors/'+article.authorId+'">'+article.authorName+'</a></span>&nbsp;<span class="ico-comment ico" title="'+Label.commentLabel+'"><a rel="nofollow" href="'+latkeConfig.servePath+article.articlePermalink+'#comments">'+(article.articleCommentCount===0?Label.noCommentLabel:article.articleCommentCount)+'</a></span>&nbsp;<span class="ico-view ico" title="'+Label.viewLabel+'">'+'<a rel="nofollow" href="${servePath}${article.articlePermalink}">'+article.articleViewCount+'</a></span></div></article>'}var colH=[parseInt($(".article-more").prev().prev().css("top"))+$(".article-more").prev().prev().outerHeight(true),parseInt($(".article-more").prev().css("top"))+$(".article-more").prev().outerHeight(true)];$more.before(articlesHTML).data("page",currentPage);if(pagination.paginationPageCount===currentPage){$more.remove()}else{$more.css("background","none #60829F").text(Label.moreLabel)}$((archive?"#"+archive.replace("/",""):".articles")+" article").each(function(){if(this.className!=="r"&&this.className!=="l"){var $it=$(this),isLeft=colH[1]>colH[0],top=isLeft?colH[0]:colH[1];$it.css({"top":top+"px","position":"absolute"});if(isLeft){$it.addClass("l")}else{$it.addClass("r")}colH[(isLeft?'0':'1')]+=parseInt($it.outerHeight(true))}});$(archive?"#"+archive.replace("/",""):".articles").height(colH[0]>colH[1]?colH[0]:colH[1])}})},toggleArchives:function(year){$(".nav-abs li").each(function(i){var $this=$(this);if(year===$this.data("year")){$this.toggle()}})}};(function(){Util.init();Util.replaceSideEm($(".recent-comments-content"));Util.buildTags("tagsSide");timeline.init()})();
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment