fullcalendar显示出勤日,fullcalendar当前时间线在周视图和日视图

I understand that according to this issue ticket on google code http://code.google.com/p/fullcalendar/issues/detail?id=143 that there is a soloution floating around, however I cant seem to find it.

I am wondering if anyone knows how to show a red solid line on the current time on the calendar

解决方案function setTimeline(view) {

var parentDiv = jQuery(".fc-agenda-slots:visible").parent();

var timeline = parentDiv.children(".timeline");

if (timeline.length == 0) { //if timeline isn't there, add it

timeline = jQuery("


").addClass("timeline");

parentDiv.prepend(timeline);

}

var curTime = new Date();

var curCalView = jQuery("#calendar").fullCalendar('getView');

if (curCalView.visStart < curTime && curCalView.visEnd > curTime) {

timeline.show();

} else {

timeline.hide();

return;

}

var curSeconds = (curTime.getHours() * 60 * 60) + (curTime.getMinutes() * 60) + curTime.getSeconds();

var percentOfDay = curSeconds / 86400; //24 * 60 * 60 = 86400, # of seconds in a day

var topLoc = Math.floor(parentDiv.height() * percentOfDay);

timeline.css("top", topLoc + "px");

if (curCalView.name == "agendaWeek") { //week view, don't want the timeline to go the whole way across

var dayCol = jQuery(".fc-today:visible");

var left = dayCol.position().left + 1;

var width = dayCol.width()-2;

timeline.css({

left: left + "px",

width: width + "px"

});

}

}

And then in the setup:

viewDisplay: function(view) {

try {

setTimeline();

} catch(err) {}

},

and in the css:

.timeline {

position: absolute;

left: 59px;

border: none;

border-top: 1px solid red;

width: 100%;

margin: 0;

padding: 0;

z-index: 999;

}

Only tried this on week-view since that's all I use.

Good luck.

Edit:

To get the timeline to update during the day you could try something like this in the viewDisplay:

viewDisplay: function(view) {

if(first){

first = false;

}else {

window.clearInterval(timelineInterval);

}

timelineInterval = window.setInterval(setTimeline, 300000);

try {

setTimeline();

} catch(err) {}

},

You will need to set first=true in the top of the tag. This will move the timeline every 300 second = 5 minutes. You can lower it if you need it more smooth..

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值