allow for selection of calendar events that are outside the current view
This commit is contained in:
parent
d7507ee5ab
commit
96d03fc386
1 changed files with 23 additions and 8 deletions
|
@ -633,14 +633,23 @@ Ox.Calendar = function(options, self) {
|
||||||
return $element;
|
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() {
|
function getLines() {
|
||||||
self.lineEvents = [];
|
self.lineEvents = [];
|
||||||
self.$content.find('.OxLine').remove();
|
self.$content.find('.OxLine').remove();
|
||||||
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 <-- commented out to keep layout from changing
|
return self.options.showTypes.indexOf(event.type) > -1;
|
||||||
return self.options.showTypes.indexOf(event.type) > -1
|
|
||||||
/*&& overlaps(event, calendarEvent)*/;
|
|
||||||
}).sort(function(a, b) {
|
}).sort(function(a, b) {
|
||||||
// sort events (dates first, people last, longer before shorter)
|
// sort events (dates first, people last, longer before shorter)
|
||||||
if (a.type == 'date' && b.type != 'date') {
|
if (a.type == 'date' && b.type != 'date') {
|
||||||
|
@ -858,16 +867,17 @@ Ox.Calendar = function(options, self) {
|
||||||
marginLeft: -delta / getScrollbarFactor() + 'px'
|
marginLeft: -delta / getScrollbarFactor() + 'px'
|
||||||
}, ms);
|
}, ms);
|
||||||
if (!Ox.isUndefined(line)) {
|
if (!Ox.isUndefined(line)) {
|
||||||
scrollTo(line * 16 + 8 - self.$container.height() / 2, true);
|
scrollTo((line + 1) * 16 - self.$container.height() / 2, true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function panToSelected() {
|
function panToSelected() {
|
||||||
// fixme: '0' should zoom to selected if selected is already centered
|
// fixme: '0' should zoom to selected if selected is already centered
|
||||||
// (both horizontally and vertically, the latter is a bit more work)
|
// (both horizontally and vertically, the latter is a bit more work)
|
||||||
|
var event = getSelectedEvent();
|
||||||
self.options.selected !== '' && panTo(
|
self.options.selected !== '' && panTo(
|
||||||
getEventCenter(getSelectedEvent()),
|
getEventCenter(event),
|
||||||
getSelectedEventElement().data('line')
|
getEventLine(event.id)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -900,7 +910,7 @@ Ox.Calendar = function(options, self) {
|
||||||
event.id == self.options.selected
|
event.id == self.options.selected
|
||||||
|| overlaps(event, calendarEvent)
|
|| 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');
|
self.$content.find('.OxSelected').removeClass('OxSelected');
|
||||||
if (id) {
|
if (id) {
|
||||||
self.options.selected = 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'
|
// fixme: map event should also be 'select', not 'selectplace'
|
||||||
that.triggerEvent('select', Ox.getObjectById(self.options.events, id));
|
that.triggerEvent('select', Ox.getObjectById(self.options.events, id));
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue