diff --git a/event/static/js/calendar.js b/event/static/js/calendar.js index 02c1990..0f30b7f 100644 --- a/event/static/js/calendar.js +++ b/event/static/js/calendar.js @@ -906,37 +906,41 @@ class EventDetails { } setPopupPosition (mouseClickEvent) { - let eventOffset = this.event.node.offset(); + let calendarOffset = this.event.calendar.containerNode.offset(); + + let eventOffset = this.event.node.position(); let eventNodeHeight = this.event.node.outerHeight(); - let detailNodeOffset = this.node.offset(); + let detailNodeOffset = this.node.position(); let detailsNodeWidth = this.node.outerWidth(); let detailsNodeHeight = this.node.outerHeight(); - let x = mouseClickEvent.pageX - (detailsNodeWidth / 2); - let y = eventOffset.top + eventNodeHeight + 10; + let x = mouseClickEvent.pageX - (detailsNodeWidth / 2) + - calendarOffset.left; + let y = eventOffset.top + eventNodeHeight + 50; // If the popup is too high to vertically fit in the window, // it is displayed above the event instead - let bottomMargin = 50; // px - let detailsNodeBottom = eventOffset.top - + eventNodeHeight - + detailsNodeHeight; + // let bottomMargin = 50; // px + // let detailsNodeBottom = y + // + calendarOffset.top + // + detailsNodeHeight; - if (detailsNodeBottom > window.innerHeight - bottomMargin) { - y = eventOffset.top - detailsNodeHeight - 10; - this.node.addClass("above-event") - } + // if (detailsNodeBottom > $(window).height() - bottomMargin) { + // y = eventOffset.top - detailsNodeHeight - 10; + // this.node.addClass("above-event") + // } // If the popup is about to be displayed outside of // the left/right side of the screen, correct its future x position + let absoluteX = x + calendarOffset.left; let sideMargin = 20; // px - if (x < sideMargin) { - x += sideMargin - x; + if (absoluteX < sideMargin) { + x += sideMargin - absoluteX; } - else if (x + detailsNodeWidth > window.innerWidth - sideMargin) { - x -= (x + detailsNodeWidth) - (window.innerWidth - sideMargin); + else if (absoluteX + detailsNodeWidth > $(window).width() - sideMargin) { + x -= (absoluteX + detailsNodeWidth) - ($(window).width() - sideMargin); } this.node.css({