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

7 lines
6.9 KiB
JavaScript

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