/*
* 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.0, Jan 30, 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];
if (!$it.hasClass("r") && !$it.hasClass("l")) {
$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]);
});
setTimeout(function () {
$(window).resize();
}, 500);
},
_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("