!import
1 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is Mozilla Communicator client code, released
16 * March 31, 1998.
17 *
18 * The Initial Developer of the Original Code is
19 * Netscape Communications Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 2002
21 * the Initial Developer. All Rights Reserved.
22 *
23 * Contributor(s):
24 * Scott MacGregor <mscott@netscape.com>
25 *
26 * Alternatively, the contents of this file may be used under the terms of
27 * either of the GNU General Public License Version 2 or later (the "GPL"),
28 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
37 *
38 * ***** END LICENSE BLOCK ***** */
39
40 var nsMsgSearchScope = Components.interfaces.nsMsgSearchScope;
41 var gMailView = null;
42
43 var dialog;
44
mailViewOnLoad
45 function mailViewOnLoad()
46 {
47 initializeSearchWidgets();
48 initializeMailViewOverrides();
49 dialog = {};
50
51 if ("arguments" in window && window.arguments[0])
52 {
53 var args = window.arguments[0];
54 if ("mailView" in args)
55 gMailView = window.arguments[0].mailView;
56 if ("onOkCallback" in args)
57 dialog.okCallback = window.arguments[0].onOkCallback;
58 }
59
60 dialog.OKButton = document.documentElement.getButton("accept");
61 dialog.nameField = document.getElementById("name");
62 dialog.nameField.focus();
63
64 setSearchScope(nsMsgSearchScope.offlineMail);
65
66 if (gMailView)
67 {
68 dialog.nameField.value = gMailView.prettyName;
69 initializeSearchRows(nsMsgSearchScope.offlineMail, gMailView.searchTerms);
70 }
71 else
72 onMore(null);
73
74 doEnabling();
75 }
76
mailViewOnUnLoad
77 function mailViewOnUnLoad()
78 {
79
80 }
81
onOK
82 function onOK()
83 {
84 var mailViewList = Components.classes["@mozilla.org/messenger/mailviewlist;1"].getService(Components.interfaces.nsIMsgMailViewList);
85
86 // reflect the search widgets back into the search session
87 var newMailView = null;
88 if (gMailView)
89 {
90 saveSearchTerms(gMailView.searchTerms, gMailView);
91 // if the name of the view has been changed...
92 if (gMailView.prettyName != dialog.nameField.value)
93 gMailView.mailViewName = dialog.nameField.value;
94 }
95 else
96 {
97 // otherwise, create a new mail view
98 newMailView = mailViewList.createMailView();
99
100 saveSearchTerms(newMailView.searchTerms, newMailView);
101 newMailView.mailViewName = dialog.nameField.value;
102 // now add the mail view to our mail view list
103 mailViewList.addMailView(newMailView);
104 }
105
106 mailViewList.save();
107
108 if (dialog.okCallback)
109 dialog.okCallback(gMailView ? gMailView : newMailView);
110
111 return true;
112 }
113
initializeMailViewOverrides
114 function initializeMailViewOverrides()
115 {
116 // replace some text with something we want. Need to add some ids to searchOverlay.js
117 //var orButton = document.getElementById('or');
118 //orButton.setAttribute('label', 'Any of the following');
119 //var andButton = document.getElementById('and');
120 //andButton.setAttribute('label', 'All of the following');
121 // matchAll doesn't make sense for views, since views are a single folder
122 hideMatchAllItem();
123
124 }
125
126 function UpdateAfterCustomHeaderChange()
127 {
128 updateSearchAttributes();
129 }
130
doEnabling
131 function doEnabling()
132 {
133 if (dialog.nameField.value)
134 {
135 if (dialog.OKButton.disabled)
136 dialog.OKButton.disabled = false;
137 } else
138 {
139 if (!dialog.OKButton.disabled)
140 dialog.OKButton.disabled = true;
141 }
142 }
143
onEnterInSearchTerm
144 function onEnterInSearchTerm()
145 {
146 // no-op for us...
147 }
148
doHelpButton
149 function doHelpButton()
150 {
151 openHelp("message-views-create-new");
152 }