more calendar improvements (positioning, scrolling)

This commit is contained in:
rolux 2011-05-25 21:52:33 +02:00
parent 474d5f92cb
commit 06f27b75bd

View file

@ -762,7 +762,7 @@ Ox.Calendar = function(options, self) {
function panTo(date) { function panTo(date) {
var delta = (date - self.options.date) / 1000 * getPixelsPerSecond(), var delta = (date - self.options.date) / 1000 * getPixelsPerSecond(),
ms = 250 * Math.max(Math.abs(delta) / (self.$content.width() / 2), 1); ms = 250 * Math.min(Math.abs(delta) / (self.$content.width() / 2), 1);
self.$content.animate({ self.$content.animate({
marginLeft: -delta + 'px' marginLeft: -delta + 'px'
}, ms, function() { }, ms, function() {
@ -801,17 +801,19 @@ Ox.Calendar = function(options, self) {
function renderEvents() { function renderEvents() {
var calendarEvent = getCalendarEvent(); var calendarEvent = getCalendarEvent();
lineEvents = [], lineEvents = [];
types = ['date']; //['date', 'place', 'person', 'other']; //types = ['date', 'place', 'person', 'other'];
self.options.events.filter(function(event) { self.options.events.filter(function(event) {
// filter out events with types not shown // filter out events with types not shown
// and events outside the visible area // and events outside the visible area
return self.options.showTypes.indexOf(event.type) > -1 return self.options.showTypes.indexOf(event.type) > -1
&& overlaps(event, calendarEvent); /*&& overlaps(event, calendarEvent)*/;
}).sort(function(a, b) { }).sort(function(a, b) {
// sort events // sort events
if (a.type != b.type) { if (a.type == 'date' && b.type != 'date') {
return types.indexOf(b.type) - types.indexOf(a.type); return -1;
} else if (a.type != 'date' && b.type == 'date') {
return 1;
} else if (a.start < b.start || a.start > b.start) { } else if (a.start < b.start || a.start > b.start) {
return a.start - b.start; return a.start - b.start;
} else { } else {
@ -852,7 +854,8 @@ Ox.Calendar = function(options, self) {
// sort events by start, ascending // sort events by start, ascending
return a.start - b.start; return a.start - b.start;
}).forEach(function(event) { }).forEach(function(event) {
getEventElement(event).appendTo($line); overlaps(event, calendarEvent) &&
getEventElement(event).appendTo($line);
}); });
}); });
} }