gecko-dev/mailnews/base/resources/content/mailNavigatorOverlay.xul

119 lines
4.6 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 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;
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>