Bug #110543 --> afire a custom event when the message pane loads

inform any listeners when we start to display a message
r=kai
sr=sspitzer
This commit is contained in:
mscott%netscape.com 2001-11-28 01:06:37 +00:00
Родитель 419d8f6b7b
Коммит a3df778647
2 изменённых файлов: 48 добавлений и 12 удалений

Просмотреть файл

@ -22,7 +22,7 @@
message pane live. */ message pane live. */
//////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////
// Warning: if you go to modify any of these JS routines please get a code review from either // Warning: if you go to modify any of these JS routines please get a code review from
// mscott@netscape.com. It's critical that the code in here for displaying // mscott@netscape.com. It's critical that the code in here for displaying
// the message headers for a selected message remain as fast as possible. In particular, // the message headers for a selected message remain as fast as possible. In particular,
// right now, we only introduce one reflow per message. i.e. if you click on a message in the thread // right now, we only introduce one reflow per message. i.e. if you click on a message in the thread
@ -51,6 +51,12 @@ var gSaveLabel;
var msgHeaderParser = Components.classes[msgHeaderParserContractID].getService(Components.interfaces.nsIMsgHeaderParser); var msgHeaderParser = Components.classes[msgHeaderParserContractID].getService(Components.interfaces.nsIMsgHeaderParser);
var abAddressCollector = Components.classes[abAddressCollectorContractID].getService(Components.interfaces.nsIAbAddressCollecter); var abAddressCollector = Components.classes[abAddressCollectorContractID].getService(Components.interfaces.nsIAbAddressCollecter);
// other components may listen to on start header & on end header notifications for each message we display
// to do that you need to add yourself to our gMessageListeners array with object that has two properties:
// onStartHeaders and onEndHeaders.
var gMessageListeners = new Array;
// For every possible "view" in the message pane, you need to define the header names you want to // For every possible "view" in the message pane, you need to define the header names you want to
// see in that view. In addition, include information describing how you want that header field to be // see in that view. In addition, include information describing how you want that header field to be
// presented. i.e. if it's an email address field, if you want a toggle inserted on the node in case // presented. i.e. if it's an email address field, if you want a toggle inserted on the node in case
@ -196,6 +202,12 @@ function OnLoadMsgHeaderPane()
var initialCollapsedSetting = toggleHeaderView.getAttribute("state"); var initialCollapsedSetting = toggleHeaderView.getAttribute("state");
if (initialCollapsedSetting == "true") if (initialCollapsedSetting == "true")
gCollapsedHeaderViewMode = true; gCollapsedHeaderViewMode = true;
// dispatch an event letting any listeners know that we have loaded the message pane
var event = document.createEvent('Events');
event.initEvent('messagepane-loaded', false, true);
var headerViewElement = document.getElementById("msgHeaderView");
headerViewElement.dispatchEvent(event);
} }
// The messageHeaderSink is the class that gets notified of a message's headers as we display the message // The messageHeaderSink is the class that gets notified of a message's headers as we display the message
@ -229,6 +241,9 @@ var messageHeaderSink = {
gBuildAttachmentPopupForCurrentMsg = true; gBuildAttachmentPopupForCurrentMsg = true;
ClearAttachmentTreeList(); ClearAttachmentTreeList();
ClearEditMessageButton(); ClearEditMessageButton();
for (index in gMessageListeners)
gMessageListeners[index].onStartHeaders();
}, },
onEndHeaders: function() onEndHeaders: function()
@ -276,7 +291,7 @@ var messageHeaderSink = {
if (lowerCaseHeaderName == "from") if (lowerCaseHeaderName == "from")
{ {
if (foo.headerValue && abAddressCollector && ((gCollectIncoming && !dontCollectAddress) || (gCollectNewsgroup && dontCollectAddress))) if (foo.headerValue && abAddressCollector && ((gCollectIncoming && !dontCollectAddress) || (gCollectNewsgroup && dontCollectAddress)))
abAddressCollector.collectUnicodeAddress(foo.headerValue); abAddressCollector.collectUnicodeAddress(foo.headerValue);
} }
index++; index++;
@ -312,6 +327,16 @@ var messageHeaderSink = {
displayAttachmentsForCollapsedView(); displayAttachmentsForCollapsedView();
else else
displayAttachmentsForExpandedView(); displayAttachmentsForExpandedView();
},
mSecurityInfo : null,
getSecurityInfo: function()
{
return this.mSecurityInfo;
},
setSecurityInfo: function(aSecurityInfo)
{
this.mSecurityInfo = aSecurityInfo;
} }
}; };
@ -777,11 +802,20 @@ function displayAttachmentsForExpandedView()
gBuildAttachmentsForCurrentMsg = true; gBuildAttachmentsForCurrentMsg = true;
} }
var attachmentNode = document.getElementById('expandedAttachmentBox'); var attachmentNode = document.getElementById('attachmentTree');
var attachmentText = document.getElementById('attachmentText');
var expandedAttachmentBox = document.getElementById('expandedAttachmentBox');
if (numAttachments > 0) // make sure the attachment button is visible if (numAttachments > 0) // make sure the attachment button is visible
{
attachmentNode.removeAttribute('collapsed'); attachmentNode.removeAttribute('collapsed');
attachmentText.removeAttribute('collapsed');
expandedAttachmentBox.removeAttribute('collapsed');
}
else else
{
attachmentNode.setAttribute('collapsed', true); attachmentNode.setAttribute('collapsed', true);
attachmentText.setAttribute('collapsed', true);
}
} }
// attachment --> the attachment struct containing all the information on the attachment // attachment --> the attachment struct containing all the information on the attachment

Просмотреть файл

@ -117,15 +117,17 @@ Rights Reserved.
<spacer class="buttonSpacer"/> <spacer class="buttonSpacer"/>
</vbox> </vbox>
<hbox id="expandedAttachmentBox" class="header-part1"> <hbox id="expandedAttachmentBox" class="header-part1" collapsed="true">
<label id="attachmentText" value="&attachmentsTree.label;" crop="right"/> <vbox id="attachmentGrouping">
<tree id="attachmentTree" class="inset" flex="2" onclick="attachmentTreeClick(event);" context="attachmentTreeContext"> <label id="attachmentText" value="&attachmentsTree.label;" crop="right"/>
<treecolgroup> </vbox>
<treecol flex="1"/> <tree id="attachmentTree" class="inset" flex="2" onclick="attachmentTreeClick(event);" context="attachmentTreeContext">
</treecolgroup> <treecolgroup>
<treechildren id="attachmentsBody" flex="1"> <treecol flex="1"/>
</treechildren> </treecolgroup>
</tree> <treechildren id="attachmentsBody" flex="1">
</treechildren>
</tree>
</hbox> </hbox>
</hbox> </hbox>