Skip to content

Instantly share code, notes, and snippets.

@espen
Created July 31, 2013 20:24
Show Gist options
  • Save espen/6125807 to your computer and use it in GitHub Desktop.
Save espen/6125807 to your computer and use it in GitHub Desktop.
fullcalendar annotations
/* Global Annotation Styles
------------------------------------------------------------------------*/
.fc-annotation {
border-style: solid;
border-width: 0;
font-size: .85em;
cursor: default;
}
.fc-annotation-skin {
border-color: #999; /* default BORDER color */
background-color: #edb; /* default BACKGROUND color */
color: #777; /* default TEXT color */
text-align: center;
opacity: 0.8;
filter: alpha(opacity=80); /* for IE */
}
.fc-annotation.closed {
background-color: #f1f1f1;
}
function renderAnnotations(view,annotations) {
var container = $(view.element).find('.fc-agenda-slots').parent();
if ( container.find('#annotationSegmentContainer').length === 0 ) {
annotationSegmentContainer = $("<div style='position:absolute;z-index:-1;top:0;left:0' id='annotationSegmentContainer'>").prependTo( container );
}
else {
annotationSegmentContainer = container.find('#annotationSegmentContainer');
}
var html = '';
for (var i=0; i < annotations.length; i++) {
var ann = annotations[i];
if (ann.start >= view.start && ann.end <= view.end) {
var top = view.timePosition(ann.start, ann.start);
var bottom = view.timePosition(ann.end, ann.end);
var height = bottom - top;
var dayIndex = $.fullCalendar.dayDiff(ann.start, view.visStart);
var left = view.colContentLeft(dayIndex) - 2;
var right = view.colContentRight(dayIndex) + 3;
var width = right - left;
var cls = '';
if (ann.cls) {
cls = ' ' + ann.cls;
}
var colors = '';
if (ann.color) {
colors = 'color:' + ann.color + ';';
}
if (ann.background) {
colors += 'background:' + ann.background + ';';
}
var body = ann.title || '';
html += '<div style="position: absolute; ' +
'top: ' + top + 'px; ' +
'left: ' + left + 'px; ' +
'width: ' + width + 'px; ' +
'height: ' + height + 'px;' + colors + '" ' +
'class="fc-annotation fc-annotation-skin' + cls + '">' +
body +
'</div>';
}
}
annotationSegmentContainer.html(html);
}
// Add to line 1255
// or add to top of date_util.js if you are building manually
fc.dayDiff = dayDiff;
@espen
Copy link
Author

espen commented Jul 31, 2013

@muditdugar
Copy link

In fullcalendar.js file of main file i dont find the place where i can add the above lines.please let me know where to add fc.dayDiff in latest version of fullcalendar.js file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment