jQuery简易时光轴实现方法示例

2020-05-27 18:04:19易采站长站整理

}
//结算
function setNodeCreate(){
var bigTitleData = {
bigAction: '结算',
bigInfo: ''
};
createBigTitle(bigTitleData, index);
}
//生成大标题,一次生成一个
function createBigTitle(bigTitleData, index){
//生成大标题
$('.timeLine').append($('#bigTitleTpl').html()
.replace('{bigAction}', bigTitleData.bigAction)
.replace('{bigInfo}', bigTitleData.bigInfo)
);
//生成大标题下对应的内容
var bigContentData = [{
smallTime: '2010.10.11',
smallAction: '录单 ' + index,
smallInfo: '操作时间: 10:30:55'
},{
smallTime: '2010.10.15',
smallAction: '审核 ' + index,
smallInfo: '操作时间: 10:10:55'
},{
smallTime: '2010.10.15',
smallAction: '分发 ' + index,
smallInfo: '操作时间: 10:10:55'
}];
var bigContentTplStr = $('#bigContentTpl').html();
var str = '';
for(var i=0; i< bigContentData.length; i++){
str += bigContentTplStr.replace('{smallTime}', bigContentData[i].smallTime)
.replace('{smallAction}', bigContentData[i].smallAction)
.replace('{smallInfo}', bigContentData[i].smallInfo);
}
$('.bigContent:eq(' + index + ')').html(str).hide().slideDown(500);
}
//查看更多, 每次点击生成一个新的节点
$('.showMore').on('click', function(){
if($(this).text() === '查看更多'){
if(index === 0){
index++;
baseOrderNodeCreate();//基地生产
}
else if(index === 1){
index++;
stockNodeCreate();//仓库库存
}
else if(index === 2){
index++;
delNodeCreate();//发货
}
else if(index === 3){
index++;
setNodeCreate();//结算
$(this).text(' →_→ 没有记录了');
}
}
})
// + - 按钮 收缩效果
$(document).on('click', '.bigButtonSeeMore', function(){
var clickObj = $(this);
var bigContentObj = clickObj.parent().next().next();
if(clickObj.text() === '+'){
bigContentObj.slideDown(500, function(){
clickObj.html('<a href="javascript:;" rel="external nofollow" rel="external nofollow" ">-</a>');//切换图标
});
}
else if(clickObj.text() === '-'){
bigContentObj.slideUp(500, function(){
clickObj.html('<a href="javascript:;" rel="external nofollow" rel="external nofollow" ">+</a>');
});
}
})
</script>
</body>
</html>