Bug 1524508 - [de-xbl] convert charsetpicker binding to customized built-in based on menulist. r=pmorris
--HG-- rename : mailnews/base/content/charsetList.xml => mailnews/base/content/menulist-charsetpicker.js
This commit is contained in:
Родитель
e4f355ad26
Коммит
f19c904d38
|
@ -1,11 +1,9 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
<!-- 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/. -->
|
||||
- file, You can obtain one at https://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin/"?>
|
||||
<?xml-stylesheet href="chrome://messenger/content/charsetList.css"?>
|
||||
<?xml-stylesheet href="chrome://messenger/skin/preferences/preferences.css"?>
|
||||
|
||||
<!DOCTYPE dialog [
|
||||
|
@ -32,6 +30,7 @@
|
|||
<script type="application/javascript" src="chrome://global/content/preferencesBindings.js"/>
|
||||
<script type="application/javascript" src="chrome://mozapps/content/preferences/fontbuilder.js"/>
|
||||
<script type="application/javascript" src="chrome://messenger/content/preferences/fonts.js"/>
|
||||
<script type="application/javascript" src="chrome://messenger/content/menulist-charsetpicker.js"/>
|
||||
<linkset>
|
||||
<html:link rel="localization" href="messenger/preferences/fonts.ftl"/>
|
||||
</linkset>
|
||||
|
@ -284,7 +283,7 @@
|
|||
<label control="sendDefaultCharsetList"
|
||||
value="&sendDefaultCharset.label;"
|
||||
accesskey="&sendDefaultCharset.accesskey;"/>
|
||||
<menulist id="sendDefaultCharsetList" type="charset"
|
||||
<menulist is="menulist-charsetpicker" id="sendDefaultCharsetList"
|
||||
subset="sending"
|
||||
preference="mailnews.send_default_charset"/>
|
||||
</row>
|
||||
|
@ -293,7 +292,7 @@
|
|||
<label control="viewDefaultCharsetList"
|
||||
value="&viewDefaultCharsetList.label;"
|
||||
accesskey="&viewDefaultCharsetList.accesskey;"/>
|
||||
<menulist id="viewDefaultCharsetList" type="charset"
|
||||
<menulist is="menulist-charsetpicker" id="viewDefaultCharsetList"
|
||||
subset="viewing"
|
||||
preference="mailnews.view_default_charset"/>
|
||||
</row>
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
|
||||
|
||||
menulist[type="charset"] {
|
||||
-moz-binding: url("chrome://messenger/content/charsetList.xml#charsetpicker");
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
<?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://messenger/content/menulist.xml#xbl-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"];
|
||||
|
||||
const {Services} = ChromeUtils.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 appropriate menu item corresponding to preference stored
|
||||
// value.
|
||||
if (this.hasAttribute("preference")) {
|
||||
let preference = Services.prefs.getComplexValue(
|
||||
this.getAttribute("preference"), Ci.nsIPrefLocalizedString);
|
||||
this.value = preference.data;
|
||||
}
|
||||
]]></constructor>
|
||||
</implementation>
|
||||
</binding>
|
||||
</bindings>
|
|
@ -1,13 +1,10 @@
|
|||
<?xml version="1.0"?> <!-- -*- Mode: SGML; indent-tabs-mode: nil; -*- -->
|
||||
<!--
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
<!-- 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/. -->
|
||||
- file, You can obtain one at https://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://messenger/skin/preferences/preferences.css" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://messenger/content/charsetList.css" type="text/css"?>
|
||||
|
||||
<!DOCTYPE dialog SYSTEM "chrome://messenger/locale/folderProps.dtd">
|
||||
|
||||
|
@ -24,12 +21,7 @@
|
|||
<script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
|
||||
<script type="application/javascript" src="chrome://messenger/content/retention.js"/>
|
||||
<script type="application/javascript" src="chrome://messenger/content/folderProps.js"/>
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
Services.obs.notifyObservers(null, "charsetmenu-selected", "other");
|
||||
]]>
|
||||
</script>
|
||||
<script type="application/javascript" src="chrome://messenger/content/menulist-charsetpicker.js"/>
|
||||
|
||||
<tabbox id="folderPropTabBox">
|
||||
<tabs id="folderPropTabs">
|
||||
|
@ -75,7 +67,7 @@
|
|||
<label value="&folderCharsetFallback2.label;"
|
||||
accesskey="&folderCharsetFallback2.accesskey;"
|
||||
control="folderCharsetList"/>
|
||||
<menulist id="folderCharsetList" type="charset"/>
|
||||
<menulist is="menulist-charsetpicker" id="folderCharsetList" subset="viewing"/>
|
||||
</hbox>
|
||||
<checkbox class="indent" id="folderCharsetOverride"
|
||||
label="&folderCharsetEnforce2.label;"
|
||||
|
|
|
@ -0,0 +1,104 @@
|
|||
/* 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 https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
customElements.whenDefined("menulist").then(() => {
|
||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
/**
|
||||
* MozMenulistCharsetpicker is a menulist widget that is automatically
|
||||
* populated with charset selections.
|
||||
* - Setting subset="sending" will show the values applicable for sending
|
||||
* - Setting subset="viewing" will show the values applicable for viewing
|
||||
* - Setting preference="<name>" will set the selected value to that of the named preference value
|
||||
* @extends {MozMenuList}
|
||||
*/
|
||||
class MozMenulistCharsetpicker extends customElements.get("menulist") {
|
||||
static get observedAttributes() {
|
||||
return ["subset", "preference"];
|
||||
}
|
||||
|
||||
connectedCallback() {
|
||||
super.connectedCallback();
|
||||
if (this.delayConnectedCallback()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.menupopup) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._setupCharsets();
|
||||
this._setupSelectedValueFromPref();
|
||||
}
|
||||
|
||||
_setupCharsets() {
|
||||
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") == "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",
|
||||
];
|
||||
}
|
||||
|
||||
let charsetBundle = Services.strings.createBundle(
|
||||
"chrome://messenger/locale/charsetTitles.properties");
|
||||
let menuLabels = charsetValues.map((item) => {
|
||||
let strCharset = charsetBundle.GetStringFromName(
|
||||
item.toLowerCase() + ".title");
|
||||
return { label: strCharset, value: item };
|
||||
});
|
||||
|
||||
menuLabels.sort((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((item) => {
|
||||
this.appendItem(item.label, item.value);
|
||||
});
|
||||
}
|
||||
|
||||
_setupSelectedValueFromPref() {
|
||||
// Set appropriate selected menu item based on preference value.
|
||||
if (this.hasAttribute("preference")) {
|
||||
let preference = Services.prefs.getComplexValue(
|
||||
this.getAttribute("preference"), Ci.nsIPrefLocalizedString);
|
||||
this.value = preference.data;
|
||||
}
|
||||
}
|
||||
|
||||
attributeChangedCallback() {
|
||||
super.attributeChangedCallback();
|
||||
if (!this.isConnectedAndReady) {
|
||||
return;
|
||||
}
|
||||
this._updateAttributes();
|
||||
}
|
||||
|
||||
_updateAttributes() {
|
||||
this.removeAllItems();
|
||||
this._setupCharsets();
|
||||
this._setupSelectedValueFromPref();
|
||||
}
|
||||
}
|
||||
customElements.define("menulist-charsetpicker", MozMenulistCharsetpicker, { extends: "menulist" });
|
||||
});
|
||||
|
||||
// The menulist CE is defined lazily. Create one now to get menulist defined,
|
||||
// allowing us to inherit from it.
|
||||
if (!customElements.get("menulist")) {
|
||||
delete document.createElement("menulist");
|
||||
}
|
|
@ -112,8 +112,6 @@ function onPreInit(account, accountValues)
|
|||
var type = parent.getAccountValue(account, accountValues, "server", "type", null, false);
|
||||
hideShowControls(type);
|
||||
|
||||
Services.obs.notifyObservers(null, "charsetmenu-selected", "other");
|
||||
|
||||
gServer = account.incomingServer;
|
||||
|
||||
if(!account.incomingServer.canEmptyTrashOnExit)
|
||||
|
|
|
@ -1,15 +1,11 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!--
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
<!-- 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/. -->
|
||||
- file, You can obtain one at https://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<?xml-stylesheet href="chrome://messenger/skin/accountManage.css" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://messenger/skin/messenger.css" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://messenger/skin/folderMenus.css" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://messenger/content/charsetList.css" type="text/css"?>
|
||||
|
||||
<!DOCTYPE page [
|
||||
<!ENTITY % trashDTD SYSTEM "chrome://messenger/locale/am-server-top.dtd">
|
||||
|
@ -25,6 +21,7 @@
|
|||
<script type="application/javascript" src="chrome://messenger/content/am-server.js"/>
|
||||
<script type="application/javascript" src="chrome://messenger/content/am-prefs.js"/>
|
||||
<script type="application/javascript" src="chrome://messenger/content/amUtils.js"/>
|
||||
<script type="application/javascript" src="chrome://messenger/content/menulist-charsetpicker.js"/>
|
||||
<stringbundle id="bundle_messenger" src="chrome://messenger/locale/messenger.properties"/>
|
||||
|
||||
<label hidden="true" wsm_persist="true" id="server.type"/>
|
||||
|
@ -459,11 +456,10 @@
|
|||
|
||||
<hbox hidefor="imap,pop3,movemail" align="center" valign="middle" iscontrolcontainer="true">
|
||||
<label value="&serverDefaultCharset2.label;" control="nntp.charset"/>
|
||||
<menulist hidable="true"
|
||||
type="charset"
|
||||
<menulist is="menulist-charsetpicker" id="nntp.charset" subset="viewing"
|
||||
hidable="true"
|
||||
hidefor="imap,pop3,movemail"
|
||||
wsm_persist="true"
|
||||
id="nntp.charset"
|
||||
preftype="string"
|
||||
prefstring="mail.server.%serverkey%.charset"/>
|
||||
</hbox>
|
||||
|
|
|
@ -63,10 +63,9 @@ messenger.jar:
|
|||
content/messenger/msgSynchronize.xul (base/content/msgSynchronize.xul)
|
||||
content/messenger/msgSynchronize.js (base/content/msgSynchronize.js)
|
||||
content/messenger/folderProps.xul (base/content/folderProps.xul)
|
||||
content/messenger/menulist-charsetpicker.js (base/content/menulist-charsetpicker.js)
|
||||
content/messenger/folderProps.js (base/content/folderProps.js)
|
||||
content/messenger/folderWidgets.xml (base/content/folderWidgets.xml)
|
||||
content/messenger/charsetList.xml (base/content/charsetList.xml)
|
||||
content/messenger/charsetList.css (base/content/charsetList.css)
|
||||
content/messenger/newFolderDialog.xul (base/content/newFolderDialog.xul)
|
||||
content/messenger/newFolderDialog.js (base/content/newFolderDialog.js)
|
||||
* content/messenger/msgAccountCentral.xul (base/content/msgAccountCentral.xul)
|
||||
|
|
Загрузка…
Ссылка в новой задаче