home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / mozil06.zip / bin / chrome / messenger.jar / content / messenger / msgFolderPickerOverlay.js < prev    next >
Text File  |  2001-02-14  |  3KB  |  102 lines

  1. /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public
  4.  * License Version 1.1 (the "License"); you may not use this file
  5.  * except in compliance with the License. You may obtain a copy of
  6.  * the License at http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the License is distributed on an "AS
  9.  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  10.  * implied. See the License for the specific language governing
  11.  * rights and limitations under the License.
  12.  *
  13.  * The Original Code is mozilla.org code.
  14.  *
  15.  * The Initial Developer of the Original Code is Netscape
  16.  * Communications Corporation.  Portions created by Netscape are
  17.  * Copyright (C) 1998 Netscape Communications Corporation. All
  18.  * Rights Reserved.
  19.  *
  20.  * Contributor(s):
  21.  * Alec Flett <alecf@netscape.com>
  22.  */
  23.  
  24. var pickerBundle = srGetStrBundle("chrome://messenger/locale/messenger.properties");
  25.  
  26.  
  27. // call this from dialog onload() to set the menu item to the correct value
  28. function MsgFolderPickerOnLoad(pickerID)
  29. {
  30.     //dump("in MsgFolderPickerOnLoad()\n");
  31.     var uri = null;
  32.     try { 
  33.         uri = window.arguments[0].preselectedURI;
  34.     }
  35.     catch (ex) {
  36.         uri = null;
  37.     }
  38.  
  39.     if (uri) {
  40.         //dump("on loading, set titled button to " + uri + "\n");
  41.  
  42.         // verify that the value we are attempting to
  43.         // pre-flight the menu with is valid for this
  44.         // picker type
  45.         var msgfolder = GetMsgFolderFromUri(uri);
  46.             if (!msgfolder) return; 
  47.         
  48.         var verifyFunction = null;
  49.  
  50.         switch (pickerID) {
  51.             case "msgNewFolderPicker":
  52.                 verifyFunction = msgfolder.canCreateSubfolders;
  53.                 break;
  54.             case "msgRenameFolderPicker":
  55.                 verifyFunction = msgfolder.canRename;
  56.                 break;
  57.             default:
  58.                 verifyFunction = msgfolder.canFileMessages;
  59.                 break;
  60.         }
  61.  
  62.         if (verifyFunction) {
  63.             SetFolderPicker(uri,pickerID);
  64.         }
  65.     }
  66. }
  67.  
  68. function PickedMsgFolder(selection,pickerID)
  69. {
  70.     var selectedUri = selection.getAttribute('id');
  71.     SetFolderPicker(selectedUri,pickerID);
  72. }     
  73.  
  74. function SetFolderPicker(uri,pickerID)
  75. {
  76.     var picker = document.getElementById(pickerID);
  77.     var msgfolder = GetMsgFolderFromUri(uri);
  78.  
  79.     if (!msgfolder) return;
  80.  
  81.     var selectedValue = null;
  82.  
  83.     if (msgfolder.isServer)
  84.         selectedValue = msgfolder.name;
  85.     else {
  86.         if (msgfolder.server)
  87.             serverName = msgfolder.server.prettyName;
  88.         else {
  89.             dump("Cant' find server for " + uri + "\n");
  90.             serverName = "???";
  91.         }
  92.  
  93.         selectedValue =
  94.             pickerBundle.formatStringFromName("verboseFolderFormat",
  95.                                               [ msgfolder.name,
  96.                                               serverName ], 2);
  97.     }
  98.  
  99.     picker.setAttribute("value",selectedValue);
  100.     picker.setAttribute("uri",uri);
  101. }
  102.