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