From a921d4abc60157e596b77b225642019dddb89eb4 Mon Sep 17 00:00:00 2001 From: C Robert Date: Tue, 18 Aug 2009 18:23:13 +0000 Subject: [PATCH] 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 --- UI/WebServerResources/SchedulerUI.js | 60 ++++++++++++++++++---------- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/UI/WebServerResources/SchedulerUI.js b/UI/WebServerResources/SchedulerUI.js index 73930af89..2f9589306 100644 --- a/UI/WebServerResources/SchedulerUI.js +++ b/UI/WebServerResources/SchedulerUI.js @@ -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"])