mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-03-12 10:21:22 +00:00
Mantis 94: refreshes to the views should not change the scrolling of the calendar view
Monotone-Parent: e7b81958c4674e9abdea432ddd234af617b11eda Monotone-Revision: fd68594395e1fce1922bab89dcc37e32cb3baba5 Monotone-Author: crobert@inverse.ca Monotone-Date: 2009-08-18T18:23:13 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -23,6 +23,8 @@ var usersRightsWindowWidth = 502;
|
||||
|
||||
var calendarEvents = null;
|
||||
|
||||
var preventAutoScroll = false;
|
||||
|
||||
var userStates = [ "needs-action", "accepted", "declined", "tentative" ];
|
||||
|
||||
function newEvent(sender, type) {
|
||||
@@ -873,29 +875,31 @@ function onCalendarReload() {
|
||||
}
|
||||
|
||||
function scrollDayView(scrollEvent) {
|
||||
if (scrollEvent) {
|
||||
var contentView;
|
||||
var eventRow = $(scrollEvent);
|
||||
var eventBlocks = selectCalendarEvent(eventRow.calendar, eventRow.cname, eventRow.recurrenceTime);
|
||||
var firstEvent = eventBlocks.first();
|
||||
|
||||
if (currentView == "monthview")
|
||||
contentView = firstEvent.up("DIV.day");
|
||||
else
|
||||
contentView = $("daysView");
|
||||
|
||||
var top = firstEvent.cumulativeOffset()[1] - contentView.scrollTop;
|
||||
if (!preventAutoScroll) {
|
||||
if (scrollEvent) {
|
||||
var contentView;
|
||||
var eventRow = $(scrollEvent);
|
||||
var eventBlocks = selectCalendarEvent(eventRow.calendar, eventRow.cname, eventRow.recurrenceTime);
|
||||
var firstEvent = eventBlocks.first();
|
||||
|
||||
// Don't scroll if the event is visible to the user
|
||||
if (top < contentView.cumulativeOffset()[1])
|
||||
contentView.scrollTop = firstEvent.cumulativeOffset()[1] - contentView.cumulativeOffset()[1];
|
||||
else if (top > contentView.cumulativeOffset()[1] + contentView.getHeight() - firstEvent.getHeight())
|
||||
contentView.scrollTop = firstEvent.cumulativeOffset()[1] - contentView.cumulativeOffset()[1];
|
||||
}
|
||||
else if (currentView != "monthview") {
|
||||
var contentView = $("daysView");
|
||||
var hours = (contentView.childNodesWithTag("div")[0]).childNodesWithTag("div");
|
||||
contentView.scrollTop = hours[dayStartHour].offsetTop;
|
||||
if (currentView == "monthview")
|
||||
contentView = firstEvent.up("DIV.day");
|
||||
else
|
||||
contentView = $("daysView");
|
||||
|
||||
var top = firstEvent.cumulativeOffset()[1] - contentView.scrollTop;
|
||||
|
||||
// Don't scroll if the event is visible to the user
|
||||
if (top < contentView.cumulativeOffset()[1])
|
||||
contentView.scrollTop = firstEvent.cumulativeOffset()[1] - contentView.cumulativeOffset()[1];
|
||||
else if (top > contentView.cumulativeOffset()[1] + contentView.getHeight() - firstEvent.getHeight())
|
||||
contentView.scrollTop = firstEvent.cumulativeOffset()[1] - contentView.cumulativeOffset()[1];
|
||||
}
|
||||
else if (currentView != "monthview") {
|
||||
var contentView = $("daysView");
|
||||
var hours = (contentView.childNodesWithTag("div")[0]).childNodesWithTag("div");
|
||||
contentView.scrollTop = hours[dayStartHour].offsetTop;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1144,12 +1148,24 @@ function newMonthEventDIV(eventRep, event) {
|
||||
|
||||
function calendarDisplayCallback(http) {
|
||||
var div = $("calendarView");
|
||||
var daysView = $("daysView");
|
||||
var position = -1;
|
||||
|
||||
if (daysView)
|
||||
position = daysView.scrollTop;
|
||||
|
||||
if (position != -1)
|
||||
preventAutoScroll = true;
|
||||
|
||||
if (http.readyState == 4
|
||||
&& http.status == 200) {
|
||||
document.dayDisplayAjaxRequest = null;
|
||||
div.update(http.responseText);
|
||||
|
||||
// DOM has changed
|
||||
if (preventAutoScroll)
|
||||
$("daysView").scrollTop = position;
|
||||
|
||||
if (http.callbackData["view"])
|
||||
currentView = http.callbackData["view"];
|
||||
if (http.callbackData["day"])
|
||||
|
||||
Reference in New Issue
Block a user