Bug 721330 Part 2: Make Customizing the task-actions-toolbar work in SeaMonkey r=philipp a=philipp.
authorPhilip Chee <philip.chee@gmail.com>
Fri, 03 Feb 2012 00:14:34 +0800
changeset 10562 21ce5b4eef21d3ca00ba651e8f06c2ac65abffe8
parent 10561 bd529b6e1eb69c5ede280851c1394ed11e7d2049
child 10563 0e082f56031d32bbd4be9015897d3c86003efd1d
push idunknown
push userunknown
push dateunknown
reviewersphilipp, philipp
bugs721330
Bug 721330 Part 2: Make Customizing the task-actions-toolbar work in SeaMonkey r=philipp a=philipp.
calendar/base/content/calendar-task-view.js
calendar/base/content/calendar-task-view.xul
calendar/lightning/content/suite-overlay-sidebar.js
calendar/lightning/content/suite-overlay-sidebar.xul
--- a/calendar/base/content/calendar-task-view.js
+++ b/calendar/base/content/calendar-task-view.js
@@ -57,18 +57,16 @@ var taskDetailsView = {
             setBooleanAttribute(id, "hidden", !flag);
             return flag;
         }
 
         var item = document.getElementById("calendar-task-tree").currentTask;
         if (displayElement("calendar-task-details-container", item != null) &&
             displayElement("calendar-task-view-splitter", item != null)) {
 
-            this._initializeToolbar();
-
             displayElement("calendar-task-details-title-row", true);
             document.getElementById("calendar-task-details-title").textContent =
                 (item.title ? item.title.replace(/\n/g, ' ') : "");
 
             var organizer = item.organizer;
             if (displayElement("calendar-task-details-organizer-row", organizer != null)) {
                 var name = organizer.commonName;
                 if (!name || name.length <= 0) {
@@ -172,55 +170,17 @@ var taskDetailsView = {
                     urlLabel.setAttribute("tooltiptext", url);
                     urlLabel.setAttribute("class", "text-link");
                     urlLabel.setAttribute("crop", "end");
                     urlLabel.setAttribute("onclick", "launchBrowser(this.value)");
                     attachmentRows.appendChild(urlLabel);
                 }
             }
         }
-    },
-
-    /**
-     * Initialize the task actions toolbar by setting default mode, icon size,
-     * etc. if necessary and hooking up events for the customization dialog.
-     */
-    _initializeToolbar: function tDV_initializeToolbar() {
-        var toolbox = document.getElementById("task-actions-toolbox");
-        toolbox.customizeDone = function(aEvent) {
-            MailToolboxCustomizeDone(aEvent, "CustomizeTaskActionsToolbar");
-        };
-
-        var toolbarset = document.getElementById('customToolbars');
-        toolbox.toolbarset = toolbarset;
-
-        // Check whether we did an upgrade to a customizable header pane.
-        // If yes, set the header pane toolbar mode to icons besides text
-        var toolbar = document.getElementById("task-actions-toolbar");
-        if (toolbox && toolbar) {
-            if (!toolbox.getAttribute("mode")) {
-
-                /* set toolbox attributes to default values */
-                var mode = toolbox.getAttribute("defaultmode");
-                var align = toolbox.getAttribute("defaultlabelalign");
-                var iconsize = toolbox.getAttribute("defaulticonsize");
-                toolbox.setAttribute("mode", mode);
-                toolbox.setAttribute("labelalign", align);
-                toolbox.setAttribute("iconsize", iconsize);
-                toolbox.ownerDocument.persist(toolbox.id, "mode");
-                toolbox.ownerDocument.persist(toolbox.id, "iconsize");
-                toolbox.ownerDocument.persist(toolbox.id, "labelalign");
-
-                /* set toolbar attributes to default values */
-                iconsize = toolbar.getAttribute("defaulticonsize");
-                toolbar.setAttribute("iconsize", iconsize);
-                toolbar.ownerDocument.persist(toolbar.id, "iconsize");
-            }
-        }
-    },
+    }
 };
 
 
 /**
  * Updates the currently applied filter for the task view and refreshes the task
  * tree.
  *
  * @param aFilter        The filter name to set.
@@ -321,11 +281,25 @@ function taskViewOnLoad() {
             let base = textFilter.getAttribute("emptytextbase");
             let keyLabel = textFilter.getAttribute(Application.platformIsMac ?
                                                    "keyLabelMac" : "keyLabelNonMac");
 
             textFilter.setAttribute("placeholder", base.replace("#1", keyLabel));
             textFilter.value = "";
         }
     }
+
+    // Setup customizeDone handler for the task action toolbox.
+    var toolbox = document.getElementById("task-actions-toolbox");
+    toolbox.customizeDone = function(aEvent) {
+        MailToolboxCustomizeDone(aEvent, "CustomizeTaskActionsToolbar");
+    };
+
+    var toolbarset = document.getElementById("customToolbars");
+    toolbox.toolbarset = toolbarset;
+
+    Components.classes["@mozilla.org/observer-service;1"]
+              .getService(Components.interfaces.nsIObserverService)
+              .notifyObservers(window, "calendar-taskview-startup-done",
+                               false);
 }
 
 window.addEventListener("load", taskViewOnLoad, false);
--- a/calendar/base/content/calendar-task-view.xul
+++ b/calendar/base/content/calendar-task-view.xul
@@ -129,20 +129,23 @@
                       <menupopup id="task-actions-toolbar-context-menu">
                         <menuitem id="CustomizeTaskActionsToolbar"
                                   oncommand="CustomizeMailToolbar('task-actions-toolbox', 'CustomizeTaskActionsToolbar')"
                                   label="&calendar.menu.customize.label;"
                                   accesskey="&calendar.menu.customize.accesskey;"/>
                       </menupopup>
 
                       <toolbox id="task-actions-toolbox"
+                               minwidth="50px"
+                               mode="full"
+                               iconsize="small"
+                               labelalign="end"
+                               defaultmode="full"
                                defaulticonsize="small"
-                               minwidth="50px"
-                               defaultlabelalign="end"
-                               defaultmode="full">
+                               defaultlabelalign="end">
                         <toolbarpalette id="task-actions-toolbar-palette">
                           <toolbarbutton id="task-actions-category"
                                          type="menu"
                                          label="&calendar.unifinder.tree.categories.label;"
                                          tooltiptext="&calendar.task.category.button.tooltip;"
                                          command="calendar_task_category_command"
                                          observes="calendar_task_category_command"
                                          class="toolbarbutton-1 msgHeaderView-button">
@@ -171,18 +174,22 @@
                                          class="toolbarbutton-1 msgHeaderView-button"
                                          label="&calendar.taskview.delete.label;"
                                          tooltiptext="&calendar.context.deletetask.label;"
                                          observes="calendar_delete_todo_command"/>
                         </toolbarpalette>
 
                         <toolbar id="task-actions-toolbar" align="start"
                                  class="inline-toolbar"
-                                 customizable="true" mode="full"
-                                 defaulticonsize="small" defaultmode="full"
+                                 customizable="true"
+                                 mode="full"
+                                 iconsize="small"
+                                 labelalign="end"
+                                 defaultmode="full"
+                                 defaulticonsize="small"
                                  context="task-actions-toolbar-context-menu"
                                  defaultset="task-actions-category,task-actions-markcompleted,task-actions-priority,calendar-delete-task-button"/>
                       </toolbox>
                     </hbox>
                   </hbox>
                 </row>
                 <row id="calendar-task-details-title-row"
                      align="top"
--- a/calendar/lightning/content/suite-overlay-sidebar.js
+++ b/calendar/lightning/content/suite-overlay-sidebar.js
@@ -3,30 +3,33 @@ var ltnSuiteUtils = {
   customizeToolbar: function lSU_customizeToolbar(aItem) {
     let toolbar = aItem.parentNode.triggerNode;
     while (toolbar.localName != "toolbar")
       toolbar = toolbar.parentNode;
     goCustomizeToolbar(toolbar.toolbox);
   },
 
   addStartupObserver: function lSU_addStartupObserver() {
-    Components.classes["@mozilla.org/observer-service;1"]
-              .getService(Components.interfaces.nsIObserverService)
-              .addObserver(this.startupObserver, "lightning-startup-done",
-                           false);
+    let obs = Components.classes["@mozilla.org/observer-service;1"]
+                        .getService(Components.interfaces.nsIObserverService);
+    obs.addObserver(this.startupObserver, "lightning-startup-done", false);
+    obs.addObserver(this.startupObserver, "calendar-taskview-startup-done",
+                    false);
 
   },
 
   startupObserver: {
     observe: function lSU_observe(subject, topic, state) {
-      if (topic != "lightning-startup-done") {
+      if (topic != "lightning-startup-done" &&
+          topic != "calendar-taskview-startup-done") {
         return;
       }
 
-      [["CustomizeCalendarToolbar", "calendar-toolbox"],
+      [["CustomizeTaskActionsToolbar", "task-actions-toolbox"],
+       ["CustomizeCalendarToolbar", "calendar-toolbox"],
        ["CustomizeTaskToolbar", "task-toolbox"]].forEach(function(eIDs) {
         let [itemID, toolboxID] = eIDs;
         let item = document.getElementById(itemID);
         let toolbox = document.getElementById(toolboxID);
         toolbox.customizeInit = function() {
           item.setAttribute("disabled", "true");
           toolboxCustomizeInit("mail-menubar");
         };
--- a/calendar/lightning/content/suite-overlay-sidebar.xul
+++ b/calendar/lightning/content/suite-overlay-sidebar.xul
@@ -42,14 +42,21 @@
 
   <script type="application/javascript" src="chrome://lightning/content/suite-overlay-sidebar.js"/>
 
   <key id="openLightningKey" removeelement="true"/>
   <key id="openTasksKey" removeelement="true"/>
   <key id="calendar-new-event-key" removeelement="true"/>
   <key id="calendar-new-todo-key" removeelement="true"/>
 
+  <menuitem id="CustomizeTaskActionsToolbar"
+            oncommand="ltnSuiteUtils.customizeToolbar(this)"/>
   <menuitem id="CustomizeCalendarToolbar"
             oncommand="ltnSuiteUtils.customizeToolbar(this)"/>
   <menuitem id="CustomizeTaskToolbar"
             oncommand="ltnSuiteUtils.customizeToolbar(this)"/>
 
+  <toolbox id="task-actions-toolbox"
+           xpfe="false"/>
+  <toolbar id="task-actions-toolbar"
+           xpfe="false"/>
+
 </overlay>