HEAD
/*
* 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 timeline js.
*
* @author Liyuan Li
* @version 1.0.1.2, Jun 6, 2013
*/var timeline={_COLHA:0,_COLHB:20,_initArticleList:function(){var e=$(".articles");if(e.length===0||$(".articles > .fn-clear").length>0)return;$(window).resize(function(){if($("#hideTop").css("top")==="auto"){var t=[timeline._COLHA,timeline._COLHB];e.find("article").each(function(){var e=$(this),n=t[1]>t[0],r=n?t[0]:t[1];if(parseInt(e.css("top"))!==r||r===0)e.css({top:r+"px",position:"absolute"}),n?this.className="l":this.className="r";t[n?"0":"1"]+=parseInt(e.outerHeight(!0))}),e.height(t[0]>t[1]?t[0]:t[1])}else e.find("article").each(function(){$(this).css({position:"inherit",top:"auto"}).removeClass("r l")}),e.css("height","auto")}),$(window).resize(),$(".module img").imagesLoaded(function(){$(window).resize()})},_initIndexList:function(){var e=$(".articles > .fn-clear");if(e.length===0)return;var t=0;$(".nav-abs li").each(function(e){var n=$(this);n.hide(),t!==n.data("year")&&(t=n.data("year"),n.before("
"+t+" "))}),$(".article-more").parent().data("count")<=$(".article-more").parent().find("article").length&&$(".article-more").remove(),$(window).resize(function(){e.each(function(){if($("#hideTop").css("top")==="auto"){var e=[timeline._COLHA+60,timeline._COLHB*4],t=$(this).find("article");t.length===0?($(this).find("h2").remove(),$(this).css("margin-bottom",0)):(t.each(function(){var t=$(this),n=e[1]>e[0],r=n?e[0]:e[1];if(parseInt(t.css("top"))!==r||r===0)t.css({top:r+"px",position:"absolute"}),n?this.className="l":this.className="r";e[n?"0":"1"]+=parseInt(t.outerHeight(!0))}),$(this).height(e[0]>e[1]?e[0]:e[1]))}else{var t=$(this).find("article");t.length===0?($(this).find("h2").remove(),$(this).css("margin-bottom",0)):(t.each(function(){$(this).css({position:"inherit",top:"auto"}).removeClass("r l")}),$(this).css("height","auto"))}})}),$(window).resize(),$(".module img").imagesLoaded(function(){$(window).resize()})},_setNavCurrent:function(){$(".header li a").each(function(){$(this).prop("href")===location.href.split("#")[0]?this.className="current":this.className=""})},init:function(){$(window).scroll(function(){$(window).scrollTop()>60?$(".ico-top").show():$(".ico-top").hide()}),timeline._initIndexList(),timeline._initArticleList(),timeline._setNavCurrent(),$(".ico-list").click(function(){$(".header > .container > form").css("height")==="0px"?$(".header > .container > ul, .header > .container > form").css({height:"auto"}):$(".header > .container > ul, .header > .container > form").animate({height:"0px"})})},translate:function(){window.open("http://translate.google.com/translate?sl=auto&tl=auto&u="+location.href)},getArchive:function(e,t,n){var r=e+t,i=e+"/"+t;window.location.hash="#"+r;if($("#"+r+" > article").length===0){var s=e+" "+Label.yearLabel+" "+t+" "+Label.monthLabel;Label.localeString.substring(0,2)==="en"&&(s=n+" "+e);var o=''+s+" "+''+Label.moreLabel+"
";$("#"+r).html(o).css("margin-bottom","50px"),timeline.getNextPage($("#"+r).find(".article-more")[0],i)}},getNextPage:function(e,t){var n=$(e),r=n.data("page")+1,i="/articles/";if($("#tag").length===1){var s=location.pathname.split("/");i="/articles/tags/"+s[s.length-1]+"/"}else if($("#author").length===1){var s=location.pathname.split("/");i="/articles/authors/"+s[s.length-1]+"/"}else t&&(i="/articles/archives/"+t+"/");$.ajax({url:latkeConfig.servePath+i+r,type:"GET",beforeSend:function(){n.css("background","url("+latkeConfig.staticServePath+"/skins/timeline/images/ajax-loader.gif) no-repeat scroll center center #60829F").text("")},success:function(e,t){if(!e.sc){n.css("background","none #60829F").text("Error");return}if(e.rslts.articles.length===0){n.remove();return}var i="",s=e.rslts.pagination;for(var o=0;o
'+Util.toDate(u.articleCreateTime,"yy-MM-dd HH:mm")+' '+u.articleTitle+" ",u.hasUpdated&&(i+=""+Label.updatedLabel+" "),u.articlePutTop&&(i+=""+Label.topArticleLabel+" "),i+=""+u.articleAbstract+"
"+'
';var a=u.articleTags.split(",");for(var f=0;f'+a[f]+"",f '+''+u.authorName+' '+''+u.articleViewCount+" "}n.before(i).data("page",r),s.paginationPageCount<=r?n.remove():n.css("background","none #60829F").text(Label.moreLabel),$(window).resize(),$(".module img").imagesLoaded(function(){$(window).resize()})}})},toggleArchives:function(e,t){$(".nav-abs li").each(function(n){var r=$(this);r.hasClass("year")||(r.hide(),t===r.data("year")&&$(e).hasClass("close")&&r.show())}),$(".nav-abs li.year").each(function(){parseInt($(this).text())===t?$(e).hasClass("close")?e.className="year open":e.className="year close":this.className="year close"})}};(function(e,t){"use strict";var n="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";e.fn.imagesLoaded=function(r){function c(){var t=e(f),n=e(l);s&&(l.length?s.reject(u,t,n):s.resolve(u)),e.isFunction(r)&&r.call(i,u,t,n)}function h(e){p(e.target,e.type==="error")}function p(t,r){if(t.src===n||e.inArray(t,a)!==-1)return;a.push(t),r?l.push(t):f.push(t),e.data(t,"imagesLoaded",{isBroken:r,src:t.src}),o&&s.notifyWith(e(t),[r,u,e(f),e(l)]),u.length===a.length&&(setTimeout(c),u.unbind(".imagesLoaded",h))}var i=this,s=e.isFunction(e.Deferred)?e.Deferred():0,o=e.isFunction(s.notify),u=i.find("img").add(i.filter("img")),a=[],f=[],l=[];return e.isPlainObject(r)&&e.each(r,function(e,t){e==="callback"?r=t:s&&s[e](t)}),u.length?u.bind("load.imagesLoaded error.imagesLoaded",h).each(function(r,i){var s=i.src,o=e.data(i,"imagesLoaded");if(o&&o.src===s){p(i,o.isBroken);return}if(i.complete&&i.naturalWidth!==t){p(i,i.naturalWidth===0||i.naturalHeight===0);return}if(i.readyState||i.complete)i.src=n,i.src=s}):c(),s?s.promise(i):i}})(jQuery),function(){Util.init(),Util.replaceSideEm($(".comments .article-body")),Util.buildTags("tagsSide"),timeline.init()}();
=======
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];if(parseInt($it.css("top"))!==top){$it.css({top:top+"px",position:"absolute"});if(isLeft){this.className="l"}else{this.className="r"}}colH[isLeft?"0":"1"]+=parseInt($it.outerHeight(true))});$articles.height(colH[0]>colH[1]?colH[0]:colH[1])});$(window).resize();$(".module img").imagesLoaded(function(){$(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(""+year+" ")}});if($(".article-more").parent().data("count")<=$(".article-more").parent().find("article").length){$(".article-more").remove()}$(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();$(this).css("margin-bottom",0)}else{$articles.each(function(){var $it=$(this),isLeft=colH[1]>colH[0],top=isLeft?colH[0]:colH[1];if(parseInt($it.css("top"))!==top){$it.css({top:top+"px",position:"absolute"});if(isLeft){this.className="l"}else{this.className="r"}}colH[isLeft?"0":"1"]+=parseInt($it.outerHeight(true))});$(this).height(colH[0]>colH[1]?colH[0]:colH[1])}})});$(window).resize();$(".module img").imagesLoaded(function(){$(window).resize()})},_setNavCurrent:function(){$(".header li a").each(function(){if($(this).prop("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(year,month,monthName){var archiveDate=year+month,archive=year+"/"+month;window.location.hash="#"+archiveDate;if($("#"+archiveDate+" > article").length===0){var archiveDataTitle=year+" "+Label.yearLabel+" "+month+" "+Label.monthLabel;if(Label.localeString.substring(0,2)==="en"){archiveDataTitle=monthName+" "+year}var archiveHTML=''+archiveDataTitle+" "+''+Label.moreLabel+"
";$("#"+archiveDate).html(archiveHTML).css("margin-bottom","50px");timeline.getNextPage($("#"+archiveDate).find(".article-more")[0],archive)}},getNextPage:function(it,archive){var $more=$(it),currentPage=$more.data("page")+1,path="/articles/";if($("#tag").length===1){var pathnames=location.pathname.split("/");path="/articles/tags/"+pathnames[pathnames.length-1]+"/"}else if($("#author").length===1){var pathnames=location.pathname.split("/");path="/articles/authors/"+pathnames[pathnames.length-1]+"/"}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){$more.css("background","none #60829F").text("Error");return}if(result.rslts.articles.length===0){$more.remove();return}var articlesHTML="",pagination=result.rslts.pagination;for(var i=0;i
'+'
'+Util.toDate(article.articleCreateTime,"yy-MM-dd HH:mm")+' '+article.articleTitle+" ";if(article.hasUpdated){articlesHTML+=""+Label.updatedLabel+" "}if(article.articlePutTop){articlesHTML+=""+Label.topArticleLabel+" "}articlesHTML+=""+article.articleAbstract+"
"+'
';var articleTags=article.articleTags.split(",");for(var j=0;j'+articleTags[j]+"";if(j '+''+article.authorName+' '+''+article.articleViewCount+" "}$more.before(articlesHTML).data("page",currentPage);if(pagination.paginationPageCount<=currentPage){$more.remove()}else{$more.css("background","none #60829F").text(Label.moreLabel)}$(window).resize();$(".module img").imagesLoaded(function(){$(window).resize()})}})},toggleArchives:function(it,year){$(".nav-abs li").each(function(i){var $it=$(this);if(!$it.hasClass("year")){$it.hide();if(year===$it.data("year")&&$(it).hasClass("close")){$it.show()}}});$(".nav-abs li.year").each(function(){if(parseInt($(this).text())===year){if($(it).hasClass("close")){it.className="year open"}else{it.className="year close"}}else{this.className="year close"}})}};!function($,undefined){"use strict";var BLANK="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";$.fn.imagesLoaded=function(callback){var $this=this,deferred=$.isFunction($.Deferred)?$.Deferred():0,hasNotify=$.isFunction(deferred.notify),$images=$this.find("img").add($this.filter("img")),loaded=[],proper=[],broken=[];if($.isPlainObject(callback)){$.each(callback,function(key,value){if(key==="callback"){callback=value}else if(deferred){deferred[key](value)}})}function doneLoading(){var $proper=$(proper),$broken=$(broken);if(deferred){if(broken.length){deferred.reject($images,$proper,$broken)}else{deferred.resolve($images)}}if($.isFunction(callback)){callback.call($this,$images,$proper,$broken)}}function imgLoadedHandler(event){imgLoaded(event.target,event.type==="error")}function imgLoaded(img,isBroken){if(img.src===BLANK||$.inArray(img,loaded)!==-1){return}loaded.push(img);if(isBroken){broken.push(img)}else{proper.push(img)}$.data(img,"imagesLoaded",{isBroken:isBroken,src:img.src});if(hasNotify){deferred.notifyWith($(img),[isBroken,$images,$(proper),$(broken)])}if($images.length===loaded.length){setTimeout(doneLoading);$images.unbind(".imagesLoaded",imgLoadedHandler)}}if(!$images.length){doneLoading()}else{$images.bind("load.imagesLoaded error.imagesLoaded",imgLoadedHandler).each(function(i,el){var src=el.src;var cached=$.data(el,"imagesLoaded");if(cached&&cached.src===src){imgLoaded(el,cached.isBroken);return}if(el.complete&&el.naturalWidth!==undefined){imgLoaded(el,el.naturalWidth===0||el.naturalHeight===0);return}if(el.readyState||el.complete){el.src=BLANK;el.src=src}})}return deferred?deferred.promise($this):$this}}(jQuery);!function(){Util.init();Util.replaceSideEm($(".comments .article-body"));Util.buildTags("tagsSide");timeline.init()}();
>>>>>>> origin/master