1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
<?xml version="1.0"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/.
-->
<bindings id="charsetListBinding"
xmlns="http://www.mozilla.org/xbl"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="charsetpicker"
extends="chrome://global/content/bindings/menulist.xml#menulist">
<implementation>
<constructor><![CDATA[
let charsetValues = "";
if (this.getAttribute("subset") == "sending")
charsetValues = ["UTF-8", "EUC-KR", "gbk", "gb18030", "ISO-2022-JP",
"ISO-8859-1", "ISO-8859-7", "windows-1252"];
else if (!this.getAttribute("subset")
|| this.getAttribute("subset") == "viewing")
charsetValues = ["UTF-8", "Big5", "EUC-KR", "gbk", "ISO-2022-JP",
"ISO-8859-1", "ISO-8859-2", "ISO-8859-7",
"windows-874", "windows-1250", "windows-1251",
"windows-1252", "windows-1255", "windows-1256",
"windows-1257", "windows-1258"];
Components.utils.import("resource://gre/modules/Services.jsm");
let charsetBundle = Services.strings.createBundle(
"chrome://messenger/locale/charsetTitles.properties");
let aMenuList = this;
let menuLabels = [];
charsetValues.forEach(function(item) {
let strCharset = charsetBundle.GetStringFromName(
item.toLowerCase() + ".title");
menuLabels.push({label: strCharset, value: item});
});
menuLabels.sort(function(a, b) {
if (a.value == "UTF-8" || a.label < b.label)
return -1;
else if (b.value == "UTF-8" || a.label > b.label)
return 1;
return 0;
});
menuLabels.forEach(function(item) {
aMenuList.appendItem(item.label, item.value);
});
// Selecting appropiate menu item corresponding to preference stored
// value.
if (this.hasAttribute("preference")) {
const Ci = Components.interfaces;
let preference = Services.prefs.getComplexValue(
this.getAttribute("preference"), Ci.nsIPrefLocalizedString);
this.value = preference.data;
}
]]></constructor>
</implementation>
</binding>
</bindings>
|