My favorites | Sign in
Project Home Issues
New issue   Search
for
  Advanced search   Search tips   Subscriptions

Issue 143 attachment: current_time_indicator_143.diff (2.3 KB)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
diff --git a/src/agenda/AgendaEventRenderer.js b/src/agenda/AgendaEventRenderer.js
index 9e7243b..9dd6ad0 100644
--- a/src/agenda/AgendaEventRenderer.js
+++ b/src/agenda/AgendaEventRenderer.js
@@ -47,6 +47,7 @@ function AgendaEventRenderer() {
var calendar = t.calendar;
var formatDate = calendar.formatDate;
var formatDates = calendar.formatDates;
+ var timeLineInterval;



@@ -71,6 +72,12 @@ function AgendaEventRenderer() {
setHeight(); // no params means set to viewHeight
}
renderSlotSegs(compileSlotSegs(slotEvents), modifiedEventId);
+
+ if (opt('currentTimeIndicator')) {
+ window.clearInterval(timeLineInterval);
+ timeLineInterval = window.setInterval(setTimeIndicator, 30000);
+ setTimeIndicator();
+ }
}


@@ -349,6 +356,37 @@ function AgendaEventRenderer() {
}


+ // draw a horizontal line indicating the current time (#143)
+ function setTimeIndicator()
+ {
+ var container = getBodyContent();
+ var timeline = container.children('.fc-timeline');
+ if (timeline.length == 0) { // if timeline isn't there, add it
+ timeline = $('<hr>').addClass('fc-timeline').appendTo(container);
+ }
+
+ var cur_time = new Date();
+ if (t.visStart < cur_time && t.visEnd > cur_time) {
+ timeline.show();
+ }
+ else {
+ timeline.hide();
+ return;
+ }
+
+ var secs = (cur_time.getHours() * 60 * 60) + (cur_time.getMinutes() * 60) + cur_time.getSeconds();
+ var percents = secs / 86400; // 24 * 60 * 60 = 86400, # of seconds in a day
+
+ timeline.css('top', Math.floor(container.height() * percents - 1) + 'px');
+
+ if (t.name == 'agendaWeek') { // week view, don't want the timeline to go the whole way across
+ var daycol = $('.fc-today', t.element);
+ var left = daycol.position().left + 1;
+ var width = daycol.width();
+ timeline.css({ left: left + 'px', width: width + 'px' });
+ }
+ }
+

/* Dragging
-----------------------------------------------------------------------------------*/
diff --git a/src/agenda/agenda.css b/src/agenda/agenda.css
index 21a91ae..8287a98 100644
--- a/src/agenda/agenda.css
+++ b/src/agenda/agenda.css
@@ -141,4 +141,13 @@
_overflow: hidden;
}

-
+.fc-timeline {
+ position: absolute;
+ width: 100%;
+ left: 0;
+ margin: 0;
+ padding: 0;
+ border: none;
+ border-top: 2px solid #3ec400;
+ z-index: 999;
+}
Powered by Google Project Hosting