!import
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 *
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
8 *
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
13 *
14 * The Original Code is mozilla.org code.
15 *
16 * The Initial Developer of the Original Code is
17 * Netscape Communications Corporation.
18 * Portions created by the Initial Developer are Copyright (C) 2000
19 * the Initial Developer. All Rights Reserved.
20 *
21 * Contributor(s):
22 * Jean-Francois Ducarroz <ducarroz@netscape.com>
23 * Ben Bucksch <mozilla.BenB@bucksch.org>
24 * Ian Neal <bugzilla@arlen.demon.co.uk>
25 * Žiga Sancin <bisi@pikslar.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 var msgCompSendFormat = Components.interfaces.nsIMsgCompSendFormat;
42 var msgCompConvertible = Components.interfaces.nsIMsgCompConvertible;
43 var param = null;
44
45 /* There are 3 preferences that let you customize the behavior of this dialog
46
47 1. pref("mail.asksendformat.default", 1); //1=plaintext, 2=html, 3=both
48 This defines the default action selected when the dialog opens. It can be overwritten by the preference
49 mail.asksendformat.recommended_as_default
50
51
52 2. pref("mail.asksendformat.recommended_as_default", true);
53 If you set this preference to true and we have a recommended action, this action will be selected by default.
54 In this case, we ignore the preference mail.asksendformat.default
55
56
57 3. pref("mail.asksendformat.display_recommendation", true);
58 When this preference is set to false, the recommended action label will not be displayed next to the action
59 radio button. However, the default action might change to the recommended one if the preference
60 mail.asksendformat.recommended_as_default is set.
61 */
62
63 var defaultAction = msgCompSendFormat.PlainText;
64 var recommended_as_default = true;
65 var display_recommendation = true;
66 var useDefault = false;
67
68 var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService();
69 if (prefs)
70 {
71 prefs = prefs.QueryInterface(Components.interfaces.nsIPrefBranch);
72 if (prefs)
73 {
74 try
75 {
76 defaultAction = prefs.getIntPref("mail.asksendformat.default");
77 useDefault = true;
78 }
79 catch (ex) {}
80
81 try
82 {
83 recommended_as_default = prefs.getBoolPref("mail.asksendformat.recommended_as_default");
84 }
85 catch (ex) {}
86
87 try
88 {
89 display_recommendation = prefs.getBoolPref("mail.asksendformat.display_recommendation");
90 }
91 catch (ex) {}
92 }
93 }
94
Startup
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
95 function Startup()
96 {
97 if (window.arguments && window.arguments[0])
98 {
99 var askSendFormatStringBundle = document.getElementById("askSendFormatStringBundle");
100 param = window.arguments[0];
101 // If the user hits the close box, we will abort.
102 param.abort = true;
103 if (param.action)
104 {
105 // Set the question label
106 var mailSendFormatExplanation = document.getElementById("mailSendFormatExplanation");
107 var icon = document.getElementById("convertDefault");
108 switch (param.convertible)
109 {
110 case msgCompConvertible.Plain:
111 // We shouldn't be here at all
112 mailSendFormatExplanation.textContent = askSendFormatStringBundle.getString("convertibleYes");
113 // No icon
114 break;
115 case msgCompConvertible.Yes:
116 mailSendFormatExplanation.textContent = askSendFormatStringBundle.getString("convertibleYes");
117 icon.setAttribute("id", "convertYes");
118 break;
119 case msgCompConvertible.Altering:
120 mailSendFormatExplanation.textContent = askSendFormatStringBundle.getString("convertibleAltering");
121 icon.setAttribute("id", "convertAltering");
122 break;
123 case msgCompConvertible.No:
124 mailSendFormatExplanation.textContent = askSendFormatStringBundle.getString("convertibleNo");
125 icon.setAttribute("id", "convertNo");
126 break;
127 }
128
129 // Set the default radio array value and recommendation
130 var group = document.getElementById("mailDefaultHTMLAction");
131 var radio;
132 var radioButtons = group.getElementsByTagName("radio");
133 var haveRecommendation = false;
134 var format = (useDefault) ? defaultAction : param.action;
135
136 switch (format)
137 {
138 case msgCompSendFormat.AskUser:
139 // haveRecommendation = false;
140 break;
141 case msgCompSendFormat.PlainText:
142 radio = radioButtons[1];
143 haveRecommendation = true;
144 break;
145 case msgCompSendFormat.Both:
146 radio = radioButtons[0];
147 haveRecommendation = true;
148 break;
149 case msgCompSendFormat.HTML:
150 radio = radioButtons[2];
151 haveRecommendation = true;
152 break;
153 }
154
155 if (haveRecommendation)
156 {
157 if (display_recommendation)
158 radio.label += " " + askSendFormatStringBundle.getString("recommended");
159
160 if (recommended_as_default)
161 group.value = format;
162 }
163
164 if (!haveRecommendation || !recommended_as_default)
165 group.value = defaultAction;
166 }
167 }
168 else
169 {
170 dump("error, no return object registered\n");
171 }
172 }
173
Send
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
174 function Send()
175 {
176 if (param)
177 {
178 // param.action should be an integer for when it is returned to MsgComposeCommands.js
179 param.action = parseInt(document.getElementById("mailDefaultHTMLAction").value);
180 param.abort = false;
181 }
182 return true;
183 }
184
Cancel
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
185 function Cancel()
186 {
187 if (param)
188 param.abort = true;
189 return true;
190 }