From a38722d9cb069485477cc6afc223d8d73e54de05 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Thu, 27 Aug 2009 16:51:30 +0000 Subject: [PATCH] Fix scrolling issues and useless Ajax calls in Calendar web view Monotone-Parent: fa7d871f17a70530eb91cb1db11d03a8fa643108 Monotone-Revision: a8698cc119066cef660b176c3e956b5d0d843e7f Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2009-08-27T16:51:30 Monotone-Branch: ca.inverse.sogo --- UI/WebServerResources/SchedulerUI.js | 30 +++++++++++----------------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/UI/WebServerResources/SchedulerUI.js b/UI/WebServerResources/SchedulerUI.js index 4946f82b2..fc47b6cce 100644 --- a/UI/WebServerResources/SchedulerUI.js +++ b/UI/WebServerResources/SchedulerUI.js @@ -562,7 +562,6 @@ function dateSelectorCallback(http) { var content = http.responseText; setDateSelectorContent(content); cachedDateSelectors[http.callbackData] = content; - changeCalendarDisplay( { "day": currentDay } ); } else log ("dateSelectorCallback Ajax error"); @@ -822,7 +821,8 @@ function changeCalendarDisplay(data, newView) { } // Scroll to event - scrollDayView(scrollEvent); + if (scrollEvent) + scrollDayView(scrollEvent); return false; } @@ -916,19 +916,17 @@ function refreshCalendarEvents(scrollEvent) { var todayDate = new Date(); var sd; var ed; + + if (!currentDay) + currentDay = todayDate.getDayString(); + if (currentView == "dayview") { - if (currentDay) - sd = currentDay; - else - sd = todayDate.getDayString(); + sd = currentDay; ed = sd; } else if (currentView == "weekview") { var startDate; - if (currentDay) - startDate = currentDay.asDate(); - else - startDate = todayDate; + startDate = currentDay.asDate(); startDate = startDate.beginOfWeek(); sd = startDate.getDayString(); var endDate = new Date(); @@ -938,10 +936,7 @@ function refreshCalendarEvents(scrollEvent) { } else { var monthDate; - if (currentDay) - monthDate = currentDay.asDate(); - else - monthDate = todayDate; + monthDate = currentDay.asDate(); monthDate.setDate(1); sd = monthDate.beginOfWeek().getDayString(); @@ -1155,12 +1150,11 @@ function calendarDisplayCallback(http) { var daysView = $("daysView"); var position = -1; + // Check the previous view to restore the scrolling position if (daysView) position = daysView.scrollTop; - - if (position != -1) - preventAutoScroll = true; - + preventAutoScroll = (position != -1); + if (http.readyState == 4 && http.status == 200) { document.dayDisplayAjaxRequest = null;