-
Notifications
You must be signed in to change notification settings - Fork 246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Current time line/indicator #9
Comments
Hi, I am the guy who opened this issue on googlecode. Sorry for that last grammar mistake, english is not my native language. So, this is how I did my current time line/indicator. It looks like this: This is my css. It's pretty similar to another solution to this issue on AgendaWeek. .timeline {
position: absolute;
border: 2px dotted red;
width: 1px;
margin: 0;
padding: 0;
z-index: 9;
height: auto;
} And here I developed my function which draws a vertical line on ResourceView function setTimelineRec(view) {
//I get the div where the line will be shown.
var parentDivAux = jQuery(".fc-time-area.fc-widget-content").children().children().children().children();
var parentDiv = jQuery();
for (var i = 0; i < parentDivAux.length; i++) {
//I need only (i think so) the fc-bg, cause fc-content is defined on multiple ocassions and line would be painted multiple times.
if (parentDivAux[i].className === "fc-bg") {
parentDiv.push(parentDivAux[i]);
}
}
var timeline = parentDiv.children(".timeline").children();
if (timeline.length == 0) { //if timeline isn't there, add it
timeline = jQuery("<hr>").addClass("timeline");
//my calendar starts at 9 am and finishes at 9 pm, so I get the total amount of seconds from midnight to 9 am and from 9 am to 9 pm
var secondsHourMin = 9 * 3600;
var totalSeconds = 12 * 3600 ;
//I get the width of the div where the line will be painted
var widthAux = jQuery(".fc-time-area.fc-widget-content").children().children().children();
var width = widthAux.width();
//we obtain the current time/date to know where we should draw the vertical line
var curTime = new Date();
var curSeconds = (curTime.getHours() * 60 * 60) + (curTime.getMinutes() * 60) + curTime.getSeconds() - secondsHourMin;
var percentOfDay = curSeconds / totalSeconds; //totalSeconds = 12 hours
//I calculate the margin with a known width and the actual percentOfDay
var margin = (percentOfDay * width);
//margin is applied and finally I prepend the timeline.
timeline.css({
left: margin + "px",
height: "100%",
width: 1 + "px"
});
parentDiv.prepend(timeline);
}
} Then I have two functions, one is launched when the windows is resized and another one to update the line every 5 seconds. I remove the hr, and inmediately I call the previous function. It does not flicker at all, so I find it enough. setInterval(function () {
$('.timeline').remove();
setTimelineRec();
}, 5000);
$(window).on('resize', function () {
$('.timeline').remove();
setTimelineRec();
}); I know this is not the best way to do it, but I am almost a noob with JS and JQuery. Hope this helps anyone in future. |
Another workaround function highlight_hour() { and in eventAfterAllRender simply call it highlight_hour(); Add this in your CSS if you are not using jquery ui Working jsbin |
this has been release in 1.2.0: |
So awesome! 👍 👍 |
Originally reported on Google Code with ID 2564
Reported by
pereiraschumy
on 2015-08-18 11:42:41The text was updated successfully, but these errors were encountered: