allow for selection of calendar events that are outside the current view

This commit is contained in:
rlx 2011-10-10 09:43:07 +00:00
parent d7507ee5ab
commit 96d03fc386

View file

@ -633,14 +633,23 @@ Ox.Calendar = function(options, self) {
return $element;
}
function getEventLine(id) {
var line = -1;
Ox.forEach(self.lineEvents, function(events, line_) {
if (Ox.getPositionById(events, id) > -1) {
line = line_;
return false;
}
});
return line;
}
function getLines() {
self.lineEvents = [];
self.$content.find('.OxLine').remove();
self.options.events.filter(function(event) {
// filter out events with types not shown
// and events outside the visible area <-- commented out to keep layout from changing
return self.options.showTypes.indexOf(event.type) > -1
/*&& overlaps(event, calendarEvent)*/;
return self.options.showTypes.indexOf(event.type) > -1;
}).sort(function(a, b) {
// sort events (dates first, people last, longer before shorter)
if (a.type == 'date' && b.type != 'date') {
@ -858,16 +867,17 @@ Ox.Calendar = function(options, self) {
marginLeft: -delta / getScrollbarFactor() + 'px'
}, ms);
if (!Ox.isUndefined(line)) {
scrollTo(line * 16 + 8 - self.$container.height() / 2, true);
scrollTo((line + 1) * 16 - self.$container.height() / 2, true);
}
};
function panToSelected() {
// fixme: '0' should zoom to selected if selected is already centered
// (both horizontally and vertically, the latter is a bit more work)
var event = getSelectedEvent();
self.options.selected !== '' && panTo(
getEventCenter(getSelectedEvent()),
getSelectedEventElement().data('line')
getEventCenter(event),
getEventLine(event.id)
);
}
@ -900,7 +910,7 @@ Ox.Calendar = function(options, self) {
event.id == self.options.selected
|| overlaps(event, calendarEvent)
) {
getEventElement(event).data({line: line}).appendTo(self.$lines[line]);
getEventElement(event).appendTo(self.$lines[line]);
}
});
});
@ -978,7 +988,12 @@ Ox.Calendar = function(options, self) {
self.$content.find('.OxSelected').removeClass('OxSelected');
if (id) {
self.options.selected = id;
($element || getEventElementById(id)).addClass('OxSelected');
$element = $element || getEventElementById(id);
if ($element) {
$element.addClass('OxSelected');
} else {
panToSelected();
}
// fixme: map event should also be 'select', not 'selectplace'
that.triggerEvent('select', Ox.getObjectById(self.options.events, id));
} else {