[Pkg-mozext-commits] [compactheader] 87/441: New version 0.9.4: Internal cleanup: Wrapper for java script namespace Tooltip for subject No scrollbar in collapsed header pane.

David Prévot taffit at moszumanska.debian.org
Wed Mar 18 12:28:47 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository compactheader.

commit d5b32498ec74057087ae632ca6e5d3691c093ac2
Author: joachim.herb <none at none>
Date:   Fri Nov 13 23:26:41 2009 +0000

    New version 0.9.4:
    Internal cleanup: Wrapper for java script namespace
    Tooltip for subject
    No scrollbar in collapsed header pane.
---
 .../CompactHeader/content/compactHeaderOverlay.js  | 1171 ++++++++++----------
 1 file changed, 597 insertions(+), 574 deletions(-)

diff --git a/chrome/CompactHeader/content/compactHeaderOverlay.js b/chrome/CompactHeader/content/compactHeaderOverlay.js
index 7a89e05..96bd586 100644
--- a/chrome/CompactHeader/content/compactHeaderOverlay.js
+++ b/chrome/CompactHeader/content/compactHeaderOverlay.js
@@ -51,651 +51,674 @@
 // view in the message header pane.
 ////////////////////////////////////////////////////////////////////////////////////
 
-const COHE_EXTENSION_UUID = "{58D4392A-842E-11DE-B51A-C7B855D89593}";
+if(!org) var org={};
+if(!org.mozdev) org.mozdev={};
+if(!org.mozdev.compactHeader) org.mozdev.compactHeader = {};
 
-var gCoheCollapsedHeaderViewMode = false;
-var gCoheBuiltCollapsedView = false;
+org.mozdev.compactHeader.pane = function() {
+  var pub = {};
 
-/**
- * The collapsed view: very lightweight. We only show a couple of fields.  See
- * msgHdrViewOverlay.js for details of the field definition semantics.
- */
-var gCoheCollapsedHeader1LListLongAddresses = [
-  {name:"subject"},
-  {name:"from", useToggle:true, outputFunction:coheOutputEmailAddresses},
-  {name:"toCcBcc", useToggle:true, outputFunction:coheOutputEmailAddresses},
-  {name:"date", outputFunction:coheUpdateDateValue}
-  ];
-
-var gCoheCollapsedHeader2LListLongAddresses = [
-  {name:"subject"},
-  {name:"from", useToggle:true, outputFunction:coheOutputEmailAddresses},
-  {name:"toCcBcc", useToggle:true, outputFunction:coheOutputEmailAddresses},
-  {name:"date", outputFunction:coheUpdateDateValue}
-  ];
-  
-var cohePrefBranch = Components.classes["@mozilla.org/preferences-service;1"]
-  .getService(Components.interfaces.nsIPrefService)
-  .getBranch("extensions.CompactHeader.");
-
-var coheIntegrateRSSLinkify = false;
-
-var RSSLinkify = {
-    oldSubject: null,
-    newSubject: null
-};
-
-var cohe={
-  version: -1,
-  firstrun: true,
-  current: -1
-};
-
-var coheFirstTime = true;
-
-function coheOutputEmailAddresses(headerEntry, emailAddresses) {
-  OutputEmailAddresses(headerEntry, emailAddresses);
-}
-
-// Now, for each view the message pane can generate, we need a global table
-// of headerEntries. These header entry objects are generated dynamically
-// based on the static data in the header lists (see above) and elements
-// we find in the DOM based on properties in the header lists.
-var gCoheCollapsedHeaderView = {};
-
-function coheInitializeHeaderViewTables()
-{
-  gCoheCollapsedHeaderView = {};
-  var index;
-
-  if (cohePrefBranch.getBoolPref("headersize.twolineview")) {
-    for (index = 0; index < gCoheCollapsedHeader2LListLongAddresses.length; index++) {
-      gCoheCollapsedHeaderView[gCoheCollapsedHeader2LListLongAddresses[index].name] =
-        new createHeaderEntry('collapsed2L', gCoheCollapsedHeader2LListLongAddresses[index]);
+  const COHE_EXTENSION_UUID = "{58D4392A-842E-11DE-B51A-C7B855D89593}";
+  
+  var gCoheCollapsedHeaderViewMode = false;
+  var gCoheBuiltCollapsedView = false;
+  
+  /**
+   * The collapsed view: very lightweight. We only show a couple of fields.  See
+   * msgHdrViewOverlay.js for details of the field definition semantics.
+   */
+  var gCoheCollapsedHeader1LListLongAddresses = [
+    {name:"subject", outputFunction:coheOutputSubject},
+    {name:"from", useToggle:true, outputFunction:coheOutputEmailAddresses},
+    {name:"toCcBcc", useToggle:true, outputFunction:coheOutputEmailAddresses},
+    {name:"date", outputFunction:coheUpdateDateValue}
+    ];
+  
+  var gCoheCollapsedHeader2LListLongAddresses = [
+    {name:"subject", outputFunction:coheOutputSubject},
+    {name:"from", useToggle:true, outputFunction:coheOutputEmailAddresses},
+    {name:"toCcBcc", useToggle:true, outputFunction:coheOutputEmailAddresses},
+    {name:"date", outputFunction:coheUpdateDateValue}
+    ];
+    
+  var cohePrefBranch = Components.classes["@mozilla.org/preferences-service;1"]
+    .getService(Components.interfaces.nsIPrefService)
+    .getBranch("extensions.CompactHeader.");
+  
+  var coheIntegrateRSSLinkify = false;
+  
+  var RSSLinkify = {
+      oldSubject: null,
+      newSubject: null
+  };
+  
+  var cohe={
+    version: -1,
+    firstrun: true,
+    current: -1
+  };
+  
+  var coheFirstTime = true;
+  
+  function coheOutputSubject(headerEntry, headerValue) {
+    var subjectBox;
+    
+    if (cohePrefBranch.getBoolPref("headersize.twolineview")) {
+      subjectBox = document.getElementById("collapsed2LsubjectOutBox")
+    } else {
+      subjectBox = document.getElementById("collapsed1LsubjectOutBox")
     }
-  } else { 
-    for (index = 0; index < gCoheCollapsedHeader1LListLongAddresses.length; index++) {
-      gCoheCollapsedHeaderView[gCoheCollapsedHeader1LListLongAddresses[index].name] =
-        new createHeaderEntry('collapsed1L', gCoheCollapsedHeader1LListLongAddresses[index]);
+    
+    if (subjectBox) {
+      subjectBox.setAttribute("tooltiptext", headerValue);
     }
+    updateHeaderValue(headerEntry, headerValue);
   }
-
-  if (cohePrefBranch.getBoolPref("headersize.linkify")) {
-    RSSLinkify.newSubject = document.createElement("label");
-    RSSLinkify.newSubject.setAttribute("id", "collapsedsubjectlinkBox");
-    RSSLinkify.newSubject.setAttribute("class", "headerValue plain headerValueUrl");
-    RSSLinkify.newSubject.setAttribute("originalclass", "headerValue plain headerValueUrl");
-    RSSLinkify.newSubject.setAttribute("context", "CohecopyUrlPopup");
-    RSSLinkify.newSubject.setAttribute("keywordrelated", "true");
-    RSSLinkify.newSubject.setAttribute("readonly", "true");
-    RSSLinkify.newSubject.setAttribute("appendoriginalclass", "true");
-    RSSLinkify.newSubject.setAttribute("flex", "1");
+  
+  function coheOutputEmailAddresses(headerEntry, emailAddresses) {
+    OutputEmailAddresses(headerEntry, emailAddresses);
+  }
+  
+  // Now, for each view the message pane can generate, we need a global table
+  // of headerEntries. These header entry objects are generated dynamically
+  // based on the static data in the header lists (see above) and elements
+  // we find in the DOM based on properties in the header lists.
+  var gCoheCollapsedHeaderView = {};
+  
+  function coheInitializeHeaderViewTables()
+  {
+    gCoheCollapsedHeaderView = {};
+    var index;
+  
     if (cohePrefBranch.getBoolPref("headersize.twolineview")) {
-      RSSLinkify.oldSubject = document.getElementById("collapsed2LsubjectBox");
-    } else {
-      RSSLinkify.oldSubject = document.getElementById("collapsed1LsubjectBox");
+      for (index = 0; index < gCoheCollapsedHeader2LListLongAddresses.length; index++) {
+        gCoheCollapsedHeaderView[gCoheCollapsedHeader2LListLongAddresses[index].name] =
+          new createHeaderEntry('collapsed2L', gCoheCollapsedHeader2LListLongAddresses[index]);
+      }
+    } else { 
+      for (index = 0; index < gCoheCollapsedHeader1LListLongAddresses.length; index++) {
+        gCoheCollapsedHeaderView[gCoheCollapsedHeader1LListLongAddresses[index].name] =
+          new createHeaderEntry('collapsed1L', gCoheCollapsedHeader1LListLongAddresses[index]);
+      }
+    }
+  
+    if (cohePrefBranch.getBoolPref("headersize.linkify")) {
+      RSSLinkify.newSubject = document.createElement("label");
+      RSSLinkify.newSubject.setAttribute("id", "collapsedsubjectlinkBox");
+      RSSLinkify.newSubject.setAttribute("class", "headerValue plain headerValueUrl");
+      RSSLinkify.newSubject.setAttribute("originalclass", "headerValue plain headerValueUrl");
+      RSSLinkify.newSubject.setAttribute("context", "CohecopyUrlPopup");
+      RSSLinkify.newSubject.setAttribute("keywordrelated", "true");
+      RSSLinkify.newSubject.setAttribute("readonly", "true");
+      RSSLinkify.newSubject.setAttribute("appendoriginalclass", "true");
+      RSSLinkify.newSubject.setAttribute("flex", "1");
+      if (cohePrefBranch.getBoolPref("headersize.twolineview")) {
+        RSSLinkify.oldSubject = document.getElementById("collapsed2LsubjectBox");
+      } else {
+        RSSLinkify.oldSubject = document.getElementById("collapsed1LsubjectBox");
+      }
+      RSSLinkify.oldSubject.parentNode.insertBefore(RSSLinkify.newSubject, RSSLinkify.oldSubject);
     }
-    RSSLinkify.oldSubject.parentNode.insertBefore(RSSLinkify.newSubject, RSSLinkify.oldSubject);
   }
-}
-
-function coheOnLoadMsgHeaderPane()
-{ 
-  coheInitializeHeaderViewTables();
-
-  // Add an address book listener so we can update the header view when things
-  // change.
-  Components.classes["@mozilla.org/abmanager;1"]
-            .getService(Components.interfaces.nsIAbManager)
-            .addAddressBookListener(coheAddressBookListener,
-                                    Components.interfaces.nsIAbListener.all);
-
-  var deckHeaderView = document.getElementById("msgHeaderViewDeck");
-
-  gCoheCollapsedHeaderViewMode = 
-    deckHeaderView.selectedPanel == document.getElementById('collapsedHeaderView');    
+  
+  pub.coheOnLoadMsgHeaderPane = function() { 
+    coheInitializeHeaderViewTables();
+  
+    // Add an address book listener so we can update the header view when things
+    // change.
+    Components.classes["@mozilla.org/abmanager;1"]
+              .getService(Components.interfaces.nsIAbManager)
+              .addAddressBookListener(coheAddressBookListener,
+                                      Components.interfaces.nsIAbListener.all);
+  
+    var deckHeaderView = document.getElementById("msgHeaderViewDeck");
+  
+    gCoheCollapsedHeaderViewMode = 
+      deckHeaderView.selectedPanel == document.getElementById('collapsedHeaderView');    
+      
+    // work around XUL deck bug where collapsed header view, if it's the persisted
+    // default, wouldn't be sized properly because of the larger expanded
+    // view "stretches" the deck.
+    if (gCoheCollapsedHeaderViewMode)
+      document.getElementById('expandedHeaderView').collapsed = true;
+    else
+      document.getElementById('collapsedHeaderView').collapsed = true;
+  
+    if (cohePrefBranch.getBoolPref("headersize.twolineview")) {
+      document.getElementById('collapsed1LHeadersBox').collapsed = true;
+      document.getElementById('collapsed2LHeadersBox').collapsed = false;
+    } else {
+      document.getElementById('collapsed1LHeadersBox').collapsed = false;
+      document.getElementById('collapsed2LHeadersBox').collapsed = true;
+    }
+      
+    if (coheFirstTime)
+    {
+      coheFirstTime = false;
+      gMessageListeners.push(coheMessageListener);
+      org.mozdev.customizeHeaderToolbar.messenger.loadToolboxData();
+      fillToolboxPalette();
+      org.mozdev.customizeHeaderToolbar.messenger.saveToolboxData();
+      var toolbox = document.getElementById("header-view-toolbox");
+      toolbox.customizeDone = function(aEvent) {
+        MailToolboxCustomizeDone(aEvent, "CustomizeHeaderToolbar");
+        document.getElementById("header-view-toolbox").removeAttribute("doCustomization");
+        enableButtons();
+        org.mozdev.customizeHeaderToolbar.pane.CHTUpdateReplyButton();
+        org.mozdev.customizeHeaderToolbar.messenger.saveToolboxData();
+      };
+    }
     
-  // work around XUL deck bug where collapsed header view, if it's the persisted
-  // default, wouldn't be sized properly because of the larger expanded
-  // view "stretches" the deck.
-  if (gCoheCollapsedHeaderViewMode)
-    document.getElementById('expandedHeaderView').collapsed = true;
-  else
-    document.getElementById('collapsedHeaderView').collapsed = true;
-
-  if (cohePrefBranch.getBoolPref("headersize.twolineview")) {
-    document.getElementById('collapsed1LHeadersBox').collapsed = true;
-    document.getElementById('collapsed2LHeadersBox').collapsed = false;
-  } else {
-    document.getElementById('collapsed1LHeadersBox').collapsed = false;
-    document.getElementById('collapsed2LHeadersBox').collapsed = true;
+    if (cohe.firstrun) {
+      coheCheckFirstRun();
+    }
+    
+    if (cohe.firstrun) {
+      org.mozdev.customizeHeaderToolbar.pane.CHTSetDefaultButtons();
+      cohe.firstrun = false;
+    }
+    
+    coheToggleHeaderContent();
   }
+  
+  var coheMessageListener = 
+  {
+    onStartHeaders: 
+    function cML_onStartHeaders () {
+        gCoheBuiltCollapsedView = false;    
+    },
+    
+    onEndHeaders: 
+    function cML_onEndHeaders() {
+      ClearHeaderView(gCoheCollapsedHeaderView);  
+      coheUpdateMessageHeaders();
+    },
     
-  if (coheFirstTime)
+    onEndAttachments: function cML_onEndAttachments(){}
+  };
+  
+  pub.coheOnUnloadMsgHeaderPane = function()
   {
-    coheFirstTime = false;
-    gMessageListeners.push(coheMessageListener);
-    loadToolboxData();
-    fillToolboxPalette();
-    saveToolboxData();
-    var toolbox = document.getElementById("header-view-toolbox");
-    toolbox.customizeDone = function(aEvent) {
-      MailToolboxCustomizeDone(aEvent, "CustomizeHeaderToolbar");
-      document.getElementById("header-view-toolbox").removeAttribute("doCustomization");
-      enableButtons();
-      CHTUpdateReplyButton();
-      saveToolboxData();
-    };
+    Components.classes["@mozilla.org/abmanager;1"]
+              .getService(Components.interfaces.nsIAbManager)
+              .removeAddressBookListener(coheAddressBookListener);
+    
+    removeEventListener('messagepane-loaded', coheOnLoadMsgHeaderPane, true);
+    removeEventListener('messagepane-unloaded', coheOnUnloadMsgHeaderPane, true);
   }
   
-  if (cohe.firstrun) {
-    coheCheckFirstRun();
+  var coheAddressBookListener =
+  {
+    onItemAdded: function(aParentDir, aItem) {
+      coheOnAddressBookDataChanged(nsIAbListener.itemAdded,
+                               aParentDir, aItem);
+    },
+    onItemRemoved: function(aParentDir, aItem) {
+      coheOnAddressBookDataChanged(aItem instanceof nsIAbCard ?
+                               nsIAbListener.directoryItemRemoved :
+                               nsIAbListener.directoryRemoved,
+                               aParentDir, aItem);
+    },
+    
+    onItemPropertyChanged: function(aItem, aProperty, aOldValue, aNewValue) {
+      // We only need updates for card changes, address book and mailing list
+      // ones don't affect us here.
+      if (aItem instanceof Components.interfaces.nsIAbCard)
+        coheOnAddressBookDataChanged(nsIAbListener.itemChanged, null, aItem);
+    }
   }
   
-  if (cohe.firstrun) {
-    CHTSetDefaultButtons();
-    cohe.firstrun = false;
-  }
+  function coheOnAddressBookDataChanged(aAction, aParentDir, aItem) {
+    gEmailAddressHeaderNames.forEach(function (headerName) {
+        var headerEntry = null;
   
-  coheToggleHeaderContent();
-}
-
-var coheMessageListener = 
-{
-  onStartHeaders: 
-  function cML_onStartHeaders () {
-      gCoheBuiltCollapsedView = false;    
-  },
-  
-  onEndHeaders: 
-  function cML_onEndHeaders() {
-    ClearHeaderView(gCoheCollapsedHeaderView);  
-    coheUpdateMessageHeaders();
-  },
-  
-  onEndAttachments: function cML_onEndAttachments(){}
-};
-
-function coheOnUnloadMsgHeaderPane()
-{
-  Components.classes["@mozilla.org/abmanager;1"]
-            .getService(Components.interfaces.nsIAbManager)
-            .removeAddressBookListener(coheAddressBookListener);
-  
-  removeEventListener('messagepane-loaded', coheOnLoadMsgHeaderPane, true);
-  removeEventListener('messagepane-unloaded', coheOnUnloadMsgHeaderPane, true);
-}
-
-var coheAddressBookListener =
-{
-  onItemAdded: function(aParentDir, aItem) {
-    coheOnAddressBookDataChanged(nsIAbListener.itemAdded,
-                             aParentDir, aItem);
-  },
-  onItemRemoved: function(aParentDir, aItem) {
-    coheOnAddressBookDataChanged(aItem instanceof nsIAbCard ?
-                             nsIAbListener.directoryItemRemoved :
-                             nsIAbListener.directoryRemoved,
-                             aParentDir, aItem);
-  },
-  
-  onItemPropertyChanged: function(aItem, aProperty, aOldValue, aNewValue) {
-    // We only need updates for card changes, address book and mailing list
-    // ones don't affect us here.
-    if (aItem instanceof Components.interfaces.nsIAbCard)
-      coheOnAddressBookDataChanged(nsIAbListener.itemChanged, null, aItem);
+        if (headerName in gCoheCollapsedHeaderView) {
+          headerEntry = gCoheCollapsedHeaderView[headerName];
+          if (headerEntry)
+            headerEntry.enclosingBox.updateExtraAddressProcessing(aAction,
+                                                                  aParentDir,
+                                                                  aItem);
+        }
+      });
   }
-}
-
-function coheOnAddressBookDataChanged(aAction, aParentDir, aItem) {
-  gEmailAddressHeaderNames.forEach(function (headerName) {
-      var headerEntry = null;
-
-      if (headerName in gCoheCollapsedHeaderView) {
-        headerEntry = gCoheCollapsedHeaderView[headerName];
-        if (headerEntry)
-          headerEntry.enclosingBox.updateExtraAddressProcessing(aAction,
-                                                                aParentDir,
-                                                                aItem);
+  
+  // make sure the appropriate fields within the currently displayed view header mode
+  // are collapsed or visible...
+  function coheUpdateHeaderView()
+  {
+    if (gCoheCollapsedHeaderViewMode)
+      showHeaderView(gCoheCollapsedHeaderView);
+  
+    if (cohePrefBranch.getBoolPref("headersize.linkify")) {
+      var url = currentHeaderData["content-base"];
+      if(url) {
+          RSSLinkify.newSubject.setAttribute("onclick", "if (!event.button) messenger.launchExternalURL('" + 
+                                               url.headerValue + "');");
+          RSSLinkify.newSubject.setAttribute("value", currentHeaderData["subject"].headerValue);
+          RSSLinkify.newSubject.setAttribute("url", url.headerValue);
+          RSSLinkify.newSubject.setAttribute("collapsed", "false");
+          RSSLinkify.oldSubject.setAttribute("collapsed", "true");
+      } else {
+          RSSLinkify.newSubject.setAttribute("collapsed", "true");
+          RSSLinkify.oldSubject.setAttribute("collapsed", "false");
       }
-    });
-}
-
-// make sure the appropriate fields within the currently displayed view header mode
-// are collapsed or visible...
-function coheUpdateHeaderView()
-{
-  if (gCoheCollapsedHeaderViewMode)
-    showHeaderView(gCoheCollapsedHeaderView);
-
-  if (cohePrefBranch.getBoolPref("headersize.linkify")) {
-    var url = currentHeaderData["content-base"];
-    if(url) {
-        RSSLinkify.newSubject.setAttribute("onclick", "if (!event.button) messenger.launchExternalURL('" + 
-                                             url.headerValue + "');");
-        RSSLinkify.newSubject.setAttribute("value", currentHeaderData["subject"].headerValue);
-        RSSLinkify.newSubject.setAttribute("url", url.headerValue);
-        RSSLinkify.newSubject.setAttribute("collapsed", "false");
-        RSSLinkify.oldSubject.setAttribute("collapsed", "true");
     } else {
+    	if (RSSLinkify.newSubject) {
         RSSLinkify.newSubject.setAttribute("collapsed", "true");
+    	}
+    	if (RSSLinkify.oldSubject) {
         RSSLinkify.oldSubject.setAttribute("collapsed", "false");
+    	}
     }
-  } else {
-  	if (RSSLinkify.newSubject) {
-      RSSLinkify.newSubject.setAttribute("collapsed", "true");
-  	}
-  	if (RSSLinkify.oldSubject) {
-      RSSLinkify.oldSubject.setAttribute("collapsed", "false");
-  	}
-  }
-  if (cohePrefBranch.getBoolPref("headersize.addressstyle")) {
-    selectEmailDisplayed();
+    if (cohePrefBranch.getBoolPref("headersize.addressstyle")) {
+      selectEmailDisplayed();
+    }
+    
+    //fillToolboxPalette();
+    coheToggleHeaderContent();
+    org.mozdev.customizeHeaderToolbar.pane.CHTUpdateReplyButton();
+    org.mozdev.customizeHeaderToolbar.pane.CHTUpdateJunkButton();
   }
   
-  //fillToolboxPalette();
-  coheToggleHeaderContent();
-  CHTUpdateReplyButton();
-  CHTUpdateJunkButton();
-}
-
-function enableButtons() {
-  var hdrToolbar = document.getElementById("header-view-toolbar");
-  if (toolbar) {
-    var buttons = hdrToolbar.querySelectorAll("[disabled*='true']");
-    for (var i=0; i<buttons.length; i++) {
-      buttons[i].removeAttribute("disabled");
+  function enableButtons() {
+    var hdrToolbar = document.getElementById("header-view-toolbar");
+    if (toolbar) {
+      var buttons = hdrToolbar.querySelectorAll("[disabled*='true']");
+      for (var i=0; i<buttons.length; i++) {
+        buttons[i].removeAttribute("disabled");
+      }
     }
   }
-}
-
-function fillToolboxPalette() {
-  var hdrToolbar = document.getElementById("header-view-toolbar");
-  var hdrToolbox = document.getElementById("header-view-toolbox");
-  var buttons = ["button-reply", "button-replyall", "button-replylist", "button-print", 
-                 "button-tag", "button-forward", "button-archive", "button-mark", "button-file"];
-  var currentSet=hdrToolbar.getAttribute("currentset");
-  hdrToolbar.currentSet = currentSet;
-  for (var i=0; i<buttons.length; i++) {
-    var buttonName = buttons[i];
-    var button = document.getElementById(buttonName) || 
-        document.getElementById("mail-toolbox").palette.getElementsByAttribute("id", buttonName)[0];
-    if (button) {
-      var hdrButton = button.cloneNode(true);
-      if (hdrButton) {
-      	if (hdrButton.localName == "toolbaritem") {
-      		var subButtons = hdrButton.querySelectorAll(".toolbarbutton-1");
-      		for (var j=0; j<subButtons.length; j++) {
-      			addClass(subButtons[j], "msgHeaderView-button");
-      		}
-      	} else {
-          addClass(hdrButton, "msgHeaderView-button");
-      	}
-        //hdrButton.id = "hdr" + hdrButton.id;
-        hdrToolbox.palette.appendChild(hdrButton);
-/*        var bStyle = document.defaultView.getComputedStyle(button, null);
-        hdrButton.style.MozImageRegion = bStyle.MozImageRegion;
-        hdrButton.style.listStyleImage = bStyle.listStyleImage;*/
+  
+  function fillToolboxPalette() {
+    var hdrToolbar = document.getElementById("header-view-toolbar");
+    var hdrToolbox = document.getElementById("header-view-toolbox");
+    var buttons = ["button-reply", "button-replyall", "button-replylist", "button-print", 
+                   "button-tag", "button-forward", "button-archive", "button-mark", "button-file"];
+    var currentSet=hdrToolbar.getAttribute("currentset");
+    hdrToolbar.currentSet = currentSet;
+    for (var i=0; i<buttons.length; i++) {
+      var buttonName = buttons[i];
+      var button = document.getElementById(buttonName) || 
+          document.getElementById("mail-toolbox").palette.getElementsByAttribute("id", buttonName)[0];
+      if (button) {
+        var hdrButton = button.cloneNode(true);
+        if (hdrButton) {
+        	if (hdrButton.localName == "toolbaritem") {
+        		var subButtons = hdrButton.querySelectorAll(".toolbarbutton-1");
+        		for (var j=0; j<subButtons.length; j++) {
+        			addClass(subButtons[j], "msgHeaderView-button");
+        		}
+        	} else {
+            addClass(hdrButton, "msgHeaderView-button");
+        	}
+          //hdrButton.id = "hdr" + hdrButton.id;
+          hdrToolbox.palette.appendChild(hdrButton);
+  /*        var bStyle = document.defaultView.getComputedStyle(button, null);
+          hdrButton.style.MozImageRegion = bStyle.MozImageRegion;
+          hdrButton.style.listStyleImage = bStyle.listStyleImage;*/
+        }
+        if (currentSet.indexOf(buttonName)>=0) {
+          var result = hdrToolbar.insertItem(hdrButton.id);
+          currentSet = hdrToolbar.getAttribute("currentset");
+          hdrToolbar.currentSet = currentSet;
+        }
       }
-      if (currentSet.indexOf(buttonName)>=0) {
-        var result = hdrToolbar.insertItem(hdrButton.id);
-        currentSet = hdrToolbar.getAttribute("currentset");
-        hdrToolbar.currentSet = currentSet;
+    }
+  
+    var buttonsRemove = ["hdrJunkButton", "hdrForwardButton", "hdrArchiveButton",
+                         "hdrReplyToSenderButton", "hdrReplyButton",
+                         "hdrReplyAllButton", "hdrReplyListButton"];
+    for (var i=0; i<buttonsRemove.length; i++) {
+      var buttonName = buttonsRemove[i];
+      var button = document.getElementById(buttonName) || 
+          document.getElementById("header-view-toolbox").palette.getElementsByAttribute("id", buttonName)[0];
+      if (button) {
+        button.setAttribute("collapsed", "true");
       }
     }
-  }
-
-  var buttonsRemove = ["hdrJunkButton", "hdrForwardButton", "hdrArchiveButton",
-                       "hdrReplyToSenderButton", "hdrReplyButton",
-                       "hdrReplyAllButton", "hdrReplyListButton"];
-  for (var i=0; i<buttonsRemove.length; i++) {
-    var buttonName = buttonsRemove[i];
-    var button = document.getElementById(buttonName) || 
-        document.getElementById("header-view-toolbox").palette.getElementsByAttribute("id", buttonName)[0];
-    if (button) {
-      button.setAttribute("collapsed", "true");
+    
+    var target = "hdrOtherActionsButton";
+    
+    var newParent = document.getElementById(target) || 
+        document.getElementById("header-view-toolbox").palette.getElementsByAttribute("id", target)[0];
+  
+    if (newParent != null) {
+      var myElement;
+      myElement= document.getElementById("otherActionsPopup");
+      if (myElement) {
+        newParent.appendChild(myElement);
+      }
     }
   }
   
-  var target = "hdrOtherActionsButton";
+  pub.coheToggleHeaderView = function() {
+    gCoheCollapsedHeaderViewMode = !gCoheCollapsedHeaderViewMode;
+    
+    let deck = document.getElementById('msgHeaderViewDeck');
+    // Work around a xul deck bug where the height of the deck is determined
+    // by the tallest panel in the deck even if that panel is not selected...
+    deck.selectedPanel.collapsed = true;
   
-  var newParent = document.getElementById(target) || 
-      document.getElementById("header-view-toolbox").palette.getElementsByAttribute("id", target)[0];
-
-  if (newParent != null) {
-    var myElement;
-    myElement= document.getElementById("otherActionsPopup");
-    if (myElement) {
-      newParent.appendChild(myElement);
+    if (gCoheCollapsedHeaderViewMode) {
+      deck.selectedPanel = document.getElementById("collapsedHeaderView")
+      coheUpdateMessageHeaders();
+    } else {
+      deck.selectedPanel = document.getElementById("expandedHeaderView");
+      ClearHeaderView(gExpandedHeaderView);
+      UpdateExpandedMessageHeaders();
+      gDBView.reloadMessage();
     }
+    
+    // Work around a xul deck bug where the height of the deck is determined
+    // by the tallest panel in the deck even if that panel is not selected...
+    deck.selectedPanel.collapsed = false;
+    
+    coheToggleHeaderContent();
   }
-}
-
-function coheToggleHeaderView ()
-{
-  gCoheCollapsedHeaderViewMode = !gCoheCollapsedHeaderViewMode;
-  
-  let deck = document.getElementById('msgHeaderViewDeck');
-  // Work around a xul deck bug where the height of the deck is determined
-  // by the tallest panel in the deck even if that panel is not selected...
-  deck.selectedPanel.collapsed = true;
-
-  if (gCoheCollapsedHeaderViewMode) {
-    deck.selectedPanel = document.getElementById("collapsedHeaderView")
-    coheUpdateMessageHeaders();
-  } else {
-    deck.selectedPanel = document.getElementById("expandedHeaderView");
-    ClearHeaderView(gExpandedHeaderView);
-    UpdateExpandedMessageHeaders();
-    gDBView.reloadMessage();
-  }
-  
-  // Work around a xul deck bug where the height of the deck is determined
-  // by the tallest panel in the deck even if that panel is not selected...
-  deck.selectedPanel.collapsed = false;
   
-  coheToggleHeaderContent();
-}
-
-function coheToggleHeaderContent() {
-  var strHideLabel = document.getElementById("CoheHideDetailsLabel").value;
-  var strShowLabel = document.getElementById("CoheShowDetailsLabel").value;
-  var strLabel;
+  function coheToggleHeaderContent() {
+    var strHideLabel = document.getElementById("CoheHideDetailsLabel").value;
+    var strShowLabel = document.getElementById("CoheShowDetailsLabel").value;
+    var strLabel;
+    
+    org.mozdev.customizeHeaderToolbar.messenger.loadToolboxData();
   
-  loadToolboxData();
-
-  var hdrToolbox = document.getElementById("header-view-toolbox");
-  var hdrToolbar = document.getElementById("header-view-toolbar");
-  var firstPermanentChild = hdrToolbar.firstPermanentChild;
-  var lastPermanentChild = hdrToolbar.lastPermanentChild;
-  if (gCoheCollapsedHeaderViewMode) {
-    strLabel = strShowLabel;
-    var cBox = document.getElementById("collapsed2LButtonBox");
-    if (cBox.parentNode.id != hdrToolbox.parentNode.id) {
-      var cloneToolboxPalette = hdrToolbox.palette.cloneNode(true);
-      var cloneToolbarset = hdrToolbox.toolbarset.cloneNode(true);
-      cBox.parentNode.insertBefore(hdrToolbox, cBox);
-      hdrToolbox.palette = cloneToolboxPalette;
-      hdrToolbox.toolbarset = cloneToolbarset;
-      hdrToolbar = document.getElementById("header-view-toolbar");
-      hdrToolbar.firstPermanentChild = firstPermanentChild;
-      hdrToolbar.lastPermanentChild = lastPermanentChild;
+    var hdrToolbox = document.getElementById("header-view-toolbox");
+    var hdrToolbar = document.getElementById("header-view-toolbar");
+    var firstPermanentChild = hdrToolbar.firstPermanentChild;
+    var lastPermanentChild = hdrToolbar.lastPermanentChild;
+    if (gCoheCollapsedHeaderViewMode) {
+      strLabel = strShowLabel;
+      var cBox = document.getElementById("collapsed2LButtonBox");
+      if (cBox.parentNode.id != hdrToolbox.parentNode.id) {
+        var cloneToolboxPalette = hdrToolbox.palette.cloneNode(true);
+        var cloneToolbarset = hdrToolbox.toolbarset.cloneNode(true);
+        cBox.parentNode.insertBefore(hdrToolbox, cBox);
+        hdrToolbox.palette = cloneToolboxPalette;
+        hdrToolbox.toolbarset = cloneToolbarset;
+        hdrToolbar = document.getElementById("header-view-toolbar");
+        hdrToolbar.firstPermanentChild = firstPermanentChild;
+        hdrToolbar.lastPermanentChild = lastPermanentChild;
+      }
+    } else {
+      strLabel = strHideLabel;
+      var cBox = document.getElementById("expandedHeaders");
+      if (cBox.parentNode.id != hdrToolbox.parentNode.id) {
+        var cloneToolboxPalette = hdrToolbox.palette.cloneNode(true);
+        var cloneToolbarset = hdrToolbox.toolbarset.cloneNode(true);
+        cBox.parentNode.appendChild(hdrToolbox);
+        hdrToolbox.palette = cloneToolboxPalette;
+        hdrToolbox.toolbarset = cloneToolbarset;
+        hdrToolbar = document.getElementById("header-view-toolbar");
+        hdrToolbar.firstPermanentChild = firstPermanentChild;
+        hdrToolbar.lastPermanentChild = lastPermanentChild;
+      }
     }
-  } else {
-    strLabel = strHideLabel;
-    var cBox = document.getElementById("expandedHeaders");
-    if (cBox.parentNode.id != hdrToolbox.parentNode.id) {
-      var cloneToolboxPalette = hdrToolbox.palette.cloneNode(true);
-      var cloneToolbarset = hdrToolbox.toolbarset.cloneNode(true);
-      cBox.parentNode.appendChild(hdrToolbox);
-      hdrToolbox.palette = cloneToolboxPalette;
-      hdrToolbox.toolbarset = cloneToolbarset;
-      hdrToolbar = document.getElementById("header-view-toolbar");
-      hdrToolbar.firstPermanentChild = firstPermanentChild;
-      hdrToolbar.lastPermanentChild = lastPermanentChild;
+    
+    if (document.getElementById("hideDetailsMenu")) {
+      document.getElementById("hideDetailsMenu").setAttribute("label", strLabel);
     }
   }
   
-  if (document.getElementById("hideDetailsMenu")) {
-    document.getElementById("hideDetailsMenu").setAttribute("label", strLabel);
+  // default method for updating a header value into a header entry
+  function coheUpdateHeaderValueInTextNode(headerEntry, headerValue)
+  {
+    headerEntry.textNode.value = headerValue;
   }
-}
-
-// default method for updating a header value into a header entry
-function coheUpdateHeaderValueInTextNode(headerEntry, headerValue)
-{
-  headerEntry.textNode.value = headerValue;
-}
-
-function coheUpdateDateValue(headerEntry, headerValue) {
-  //var t = currentHeaderData.date.headerValue;
-  var d
-  d = document.getElementById("collapsed1LdateBox");
-  d.textContent = headerValue;
-  d = document.getElementById("collapsed2LdateBox");
-  d.textContent = headerValue;
-}
-
-
-// coheUpdateMessageHeaders: Iterate through all the current header data we received from mime for this message
-// for each header entry table, see if we have a corresponding entry for that header. i.e. does the particular
-// view care about this header value. if it does then call updateHeaderEntry
-function coheUpdateMessageHeaders()
-{
-  // Remove the height attr so that it redraws correctly. Works around a
-  // problem that attachment-splitter causes if it's moved high enough to
-  // affect the header box:
-  document.getElementById('msgHeaderView').removeAttribute('height');
-  
-  // iterate over each header we received and see if we have a matching entry
-  // in each header view table...
-  for (var headerName in currentHeaderData)
+  
+  function coheUpdateDateValue(headerEntry, headerValue) {
+    //var t = currentHeaderData.date.headerValue;
+    var d
+    d = document.getElementById("collapsed1LdateBox");
+    d.textContent = headerValue;
+    d = document.getElementById("collapsed2LdateBox");
+    d.textContent = headerValue;
+  }
+  
+  
+  // coheUpdateMessageHeaders: Iterate through all the current header data we received from mime for this message
+  // for each header entry table, see if we have a corresponding entry for that header. i.e. does the particular
+  // view care about this header value. if it does then call updateHeaderEntry
+  function coheUpdateMessageHeaders()
   {
-    var headerField = currentHeaderData[headerName];
-    var headerEntry = null;
-
-    if (gCoheCollapsedHeaderViewMode && !gCoheBuiltCollapsedView)
+    // Remove the height attr so that it redraws correctly. Works around a
+    // problem that attachment-splitter causes if it's moved high enough to
+    // affect the header box:
+    document.getElementById('msgHeaderView').removeAttribute('height');
+    
+    // iterate over each header we received and see if we have a matching entry
+    // in each header view table...
+    for (var headerName in currentHeaderData)
     {
-      if (headerName == "cc" || headerName == "to" || headerName == "bcc")
-        headerEntry = gCoheCollapsedHeaderView["toCcBcc"];
-      else if (headerName in gCoheCollapsedHeaderView)
-        headerEntry = gCoheCollapsedHeaderView[headerName];
+      var headerField = currentHeaderData[headerName];
+      var headerEntry = null;
+  
+      if (gCoheCollapsedHeaderViewMode && !gCoheBuiltCollapsedView)
+      {
+        if (headerName == "cc" || headerName == "to" || headerName == "bcc")
+          headerEntry = gCoheCollapsedHeaderView["toCcBcc"];
+        else if (headerName in gCoheCollapsedHeaderView)
+          headerEntry = gCoheCollapsedHeaderView[headerName];
+      }
+  
+      if (headerEntry) {
+        headerEntry.outputFunction(headerEntry, headerField.headerValue);
+        headerEntry.valid = true;
+      }
     }
-
-    if (headerEntry) {
-      headerEntry.outputFunction(headerEntry, headerField.headerValue);
-      headerEntry.valid = true;
+  
+    if (gCoheCollapsedHeaderViewMode)
+     gCoheBuiltCollapsedView = true;
+  
+    // now update the view to make sure the right elements are visible
+    coheUpdateHeaderView();
+  }
+  
+  function addClass(el, strClass) {
+    var testnew = new RegExp('\\b'+strClass+'\\b').test(el.className);  
+    if (!testnew) {
+      el.className += el.className?' '+strClass:strClass;
     }
   }
-
-  if (gCoheCollapsedHeaderViewMode)
-   gCoheBuiltCollapsedView = true;
-
-  // now update the view to make sure the right elements are visible
-  coheUpdateHeaderView();
-}
-
-addEventListener('messagepane-loaded', coheOnLoadMsgHeaderPane, true);
-addEventListener('messagepane-unloaded', coheOnUnloadMsgHeaderPane, true);
-addEventListener('load', coheInitializeOverlay, false);
-
-function addClass(el, strClass) {
-  var testnew = new RegExp('\\b'+strClass+'\\b').test(el.className);  
-  if (!testnew) {
-    el.className += el.className?' '+strClass:strClass;
+  
+  function removeClass(el, strClass) {
+    el.className = el.className.replace(strClass, '');
   }
-}
-
-function removeClass(el, strClass) {
-  el.className = el.className.replace(strClass, '');
-}
-
-function CoheCopyWebsiteAddress(websiteAddressNode)
-{
-  if (websiteAddressNode)
+  
+  function CoheCopyWebsiteAddress(websiteAddressNode)
   {
-    var websiteAddress = websiteAddressNode.getAttribute("url");
-
-    var contractid = "@mozilla.org/widget/clipboardhelper;1";
-    var iid = Components.interfaces.nsIClipboardHelper;
-    var clipboard = Components.classes[contractid].getService(iid);
-    clipboard.copyString(websiteAddress);
+    if (websiteAddressNode)
+    {
+      var websiteAddress = websiteAddressNode.getAttribute("url");
+  
+      var contractid = "@mozilla.org/widget/clipboardhelper;1";
+      var iid = Components.interfaces.nsIClipboardHelper;
+      var clipboard = Components.classes[contractid].getService(iid);
+      clipboard.copyString(websiteAddress);
+    }
   }
-}
-
-function selectEmailDisplayed() {
-  var xulemail = document.getElementById("collapsedtoCcBccBox");
-  if (xulemail != null) {
-    var nextbox = document.getAnonymousElementByAttribute(xulemail, "anonid", "longEmailAddresses");
-    if (nextbox != null) {
-      var xuldesc = document.getAnonymousElementByAttribute(xulemail, "containsEmail", "true");
-      if (xuldesc != null) {
-        var children = xuldesc.children;
-        for (var i=0; i<children.length; i++) {
-          if (children[i].localName == "mail-emailaddress") {
-            var rawAddress = children[i].getAttribute("emailAddress");
-            if (rawAddress) {
-              children[i].setAttribute("label", rawAddress);
+  
+  function selectEmailDisplayed() {
+    var xulemail = document.getElementById("collapsedtoCcBccBox");
+    if (xulemail != null) {
+      var nextbox = document.getAnonymousElementByAttribute(xulemail, "anonid", "longEmailAddresses");
+      if (nextbox != null) {
+        var xuldesc = document.getAnonymousElementByAttribute(xulemail, "containsEmail", "true");
+        if (xuldesc != null) {
+          var children = xuldesc.children;
+          for (var i=0; i<children.length; i++) {
+            if (children[i].localName == "mail-emailaddress") {
+              var rawAddress = children[i].getAttribute("emailAddress");
+              if (rawAddress) {
+                children[i].setAttribute("label", rawAddress);
+              }
             }
           }
         }
       }
     }
-  }
-  var xulemail = document.getElementById("collapsedfromBox");
-  if (xulemail != null) {
-    var nextbox = document.getAnonymousElementByAttribute(xulemail, "anonid", "longEmailAddresses");
-    if (nextbox != null) {
-      var xuldesc = document.getAnonymousElementByAttribute(xulemail, "containsEmail", "true");
-      if (xuldesc != null) {
-        var children = xuldesc.children;
-        for (var i=0; i<children.length; i++) {
-          if (children[i].localName == "mail-emailaddress") {
-            var rawAddress = children[i].getAttribute("emailAddress");
-            if (rawAddress) {
-              children[i].setAttribute("label", rawAddress);
+    var xulemail = document.getElementById("collapsedfromBox");
+    if (xulemail != null) {
+      var nextbox = document.getAnonymousElementByAttribute(xulemail, "anonid", "longEmailAddresses");
+      if (nextbox != null) {
+        var xuldesc = document.getAnonymousElementByAttribute(xulemail, "containsEmail", "true");
+        if (xuldesc != null) {
+          var children = xuldesc.children;
+          for (var i=0; i<children.length; i++) {
+            if (children[i].localName == "mail-emailaddress") {
+              var rawAddress = children[i].getAttribute("emailAddress");
+              if (rawAddress) {
+                children[i].setAttribute("label", rawAddress);
+              }
             }
           }
         }
       }
     }
   }
-}
-
-var myPrefObserverHeaderSize =
-{
-  register: function()
-  {
-    // First we'll need the preference services to look for preferences.
-    var prefService = Components.classes["@mozilla.org/preferences-service;1"]
-                                .getService(Components.interfaces.nsIPrefService);
-
-    // For this._branch we ask that the preferences for extensions.myextension. and children
-    this._branch = prefService.getBranch("extensions.CompactHeader.headersize.");
-
-    // Now we queue the interface called nsIPrefBranch2. This interface is described as:  
-    // "nsIPrefBranch2 allows clients to observe changes to pref values."
-    this._branch.QueryInterface(Components.interfaces.nsIPrefBranch2);
-
-    // Finally add the observer.
-    this._branch.addObserver("", this, false);
-  },
-
-  unregister: function()
-  {
-    if(!this._branch) return;
-    this._branch.removeObserver("", this);
-  },
-
-  observe: function(aSubject, aTopic, aData)
+  
+  var myPrefObserverHeaderSize =
   {
-    if(aTopic != "nsPref:changed") return;
-    // aSubject is the nsIPrefBranch we're observing (after appropriate QI)
-    // aData is the name of the pref that's been changed (relative to aSubject)
-
-    var event = document.createEvent('Events');
-    event.initEvent('messagepane-loaded', false, true);
-    var headerViewElement = document.getElementById("msgHeaderView");
-    headerViewElement.dispatchEvent(event);
-
-    gDBView.reloadMessage();
-  }
-}
-
-myPrefObserverHeaderSize.register();
-
-function coheCheckFirstRun() {
-  cohe.version = -1;
-  cohe.firstrun = false;
-  cohe.gExtensionManager = Components.classes["@mozilla.org/extensions/manager;1"].getService(Components.interfaces.nsIExtensionManager);
-  // check if this is part of CompactHeader
-  if ((cohe.gExtensionManager.getItemForID(COHE_EXTENSION_UUID) == null) || (isAddonDisabled(COHE_EXTENSION_UUID))) {
-    return;
+    register: function()
+    {
+      // First we'll need the preference services to look for preferences.
+      var prefService = Components.classes["@mozilla.org/preferences-service;1"]
+                                  .getService(Components.interfaces.nsIPrefService);
+  
+      // For this._branch we ask that the preferences for extensions.myextension. and children
+      this._branch = prefService.getBranch("extensions.CompactHeader.headersize.");
+  
+      // Now we queue the interface called nsIPrefBranch2. This interface is described as:  
+      // "nsIPrefBranch2 allows clients to observe changes to pref values."
+      this._branch.QueryInterface(Components.interfaces.nsIPrefBranch2);
+  
+      // Finally add the observer.
+      this._branch.addObserver("", this, false);
+    },
+  
+    unregister: function()
+    {
+      if(!this._branch) return;
+      this._branch.removeObserver("", this);
+    },
+  
+    observe: function(aSubject, aTopic, aData)
+    {
+      if(aTopic != "nsPref:changed") return;
+      // aSubject is the nsIPrefBranch we're observing (after appropriate QI)
+      // aData is the name of the pref that's been changed (relative to aSubject)
+  
+      var event = document.createEvent('Events');
+      event.initEvent('messagepane-loaded', false, true);
+      var headerViewElement = document.getElementById("msgHeaderView");
+      headerViewElement.dispatchEvent(event);
+  
+      gDBView.reloadMessage();
+    }
   }
   
-  cohe.current = cohe.gExtensionManager.getItemForID(COHE_EXTENSION_UUID).version;
-  try{
-    cohe.version = cohePrefBranch.getCharPref("version");
-    cohe.firstrun = cohePrefBranch.getBoolPref("firstrun");
-  } catch(e) {
-  } finally {
-    //check for first run
-    if (cohe.firstrun){
-      cohePrefBranch.setBoolPref("firstrun",false);
-      cohePrefBranch.setCharPref("version",cohe.current);
+  myPrefObserverHeaderSize.register();
+  
+  function coheCheckFirstRun() {
+    cohe.version = -1;
+    cohe.firstrun = false;
+    cohe.gExtensionManager = Components.classes["@mozilla.org/extensions/manager;1"].getService(Components.interfaces.nsIExtensionManager);
+    // check if this is part of CompactHeader
+    if ((cohe.gExtensionManager.getItemForID(COHE_EXTENSION_UUID) == null) || (isAddonDisabled(COHE_EXTENSION_UUID))) {
+      return;
     }
-    //check for upgrade
-    if (cohe.version!=cohe.current && !cohe.firstrun){
-      cohePrefBranch.setCharPref("version",cohe.current);
-      // XXX
+    
+    cohe.current = cohe.gExtensionManager.getItemForID(COHE_EXTENSION_UUID).version;
+    try{
+      cohe.version = cohePrefBranch.getCharPref("version");
+      cohe.firstrun = cohePrefBranch.getBoolPref("firstrun");
+    } catch(e) {
+    } finally {
+      //check for first run
+      if (cohe.firstrun){
+        cohePrefBranch.setBoolPref("firstrun",false);
+        cohePrefBranch.setCharPref("version",cohe.current);
+      }
+      //check for upgrade
+      if (cohe.version!=cohe.current && !cohe.firstrun){
+        cohePrefBranch.setCharPref("version",cohe.current);
+        // XXX
+      }
     }
   }
-}
-
-function coheInitializeOverlay() {
-  var gExtensionManager = Components.classes["@mozilla.org/extensions/manager;1"].getService(Components.interfaces.nsIExtensionManager);
-  // check if this is part of CompactHeader
-  if ((gExtensionManager.getItemForID(COHE_EXTENSION_UUID) == null) || isAddonDisabled(COHE_EXTENSION_UUID)) {
-    return;
+  
+  pub.coheInitializeOverlay = function() {
+    var gExtensionManager = Components.classes["@mozilla.org/extensions/manager;1"].getService(Components.interfaces.nsIExtensionManager);
+    // check if this is part of CompactHeader
+    if ((gExtensionManager.getItemForID(COHE_EXTENSION_UUID) == null) || isAddonDisabled(COHE_EXTENSION_UUID)) {
+      return;
+    }
+    coheUninstallObserver.register();
   }
-  coheUninstallObserver.register();
-}
-
-var coheUninstallObserver = {
-  _uninstall : false,
-  observe : function(subject, topic, data) {
-    if (topic == "em-action-requested") {
-      subject.QueryInterface(Components.interfaces.nsIUpdateItem);
-  
-      if (subject.id == COHE_EXTENSION_UUID) {
-        if (data == "item-uninstalled") {
-          this._uninstall = true;
-        } else if (data == "item-cancel-action") {
-          this._uninstall = false;
+  
+  var coheUninstallObserver = {
+    _uninstall : false,
+    observe : function(subject, topic, data) {
+      if (topic == "em-action-requested") {
+        subject.QueryInterface(Components.interfaces.nsIUpdateItem);
+    
+        if (subject.id == COHE_EXTENSION_UUID) {
+          if (data == "item-uninstalled") {
+            this._uninstall = true;
+          } else if (data == "item-cancel-action") {
+            this._uninstall = false;
+          }
         }
+      } else if (topic == "quit-application-granted") {
+        if (this._uninstall) {
+          cohePrefBranch.deleteBranch("");
+          org.mozdev.customizeHeaderToolbar.pane.CHTCleanupButtons();
+        }
+        this.unregister();
       }
-    } else if (topic == "quit-application-granted") {
-      if (this._uninstall) {
-        cohePrefBranch.deleteBranch("");
-        CHTCleanupButtons();
-      }
-      this.unregister();
+    },
+    register : function() {
+     var observerService =
+       Components.classes["@mozilla.org/observer-service;1"].
+         getService(Components.interfaces.nsIObserverService);
+    
+     observerService.addObserver(this, "em-action-requested", false);
+     observerService.addObserver(this, "quit-application-granted", false);
+    },
+    unregister : function() {
+      var observerService =
+        Components.classes["@mozilla.org/observer-service;1"].
+          getService(Components.interfaces.nsIObserverService);
+    
+      observerService.removeObserver(this,"em-action-requested");
+      observerService.removeObserver(this,"quit-application-granted");
     }
-  },
-  register : function() {
-   var observerService =
-     Components.classes["@mozilla.org/observer-service;1"].
-       getService(Components.interfaces.nsIObserverService);
-  
-   observerService.addObserver(this, "em-action-requested", false);
-   observerService.addObserver(this, "quit-application-granted", false);
-  },
-  unregister : function() {
-    var observerService =
-      Components.classes["@mozilla.org/observer-service;1"].
-        getService(Components.interfaces.nsIObserverService);
-  
-    observerService.removeObserver(this,"em-action-requested");
-    observerService.removeObserver(this,"quit-application-granted");
   }
-}
-
-function isAddonDisabled(uuid) {
-  var rdfService = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService);
-  var addon = rdfService.GetResource("urn:mozilla:item:" + uuid);
-
-  var em = Components.classes["@mozilla.org/extensions/manager;1"].getService(Components.interfaces.nsIExtensionManager);
-  var ds = em.datasource;
-
-  var appRes = rdfService.GetResource("http://www.mozilla.org/2004/em-rdf#appDisabled");
-  var appDisabled = ds.GetTarget(addon, appRes, true);
-  if(appDisabled instanceof Components.interfaces.nsIRDFLiteral && appDisabled.Value == "true")
-    return true;
-
-  var userRes = rdfService.GetResource("http://www.mozilla.org/2004/em-rdf#userDisabled");
-  var userDisabled = ds.GetTarget(addon, userRes, true);
-  if(userDisabled instanceof Components.interfaces.nsIRDFLiteral && userDisabled.Value == "true")
-    return true;
+  
+  function isAddonDisabled(uuid) {
+    var rdfService = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService);
+    var addon = rdfService.GetResource("urn:mozilla:item:" + uuid);
+  
+    var em = Components.classes["@mozilla.org/extensions/manager;1"].getService(Components.interfaces.nsIExtensionManager);
+    var ds = em.datasource;
+  
+    var appRes = rdfService.GetResource("http://www.mozilla.org/2004/em-rdf#appDisabled");
+    var appDisabled = ds.GetTarget(addon, appRes, true);
+    if(appDisabled instanceof Components.interfaces.nsIRDFLiteral && appDisabled.Value == "true")
+      return true;
+  
+    var userRes = rdfService.GetResource("http://www.mozilla.org/2004/em-rdf#userDisabled");
+    var userDisabled = ds.GetTarget(addon, userRes, true);
+    if(userDisabled instanceof Components.interfaces.nsIRDFLiteral && userDisabled.Value == "true")
+      return true;
+  
+    return false;
+  }
+  return pub;
+}();
 
-  return false;
-}
+addEventListener('messagepane-loaded', org.mozdev.compactHeader.pane.coheOnLoadMsgHeaderPane, true);
+addEventListener('messagepane-unloaded', org.mozdev.compactHeader.pane.coheOnUnloadMsgHeaderPane, true);
+addEventListener('load', org.mozdev.compactHeader.pane.coheInitializeOverlay, false);
+  

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/compactheader.git



More information about the Pkg-mozext-commits mailing list