зеркало из https://github.com/mozilla/pjs.git
Bug #315057 --> Display - Fonts tab: The pull-down menu of Character Encodings doesn't work.
build the menu popup by hand instead of using the xul template builder (which doesn't work with dynamic overlays) sr=bienvenu
This commit is contained in:
Родитель
9258492ae5
Коммит
09e8cdbd29
|
@ -44,6 +44,12 @@ var gDisplayPane = {
|
|||
var preference = document.getElementById("mail.preferences.display.selectedTabIndex");
|
||||
if (preference.value)
|
||||
document.getElementById("displayPrefs").selectedIndex = preference.value;
|
||||
|
||||
// build the charset menu list. We do this by hand instead of using the xul template
|
||||
// builder because of Bug #285076,
|
||||
this.createCharsetMenus(document.getElementById("viewDefaultCharset-menupopup"), "NC:DecodersRoot",
|
||||
document.getElementById('mailnews.view_default_charset').value);
|
||||
|
||||
this.mInitialized = true;
|
||||
},
|
||||
|
||||
|
@ -74,6 +80,44 @@ var gDisplayPane = {
|
|||
{
|
||||
document.documentElement.openSubDialog("chrome://messenger/content/preferences/fonts.xul", "", null);
|
||||
},
|
||||
|
||||
addMenuItem: function(aMenuPopup, aLabel, aValue)
|
||||
{
|
||||
var menuItem = document.createElement('menuitem');
|
||||
menuItem.setAttribute('label', aLabel);
|
||||
menuItem.setAttribute('value', aValue);
|
||||
aMenuPopup.appendChild(menuItem);
|
||||
},
|
||||
|
||||
readRDFString: function(aDS,aRes,aProp)
|
||||
{
|
||||
var n = aDS.GetTarget(aRes, aProp, true);
|
||||
return (n) ? n.QueryInterface(Components.interfaces.nsIRDFLiteral).Value : "";
|
||||
},
|
||||
|
||||
createCharsetMenus: function(aMenuPopup, aRoot, aPreferenceValue)
|
||||
{
|
||||
var rdfService = Components.classes["@mozilla.org/rdf/rdf-service;1"]
|
||||
.getService(Components.interfaces.nsIRDFService);
|
||||
var kNC_Root = rdfService.GetResource(aRoot);
|
||||
var kNC_Name = rdfService.GetResource("http://home.netscape.com/NC-rdf#Name");
|
||||
|
||||
var rdfDataSource = rdfService.GetDataSource("rdf:charset-menu");
|
||||
var rdfContainer = Components.classes["@mozilla.org/rdf/container;1"].getService(Components.interfaces.nsIRDFContainer);
|
||||
rdfContainer.Init(rdfDataSource, kNC_Root);
|
||||
|
||||
var charset;
|
||||
var availableCharsets = rdfContainer.GetElements();
|
||||
|
||||
for (var i = 0; i < rdfContainer.GetCount(); i++)
|
||||
{
|
||||
charset = availableCharsets.getNext().QueryInterface(Components.interfaces.nsIRDFResource);
|
||||
|
||||
this.addMenuItem(aMenuPopup, this.readRDFString(rdfDataSource, charset, kNC_Name), charset.Value);
|
||||
if (charset.Value == aPreferenceValue)
|
||||
aMenuPopup.parentNode.value = charset.Value;
|
||||
}
|
||||
},
|
||||
|
||||
mCharsetMenuInitialized: false,
|
||||
readDefaultCharset: function()
|
||||
|
@ -83,6 +127,10 @@ var gDisplayPane = {
|
|||
Components.classes["@mozilla.org/observer-service;1"]
|
||||
.getService(Components.interfaces.nsIObserverService)
|
||||
.notifyObservers(null, "charsetmenu-selected", "mailedit");
|
||||
// build the charset menu list. We do this by hand instead of using the xul template
|
||||
// builder because of Bug #285076,
|
||||
this.createCharsetMenus(document.getElementById("sendDefaultCharset-menupopup"), "NC:MaileditCharsetMenuRoot",
|
||||
document.getElementById('mailnews.send_default_charset').value);
|
||||
this.mCharsetMenuInitialized = true;
|
||||
}
|
||||
return undefined;
|
||||
|
|
|
@ -229,26 +229,19 @@
|
|||
<row align="center" class="indent">
|
||||
<label control="sendDefaultCharsetList"
|
||||
value="&sendDefaultCharset.label;" accesskey="&sendDefaultCharset.accesskey;"/>
|
||||
<menulist id="sendDefaultCharsetList" ref="NC:MaileditCharsetMenuRoot" datasources="rdf:charset-menu"
|
||||
preference="mailnews.send_default_charset" onsyncfrompreference="return gDisplayPane.readDefaultCharset();">
|
||||
<template>
|
||||
<menupopup>
|
||||
<menuitem label="rdf:http://home.netscape.com/NC-rdf#Name" value="..." uri="..."/>
|
||||
</menupopup>
|
||||
</template>
|
||||
|
||||
<menulist id="sendDefaultCharsetList" flex="1" preference="mailnews.send_default_charset" onsyncfrompreference="return gDisplayPane.readDefaultCharset();">
|
||||
<menupopup id="sendDefaultCharset-menupopup">
|
||||
</menupopup>
|
||||
</menulist>
|
||||
</row>
|
||||
|
||||
<row align="center" class="indent">
|
||||
<label control="viewDefaultCharsetList"
|
||||
value="&viewDefaultCharsetList.label;" accesskey="&viewDefaultCharsetList.accesskey;"/>
|
||||
<menulist id="viewDefaultCharsetList" ref="NC:DecodersRoot" datasources="rdf:charset-menu"
|
||||
preference="mailnews.view_default_charset">
|
||||
<template>
|
||||
<menupopup>
|
||||
<menuitem label="rdf:http://home.netscape.com/NC-rdf#Name" value="..." uri="..."/>
|
||||
</menupopup>
|
||||
</template>
|
||||
<menulist id="viewDefaultCharsetList" preference="mailnews.view_default_charset">
|
||||
<menupopup id="viewDefaultCharset-menupopup">
|
||||
</menupopup>
|
||||
</menulist>
|
||||
</row>
|
||||
</rows>
|
||||
|
|
Загрузка…
Ссылка в новой задаче