From 403ef0e27d6034dc81df7878dda1e5a8a5c09f10 Mon Sep 17 00:00:00 2001 From: "michael.buettner%sun.com" Date: Fri, 21 Sep 2007 12:28:07 +0000 Subject: [PATCH] Bug 386480 - View mode is not remembered after Thunderbird restart, patch=giermann@funke.de, r=mickey --- .../content/messenger-overlay-sidebar.js | 34 +++++++++---------- .../content/messenger-overlay-sidebar.xul | 8 ++--- .../content/messenger-overlay-toolbar.js | 2 -- 3 files changed, 20 insertions(+), 24 deletions(-) diff --git a/calendar/lightning/content/messenger-overlay-sidebar.js b/calendar/lightning/content/messenger-overlay-sidebar.js index 006cc8ff01b..db5c43247f3 100644 --- a/calendar/lightning/content/messenger-overlay-sidebar.js +++ b/calendar/lightning/content/messenger-overlay-sidebar.js @@ -215,24 +215,7 @@ function ltnMinimonthPick(minimonth) if (document.getElementById("displayDeck").selectedPanel != document.getElementById("calendar-view-box")) { - var view = currentView(); - - // If we've never shown the view before, we need to do some special - // things here. - if (!view.initialized) { - showCalendarView('month'); - view = currentView(); - cdt = cdt.getInTimezone(view.timezone); - cdt.isDate = true; - view.goToDay(cdt); - return; - } - - // showCalendarView is going to use the value passed in to switch to - // foo-view, so strip off the -view part of the current view. - var viewID = view.getAttribute("id"); - viewID = viewID.substring(0, viewID.indexOf('-')); - showCalendarView(viewID); + showCalendarView(gLastShownCalendarView); } cdt = cdt.getInTimezone(currentView().timezone); @@ -363,6 +346,21 @@ function ltnOnLoad(event) modeBoxAttrModified, true); + // find last shown calendar view (persist="checked") + var availableViews = getViewDeck(); + var numChilds = availableViews.childNodes.length; + for (var i = 0; i < numChilds; i++) { + var view = availableViews.childNodes[i]; + var command = document.getElementById(view.id+"-command"); + if (command && command.getAttribute("checked") == "true") { + gLastShownCalendarView = view.id.substring(0, view.id.indexOf('-')); + break; + } + } + if (!gLastShownCalendarView) { + gLastShownCalendarView = 'month'; + } + gMiniMonthLoading = true; var today = new Date(); diff --git a/calendar/lightning/content/messenger-overlay-sidebar.xul b/calendar/lightning/content/messenger-overlay-sidebar.xul index e175e576a59..2c71d918f9f 100644 --- a/calendar/lightning/content/messenger-overlay-sidebar.xul +++ b/calendar/lightning/content/messenger-overlay-sidebar.xul @@ -193,10 +193,10 @@ - - - - + + + + diff --git a/calendar/lightning/content/messenger-overlay-toolbar.js b/calendar/lightning/content/messenger-overlay-toolbar.js index ffdbf4e9a0f..a3010d82ee9 100644 --- a/calendar/lightning/content/messenger-overlay-toolbar.js +++ b/calendar/lightning/content/messenger-overlay-toolbar.js @@ -147,8 +147,6 @@ function ltnSwitch2Calendar() { deck.selectedPanel = document.getElementById("calendar-view-box"); // show the last displayed type of calendar view - if(gLastShownCalendarView == null) - gLastShownCalendarView = 'week'; showCalendarView(gLastShownCalendarView); document.commandDispatcher.updateCommands('mail-toolbar');