1 | /* ***** BEGIN LICENSE BLOCK ***** |
---|
2 | This program is free software; you can redistribute it and/or modify |
---|
3 | it under the terms of the GNU General Public License as published by |
---|
4 | the Free Software Foundation; either version 2 of the License, or |
---|
5 | (at your option) any later version. |
---|
6 | |
---|
7 | This program is distributed in the hope that it will be useful, |
---|
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
10 | GNU General Public License for more details. |
---|
11 | |
---|
12 | You should have received a copy of the GNU General Public License |
---|
13 | along with this program; if not, write to the Free Software |
---|
14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
15 | |
---|
16 | The Original Code is the Virtual Identity Extension. |
---|
17 | |
---|
18 | The Initial Developer of the Original Code is Rene Ejury. |
---|
19 | Portions created by the Initial Developer are Copyright (C) 2007 |
---|
20 | the Initial Developer. All Rights Reserved. |
---|
21 | |
---|
22 | Contributor(s): |
---|
23 | * ***** END LICENSE BLOCK ***** */ |
---|
24 | |
---|
25 | var EXPORTED_SYMBOLS = []; |
---|
26 | |
---|
27 | const Ci = Components.interfaces; |
---|
28 | const Cc = Components.classes; |
---|
29 | const Cu = Components.utils; |
---|
30 | |
---|
31 | |
---|
32 | Cu.import("resource://v_identity/vI_identityDataExtras.js"); |
---|
33 | Cu.import("resource://v_identity/vI_log.js"); |
---|
34 | let Log = setupLogging("virtualIdentity.identityDataExtras.messageFormat"); |
---|
35 | |
---|
36 | function identityDataExtrasObject_messageFormat(currentWindow) { |
---|
37 | this.currentWindow = currentWindow; |
---|
38 | this.field = "msgFormat"; // description of the option |
---|
39 | this.option = "storageExtras_messageFormat"; // option string to get preference settings |
---|
40 | } |
---|
41 | identityDataExtrasObject_messageFormat.prototype = { |
---|
42 | __proto__: identityDataExtrasObject.prototype, |
---|
43 | |
---|
44 | // functions to get nicely formatted output |
---|
45 | get valueHtml() { |
---|
46 | return this.valueNice; |
---|
47 | }, |
---|
48 | get valueNice() { |
---|
49 | return this.value ? this.currentWindow.document.getElementById(this.value).label : ""; |
---|
50 | }, |
---|
51 | |
---|
52 | setValueToEnvironment_msgCompose: function () { |
---|
53 | if (this.value == null) |
---|
54 | return |
---|
55 | this.currentWindow.document.getElementById("outputFormatMenu").removeAttribute("hidden"); |
---|
56 | this.currentWindow.document.getElementById(this.value).setAttribute("checked", "true"); |
---|
57 | this.currentWindow.OutputFormatMenuSelect(this.currentWindow.document.getElementById(this.value)) |
---|
58 | }, |
---|
59 | |
---|
60 | setValueToEnvironment_dataEditor: function () { |
---|
61 | if (this.value != null) { |
---|
62 | this.currentWindow.document.getElementById("outputFormatMenu").selectedItem = this.currentWindow.document.getElementById(this.value); |
---|
63 | this.currentWindow.document.getElementById("vI_" + this.option + "_store").setAttribute("checked", "true"); |
---|
64 | } |
---|
65 | this.currentWindow.document.getElementById("vI_" + this.option + "_store").doCommand(); |
---|
66 | }, |
---|
67 | |
---|
68 | getValueFromEnvironment_msgCompose: function () { |
---|
69 | const nsIMsgCompSendFormat = Components.interfaces.nsIMsgCompSendFormat; |
---|
70 | switch (this.currentWindow.gSendFormat) { |
---|
71 | case nsIMsgCompSendFormat.AskUser: |
---|
72 | this.value = "format_auto"; |
---|
73 | break; |
---|
74 | case nsIMsgCompSendFormat.PlainText: |
---|
75 | this.value = "format_plain"; |
---|
76 | break; |
---|
77 | case nsIMsgCompSendFormat.HTML: |
---|
78 | this.value = "format_html"; |
---|
79 | break; |
---|
80 | case nsIMsgCompSendFormat.Both: |
---|
81 | this.value = "format_both"; |
---|
82 | break; |
---|
83 | } |
---|
84 | }, |
---|
85 | |
---|
86 | getValueFromEnvironment_dataEditor: function () { |
---|
87 | if (this.currentWindow.document.getElementById("vI_" + this.option + "_store").getAttribute("checked") == "true") |
---|
88 | this.value = this.currentWindow.document.getElementById("outputFormatMenu").selectedItem.id |
---|
89 | else |
---|
90 | this.value = null; |
---|
91 | } |
---|
92 | } |
---|
93 | registerIdExtrasObject(identityDataExtrasObject_messageFormat); |
---|