?? mailwindow.js
字號:
# -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-# ***** BEGIN LICENSE BLOCK *****# Version: MPL 1.1/GPL 2.0/LGPL 2.1## The contents of this file are subject to the Mozilla 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/MPL/## 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.## The Initial Developer of the Original Code is# Netscape Communications Corporation.# Portions created by the Initial Developer are Copyright (C) 1998-1999# the Initial Developer. All Rights Reserved.## Contributor(s):# Jan Varga <varga@nixcorp.com># H錵an Waara (hwaara@chello.se)## Alternatively, the contents of this file may be used under the terms of# either the GNU General Public License Version 2 or later (the "GPL"), or# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),# in which case the provisions of the GPL or the LGPL are applicable instead# of those above. If you wish to allow use of your version of this file only# under the terms of either the GPL or the LGPL, and not to allow others to# use your version of this file under the terms of the MPL, indicate your# decision by deleting the provisions above and replace them with the notice# and other provisions required by the GPL or the LGPL. If you do not delete# the provisions above, a recipient may use your version of this file under# the terms of any one of the MPL, the GPL or the LGPL.## ***** END LICENSE BLOCK *****//This file stores variables common to mail windowsvar messengerContractID = "@mozilla.org/messenger;1";var statusFeedbackContractID = "@mozilla.org/messenger/statusfeedback;1";var mailSessionContractID = "@mozilla.org/messenger/services/session;1";var msgWindowContractID = "@mozilla.org/messenger/msgwindow;1";var messenger;var pref;var statusFeedback;var messagePaneController;var msgWindow;var msgComposeService;var accountManager;var RDF;var msgComposeType;var msgComposeFormat;var mailSession;var gMessengerBundle;var gBrandBundle;var datasourceContractIDPrefix = "@mozilla.org/rdf/datasource;1?name=";var accountManagerDSContractID = datasourceContractIDPrefix + "msgaccountmanager";var folderDSContractID = datasourceContractIDPrefix + "mailnewsfolders";var unreadFoldersDSContractID = datasourceContractIDPrefix + "mailnewsunreadfolders";var favoriteFoldersDSContractID = datasourceContractIDPrefix + "mailnewsfavefolders";var recentFoldersDSContractID = datasourceContractIDPrefix + "mailnewsrecentfolders";var accountManagerDataSource;var folderDataSource;var unreadFolderDataSource;var favoriteFoldersDataSource;var recentFoldersDataSource;var accountCentralBox = null;var gAccountCentralLoaded = true;var gFakeAccountPageLoaded = false;//End progress and Status variablesfunction OnMailWindowUnload(){ MailOfflineMgr.uninit(); ClearPendingReadTimer(); var searchSession = GetSearchSession(); if (searchSession) { removeGlobalListeners(); if (gPreQuickSearchView) //close the cached pre quick search view gPreQuickSearchView.close(); } var dbview = GetDBView(); if (dbview) { dbview.close(); } var mailSession = Components.classes[mailSessionContractID].getService(); if(mailSession) { mailSession = mailSession.QueryInterface(Components.interfaces.nsIMsgMailSession); if(mailSession) { mailSession.RemoveFolderListener(folderListener); } } mailSession.RemoveMsgWindow(msgWindow); messenger.SetWindow(null, null); var msgDS; var viewDataSources = [accountManagerDataSource, folderDataSource, unreadFolderDataSource, favoriteFoldersDataSource, recentFoldersDataSource]; for (index in viewDataSources) { msgDS = viewDataSources[index].QueryInterface(Components.interfaces.nsIMsgRDFDataSource); msgDS.window = null; } msgWindow.closeWindow();}function CreateMessenger(){ messenger = Components.classes[messengerContractID].createInstance(); messenger = messenger.QueryInterface(Components.interfaces.nsIMessenger);}function CreateMailWindowGlobals(){ // get the messenger instance CreateMessenger(); pref = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefBranch2); //Create windows status feedback // set the JS implementation of status feedback before creating the c++ one.. window.MsgStatusFeedback = new nsMsgStatusFeedback(); // double register the status feedback object as the xul browser window implementation window.QueryInterface(Components.interfaces.nsIInterfaceRequestor) .getInterface(Components.interfaces.nsIWebNavigation) .QueryInterface(Components.interfaces.nsIDocShellTreeItem).treeOwner .QueryInterface(Components.interfaces.nsIInterfaceRequestor) .getInterface(Components.interfaces.nsIXULWindow) .XULBrowserWindow = window.MsgStatusFeedback; statusFeedback = Components.classes[statusFeedbackContractID].createInstance(); statusFeedback = statusFeedback.QueryInterface(Components.interfaces.nsIMsgStatusFeedback); /* not in use unless we want the lock button back // try to create and register ourselves with a security icon... var securityIcon = document.getElementById("security-button"); if (securityIcon) { // if the client isn't built with psm enabled then we won't have a secure UI to monitor the lock icon // so be sure to wrap this in a try / catch clause... try { var secureUI; // we may not have a secure UI if psm isn't installed! if (secureUIContractID in Components.classes) { secureUI = Components.classes[secureUIContractID].createInstance(); if (secureUI) { secureUI = secureUI.QueryInterface(Components.interfaces.nsISecureBrowserUI); secureUI.init(_content, securityIcon); } } } catch (ex) {} } */ window.MsgWindowCommands = new nsMsgWindowCommands(); //Create message window object msgWindow = Components.classes[msgWindowContractID].createInstance(); msgWindow = msgWindow.QueryInterface(Components.interfaces.nsIMsgWindow); msgComposeService = Components.classes['@mozilla.org/messengercompose;1'].getService(); msgComposeService = msgComposeService.QueryInterface(Components.interfaces.nsIMsgComposeService); mailSession = Components.classes["@mozilla.org/messenger/services/session;1"].getService(Components.interfaces.nsIMsgMailSession); accountManager = Components.classes["@mozilla.org/messenger/account-manager;1"].getService(Components.interfaces.nsIMsgAccountManager); RDF = Components.classes['@mozilla.org/rdf/rdf-service;1'].getService(); RDF = RDF.QueryInterface(Components.interfaces.nsIRDFService); msgComposeType = Components.interfaces.nsIMsgCompType; msgComposeFormat = Components.interfaces.nsIMsgCompFormat; gMessengerBundle = document.getElementById("bundle_messenger"); gBrandBundle = document.getElementById("bundle_brand"); //Create datasources accountManagerDataSource = Components.classes[accountManagerDSContractID].createInstance(); folderDataSource = Components.classes[folderDSContractID].getService(); unreadFolderDataSource = Components.classes[unreadFoldersDSContractID].getService(); favoriteFoldersDataSource = Components.classes[favoriteFoldersDSContractID].getService(); recentFoldersDataSource = Components.classes[recentFoldersDSContractID].getService();}function InitMsgWindow(){ msgWindow.messagePaneController = new nsMessagePaneController(); msgWindow.statusFeedback = statusFeedback; msgWindow.msgHeaderSink = messageHeaderSink; msgWindow.SetDOMWindow(window); mailSession.AddMsgWindow(msgWindow); getBrowser().docShell.allowAuth = false; msgWindow.rootDocShell.allowAuth = true; }function AddDataSources(){ accountManagerDataSource = accountManagerDataSource.QueryInterface(Components.interfaces.nsIRDFDataSource); folderDataSource = folderDataSource.QueryInterface(Components.interfaces.nsIRDFDataSource); //to move menu item SetupMoveCopyMenus('moveMenu', accountManagerDataSource, folderDataSource); //to copy menu item SetupMoveCopyMenus('copyMenu', accountManagerDataSource, folderDataSource); //To FileButton menu SetupMoveCopyMenus('button-file', accountManagerDataSource, folderDataSource); //To move and copy menus in message pane context SetupMoveCopyMenus("messagePaneContext-copyMenu", accountManagerDataSource, folderDataSource); SetupMoveCopyMenus("messagePaneContext-moveMenu", accountManagerDataSource, folderDataSource); //Add statusFeedback var msgDS; var viewDataSources = [accountManagerDataSource, folderDataSource, unreadFolderDataSource, favoriteFoldersDataSource, recentFoldersDataSource]; for (index in viewDataSources) { msgDS = viewDataSources[index].QueryInterface(Components.interfaces.nsIMsgRDFDataSource); msgDS.window = msgWindow; }}function SetupMoveCopyMenus(menuid, accountManagerDataSource, folderDataSource){ var menu = document.getElementById(menuid); if(menu) { menu.database.AddDataSource(accountManagerDataSource); menu.database.AddDataSource(folderDataSource); menu.setAttribute('ref', 'msgaccounts:/'); }}// We're going to implement our status feedback for the mail window in JS now.// the following contains the implementation of our status feedback objectfunction nsMsgStatusFeedback(){}nsMsgStatusFeedback.prototype ={ // global variables for status / feedback information.... statusTextFld : null, statusBar : null, throbber : null, stopCmd : null, startTimeoutID : null, stopTimeoutID : null, progressMeterContainer : null, pendingStartRequests : 0, meteorsSpinning : false, myDefaultStatus : null, progressMeterVisible : false, ensureStatusFields : function() { if (!this.statusTextFld ) this.statusTextFld = document.getElementById("statusText"); if (!this.statusBar) this.statusBar = document.getElementById("statusbar-icon"); if(!this.throbber) this.throbber = document.getElementById("navigator-throbber"); if(!this.stopCmd) this.stopCmd = document.getElementById("cmd_stop"); if (!this.progressMeterContainer) this.progressMeterContainer = document.getElementById("statusbar-progresspanel"); }, // nsIXULBrowserWindow implementation setJSStatus : function(status) { if (status.length > 0) this.showStatusString(status); }, setJSDefaultStatus : function(status) { if (status.length > 0) { this.myDefaultStatus = status; this.statusTextFld.label = status; } }, setOverLink : function(link) { this.ensureStatusFields(); this.statusTextFld.label = link; }, QueryInterface : function(iid) { if (iid.equals(Components.interfaces.nsIMsgStatusFeedback) || iid.equals(Components.interfaces.nsIXULBrowserWindow) || iid.equals(Components.interfaces.nsISupports)) return this;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -