!import
1 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 *
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * The Original Code is Mozilla Communicator client code, released
17 * March 31, 1998.
18 *
19 * The Initial Developer of the Original Code is
20 * Netscape Communications Corporation.
21 * Portions created by the Initial Developer are Copyright (C) 1998-1999
22 * the Initial Developer. All Rights Reserved.
23 *
24 * Contributor(s):
25 * Fabian Guisset <hidday@geocities.com>
26 *
27 * Alternatively, the contents of this file may be used under the terms of
28 * either of the GNU General Public License Version 2 or later (the "GPL"),
29 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 * in which case the provisions of the GPL or the LGPL are applicable instead
31 * of those above. If you wish to allow use of your version of this file only
32 * under the terms of either the GPL or the LGPL, and not to allow others to
33 * use your version of this file under the terms of the MPL, indicate your
34 * decision by deleting the provisions above and replace them with the notice
35 * and other provisions required by the GPL or the LGPL. If you do not delete
36 * the provisions above, a recipient may use your version of this file under
37 * the terms of any one of the MPL, the GPL or the LGPL.
38 *
39 * ***** END LICENSE BLOCK ***** */
40
41 const FOLDERS = 1;
42 const MESSAGES = 2;
43 var dialog;
44
onLoad
45 function onLoad()
46 {
47 var arguments = window.arguments[0];
48
49 dialog = {};
50
51 dialog.OKButton = document.documentElement.getButton("accept");
52
53 dialog.nameField = document.getElementById("name");
54 dialog.nameField.focus();
55
56 // call this when OK is pressed
57 dialog.okCallback = arguments.okCallback;
58
59 // pre select the folderPicker, based on what they selected in the folder pane
60 dialog.picker = document.getElementById("msgNewFolderPicker");
61 MsgFolderPickerOnLoad("msgNewFolderPicker");
62
63 // can folders contain both folders and messages?
64 if (arguments.dualUseFolders) {
65 dialog.folderType = FOLDERS | MESSAGES;
66
67 // hide the section when folder contain both folders and messages.
68 var newFolderTypeBox = document.getElementById("newFolderTypeBox");
69 newFolderTypeBox.setAttribute("hidden", "true");
70 } else {
71 // set our folder type by calling the default selected type's oncommand
72 var selectedFolderType = document.getElementById("folderGroup").selectedItem;
73 eval(selectedFolderType.getAttribute("oncommand"));
74 }
75
76 moveToAlertPosition();
77 doEnabling();
78 }
79
onOK
80 function onOK()
81 {
82 var name = dialog.nameField.value;
83 var uri = dialog.picker.getAttribute("uri");
84
85 // do name validity check?
86
87 // make sure name ends in "/" if folder to create can only contain folders
88 if ((dialog.folderType == FOLDERS) && name.charAt(name.length-1) != "/")
89 dialog.okCallback(name + "/", uri);
90 else
91 dialog.okCallback(name, uri);
92
93 return true;
94 }
95
onFoldersOnly
96 function onFoldersOnly()
97 {
98 dialog.folderType = FOLDERS;
99 }
100
onMessagesOnly
101 function onMessagesOnly()
102 {
103 dialog.folderType = MESSAGES;
104 }
105
doEnabling
106 function doEnabling()
107 {
108 if (dialog.nameField.value && dialog.picker.getAttribute("uri")) {
109 if (dialog.OKButton.disabled)
110 dialog.OKButton.disabled = false;
111 } else {
112 if (!dialog.OKButton.disabled)
113 dialog.OKButton.disabled = true;
114 }
115 }