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

  1. /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  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 Communicator client code, released
  14.  *  March 31, 1998.
  15.  *
  16.  *  The Initial Developer of the Original Code is Netscape
  17.  *  Communications Corporation. Portions created by Netscape are
  18.  *  Copyright (C) 1998-1999 Netscape Communications Corporation. All
  19.  *  Rights Reserved.
  20.  *
  21.  *  Contributor(s):
  22.  *    Fabian Guisset <hidday@geocities.com>
  23.  */
  24.  
  25. const FOLDERS = 1;
  26. const MESSAGES = 2;
  27. var dialog;
  28.  
  29. function onLoad()
  30. {
  31.   var arguments = window.arguments[0];
  32.  
  33.   dialog = {};
  34.  
  35.   dialog.OKButton = document.getElementById("ok");
  36.  
  37.   dialog.nameField = document.getElementById("name");
  38.   dialog.nameField.focus();
  39.  
  40.   // call this when OK is pressed
  41.   dialog.okCallback = arguments.okCallback;
  42.  
  43.   // pre select the folderPicker, based on what they selected in the folder pane
  44.   dialog.picker = document.getElementById("msgNewFolderPicker");
  45.   MsgFolderPickerOnLoad("msgNewFolderPicker");
  46.  
  47.   // can folders contain both folders and messages?
  48.   if (arguments.dualUseFolders) {
  49.     dialog.folderType = FOLDERS | MESSAGES;
  50.   } else {
  51.  
  52.     // show the section which allows us to select the folder type to create
  53.     var newFolderTypeBox = document.getElementById("newFolderTypeBox");
  54.     newFolderTypeBox.removeAttribute("hidden");
  55.  
  56.     // set our folder type by calling the default selected type's oncommand
  57.     var selectedFolderType = document.getElementById("folderGroup").selectedItem;
  58.     eval(selectedFolderType.getAttribute("oncommand"));
  59.   }
  60.  
  61.   moveToAlertPosition();
  62.   doEnabling();
  63.   doSetOKCancel(onOK, onCancel);
  64. }
  65.  
  66. function onOK()
  67. {
  68.   var name = dialog.nameField.value;
  69.   var uri = dialog.picker.getAttribute("uri");
  70.  
  71.   // do name validity check?
  72.  
  73.   // make sure name ends in  "/" if folder to create can only contain folders
  74.   if ((dialog.folderType == FOLDERS) && name.charAt(name.length-1) != "/")
  75.     dialog.okCallback(name + "/", uri);
  76.   else
  77.     dialog.okCallback(name, uri);
  78.  
  79.   return true;
  80. }
  81.  
  82. function onCancel()
  83. {
  84.   // close the window
  85.   return true;
  86. }
  87.  
  88. function onFoldersOnly()
  89. {
  90.   dialog.folderType = FOLDERS;
  91. }
  92.  
  93. function onMessagesOnly()
  94. {
  95.   dialog.folderType = MESSAGES;
  96. }
  97.  
  98. function doEnabling()
  99. {
  100.   if (dialog.nameField.value && dialog.picker.getAttribute("uri")) {
  101.     if (dialog.OKButton.disabled)
  102.       dialog.OKButton.disabled = false;
  103.   } else {
  104.     if (!dialog.OKButton.disabled)
  105.       dialog.OKButton.disabled = true;
  106.   }
  107. }
  108.  
  109.