Fix bug 678649 - Today pane in Lion won't expand. r=bv1578,a=philipp
authorDecathlon <bv1578@gmail.com>
Tue, 20 Sep 2011 08:45:00 +0200
changeset 30664 2764ecb73c4f998b8f6fa8f68f162b2ec0938a81
parent 30663 dc791f85a4f6c0f002dd3468c2fd4edc6a8b28ea
child 30665 0a19c0eb253385be2e28cb286364c6130e1b6488
push id1
push userclokep@gmail.com
push dateMon, 07 May 2018 22:45:56 +0000
treeherdercomm-esr60@57eacde5ef40 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbv1578, philipp
bugs678649
Fix bug 678649 - Today pane in Lion won't expand. r=bv1578,a=philipp
calendar/base/content/today-pane.js
calendar/base/content/today-pane.xul
calendar/base/themes/pinstripe/today-pane.css
calendar/lightning/content/messenger-overlay-sidebar.xul
--- a/calendar/base/content/today-pane.js
+++ b/calendar/base/content/today-pane.js
@@ -41,16 +41,17 @@ Components.utils.import("resource://cale
 
 /**
  * Namespace object to hold functions related to the today pane.
  */
 var TodayPane = {
     paneViews: null,
     start: null,
     cwlabel: null,
+    previousMode:  null,
 
     /**
      * Load Handler, sets up the today pane controls.
      */
     onLoad: function onLoad() {
         TodayPane.paneViews = [ cal.calGetString("calendar", "eventsandtasks"),
                                 cal.calGetString("calendar", "tasksonly"),
                                 cal.calGetString("calendar", "eventsonly") ];
@@ -58,16 +59,17 @@ var TodayPane = {
         TodayPane.initializeMiniday();
         TodayPane.setShortWeekdays();
 
         document.getElementById("modeBroadcaster").addEventListener("DOMAttrModified", TodayPane.onModeModified, false);
         TodayPane.setTodayHeader();
 
         document.getElementById("today-splitter").addEventListener("command", onCalendarViewResize, false);
         TodayPane.updateSplitterState();
+        TodayPane.previousMode = document.getElementById("modeBroadcaster").getAttribute("mode");
     },
 
     /**
      * Unload handler, cleans up the today pane on window unload.
      */
     onUnload: function onUnload() {
         document.getElementById("modeBroadcaster").removeEventListener("DOMAttrModified", TodayPane.onModeModified, false);
         document.getElementById("today-splitter").removeEventListener("command", onCalendarViewResize, false);
@@ -274,18 +276,24 @@ var TodayPane = {
     /**
      * Handler function for the DOMAttrModified event used to observe the
      * todaypane-splitter.
      *
      * @param aEvent        The DOM event occurring on attribute modification.
      */
     onModeModified: function onModeModified(aEvent) {
         if (aEvent.attrName == "mode") {
+            let todaypane = document.getElementById("today-pane-panel");
+            // Store the previous mode panel's width.
+            todaypane.setModeAttribute("modewidths", todaypane.width, TodayPane.previousMode);
+
             TodayPane.setTodayHeader();
             TodayPane.updateSplitterState();
+            todaypane.width = todaypane.getModeAttribute("modewidths", "width");
+            TodayPane.previousMode = document.getElementById("modeBroadcaster").getAttribute("mode");
         }
     },
 
     /**
      * Toggle the today-pane and update its visual appearance.
      *
      * @param aEvent        The DOM event occuring on activated command.
      */
@@ -297,35 +305,28 @@ var TodayPane = {
 
     /**
      * Update the today-splitter state and today-pane width with saved
      * mode-dependent values.
      */
     updateSplitterState: function updateSplitterState() {
         let splitter = document.getElementById("today-splitter");
         let todaypane = document.getElementById("today-pane-panel");
-        if (todaypane.isVisible()) {
-            splitter.removeAttribute("hidden");
-            todaypane.width = todaypane.getModeAttribute("modewidths", "width");
-            let splitterState = todaypane.getModeAttribute("modesplitterstates", "state");
-            splitter.setAttribute("state", splitterState);
-            if (splitterState == "collapsed") {
-                todaypane.setAttribute("collapsed", "true");
-            }
-        } else {
-            splitter.hidden = true;
-        }
+        splitter.setAttribute("state", todaypane.isVisible() ? "open" : "collapsed");
+        setElementValue(splitter, !todaypane.isVisible() && "true", "hidden");
     },
 
     /**
-     * Store mode dependent values for today-pane width and today-splitter state
-     * when today-splitter is dragged or collapsed.
+     * Generates the todaypane toggle command when the today-splitter
+     * is being collapsed or uncollapsed.
      */
-    storeWidthAndState: function storeWidthAndState() {
+    onCommandTodaySplitter: function onCommandTodaySplitter() {
         let todaypane = document.getElementById("today-pane-panel");
         let splitterState = document.getElementById('today-splitter').getAttribute("state");
-        todaypane.setModeAttribute("modesplitterstates", splitterState ? splitterState : "open");
-        todaypane.setModeAttribute("modewidths", todaypane.width);
+        if (splitterState == "collapsed" && todaypane.isVisible() ||
+            splitterState != "collapsed" && !todaypane.isVisible()) {
+              document.getElementById('calendar_toggle_todaypane_command').doCommand();
+        }
     }
 };
 
 window.addEventListener("load", TodayPane.onLoad, false);
 window.addEventListener("unload", TodayPane.onUnload, false);
--- a/calendar/base/content/today-pane.xul
+++ b/calendar/base/content/today-pane.xul
@@ -60,17 +60,17 @@
 <script type="application/javascript" src="chrome://calendar/content/agenda-listbox.js"/>
 <script type="application/javascript" src="chrome://calendar/content/calendar-management.js"/>
 <script type="application/javascript" src="chrome://calendar/content/calendar-dnd-listener.js"/>
 <script type="application/javascript" src="chrome://calendar/content/calendar-item-editing.js"/>
 
     <modevbox id="today-pane-panel"
               mode="mail,calendar,task" modewidths="200,200,200" modesplitterstates="open,open,open"
               refcontrol="calendar_toggle_todaypane_command"
-              broadcaster="modeBroadcaster" persist="modewidths modesplitterstates">
+              broadcaster="modeBroadcaster" persist="modewidths">
       <sidebarheader align="center">
         <label id ="today-pane-header"/>
         <spacer flex="1"/>
         <modehbox mode="mail,calendar" broadcaster="modeBroadcaster">
           <toolbarbutton id="folderview-cycler-prev"
                          chromedir="&locale.dir;"
                          dir="prev"
                          class="folderview-cycler"
--- a/calendar/base/themes/pinstripe/today-pane.css
+++ b/calendar/base/themes/pinstripe/today-pane.css
@@ -46,16 +46,17 @@
 
 #buttonspacer {
   width: 5px;
 }
 
 #today-pane-panel {
   background-color: -moz-Dialog;
   color: -moz-DialogText;
+  min-width: 100px;
 }
 
 #today-pane-panel:-moz-lwtheme {
   background-color: transparent;
   border-top: 1px solid ThreeDShadow;
 }
 
 #agenda-panel:-moz-lwtheme > vbox,
--- a/calendar/lightning/content/messenger-overlay-sidebar.xul
+++ b/calendar/lightning/content/messenger-overlay-sidebar.xul
@@ -573,21 +573,21 @@
           <vbox id="calendar-view-box"/>
         </deck>
       </hbox>
     </vbox>
   </tabpanels>
 
   <hbox id="tabmail-container">
     <splitter id="today-splitter"
-              collapse="after"
+              collapse="none"
               resizebefore="closest"
               state="collapsed"
               class="calendar-sidebar-splitter"
-              oncommand="TodayPane.storeWidthAndState();">
+              oncommand="TodayPane.onCommandTodaySplitter();">
       <grippy/>
     </splitter>
     <modevbox id="today-pane-panel" />
   </hbox>
 
   <statusbar id="status-bar">
     <statusbarpanel id="calendar-show-todaypane-panel"
                     pack="center">