allow for vertical scrolling of calendar (pan and zoom)
This commit is contained in:
parent
acef6a822a
commit
52310babe8
1 changed files with 27 additions and 10 deletions
|
@ -73,6 +73,12 @@ Ox.Calendar = function(options, self) {
|
||||||
key_shift_0: function() {
|
key_shift_0: function() {
|
||||||
zoomToSelected();
|
zoomToSelected();
|
||||||
},
|
},
|
||||||
|
key_shift_down: function() {
|
||||||
|
scrollTo(1000000, true);
|
||||||
|
},
|
||||||
|
key_shift_up: function() {
|
||||||
|
scrollTo(0, true);
|
||||||
|
},
|
||||||
key_up: function() {
|
key_up: function() {
|
||||||
scrollBy(-1);
|
scrollBy(-1);
|
||||||
}
|
}
|
||||||
|
@ -639,6 +645,14 @@ Ox.Calendar = function(options, self) {
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getSelectedEventElement() {
|
||||||
|
var $element = null;
|
||||||
|
if (self.options.selected !== '') {
|
||||||
|
$element = getEventElementById(self.options.selected);
|
||||||
|
}
|
||||||
|
return $element;
|
||||||
|
}
|
||||||
|
|
||||||
function getBackgroundElements(zoom) {
|
function getBackgroundElements(zoom) {
|
||||||
// fixme: duplicated
|
// fixme: duplicated
|
||||||
var $elements = [],
|
var $elements = [],
|
||||||
|
@ -760,7 +774,7 @@ Ox.Calendar = function(options, self) {
|
||||||
panTo(new Date(+self.options.date + ms));
|
panTo(new Date(+self.options.date + ms));
|
||||||
}
|
}
|
||||||
|
|
||||||
function panTo(date) {
|
function panTo(date, line) {
|
||||||
var delta = (date - self.options.date) / 1000 * getPixelsPerSecond(),
|
var delta = (date - self.options.date) / 1000 * getPixelsPerSecond(),
|
||||||
// 250 ms for half the width of the visible area
|
// 250 ms for half the width of the visible area
|
||||||
ms = 250 * Math.min(Math.abs(delta) / (self.$content.width() / 2), 1);
|
ms = 250 * Math.min(Math.abs(delta) / (self.$content.width() / 2), 1);
|
||||||
|
@ -779,11 +793,15 @@ Ox.Calendar = function(options, self) {
|
||||||
self.$scrollbar.animate({
|
self.$scrollbar.animate({
|
||||||
marginLeft: -delta / getScrollbarFactor() + 'px'
|
marginLeft: -delta / getScrollbarFactor() + 'px'
|
||||||
}, ms);
|
}, ms);
|
||||||
|
if (!Ox.isUndefined(line)) {
|
||||||
|
scrollTo(line * 16 + 8 - self.$container.height() / 2, true);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function panToSelected() {
|
function panToSelected() {
|
||||||
if (self.options.selected !== '') {
|
if (self.options.selected !== '') {
|
||||||
panTo(getEventCenter(getSelectedEvent()));
|
var line = getSelectedEventElement().data('line');
|
||||||
|
panTo(getEventCenter(getSelectedEvent()), line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -864,8 +882,11 @@ Ox.Calendar = function(options, self) {
|
||||||
// sort events by start, ascending
|
// sort events by start, ascending
|
||||||
return a.startTime - b.startTime;
|
return a.startTime - b.startTime;
|
||||||
}).forEach(function(event) {
|
}).forEach(function(event) {
|
||||||
overlaps(event, calendarEvent) &&
|
if (overlaps(event, calendarEvent)) {
|
||||||
getEventElement(event).appendTo($line);
|
getEventElement(event)
|
||||||
|
.data({line: line})
|
||||||
|
.appendTo($line);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -977,12 +998,8 @@ Ox.Calendar = function(options, self) {
|
||||||
var event = getSelectedEvent(),
|
var event = getSelectedEvent(),
|
||||||
eventDuration = getEventDuration(event),
|
eventDuration = getEventDuration(event),
|
||||||
zoom = getZoom();
|
zoom = getZoom();
|
||||||
if (zoom == self.options.zoom) {
|
zoom != self.options.zoom && zoomTo(zoom);
|
||||||
panToSelected();
|
panToSelected();
|
||||||
} else {
|
|
||||||
self.options.date = getEventCenter(event);
|
|
||||||
zoomTo(zoom);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
function getZoom() {
|
function getZoom() {
|
||||||
var zoom;
|
var zoom;
|
||||||
|
|
Loading…
Reference in a new issue