solo-skins/timeline/js/timeline.min.js

1 line
6.8 KiB
JavaScript

var timeline={_COLHA:0,_COLHB:20,_initArticleList:function(){var e=$(".articles");0===e.length||0<$(".articles > .fn-clear").length||($(window).resize(function(){if("auto"===$("#hideTop").css("top")){var i=[timeline._COLHA,timeline._COLHB];e.find("article").each(function(){var e=$(this),t=i[1]>i[0],a=t?i[0]:i[1];parseInt(e.css("top"))===a&&0!==a||(e.css({top:a+"px",position:"absolute"}),this.className=t?"l":"r"),i[t?"0":"1"]+=parseInt(e.outerHeight(!0))}),e.height(i[0]>i[1]?i[0]:i[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(0!==e.length){var a=0;$(".nav-abs li").each(function(e){var t=$(this);t.hide(),a!==t.data("year")&&(a=t.data("year"),t.before("<li class='close year' onclick='timeline.toggleArchives(this, "+a+")'>"+a+"</li>"))}),$(".article-more").parent().data("count")<=$(".article-more").parent().find("article").length&&$(".article-more").remove(),$(window).resize(function(){e.each(function(){if("auto"===$("#hideTop").css("top")){var i=[timeline._COLHA+60,4*timeline._COLHB];0===(e=$(this).find("article")).length?($(this).find("h2").remove(),$(this).css("margin-bottom",0)):(e.each(function(){var e=$(this),t=i[1]>i[0],a=t?i[0]:i[1];parseInt(e.css("top"))===a&&0!==a||(e.css({top:a+"px",position:"absolute"}),this.className=t?"l":"r"),i[t?"0":"1"]+=parseInt(e.outerHeight(!0))}),$(this).height(i[0]>i[1]?i[0]:i[1]))}else{var e;0===(e=$(this).find("article")).length?($(this).find("h2").remove(),$(this).css("margin-bottom",0)):(e.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(){60<$(window).scrollTop()?$(".ico-top").show():$(".ico-top").hide()}),timeline._initIndexList(),timeline._initArticleList(),timeline._setNavCurrent(),$(".ico-list").click(function(){"0px"===$(".header > .container > form").css("height")?$(".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,a){var i=e+t,s=e+"/"+t;if(window.location.hash="#"+i,0===$("#"+i+" > article").length){var n=e+" "+Label.yearLabel+" "+t+" "+Label.monthLabel;"en"===Label.localeString.substring(0,2)&&(n=a+" "+e);var r='<h2><span class="article-archive">'+n+'</span></h2><div class="article-more" onclick="timeline.getNextPage(this, \''+s+'\')" data-page="0">'+Label.moreLabel+"</div>";$("#"+i).html(r).css("margin-bottom","50px"),timeline.getNextPage($("#"+i).find(".article-more")[0],s)}},getNextPage:function(e,t){var o=$(e),c=o.data("page")+1,a="/articles/";if(1===$("#tag").length)a="/articles/tags/"+(i=location.pathname.split("/"))[i.length-1];else if(1===$("#author").length){a="/articles/authors/"+(i=location.pathname.split("/"))[i.length-1]}else if(1===$("#category").length){var i;a="/articles/category/"+(i=location.pathname.split("/"))[i.length-1]}else t&&(a="/articles/archives/"+t);$.ajax({url:Label.servePath+a+"?p="+c,type:"GET",beforeSend:function(){o.css("background","url("+Label.staticServePath+"/skins/timeline/images/ajax-loader.gif) no-repeat scroll center center #60829F").text("")},success:function(e,t){if(e.sc)if(0!==e.rslts.articles.length){for(var a="",i=e.rslts.pagination,s=0;s<e.rslts.articles.length;s++){var n=e.rslts.articles[s];a+='<article><div class="module"><div class="dot"></div><div class="arrow"></div><time class="article-time"><span>'+Util.toDate(n.articleCreateTime,"yy-MM-dd HH:mm")+'</span></time><h3 class="article-title"><a rel="bookmark" href="'+Label.servePath+n.articlePermalink+'">'+n.articleTitle+"</a>",n.articlePutTop&&(a+="<sup>"+Label.topArticleLabel+"</sup>"),n.hasUpdated&&(a+='<sup><a href="'+Label.servePath+n.articlePermalink+'">'+Label.updatedLabel+"</a></sup>"),a+="</h3><p>"+n.articleAbstract+'</p><span class="ico-tags ico" title="'+Label.tagLabel+'">';for(var r=n.articleTags.split(","),l=0;l<r.length;l++)a+='<a rel="category tag" href="'+Label.servePath+"/tags/"+encodeURIComponent(r[l])+'">'+r[l]+"</a>",l<r.length-1&&(a+=",");a+='</span>&nbsp;<span class="ico-author ico" title="'+Label.authorLabel+'"><a rel="author" href="'+Label.servePath+"/authors/"+n.authorId+'">'+n.authorName+'</a></span>&nbsp;<span class="ico-comment ico" title="'+Label.commentLabel+'"><a rel="nofollow" href="'+Label.servePath+n.articlePermalink+'#comments">'+(0===n.articleCommentCount?Label.noCommentLabel:n.articleCommentCount)+'</a></span>&nbsp;<span class="ico-view ico" title="'+Label.viewLabel+'"><a rel="nofollow" href="${servePath}${article.articlePermalink}">'+n.articleViewCount+"</a></span></div></article>"}o.before(a).data("page",c),i.paginationPageCount<=c?o.remove():o.css("background","none #60829F").text(Label.moreLabel),$(window).resize(),$(".module img").imagesLoaded(function(){$(window).resize()})}else o.remove();else o.css("background","none #60829F").text("Error")}})},toggleArchives:function(a,i){$(".nav-abs li").each(function(e){var t=$(this);t.hasClass("year")||(t.hide(),i===t.data("year")&&$(a).hasClass("close")&&t.show())}),$(".nav-abs li.year").each(function(){parseInt($(this).text())===i?$(a).hasClass("close")?a.className="year open":a.className="year close":this.className="year close"})}};!function(u,e){"use strict";var g="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";u.fn.imagesLoaded=function(a){var i=this,s=u.isFunction(u.Deferred)?u.Deferred():0,n=u.isFunction(s.notify),r=i.find("img").add(i.filter("img")),l=[],o=[],c=[];function h(){var e=u(o),t=u(c);s&&(c.length?s.reject(r,e,t):s.resolve(r)),u.isFunction(a)&&a.call(i,r,e,t)}function d(e){m(e.target,"error"===e.type)}function m(e,t){e.src!==g&&-1===u.inArray(e,l)&&(l.push(e),t?c.push(e):o.push(e),u.data(e,"imagesLoaded",{isBroken:t,src:e.src}),n&&s.notifyWith(u(e),[t,r,u(o),u(c)]),r.length===l.length&&(setTimeout(h),r.unbind(".imagesLoaded",d)))}return u.isPlainObject(a)&&u.each(a,function(e,t){"callback"===e?a=t:s&&s[e](t)}),r.length?r.bind("load.imagesLoaded error.imagesLoaded",d).each(function(e,t){var a=t.src,i=u.data(t,"imagesLoaded");i&&i.src===a?m(t,i.isBroken):t.complete&&void 0!==t.naturalWidth?m(t,0===t.naturalWidth||0===t.naturalHeight):(t.readyState||t.complete)&&(t.src=g,t.src=a)}):h(),s?s.promise(i):i}}(jQuery),Util.setTopBar(),Util.replaceSideEm($(".comments .vditor-reset")),Util.buildTags("tagsSide"),timeline.init();