From 06f27b75bd53696a002ad88b174906567f0c0969 Mon Sep 17 00:00:00 2001 From: rolux Date: Wed, 25 May 2011 21:52:33 +0200 Subject: [PATCH] more calendar improvements (positioning, scrolling) --- source/Ox.UI/js/Calendar/Ox.Calendar.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/source/Ox.UI/js/Calendar/Ox.Calendar.js b/source/Ox.UI/js/Calendar/Ox.Calendar.js index a61278f6..87555944 100644 --- a/source/Ox.UI/js/Calendar/Ox.Calendar.js +++ b/source/Ox.UI/js/Calendar/Ox.Calendar.js @@ -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); }); }); }