gecko-dev/mailnews/base/resources/content/mailNavigatorOverlay.xul
2002-02-20 03:05:53 +00:00

141 lines
5.4 KiB
XML

<?xml version="1.0"?>
<!-- retrieve generic commands -->
<?xul-overlay href="chrome://messenger/content/mailOverlay.xul"?>
<!DOCTYPE window SYSTEM "chrome://messenger/locale/mailNavigatorOverlay.dtd" >
<overlay id="mailNavigatorOverlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript">
<![CDATA[
function getCurrentIdentityKey()
{
try
{
var cwindowManager = Components.classes['@mozilla.org/rdf/datasource;1?name=window-mediator'].getService();
var iwindowManager = Components.interfaces.nsIWindowMediator;
var windowManager = cwindowManager.QueryInterface(iwindowManager);
var mailWindow = windowManager.getMostRecentWindow('mail:3pane');
var folder = mailWindow.GetFirstSelectedMsgFolder();
var server = folder.server;
if (server.type == "nntp")//if the account is a news account use default identity
return null;
else {
var identity = mailWindow.getIdentityForServer(server);
return identity;
}
}
catch(ex) {
return null;
}
}
function openComposeWindow(pageUrl, pageTitle, attachPage)
{
var params = Components.classes["@mozilla.org/messengercompose/composeparams;1"].createInstance(Components.interfaces.nsIMsgComposeParams);
if (params)
{
params.composeFields = Components.classes['@mozilla.org/messengercompose/composefields;1'].createInstance(Components.interfaces.nsIMsgCompFields);
if (params.composeFields)
{
params.composeFields.body = pageUrl;
params.composeFields.subject = pageTitle;
if (attachPage)
{
var attachmentData = Components.classes["@mozilla.org/messengercompose/attachment;1"].createInstance(Components.interfaces.nsIMsgAttachment);
if (attachmentData)
{
attachmentData.url = pageUrl;
params.composeFields.addAttachment(attachmentData);
}
}
params.bodyIsLink = true;
params.identity = getCurrentIdentityKey();
var composeService = Components.classes["@mozilla.org/messengercompose;1"].getService(Components.interfaces.nsIMsgComposeService);
if (composeService)
composeService.OpenComposeWindowWithParams(null, params);
}
}
}
function sendLink(pageUrl, pageTitle)
{
try {
openComposeWindow(pageUrl, pageTitle, false);
} catch(ex) { dump("Cannot Send Link: " + ex + "\n"); }
}
function sendPage(aDocument)
{
if (!aDocument)
aDocument = window._content.document;
var pageUrl = aDocument.URL;
var pageTitle = aDocument.title;
try {
openComposeWindow(pageUrl, pageTitle, true);
} catch(ex) { dump("Cannot Send Page: " + ex + "\n"); }
}
function initMailContextMenuItems(aEvent)
{
var shouldShowSendPage = !gContextMenu.onImage && !gContextMenu.onLink && !gContextMenu.onTextInput;
gContextMenu.showItem("context-sendpage", shouldShowSendPage);
var shouldShowSendLink = gContextMenu.onLink;
gContextMenu.showItem("context-sendlink", shouldShowSendLink);
gContextMenu.showItem("context-sep-apps", gContextMenu.shouldShowSeparator("context-sep-apps"));
}
var gAddedMailContextMenuPopupListener = false;
function initMailContextMenuPopupListener(aEvent)
{
// This is really lame, but we can't seem to add a bubbling listener to the DOMWindow (!)
if (gAddedMailContextMenuPopupListener)
return;
var popup = document.getElementById("contentAreaContextMenu");
popup.addEventListener("popupshowing", initMailContextMenuItems, false);
gAddedMailContextMenuPopupListener = true;
}
addEventListener("load", initMailContextMenuPopupListener, true);
]]>
</script>
<!-- navigator specific commands -->
<commandset id="tasksCommands">
<command id="cmd_sendPage" oncommand="sendPage();"/>
<command id="Browser:SendLink" oncommand="sendLink(window._content.location.href, window._content.document.title);"/>
</commandset>
<!-- navigator specific UI items -->
<menupopup id="menu_NewPopup">
<menuitem id="menu_newCard" position="3"/>
<menuitem id="menu_newMessage" position="2"/>
</menupopup>
<menupopup id="menu_FilePopup">
<menuitem id="menu_sendPage" label="&sendPage.label;" accesskey="&sendPage.accesskey;" command="cmd_sendPage" position="11"/>
<menuitem id="menu_sendLink" label="&sendLinkCmd.label;" accesskey="&sendLinkCmd.accesskey;" command="Browser:SendLink" position="12"/>
</menupopup>
<popup id="contentAreaContextMenu">
<menuitem id="context-sendpage"
label="&sendPage.label;"
accesskey="&sendPage.accesskey;"
oncommand="sendPage(gContextMenu.target.ownerDocument);"
insertafter="context-sep-save"/>
<menuitem id="context-sendlink"
label="&sendLinkCmd.label;"
accesskey="&sendLinkCmd.accesskey;"
oncommand="sendLink(gContextMenu.linkURL(), gContextMenu.linkText());"
insertafter="context-sep-save"/>
</popup>
</overlay>