From 8f6d5824c5596d8c4b4c1c21e7c7cca4f3f384df Mon Sep 17 00:00:00 2001 From: "scott%scott-macgregor.org" Date: Tue, 22 Nov 2005 01:55:14 +0000 Subject: [PATCH] Bug #312940 --> more work on the new mail alert prototype sr=bienvenu --- mail/base/content/newmailalert.js | 11 ------ .../base/resources/content/mailWidgets.xml | 37 +++++++------------ 2 files changed, 13 insertions(+), 35 deletions(-) diff --git a/mail/base/content/newmailalert.js b/mail/base/content/newmailalert.js index fa5dcf81b3ec..9f743af8b206 100644 --- a/mail/base/content/newmailalert.js +++ b/mail/base/content/newmailalert.js @@ -77,17 +77,6 @@ function prefillAlertInfo() } function onAlertLoad() -{ - // this delay is required because the folder summary element - // ends up dynamically creating an arbitrary number of folderSummaryMessage xbl widgets - // and we have to fire a timeout to wait for the various properties and methods on the folderSummaryMessage widget - // before we can actually initialize it. Because of that timeout, we don't know the total width of the alert - // dialog when onAlertLoad is called, so we have to delay again. This work around in turn causes the alert to flash up in the middle - // of your window for a second until onDelayAlertLoad gets called and moves the window to the right position. - setTimeout(onDelayAlertLoad, 0); -} - -function onDelayAlertLoad() { // read out our initial settings from prefs. try diff --git a/mailnews/base/resources/content/mailWidgets.xml b/mailnews/base/resources/content/mailWidgets.xml index c0d1cde101e8..355f2d4ac439 100644 --- a/mailnews/base/resources/content/mailWidgets.xml +++ b/mailnews/base/resources/content/mailWidgets.xml @@ -2059,13 +2059,22 @@ } var index = 0; + var hdrParser = Components.classes["@mozilla.org/messenger/headerparser;1"].getService(Components.interfaces.nsIMsgHeaderParser); while (document.getAnonymousNodes(this)[0].childNodes.length < this.mMaxMsgHdrsInPopup && index < numMsgKeys.value) { var msgPopup = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "folderSummaryMessage"); - // hack to work around the fact that the xbl binding from createElementNS is asynch. - setTimeout(function(aMsgPopup, aMsgHdr) { - aMsgPopup.init(aMsgHdr); }, 0, - msgPopup, msgDatabase.GetMsgHdrForKey(msgKeys.value[index++])); + var msgHdr = msgDatabase.GetMsgHdrForKey(msgKeys.value[index++]); + msgPopup.setAttribute('subject', msgHdr.mime2DecodedSubject); + + // TO DO: worry about character set conversions + var previewText = msgHdr.getStringProperty('preview'); // replace tabs, line returns, etc. with a space + if (previewText) + msgPopup.setAttribute('previewText', previewText); + + var names = {}; + var emails = {}; + var numAddresses = hdrParser.parseHeadersWithArray(msgHdr.mime2DecodedAuthor, emails, names, {}); + msgPopup.setAttribute('sender', ' - ' + (names.value[0] ? names.value[0] : emails.value[0])); document.getAnonymousNodes(this)[0].appendChild(msgPopup); } return true; @@ -2095,25 +2104,5 @@ - - - - - - - -