Bug 454574 LDAP account preferences don't update r=philor r+a=Standard8

This commit is contained in:
Neil Rashbrook 2008-09-14 19:50:22 +01:00
Родитель 732ec4d079
Коммит 4a9c3c3317
2 изменённых файлов: 19 добавлений и 108 удалений

Просмотреть файл

@ -52,7 +52,6 @@ function onInit(aPageId, aServerId)
function onInitCompositionAndAddressing()
{
setupDirectoriesList();
enabling();
quoteEnabling();
}
@ -63,32 +62,6 @@ function onEditDirectories()
"editDirectories", "chrome,modal=yes,resizable=no", null);
}
function setupDirectoriesList()
{
var override = document.getElementById("identity.overrideGlobalPref").getAttribute("value");
var autocomplete = document.getElementById("ldapAutocomplete");
// useGlobalFlag is set when user changes the selectedItem on the radio button and switches
// to a different pane and switches back in Mail/news AccountSettings
var useGlobalFlag = document.getElementById("overrideGlobalPref").getAttribute("value");
// directoryServerFlag is set when user changes the server to None and switches
// to a different pane and switches back in Mail/news AccountSettings
var directoryServerFlag = document.getElementById("directoryServer").getAttribute("value");
if(override == "true" && !useGlobalFlag)
autocomplete.selectedItem = document.getElementById("directories");
else
autocomplete.selectedItem = document.getElementById("useGlobalPref");
var directoriesList = document.getElementById("directoriesList");
var directoryServer =
document.getElementById("identity.directoryServer").getAttribute('value');
if (directoryServerFlag) {
document.getElementById("identity.directoryServer").setAttribute("value", "");
directoryServer = "";
}
directoriesList.value = directoryServer;
}
function onPreInit(account, accountValues)
{
gIdentity = account.defaultIdentity;
@ -96,24 +69,18 @@ function onPreInit(account, accountValues)
function enabling()
{
var autocomplete = document.getElementById("ldapAutocomplete");
var directoriesList = document.getElementById("directoriesList");
var directoriesListPopup = document.getElementById("directoriesListPopup");
var autocomplete = document.getElementById("identity.overrideGlobal_Pref");
var directoriesList = document.getElementById("identity.directoryServer");
var editButton = document.getElementById("editButton");
// this is the hidden text element that assigned a value from the prefs
var overrideGlobalPref = document.getElementById("identity.overrideGlobalPref");
switch (autocomplete.value)
{
case "0":
case "false":
directoriesList.setAttribute("disabled", true);
directoriesListPopup.setAttribute("disabled", true);
editButton.setAttribute("disabled", true);
break;
case "1":
case "true":
directoriesList.removeAttribute("disabled");
directoriesListPopup.removeAttribute("disabled");
editButton.removeAttribute("disabled");
break;
}
@ -123,60 +90,8 @@ function enabling()
.getService(Components.interfaces.nsIPrefBranch);
}
// If the default per-identity directory preferences are locked
// disable the corresponding elements.
if (gIdentity && gPrefInt.prefIsLocked("mail.identity." + gIdentity.key + ".overrideGlobal_Pref")) {
document.getElementById("useGlobalPref").setAttribute("disabled", "true");
document.getElementById("directories").setAttribute("disabled", "true");
}
else
{
document.getElementById("useGlobalPref").removeAttribute("disabled");
document.getElementById("directories").removeAttribute("disabled");
}
if (gIdentity && gPrefInt.prefIsLocked("mail.identity." + gIdentity.key + ".directoryServer")) {
document.getElementById("directoriesList").setAttribute("disabled", "true");
document.getElementById("directoriesListPopup").setAttribute("disabled", "true");
}
}
function onSave()
{
onSaveCompositionAndAddressing();
}
function onSaveCompositionAndAddressing()
{
var override = document.getElementById("identity.overrideGlobalPref");
var autocomplete = document.getElementById("ldapAutocomplete");
var directoryServer = document.getElementById("identity.directoryServer");
var directoriesList =
document.getElementById("directoriesList").getAttribute('value');
// When switching between panes,
// if we save the value of an element as null
// we will be forced to get the value from preferences when we get back.
// We are saving the value as "" for the radio button and also for
// the directory server if the selected directory is "None"
// So, we need the two elements overrideGlobalPref and directoryServer
// to save the state when the directory is
// set to none and the first radio button is selected.
switch(autocomplete.value)
{
case "0":
override.setAttribute('value', "");
document.getElementById("overrideGlobalPref").setAttribute("value", "0");
document.getElementById("directoryServer").setAttribute("value", "");
break;
case "1":
override.setAttribute('value', true);
directoryServer.setAttribute("value", directoriesList);
document.getElementById("overrideGlobalPref").setAttribute("value", "");
if(directoriesList == "")
document.getElementById("directoryServer").setAttribute("value", "none");
else
document.getElementById("directoryServer").setAttribute("value", "");
break;
directoriesList.setAttribute("disabled", "true");
}
}

Просмотреть файл

@ -48,14 +48,6 @@
<vbox flex="1" id="compositionAndAddressing">
<stringbundle id="bundle_addressBook" src="chrome://messenger/locale/addressbook/addressBook.properties"/>
<label hidden="true" wsm_persist="true" id="identity.directoryServer"
pref="true" preftype="string" prefattribute="value"
prefstring="mail.identity.%identitykey%.directoryServer"/>
<label hidden="true" wsm_persist="true" id="identity.overrideGlobalPref"
pref="true" preftype="bool" prefattribute="value"
prefstring="mail.identity.%identitykey%.overrideGlobal_Pref"/>
<label hidden="true" wsm_persist="true" id="overrideGlobalPref" value=""/>
<label hidden="true" wsm_persist="true" id="directoryServer" value=""/>
<checkbox hidden="true" wsm_persist="true" id="identity.attachSignature"
pref="true" preftype="bool" prefattribute="value"
prefstring="mail.identity.%identitykey%.attach_signature"/>
@ -118,17 +110,21 @@
<separator class="thin"/>
#endif
<label control="ldapAutocomplete">&addressingText.label;</label>
<radiogroup class="indent" id="ldapAutocomplete" wsm_persist="true" oncommand="enabling();">
<observes element="identity.overrideGlobalPref" attribute="disabled"/>
<radio id="useGlobalPref" value="0" label="&useGlobal.label;"
<label control="identity.overrideGlobal_Pref">&addressingText.label;</label>
<radiogroup id="identity.overrideGlobal_Pref" class="indent"
oncommand="enabling();" wsm_persist="true"
genericattr="true" preftype="bool"
prefstring="mail.identity.%identitykey%.overrideGlobal_Pref">
<radio value="false" label="&useGlobal.label;"
accesskey="&useGlobal.accesskey;"/>
<radio id="directories" value="1" label="&directories.label;"
<radio id="directories" value="true" label="&directories.label;"
accesskey="&directories.accesskey;"/>
<hbox class="indent">
<menulist id="directoriesList" wsm_persist="true"
<menulist id="identity.directoryServer"
wsm_persist="true" preftype="string"
prefstring="mail.identity.%identitykey%.directoryServer"
style="min-width: 16em;" aria-labelledby="directories">
<menupopup id="directoriesListPopup" class="addrbooksPopup"
<menupopup class="addrbooksPopup"
none="&directoriesNone.label;"
remoteonly="true" value="dirPrefId"/>
</menulist>