зеркало из https://github.com/mozilla/pjs.git
second part of fix for #28898 - fix multiple server selector functional, which was broken by me skinning this dialog. needed to update the way <text> node state is maintained to make it reliable for edge cases like undefined and null
r=sspitzer
This commit is contained in:
Родитель
74aabd0145
Коммит
6cc5ec69b9
|
@ -552,6 +552,17 @@ function getFormElementValue(formElement) {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
else if (type == "text") {
|
||||
var val = formElement.getAttribute("value");
|
||||
dump("getting text element '" +
|
||||
formElement.id + "` = " +
|
||||
val + "\n");
|
||||
|
||||
if (val) return val;
|
||||
else return null;
|
||||
}
|
||||
|
||||
else {
|
||||
return formElement.value;
|
||||
}
|
||||
|
@ -614,6 +625,14 @@ function setFormElementValue(formElement, value) {
|
|||
}
|
||||
}
|
||||
|
||||
else if (type == "text") {
|
||||
dump("setting text element '" + formElement.id + "' to " + value + "\n");
|
||||
if (value == null || value == undefined)
|
||||
formElement.removeAttribute("value");
|
||||
else
|
||||
formElement.setAttribute("value",value);
|
||||
}
|
||||
|
||||
// let the form figure out what to do with it
|
||||
else {
|
||||
if (value == undefined) {
|
||||
|
|
|
@ -32,12 +32,12 @@ function onInit() {
|
|||
|
||||
function initFolderDisplay(fieldname, pickerID) {
|
||||
var formElement = document.getElementById(fieldname);
|
||||
var uri = formElement.value;
|
||||
var uri = formElement.getAttribute("value");
|
||||
SetFolderPicker(uri,pickerID);
|
||||
}
|
||||
|
||||
function initBccSelf() {
|
||||
var bccValue = document.getElementById("identity.email").value;
|
||||
var bccValue = document.getElementById("identity.email").getAttribute("value");
|
||||
setDivText("identity.bccSelf",bccValue);
|
||||
}
|
||||
|
||||
|
@ -74,6 +74,6 @@ function SaveUriFromPicker(fieldName, pickerID)
|
|||
|
||||
formElement = document.getElementById(fieldName);
|
||||
//dump("old value = " + formElement.value + "\n");
|
||||
formElement.value = uri;
|
||||
formElement.setAttribute("value",uri);
|
||||
//dump("new value = " + formElement.value + "\n");
|
||||
}
|
||||
|
|
|
@ -21,62 +21,55 @@
|
|||
* Alec Flett <alecf@netscape.com>
|
||||
*/
|
||||
|
||||
var smtpService;
|
||||
var serverList;
|
||||
|
||||
var stringBundle;
|
||||
function init() {
|
||||
|
||||
serverList = document.getElementById("smtpServerList");
|
||||
|
||||
}
|
||||
|
||||
function preSelectServer(key)
|
||||
{
|
||||
if (!key) {
|
||||
// no key, so preselect the "useDefault" item.
|
||||
serverList.selectedItem = document.getElementById("useDefaultItem");
|
||||
return;
|
||||
}
|
||||
|
||||
var preselectedItems = serverList.getElementsByAttribute("key", key);
|
||||
|
||||
if (preselectedItems && preselectedItems.length > 0)
|
||||
serverList.selectedItem = preselectedItems[0];
|
||||
}
|
||||
|
||||
function onLoad()
|
||||
{
|
||||
var selectedServer = null;
|
||||
if (window.arguments && window.arguments[0] && window.arguments[0].server)
|
||||
selectedServer = window.arguments[0].server;
|
||||
init();
|
||||
if (window.arguments && window.arguments[0]) {
|
||||
selectedServerKey = window.arguments[0].smtpServerKey;
|
||||
preSelectServer(selectedServerKey);
|
||||
}
|
||||
|
||||
dump("pre-select server: " + selectedServer + "\n");
|
||||
|
||||
if (!smtpService)
|
||||
smtpService = Components.classes["component://netscape/messengercompose/smtp"].getService(Components.interfaces.nsISmtpService);
|
||||
|
||||
if (!stringBundle)
|
||||
stringBundle = srGetStrBundle("chrome://messenger/locale/messenger.properties");
|
||||
|
||||
//serverList = document.getElementById("smtpPopup");
|
||||
|
||||
refreshServerList(smtpService.smtpServers, selectedServer);
|
||||
|
||||
doSetOKCancel(onOk, 0);
|
||||
}
|
||||
|
||||
function onOk()
|
||||
{
|
||||
dump("serverList.selectedItem = " + document.getElementById("smtpPopup").getAttribute("selectedKey") + "\n");
|
||||
|
||||
var selectedServerElement = serverList.selectedItem;
|
||||
dump("selectedServerKey: " + selectedServerElement + "\n");
|
||||
|
||||
var key = selectedServerElement.getAttribute("key");
|
||||
if (key)
|
||||
window.arguments[0].smtpServerKey = key;
|
||||
else
|
||||
window.arguments[0].smtpServerKey = null;
|
||||
|
||||
window.close();
|
||||
}
|
||||
|
||||
function refreshServerList(servers, selectedServer)
|
||||
{
|
||||
var defaultMenuItem = document.createElement("menuitem");
|
||||
defaultMenuItem.setAttribute("value", stringBundle.GetStringFromName("useDefaultServer"));
|
||||
document.getElementById("smtpPopup").appendChild(defaultMenuItem);
|
||||
|
||||
var serverCount = servers.Count();
|
||||
|
||||
for (var i=0; i<serverCount; i++) {
|
||||
var server = servers.QueryElementAt(i, Components.interfaces.nsISmtpServer);
|
||||
var menuitem = document.createElement("menuitem");
|
||||
menuitem.setAttribute("value", server.hostname);
|
||||
menuitem.setAttribute("id", server.serverURI);
|
||||
menuitem.setAttribute("key", server.key);
|
||||
|
||||
document.getElementById("smtpPopup").appendChild(menuitem);
|
||||
if (server == selectedServer) {
|
||||
dump("found the selected one!\n");
|
||||
serverList.setAttribute("selectedKey", server.key);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function onSelected(event)
|
||||
{
|
||||
serverList.setAttribute("selectedKey", event.target.getAttribute("key"));
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
<window class="dialog"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
title="&identityAdvanced.label;"
|
||||
align="vertical"
|
||||
onload="onLoad();">
|
||||
|
@ -37,9 +38,25 @@
|
|||
|
||||
<html style="width: 20em; ">&smtpDesc.label;</html>
|
||||
<box orient="horizontal">
|
||||
<text value="&smtpName.label;" class="label"/>
|
||||
<menulist oncommand="onSelected(event)">
|
||||
<menupopup id="smtpPopup"/>
|
||||
<text value="&smtpName.label;" class="label" for="smtpServerList"/>
|
||||
<menulist rdf:datasources="rdf:smtp"
|
||||
rdf:containment="http://home.netscape.com/NC-rdf#child"
|
||||
ref="NC:smtpservers"
|
||||
oncommand="onSelected(event)" id="smtpServerList">
|
||||
<template>
|
||||
<rule>
|
||||
<menupopup>
|
||||
<menuitem uri="..." key="rdf:http://home.netscape.com/NC-rdf#Key"
|
||||
value="rdf:http://home.netscape.com/NC-rdf#Name"/>
|
||||
</menupopup>
|
||||
</rule>
|
||||
<menupopup/>
|
||||
</template>
|
||||
<menupopup id="smtpPopup">
|
||||
<menuitem value="&smtpDefaultServer.label;" id="useDefaultItem"/>
|
||||
<menuseparator/>
|
||||
<!-- template will be inserted here -->
|
||||
</menupopup>
|
||||
</menulist>
|
||||
</box>
|
||||
|
||||
|
|
|
@ -24,15 +24,19 @@
|
|||
function onAdvanced()
|
||||
{
|
||||
dump("onAdvanced..\n");
|
||||
var oldSmtpServer = null; // where will I get this from?
|
||||
var arg = {result: false,
|
||||
smtpServer: oldSmtpServer };
|
||||
var serverKeyElement = document.getElementById("identity.smtpServerKey");
|
||||
var oldSmtpServerKey = serverKeyElement.getAttribute("value");
|
||||
dump("selected key = " + oldSmtpServerKey + "\n");
|
||||
var arg = { smtpServerKey: oldSmtpServerKey };
|
||||
window.openDialog('am-identity-advanced.xul','smtpadvanced',
|
||||
'modal,chrome', arg);
|
||||
|
||||
if (arg.result && arg.smtpServer != oldSmtpServer) {
|
||||
if (arg.smtpServerKey != oldSmtpServerKey) {
|
||||
// save the identity back to the page as a key
|
||||
document.getElementById("identity.smtpServerKey").value =
|
||||
arg.smtpServer.key;
|
||||
dump("Setting the smtp server to " + arg.smtpServerKey + "\n");
|
||||
if (arg.smtpServerKey)
|
||||
serverKeyElement.setAttribute("value", arg.smtpServerKey);
|
||||
else
|
||||
serverKeyElement.removeAttribute("value");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,8 +87,8 @@
|
|||
value="&useHtml.label;"/>
|
||||
|
||||
<box orient="horizontal">
|
||||
<spring flex="100%"/>
|
||||
<spring flex="1"/>
|
||||
<button onclick="onAdvanced();" value="&advancedButton.label;"/>
|
||||
<text hidden="true" wsm_persist="true" type="hidden" id="identity.smtpServerKey"/>
|
||||
<text hidden="true" wsm_persist="true" id="identity.smtpServerKey"/>
|
||||
</box>
|
||||
</window>
|
||||
|
|
|
@ -34,7 +34,7 @@ function onPreInit(account, accountValues)
|
|||
|
||||
|
||||
function initServerType() {
|
||||
var serverType = document.getElementById("server.type").value;
|
||||
var serverType = document.getElementById("server.type").getAttribute("value");
|
||||
|
||||
var verboseName;
|
||||
|
||||
|
@ -42,8 +42,8 @@ function initServerType() {
|
|||
|
||||
verboseName = stringBundle.GetStringFromName(propertyName);
|
||||
|
||||
var hostname = document.getElementById("server.hostName").value;
|
||||
var username = document.getElementById("server.username").value;
|
||||
var hostname = document.getElementById("server.hostName").getAttribute("value");
|
||||
var username = document.getElementById("server.username").getAttribute("value");
|
||||
|
||||
setDivText("servertype.verbose", verboseName);
|
||||
setDivText("servername.verbose", hostname);
|
||||
|
@ -112,39 +112,32 @@ function openImapAdvanced()
|
|||
function getImapServer() {
|
||||
var imapServer = new Array;
|
||||
|
||||
// boolean prefs, need to do special convertion
|
||||
imapServer.dualUseFolders =
|
||||
(document.getElementById("imap.dualUseFolders").value == "true" ?
|
||||
true : false);
|
||||
imapServer.usingSubscription =
|
||||
(document.getElementById("imap.usingSubscription").value == "true" ? true : false);
|
||||
imapServer.dualUseFolders = document.getElementById("imap.dualUseFolders").checked
|
||||
|
||||
imapServer.usingSubscription = document.getElementById("imap.usingSubscription").checked;
|
||||
|
||||
// string prefs
|
||||
imapServer.personalNamespace = document.getElementById("imap.personalNamespace").value;
|
||||
imapServer.publicNamespace = document.getElementById("imap.publicNamespace").value;
|
||||
imapServer.serverDirectory = document.getElementById("imap.serverDirectory").value;
|
||||
imapServer.otherUsersNamespace = document.getElementById("imap.otherUsersNamespace").value;
|
||||
imapServer.personalNamespace = document.getElementById("imap.personalNamespace").getAttribute("value");
|
||||
imapServer.publicNamespace = document.getElementById("imap.publicNamespace").getAttribute("value");
|
||||
imapServer.serverDirectory = document.getElementById("imap.serverDirectory").getAttribute("value");
|
||||
imapServer.otherUsersNamespace = document.getElementById("imap.otherUsersNamespace").getAttribute("value");
|
||||
|
||||
// boolean prefs, need to do special convertion
|
||||
imapServer.overrideNamespaces =
|
||||
(document.getElementById("imap.overrideNamespaces").value == "true" ? true : false);
|
||||
imapServer.overrideNamespaces = document.getElementById("imap.overrideNamespaces").checked;
|
||||
return imapServer;
|
||||
}
|
||||
|
||||
function saveServerLocally(imapServer)
|
||||
{
|
||||
// boolean prefs, JS does the conversion for us
|
||||
document.getElementById("imap.dualUseFolders").value = imapServer.dualUseFolders.toString();
|
||||
document.getElementById("imap.usingSubscription").value = imapServer.usingSubscription.toString();
|
||||
document.getElementById("imap.dualUseFolders").checked = imapServer.dualUseFolders;
|
||||
document.getElementById("imap.usingSubscription").checked = imapServer.usingSubscription;
|
||||
|
||||
// string prefs
|
||||
document.getElementById("imap.personalNamespace").value = imapServer.personalNamespace;
|
||||
document.getElementById("imap.publicNamespace").value = imapServer.publicNamespace;
|
||||
document.getElementById("imap.serverDirectory").value = imapServer.serverDirectory;
|
||||
document.getElementById("imap.otherUsersNamespace").value = imapServer.otherUsersNamespace;
|
||||
document.getElementById("imap.personalNamespace").setAttribute("value", imapServer.personalNamespace);
|
||||
document.getElementById("imap.publicNamespace").setAttribute("value", imapServer.publicNamespace);
|
||||
document.getElementById("imap.serverDirectory").setAttribute("value", imapServer.serverDirectory);
|
||||
document.getElementById("imap.otherUsersNamespace").setAttribute("value", imapServer.otherUsersNamespace);
|
||||
|
||||
// boolean prefs, JS does the conversion for us
|
||||
document.getElementById("imap.overrideNamespaces").value = imapServer.overrideNamespaces.toString();
|
||||
document.getElementById("imap.overrideNamespaces").checked = imapServer.overrideNamespaces;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -87,13 +87,13 @@
|
|||
onclick="openImapAdvanced(event);"/>
|
||||
</box>
|
||||
|
||||
<text hidden="true" wsm_persist="true" id="imap.dualUseFolders"/>
|
||||
<text hidden="true" wsm_persist="true" id="imap.usingSubscription"/>
|
||||
<checkbox hidden="true" wsm_persist="true" id="imap.dualUseFolders"/>
|
||||
<checkbox hidden="true" wsm_persist="true" id="imap.usingSubscription"/>
|
||||
<text hidden="true" wsm_persist="true" id="imap.personalNamespace"/>
|
||||
<text hidden="true" wsm_persist="true" id="imap.publicNamespace"/>
|
||||
<text hidden="true" wsm_persist="true" id="imap.otherUsersNamespace"/>
|
||||
<text hidden="true" wsm_persist="true" id="imap.serverDirectory"/>
|
||||
<text hidden="true" wsm_persist="true" id="imap.overrideNamespaces"/>
|
||||
<checkbox hidden="true" wsm_persist="true" id="imap.overrideNamespaces"/>
|
||||
</box>
|
||||
|
||||
<!-- News -->
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<!ENTITY identityAdvanced.label "Advanced Account Settings">
|
||||
<!ENTITY smtpDesc.label "When sending mail from this identity, always use the following Outgoing (SMTP) server:">
|
||||
<!ENTITY smtpName.label "Server:">
|
||||
<!ENTITY smtpDefaultServer.label "Always use default server">
|
Загрузка…
Ссылка в новой задаче