mscott%netscape.com 1572583b0f Minotaur base
git-svn-id: svn://10.0.0.236/trunk@140743 18797224-902f-48f8-a5cc-f745e15eee43
2003-04-05 07:27:20 +00:00

118 lines
4.0 KiB
JavaScript

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator client code, released
* March 31, 1998.
*
*
* Contributor(s):
*/
/*
* Core mail routines used by all of the major mail windows (address book, 3-pane, compose and stand alone message window).
* Routines to support custom toolbars in mail windows, opening up a new window of a particular type all live here.
* Before adding to this file, ask yourself, is this a JS routine that is going to be used by all of the main mail windows?
*/
function CustomizeMailToolbar(id)
{
// Disable the toolbar context menu items
var menubar = document.getElementById("mail-menubar");
for (var i = 0; i < menubar.childNodes.length; ++i)
menubar.childNodes[i].setAttribute("disabled", true);
//var cmd = document.getElementById("cmd_CustomizeToolbars");
//cmd.setAttribute("disabled", "true");
window.openDialog("chrome://global/content/customizeToolbar.xul", "CustomizeToolbar",
"chrome,all,dependent", document.getElementById(id));
}
function MailToolboxCustomizeDone(aToolboxChanged)
{
// Update global UI elements that may have been added or removed
// Re-enable parts of the UI we disabled during the dialog
var menubar = document.getElementById("mail-menubar");
for (var i = 0; i < menubar.childNodes.length; ++i)
menubar.childNodes[i].setAttribute("disabled", false);
//var cmd = document.getElementById("cmd_CustomizeToolbars");
//cmd.removeAttribute("disabled");
// make sure our toolbar buttons have the correct enabled state restored to them...
if (this.UpdateMailToolbar != undefined)
UpdateMailToolbar(focus);
}
function onViewToolbarCommand(id, aEvent)
{
var toolbar = document.getElementById(id);
if (!toolbar) return;
toolbar.collapsed = aEvent.originalTarget.getAttribute("checked") != "true";
document.persist(id, "collapsed");
}
function toJavaScriptConsole()
{
toOpenWindowByType("global:console", "chrome://global/content/console.xul");
}
const nsIWindowMediator = Components.interfaces.nsIWindowMediator;
function toOpenWindowByType( inType, uri )
{
var windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService();
var windowManagerInterface = windowManager.QueryInterface(nsIWindowMediator);
var topWindow = windowManagerInterface.getMostRecentWindow( inType );
if ( topWindow )
topWindow.focus();
else
window.open(uri, "_blank", "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar");
}
function toMessengerWindow()
{
var pref = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
var windowDoc = "chrome://messenger/content/messenger.xul";
try
{
var layoutType = pref.getIntPref("mail.pane_config");
windowDoc = !layoutType ? "chrome://messenger/content/messenger.xul" :
"chrome://messenger/content/mail3PaneWindowVertLayout.xul";
}
catch(ex)
{
}
toOpenWindowByType("mail:3pane", windowDoc);
}
function toAddressBook()
{
toOpenWindowByType("mail:addressbook", "chrome://messenger/content/addressbook/addressbook.xul");
}
function toImport()
{
window.openDialog("chrome://messenger/content/importDialog.xul","importDialog","chrome, modal, titlebar", {importType: "addressbook"});
}
// this method is overridden by mail-offline.js if we build with the offline extensions
function CheckOnline()
{
return true;
}