home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 January / 01_02.iso / software / netscape62win / mail.xpi / bin / chrome / messenger.jar / content / messenger / am-help.js < prev    next >
Text File  |  2001-07-06  |  4KB  |  98 lines

  1. /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  * The contents of this file are subject to the Netscape Public
  3.  * License Version 1.1 (the "License"); you may not use this file
  4.  * except in compliance with the License. You may obtain a copy of
  5.  * the License at http://www.mozilla.org/NPL/
  6.  * 
  7.  * Software distributed under the License is distributed on an "AS
  8.  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  9.  * implied. See the License for the specific language governing
  10.  * rights and limitations under the License.
  11.  * 
  12.  * The Original Code is Mozilla Communicator client code, released
  13.  * March 31, 1998.
  14.  * 
  15.  * The Initial Developer of the Original Code is Netscape
  16.  * Communications Corporation. Portions created by Netscape are
  17.  * Copyright (C) 1998-1999 Netscape Communications Corporation. All
  18.  * Rights Reserved.
  19.  */
  20.  
  21. /**
  22.  * Global help XUL document from which the URI corresponding to 
  23.  * the help tag passed is extracted.
  24.  */
  25. var gHelpURL = 'chrome://help/content/help.xul';
  26.  
  27. /**
  28.  * Key value pairs to derive the tag based on the page loaded.
  29.  * Each key is the page loaded when user clicks on one of the items on
  30.  * the accounttree of the AccountManager window.
  31.  * Value is a tag that is preset which will be used to display
  32.  * context sensitive help. 
  33.  */
  34. var pageTagPairs = {
  35.   "chrome://messenger/content/am-main.xul": "?mail_account_identity",
  36.   "chrome://messenger/content/am-server.xul": "?mail",
  37.   "chrome://messenger/content/am-copies.xul": "?mail_copies",
  38.   "chrome://messenger/content/am-addressing.xul": "?mail_addressing_settings",
  39.   "chrome://messenger/content/am-offline.xul": "?mail",
  40.   "chrome://messenger/content/am-smtp.xul": "?mail_smtp"
  41.  
  42. function doHelpButton() 
  43. {
  44.   // Get the URI of the page loaded in the AccountManager's content frame.
  45.   var pageSourceURI = document.getElementById("contentFrame").getAttribute("src");
  46.   // Get the help tag corresponding to the page loaded.
  47.   var helpTag = pageTagPairs[pageSourceURI];
  48.  
  49.   // If the help tag is generic, check if there is a need to set tags per server type
  50.   if (helpTag == "?mail") {
  51.     // Get server type, as we may need to set help tags per server type for some pages
  52.     var serverType = GetServerType();
  53.   
  54.     /**
  55.      * Check the page to be loaded. Following pages needed to be presented with the 
  56.      * help content that is based on server type. For any pages with such requirement
  57.      * do add comments here about the page and a new case statement for pageSourceURI
  58.      * switch.
  59.      * - server settings ("chrome://messenger/content/am-server.xul")
  60.      * - offline/diskspace settings ("chrome://messenger/content/am-offline.xul")
  61.      */ 
  62.     switch (pageSourceURI) {
  63.       case "chrome://messenger/content/am-server.xul":
  64.         helpTag = "?mail_server_" + serverType;
  65.         break;
  66.  
  67.       case "chrome://messenger/content/am-offline.xul":
  68.         helpTag = "?mail_offline_" + serverType;
  69.         break;
  70.  
  71.       default :
  72.         break;
  73.     }
  74.   }
  75.  
  76.   if ( helpTag ) 
  77.       openHelp(gHelpURL + helpTag);  
  78.   else
  79.     openHelp(gHelpURL + '?mail'); 
  80. }
  81.  
  82. /**
  83.  * Get server type of the seleted item
  84.  */
  85. function GetServerType()
  86. {
  87.   var serverType = null;
  88.   var idStruct = getServerIdAndPageIdFromTree(accounttree);
  89.   if (idStruct) {
  90.     var account = getAccountFromServerId(idStruct.serverId);
  91.     if (account) {
  92.       serverType = account.incomingServer.type;
  93.     }
  94.   }
  95.   return serverType;
  96. }
  97.