зеркало из https://github.com/mozilla/pjs.git
Bug 245325 Really fix addressbook's abuse of menulists r/sr=mscott
This commit is contained in:
Родитель
d44bf5a284
Коммит
8039026b66
|
@ -87,7 +87,7 @@ var gAddressBookPanelAbListener = {
|
|||
// if so, select the person addressbook (it can't be removed)
|
||||
if (directory == GetAbView().directory) {
|
||||
var abPopup = document.getElementById('addressbookList');
|
||||
abPopup.setAttribute("selectedAB", kPersonalAddressbookURI);
|
||||
abPopup.value = kPersonalAddressbookURI;
|
||||
LoadPreviouslySelectedAB();
|
||||
}
|
||||
}
|
||||
|
@ -115,6 +115,9 @@ var gAddressBookPanelAbListener = {
|
|||
function LoadPreviouslySelectedAB()
|
||||
{
|
||||
var abPopup = document.getElementById('addressbookList');
|
||||
var value = abPopup.value || kPersonalAddressbookURI;
|
||||
abPopup.selectedItem = null;
|
||||
abPopup.value = value;
|
||||
ChangeDirectoryByURI(abPopup.selectedItem.id);
|
||||
}
|
||||
|
||||
|
@ -135,13 +138,6 @@ function AbPanelLoad()
|
|||
gSearchInput = document.getElementById("searchInput");
|
||||
}
|
||||
|
||||
|
||||
function AbPanelOnChange(event)
|
||||
{
|
||||
var abPopup = document.getElementById('addressbookList');
|
||||
abPopup.setAttribute("selectedAB", abPopup.value);
|
||||
}
|
||||
|
||||
function AbPanelUnload()
|
||||
{
|
||||
var addrbookSession = Components.classes["@mozilla.org/addressbook/services/session;1"].getService().QueryInterface(Components.interfaces.nsIAddrBookSession);
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
<label value="&addressbookPicker.label;"/>
|
||||
<hbox id="panel-bar" class="toolbar" align="center">
|
||||
<menulist id="addressbookList"
|
||||
oncommand="DirPaneSelectionChangeMenulist(); AbPanelOnChange(event)" flex="1"
|
||||
oncommand="DirPaneSelectionChangeMenulist();" flex="1"
|
||||
persist="value">
|
||||
<menupopup id="addressbookList-menupopup"
|
||||
datasources="rdf:addressdirectory"
|
||||
|
|
|
@ -93,19 +93,11 @@ function setupDirectoriesList()
|
|||
var directoriesList = document.getElementById("directoriesList");
|
||||
var directoryServer =
|
||||
document.getElementById("identity.directoryServer").getAttribute('value');
|
||||
try {
|
||||
var directoryServerString = gPrefInt.getComplexValue(directoryServer + ".description",
|
||||
Components.interfaces.nsISupportsString).data;
|
||||
}
|
||||
catch(ex) {}
|
||||
if (directoryServerFlag || !directoryServerString) {
|
||||
if (directoryServerFlag) {
|
||||
document.getElementById("identity.directoryServer").setAttribute("value", "");
|
||||
directoryServer = "";
|
||||
var addressBookBundle = document.getElementById("bundle_addressBook");
|
||||
directoryServerString = addressBookBundle.getString("directoriesListItemNone");
|
||||
}
|
||||
directoriesList.value = directoryServer;
|
||||
directoriesList.label = directoryServerString;
|
||||
gFromGlobalPref = false;
|
||||
}
|
||||
|
||||
|
@ -200,27 +192,11 @@ function LoadDirectories(popup)
|
|||
if (gRefresh) {
|
||||
// gRefresh is true if user edits, removes or adds a directory.
|
||||
directoriesList = document.getElementById("directoriesList");
|
||||
directoryDescription = null;
|
||||
if(directoriesList.value != "") {
|
||||
// make sure the selected directory still exists
|
||||
try {
|
||||
directoryDescription = gPrefInt.
|
||||
getComplexValue(directoriesList.value + ".description",
|
||||
Components.interfaces.nsISupportsString).data;
|
||||
}
|
||||
catch (ex) {}
|
||||
}
|
||||
if(!directoryDescription) {
|
||||
// if selected directory doesn't exist, set it to none
|
||||
var value = directoriesList.value;
|
||||
directoriesList.selectedItem = null;
|
||||
directoriesList.value = value;
|
||||
if (!directoriesList.selectedItem)
|
||||
directoriesList.value = "";
|
||||
addressBookBundle = document.getElementById("bundle_addressBook");
|
||||
directoriesList.label = addressBookBundle.
|
||||
getString("directoriesListItemNone");
|
||||
}
|
||||
else {
|
||||
directoriesList.label = directoryDescription;
|
||||
directoriesList.value = directoriesList.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (popup && gFromGlobalPref) {
|
||||
|
@ -228,72 +204,31 @@ function LoadDirectories(popup)
|
|||
directoriesList = document.getElementById("directoriesList");
|
||||
if (gRefresh) {
|
||||
// gRefresh is true if user edits, removes or adds a directory.
|
||||
directoryDescription = null;
|
||||
if(directoriesList.label != "") {
|
||||
// make sure the selected directory still exists
|
||||
try {
|
||||
directoryDescription = gPrefInt.
|
||||
getComplexValue(directoriesList.value + ".description",
|
||||
Components.interfaces.nsISupportsString).data;
|
||||
}
|
||||
catch (ex) {}
|
||||
}
|
||||
if(!directoryDescription) {
|
||||
// if selected directory doesn't exist,
|
||||
// set it the first one in the list of directories
|
||||
// if we have atleast one directory.
|
||||
// or else set it to ""
|
||||
if (gAvailDirectories.length) {
|
||||
directoriesList.label = gAvailDirectories[0].label;
|
||||
directoriesList.value = gAvailDirectories[0].value;
|
||||
directoriesList.removeAttribute("disabled");
|
||||
}
|
||||
else {
|
||||
directoriesList.label = "";
|
||||
directoriesList.value = null;
|
||||
directoriesList.setAttribute("disabled", true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
directoriesList.label = directoryDescription;
|
||||
directoriesList.value = directoriesList.value;
|
||||
var value = directoriesList.value;
|
||||
directoriesList.selectedItem = null;
|
||||
directoriesList.value = value;
|
||||
if (!directoriesList.selectedItem)
|
||||
directoriesList.selectedIndex = 0;
|
||||
if (!directoriesList.selectedItem) {
|
||||
directoriesList.value = "";
|
||||
directoriesList.disabled = true;
|
||||
}
|
||||
else if (!gPrefInt.prefIsLocked("ldap_2.autoComplete.directoryServer"))
|
||||
directoriesList.disabled = false;
|
||||
return;
|
||||
}
|
||||
var pref_string_title = "ldap_2.autoComplete.directoryServer";
|
||||
try {
|
||||
var directoryServer = gPrefInt.getCharPref(pref_string_title);
|
||||
directoriesList.value = directoryServer;
|
||||
if (!directoriesList.selectedItem)
|
||||
directoriesList.selectedIndex = 0;
|
||||
if (!directoriesList.selectedItem)
|
||||
directoriesList.value = "";
|
||||
}
|
||||
catch (ex)
|
||||
{
|
||||
directoryServer = "";
|
||||
}
|
||||
if (directoryServer != "")
|
||||
{
|
||||
pref_string_title = directoryServer + ".description";
|
||||
try {
|
||||
description = gPrefInt.getComplexValue(pref_string_title,
|
||||
Components.interfaces.nsISupportsString).data;
|
||||
}
|
||||
catch (ex) {
|
||||
description = "";
|
||||
}
|
||||
}
|
||||
if ((directoryServer != "") && (description != ""))
|
||||
{
|
||||
directoriesList.label = description;
|
||||
directoriesList.value = directoryServer;
|
||||
}
|
||||
else if(gAvailDirectories.length) {
|
||||
directoriesList.label = gAvailDirectories[0].label;
|
||||
directoriesList.value = gAvailDirectories[0].value;
|
||||
gPrefInt.setCharPref("ldap_2.autoComplete.directoryServer",
|
||||
gAvailDirectories[0].value);
|
||||
}
|
||||
else {
|
||||
directoriesList.label = "";
|
||||
directoriesList.value = null;
|
||||
gPrefInt.setCharPref("ldap_2.autoComplete.directoryServer", "");
|
||||
directoriesList.selectedItem = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ var gAddressBookPanelAbListener = {
|
|||
// if so, select the person addressbook (it can't be removed)
|
||||
if (directory == GetAbView().directory) {
|
||||
var abPopup = document.getElementById('addressbookList');
|
||||
abPopup.setAttribute("selectedAB", kPersonalAddressbookURI);
|
||||
abPopup.value = kPersonalAddressbookURI;
|
||||
LoadPreviouslySelectedAB();
|
||||
}
|
||||
}
|
||||
|
@ -81,26 +81,9 @@ var gAddressBookPanelAbListener = {
|
|||
function LoadPreviouslySelectedAB()
|
||||
{
|
||||
var abPopup = document.getElementById('addressbookList');
|
||||
if ( abPopup )
|
||||
{
|
||||
var menupopup = document.getElementById('addressbookList-menupopup');
|
||||
var selectedAB = abPopup.getAttribute("selectedAB");
|
||||
if (!selectedAB)
|
||||
selectedAB = kPersonalAddressbookURI;
|
||||
|
||||
if ( selectedAB && menupopup && menupopup.childNodes )
|
||||
{
|
||||
for ( var index = menupopup.childNodes.length - 1; index >= 0; index-- )
|
||||
{
|
||||
if ( menupopup.childNodes[index].getAttribute('value') == selectedAB )
|
||||
{
|
||||
abPopup.label = menupopup.childNodes[index].getAttribute('label');
|
||||
abPopup.value = menupopup.childNodes[index].getAttribute('value');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var value = abPopup.value || kPersonalAddressbookURI;
|
||||
abPopup.selectedItem = null;
|
||||
abPopup.value = value;
|
||||
ChangeDirectoryByURI(abPopup.selectedItem.id);
|
||||
}
|
||||
|
||||
|
@ -123,13 +106,6 @@ function AbPanelLoad()
|
|||
gSearchInput = document.getElementById("searchInput");
|
||||
}
|
||||
|
||||
|
||||
function AbPanelOnChange(event)
|
||||
{
|
||||
var abPopup = document.getElementById('addressbookList');
|
||||
abPopup.setAttribute("selectedAB", abPopup.value);
|
||||
}
|
||||
|
||||
function AbPanelUnload()
|
||||
{
|
||||
var addrbookSession = Components.classes["@mozilla.org/addressbook/services/session;1"].getService().QueryInterface(Components.interfaces.nsIAddrBookSession);
|
||||
|
|
|
@ -78,8 +78,8 @@
|
|||
<hbox id="panel-bar" class="toolbar" align="center">
|
||||
<label value="&lookIn.label;"/>
|
||||
<menulist id="addressbookList"
|
||||
oncommand="DirPaneSelectionChangeMenulist(); AbPanelOnChange(event)" flex="1"
|
||||
persist="selectedAB">
|
||||
oncommand="DirPaneSelectionChangeMenulist();" flex="1"
|
||||
persist="value">
|
||||
<menupopup id="addressbookList-menupopup"
|
||||
datasources="rdf:addressdirectory"
|
||||
ref="moz-abdirectory://"
|
||||
|
|
Загрузка…
Ссылка в новой задаче