Calculate slot height based on the second row instead of first inner div. The reason we pick second row is to substract height of the first row (without border-top) to also calculate border-size. This should fix following issues:

* 1229: In "Week" and "Day" modes, selection doesn't work correctly if font-size != 14px
* 650: my events does not render correctly
* 1035:	On select click event selection start below mouse position
* 1149: strange behavior in selectable demo
This commit is contained in:
Wojciech Zylinski 2012-01-08 22:46:27 +00:00
parent d234db1972
commit b2941025f1
3 changed files with 23 additions and 8 deletions

View file

@ -36,6 +36,8 @@ function AgendaEventRenderer() {
var getColCnt = t.getColCnt; var getColCnt = t.getColCnt;
var getColWidth = t.getColWidth; var getColWidth = t.getColWidth;
var getSlotHeight = t.getSlotHeight; var getSlotHeight = t.getSlotHeight;
var getBorderHeight = t.getBorderHeight;
var getSlotTableHeight = t.getSlotTableHeight;
var getBodyContent = t.getBodyContent; var getBodyContent = t.getBodyContent;
var reportEventElement = t.reportEventElement; var reportEventElement = t.reportEventElement;
var showEvents = t.showEvents; var showEvents = t.showEvents;
@ -139,7 +141,6 @@ function AgendaEventRenderer() {
// renders events in the 'time slots' at the bottom // renders events in the 'time slots' at the bottom
function renderSlotSegs(segs, modifiedEventId) { function renderSlotSegs(segs, modifiedEventId) {
var i, segCnt=segs.length, seg, var i, segCnt=segs.length, seg,
event, event,
classes, classes,
@ -160,7 +161,9 @@ function AgendaEventRenderer() {
height, height,
slotSegmentContainer = getSlotSegmentContainer(), slotSegmentContainer = getSlotSegmentContainer(),
rtl, dis, dit, rtl, dis, dit,
colCnt = getColCnt(); colCnt = getColCnt(),
borderHeight = getBorderHeight(),
slotTableHeight = getSlotTableHeight();
if (rtl = opt('isRTL')) { if (rtl = opt('isRTL')) {
dis = -1; dis = -1;
@ -176,6 +179,9 @@ function AgendaEventRenderer() {
event = seg.event; event = seg.event;
top = timePosition(seg.start, seg.start); top = timePosition(seg.start, seg.start);
bottom = timePosition(seg.start, seg.end); bottom = timePosition(seg.start, seg.end);
if (bottom < slotTableHeight) {
bottom -= borderHeight;
}
colI = seg.col; colI = seg.col;
levelI = seg.level; levelI = seg.level;
forward = seg.forward || 0; forward = seg.forward || 0;

View file

@ -52,6 +52,8 @@ function AgendaView(element, calendar, viewName) {
t.getColCnt = function() { return colCnt }; t.getColCnt = function() { return colCnt };
t.getColWidth = function() { return colWidth }; t.getColWidth = function() { return colWidth };
t.getSlotHeight = function() { return slotHeight }; t.getSlotHeight = function() { return slotHeight };
t.getBorderHeight = function() { return borderHeight };
t.getSlotTableHeight = function() { return slotTable.height() };
t.defaultSelectionEnd = defaultSelectionEnd; t.defaultSelectionEnd = defaultSelectionEnd;
t.renderDayOverlay = renderDayOverlay; t.renderDayOverlay = renderDayOverlay;
t.renderSelection = renderSelection; t.renderSelection = renderSelection;
@ -96,7 +98,8 @@ function AgendaView(element, calendar, viewName) {
var slotContent; var slotContent;
var slotSegmentContainer; var slotSegmentContainer;
var slotTable; var slotTable;
var slotTableFirstInner; var slotTableFirstRow;
var slotTableSecondRow;
var axisFirstCells; var axisFirstCells;
var gutterCells; var gutterCells;
var selectionHelper; var selectionHelper;
@ -107,6 +110,7 @@ function AgendaView(element, calendar, viewName) {
var colWidth; var colWidth;
var gutterWidth; var gutterWidth;
var slotHeight; // TODO: what if slotHeight changes? (see issue 650) var slotHeight; // TODO: what if slotHeight changes? (see issue 650)
var borderHeight;
var savedScrollTop; var savedScrollTop;
var colCnt; var colCnt;
@ -296,7 +300,8 @@ function AgendaView(element, calendar, viewName) {
"</tbody>" + "</tbody>" +
"</table>"; "</table>";
slotTable = $(s).appendTo(slotContent); slotTable = $(s).appendTo(slotContent);
slotTableFirstInner = slotTable.find('div:first'); slotTableFirstRow = slotTable.find('tr:first');
slotTableSecondRow = slotTable.find('tr:nth-child(2)');
slotBind(slotTable.find('td')); slotBind(slotTable.find('td'));
@ -351,7 +356,8 @@ function AgendaView(element, calendar, viewName) {
} }
slotLayer.css('top', headHeight); slotLayer.css('top', headHeight);
slotHeight = slotTableFirstInner.height() + 1; // +1 for border slotHeight = slotTableSecondRow.outerHeight();
borderHeight = slotHeight - slotTableFirstRow.outerHeight();
if (dateChanged) { if (dateChanged) {
resetScroll(); resetScroll();
@ -401,7 +407,7 @@ function AgendaView(element, calendar, viewName) {
var d0 = zeroDate(); var d0 = zeroDate();
var scrollDate = cloneDate(d0); var scrollDate = cloneDate(d0);
scrollDate.setHours(opt('firstHour')); scrollDate.setHours(opt('firstHour'));
var top = timePosition(d0, scrollDate) + 1; // +1 for the border var top = timePosition(d0, scrollDate) + borderHeight;
function scroll() { function scroll() {
slotScroller.scrollTop(top); slotScroller.scrollTop(top);
} }
@ -624,7 +630,7 @@ function AgendaView(element, calendar, viewName) {
slotTop = slotTopCache[slotI] = slotTable.find('tr:eq(' + slotI + ') td div')[0].offsetTop; //.position().top; // need this optimization??? slotTop = slotTopCache[slotI] = slotTable.find('tr:eq(' + slotI + ') td div')[0].offsetTop; //.position().top; // need this optimization???
} }
return Math.max(0, Math.round( return Math.max(0, Math.round(
slotTop - 1 + slotHeight * ((minutes % slotMinutes) / slotMinutes) slotTop + slotHeight * ((minutes % slotMinutes) / slotMinutes)
)); ));
} }
@ -684,6 +690,9 @@ function AgendaView(element, calendar, viewName) {
var rect = coordinateGrid.rect(0, col, 0, col, slotContent); // only for horizontal coords var rect = coordinateGrid.rect(0, col, 0, col, slotContent); // only for horizontal coords
var top = timePosition(startDate, startDate); var top = timePosition(startDate, startDate);
var bottom = timePosition(startDate, endDate); var bottom = timePosition(startDate, endDate);
if (bottom < slotTable.height()) {
bottom -= borderHeight;
}
if (bottom > top) { // protect against selections that are entirely before or after visible range if (bottom > top) { // protect against selections that are entirely before or after visible range
rect.top = top; rect.top = top;
rect.height = bottom - top; rect.height = bottom - top;

View file

@ -50,4 +50,4 @@ function _fixUIEvent(event) { // jQuery 1.7 workaround (for issue 1168)
event.pageX = event.originalEvent.pageX; event.pageX = event.originalEvent.pageX;
event.pageY = event.originalEvent.pageY; event.pageY = event.originalEvent.pageY;
} }
} }