зеркало из https://github.com/mozilla/pjs.git
Address book; partial fix to 15108, performance improvements. r=slogan
This commit is contained in:
Родитель
c6bd8f2f3d
Коммит
4b27cbbd0c
|
@ -22,11 +22,6 @@
|
|||
|
||||
var editCard;
|
||||
|
||||
var newCardTitlePrefix = "New Card for ";
|
||||
var editCardTitlePrefix = "Card for ";
|
||||
var editCardFirstLastSeparator = " ";
|
||||
var editCardLastFirstSeparator = ", ";
|
||||
|
||||
function OnLoadNewCard()
|
||||
{
|
||||
InitEditCard();
|
||||
|
@ -35,7 +30,7 @@ function OnLoadNewCard()
|
|||
|
||||
editCard.card = 0;
|
||||
editCard.okCallback = 0;
|
||||
editCard.titlePrefix = newCardTitlePrefix;
|
||||
editCard.titlePrefix = editCard.newCardTitlePrefix;
|
||||
|
||||
if (window.arguments && window.arguments[0])
|
||||
{
|
||||
|
@ -69,7 +64,7 @@ function OnLoadEditCard()
|
|||
|
||||
doSetOKCancel(EditCardOKButton, 0);
|
||||
|
||||
editCard.titlePrefix = editCardTitlePrefix;
|
||||
editCard.titlePrefix = editCard.editCardTitlePrefix;
|
||||
|
||||
if (window.arguments && window.arguments[0])
|
||||
{
|
||||
|
@ -116,17 +111,15 @@ function InitEditCard()
|
|||
if ( prefs )
|
||||
{
|
||||
try {
|
||||
editCard.displayLastNameFirst = prefs.GetIntPref("mail.addr_book.displayName.lastnamefirst");
|
||||
}
|
||||
catch (ex) {
|
||||
dump("failed to get the mail.addr_book.displayName.lastnamefirst pref\n");
|
||||
}
|
||||
|
||||
try {
|
||||
editCard.displayLastNameFirst = prefs.GetBoolPref("mail.addr_book.displayName.lastnamefirst");
|
||||
editCard.generateDisplayName = prefs.GetBoolPref("mail.addr_book.displayName.autoGeneration");
|
||||
editCard.lastFirstSeparator = ", ";
|
||||
editCard.firstLastSeparator = " ";
|
||||
editCard.newCardTitlePrefix = "New Card for ";
|
||||
editCard.editCardTitlePrefix = "Card for ";
|
||||
}
|
||||
catch (ex) {
|
||||
dump("failed to get the mail.addr_book.displayName.autoGeneration pref\n");
|
||||
dump("failed to get pref\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -301,22 +294,13 @@ function GenerateDisplayName()
|
|||
/* todo: i18N work todo here */
|
||||
/* this used to be XP_GetString(MK_ADDR_FIRST_LAST_SEP) */
|
||||
|
||||
/* todo: mscott says there was a pref in 4.5 that would */
|
||||
/* cause GenerateDisplayName() to do nothing. */
|
||||
/* the i18N people need it. */
|
||||
/* find the pref and heed it. */
|
||||
|
||||
/* trying to be smart about no using the first last sep */
|
||||
/* if first or last is missing */
|
||||
/* todo: is this i18N safe? */
|
||||
|
||||
var separator = "";
|
||||
if ( lastNameField.value && firstNameField.value )
|
||||
{
|
||||
if ( editCard.displayLastNameFirst )
|
||||
separator = editCardLastFirstSeparator;
|
||||
separator = editCard.lastFirstSeparator;
|
||||
else
|
||||
separator = editCardFirstLastSeparator;
|
||||
separator = editCard.firstLastSeparator;
|
||||
}
|
||||
|
||||
if ( editCard.displayLastNameFirst )
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
var zName = "Name";
|
||||
var zNickname = "Nickname: ";
|
||||
var zDisplayName = "Display Name: ";
|
||||
var zWork = "Work: ";
|
||||
var zHome = "Home: ";
|
||||
var zFax = "Fax: ";
|
||||
|
@ -10,13 +13,17 @@ var zCustom4 = "Custom 4: ";
|
|||
|
||||
var rdf;
|
||||
var cvData;
|
||||
var cvPrefs = 0;
|
||||
|
||||
function OnLoadCardView()
|
||||
{
|
||||
// This should be in an onload for the card view window, but that is not currently working
|
||||
rdf = Components.classes["component://netscape/rdf/rdf-service"].getService();
|
||||
rdf = rdf.QueryInterface(Components.interfaces.nsIRDFService);
|
||||
|
||||
// prefs
|
||||
cvPrefs = new Object;
|
||||
GetCurrentPrefs();
|
||||
|
||||
var doc = document;
|
||||
|
||||
/* data for address book, prefixes: "cvb" = card view box
|
||||
|
@ -32,6 +39,7 @@ function OnLoadCardView()
|
|||
cvData.cvbName = doc.getElementById("cvbName");
|
||||
cvData.cvhName = doc.getElementById("cvhName");
|
||||
cvData.cvNickname = doc.getElementById("cvNickname");
|
||||
cvData.cvDisplayName = doc.getElementById("cvDisplayName");
|
||||
cvData.cvEmail1 = doc.getElementById("cvEmail1");
|
||||
cvData.cvEmail2 = doc.getElementById("cvEmail2");
|
||||
// Home section
|
||||
|
@ -69,31 +77,105 @@ function OnLoadCardView()
|
|||
cvData.cvWorkCountry = doc.getElementById("cvWorkCountry");
|
||||
}
|
||||
|
||||
function SetNameColumn(cmd)
|
||||
{
|
||||
var prefValue;
|
||||
|
||||
switch ( cmd )
|
||||
{
|
||||
case 'firstLastCmd':
|
||||
prefValue = 2;
|
||||
break;
|
||||
case 'lastFirstCmd':
|
||||
prefValue = 1;
|
||||
break;
|
||||
case 'displayNameCmd':
|
||||
prefValue = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
// set pref in file and locally
|
||||
cvPrefs.prefs.SetIntPref("mail.addr_book.lastnamefirst", prefValue);
|
||||
cvPrefs.nameColumn = prefValue;
|
||||
|
||||
// FIX ME - this should redraw the card view pane when we can reselect the node
|
||||
ClearResultsTreeSelection();
|
||||
ClearCardViewPane();
|
||||
|
||||
// redraw results tree
|
||||
var resultsTree = top.document.getElementById('resultsTree');
|
||||
if ( resultsTree )
|
||||
{
|
||||
var ref = resultsTree.getAttribute('ref');
|
||||
resultsTree.setAttribute('ref', ref);
|
||||
}
|
||||
}
|
||||
|
||||
function GetCurrentPrefs()
|
||||
{
|
||||
var prefs = Components.classes["component://netscape/preferences"];
|
||||
if ( prefs )
|
||||
{
|
||||
prefs = prefs.getService();
|
||||
if ( prefs )
|
||||
prefs = prefs.QueryInterface(Components.interfaces.nsIPref);
|
||||
}
|
||||
|
||||
if ( prefs )
|
||||
{
|
||||
try {
|
||||
cvPrefs.prefs = prefs;
|
||||
cvPrefs.displayLastNameFirst = prefs.GetBoolPref("mail.addr_book.displayName.lastnamefirst");
|
||||
cvPrefs.nameColumn = prefs.GetIntPref("mail.addr_book.lastnamefirst");
|
||||
cvPrefs.lastFirstSeparator = ", ";
|
||||
cvPrefs.firstLastSeparator = " ";
|
||||
cvPrefs.titlePrefix = "Card for ";
|
||||
}
|
||||
catch (ex) {
|
||||
dump("failed to get the mail.addr_book.displayName.lastnamefirst pref\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function DisplayCardViewPane(abNode)
|
||||
{
|
||||
var uri = abNode.getAttribute('id');
|
||||
var cardResource = top.rdf.GetResource(uri);
|
||||
var card = cardResource.QueryInterface(Components.interfaces.nsIAbCard);
|
||||
|
||||
// FIX ME - this should use a i18n name routine in JS
|
||||
var name = card.displayName;
|
||||
if ( card.firstName.length + card.lastName.length > 0 )
|
||||
name = card.firstName + " " + card.lastName;
|
||||
// name
|
||||
var name;
|
||||
var separator = "";
|
||||
if ( card.lastName && card.firstName )
|
||||
{
|
||||
if ( cvPrefs.displayLastNameFirst )
|
||||
separator = cvPrefs.lastFirstSeparator;
|
||||
else
|
||||
separator = cvPrefs.firstLastSeparator;
|
||||
}
|
||||
if ( cvPrefs.displayLastNameFirst )
|
||||
name = card.lastName + separator + card.firstName;
|
||||
else
|
||||
name = card.firstName + separator + card.lastName;
|
||||
|
||||
var cardTitle = card.name;
|
||||
var nameHeader = name;
|
||||
|
||||
var nickname;
|
||||
if ( card.nickName )
|
||||
nickname = "\"" + card.nickName + "\"";
|
||||
if ( !nameHeader )
|
||||
nameHeader = zName;
|
||||
|
||||
var data = top.cvData;
|
||||
var visible;
|
||||
|
||||
|
||||
// set fields in card view pane
|
||||
|
||||
cvSetNode(data.CardTitle, "Card for " + card.displayName);
|
||||
cvSetNode(data.CardTitle, cvPrefs.titlePrefix + cardTitle);
|
||||
|
||||
// Name section
|
||||
cvSetNode(data.cvhName, name);
|
||||
cvSetNode(data.cvNickname, nickname);
|
||||
cvSetNode(data.cvhName, nameHeader);
|
||||
cvSetNodeWithLabel(data.cvNickname, zNickname, card.nickName);
|
||||
cvSetNodeWithLabel(data.cvDisplayName, zDisplayName, card.displayName);
|
||||
cvSetNode(data.cvEmail1, card.primaryEmail);
|
||||
cvSetNode(data.cvEmail2, card.secondEmail);
|
||||
// Home section
|
||||
|
@ -136,48 +218,7 @@ function DisplayCardViewPane(abNode)
|
|||
|
||||
function ClearCardViewPane()
|
||||
{
|
||||
dump("ClearCardViewPane\n");
|
||||
cvSetVisible(top.cvData.CardViewBox, false);
|
||||
|
||||
// HACK - we need to be able to set the entire box or div to display:none when bug fixed
|
||||
var data = top.cvData;
|
||||
|
||||
// title
|
||||
cvSetVisible(data.CardTitle, false);
|
||||
// Name section
|
||||
cvSetVisible(data.cvhName, false);
|
||||
cvSetVisible(data.cvNickname, false);
|
||||
cvSetVisible(data.cvEmail1, false);
|
||||
cvSetVisible(data.cvEmail2, false);
|
||||
// Home section
|
||||
cvSetVisible(data.cvhHome, false);
|
||||
cvSetVisible(data.cvHomeAddress, false);
|
||||
cvSetVisible(data.cvHomeAddress2, false);
|
||||
cvSetVisible(data.cvHomeCityStZip, false);
|
||||
cvSetVisible(data.cvHomeCountry, false);
|
||||
// Other section
|
||||
cvSetVisible(data.cvhOther, false);
|
||||
cvSetVisible(data.cvCustom1, false);
|
||||
cvSetVisible(data.cvCustom2, false);
|
||||
cvSetVisible(data.cvCustom3, false);
|
||||
cvSetVisible(data.cvCustom4, false);
|
||||
cvSetVisible(data.cvNotes, false);
|
||||
// Phone section
|
||||
cvSetVisible(data.cvhPhone, false);
|
||||
cvSetVisible(data.cvPhWork, false);
|
||||
cvSetVisible(data.cvPhHome, false);
|
||||
cvSetVisible(data.cvPhFax, false);
|
||||
cvSetVisible(data.cvPhCellular, false);
|
||||
cvSetVisible(data.cvPhPager, false);
|
||||
// Work section
|
||||
cvSetVisible(data.cvhWork, false);
|
||||
cvSetVisible(data.cvJobTitle, false);
|
||||
cvSetVisible(data.cvDepartment, false);
|
||||
cvSetVisible(data.cvCompany, false);
|
||||
cvSetVisible(data.cvWorkAddress, false);
|
||||
cvSetVisible(data.cvWorkAddress2, false);
|
||||
cvSetVisible(data.cvWorkCityStZip, false);
|
||||
cvSetVisible(data.cvWorkCountry, false);
|
||||
}
|
||||
|
||||
function cvSetNodeWithLabel(node, label, text)
|
||||
|
@ -185,10 +226,7 @@ function cvSetNodeWithLabel(node, label, text)
|
|||
if ( text )
|
||||
return cvSetNode(node, label + text);
|
||||
else
|
||||
{
|
||||
cvSetVisible(node, false);
|
||||
return false;
|
||||
}
|
||||
return cvSetNode(node, "");
|
||||
}
|
||||
|
||||
function cvSetCityStateZip(node, city, state, zip)
|
||||
|
@ -211,15 +249,26 @@ function cvSetCityStateZip(node, city, state, zip)
|
|||
|
||||
function cvSetNode(node, text)
|
||||
{
|
||||
node.childNodes[0].nodeValue = text;
|
||||
var visible;
|
||||
|
||||
if ( text )
|
||||
visible = true;
|
||||
else
|
||||
visible = false;
|
||||
|
||||
cvSetVisible(node, visible);
|
||||
if ( node )
|
||||
{
|
||||
if ( node.childNodes.length == 0 )
|
||||
{
|
||||
var textNode = document.createTextNode(text);
|
||||
node.appendChild(textNode);
|
||||
}
|
||||
else if ( node.childNodes.length == 1 )
|
||||
node.childNodes[0].nodeValue = text;
|
||||
|
||||
var visible;
|
||||
|
||||
if ( text )
|
||||
visible = true;
|
||||
else
|
||||
visible = false;
|
||||
|
||||
cvSetVisible(node, visible);
|
||||
}
|
||||
|
||||
return visible;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,33 +31,34 @@ Rights Reserved.
|
|||
|
||||
<box id="CardViewInnerBox" align="vertical" flex="1">
|
||||
|
||||
<html:div hide="true" id="CardTitle">*</html:div>
|
||||
<html:div hide="true" id="CardTitle"/>
|
||||
|
||||
<box align="horizontal" style="width:100%" flex="1">
|
||||
|
||||
<box align="vertical" flex="1" style="width:200px">
|
||||
<box id="cvbName" class="cardViewGroup" align="vertical">
|
||||
<html:div class="CardViewHeading" hide="true" id="cvhName">*</html:div>
|
||||
<html:div class="CardViewText" hide="true" id="cvNickname">*</html:div>
|
||||
<html:div class="CardViewText" hide="true" id="cvEmail1">*</html:div>
|
||||
<html:div class="CardViewText" hide="true" id="cvEmail2">*</html:div>
|
||||
<html:div class="CardViewHeading" hide="true" id="cvhName"/>
|
||||
<html:div class="CardViewText" hide="true" id="cvDisplayName"/>
|
||||
<html:div class="CardViewText" hide="true" id="cvNickname"/>
|
||||
<html:div class="CardViewText" hide="true" id="cvEmail1"/>
|
||||
<html:div class="CardViewText" hide="true" id="cvEmail2"/>
|
||||
</box>
|
||||
|
||||
<box id="cvbHome" class="cardViewGroup" align="vertical">
|
||||
<html:div class="CardViewHeading" hide="true" id="cvhHome">&home.heading;</html:div>
|
||||
<html:div class="CardViewText" hide="true" id="cvHomeAddress">*</html:div>
|
||||
<html:div class="CardViewText" hide="true" id="cvHomeAddress2">*</html:div>
|
||||
<html:div class="CardViewText" hide="true" id="cvHomeCityStZip">*</html:div>
|
||||
<html:div class="CardViewText" hide="true" id="cvHomeCountry">*</html:div>
|
||||
<html:div class="CardViewText" hide="true" id="cvHomeAddress"/>
|
||||
<html:div class="CardViewText" hide="true" id="cvHomeAddress2"/>
|
||||
<html:div class="CardViewText" hide="true" id="cvHomeCityStZip"/>
|
||||
<html:div class="CardViewText" hide="true" id="cvHomeCountry"/>
|
||||
</box>
|
||||
|
||||
<box id="cvbOther" class="cardViewGroup" align="vertical">
|
||||
<html:div class="CardViewHeading" hide="true" id="cvhOther">&other.heading;</html:div>
|
||||
<html:div class="CardViewText" hide="true" id="cvCustom1">*</html:div>
|
||||
<html:div class="CardViewText" hide="true" id="cvCustom2">*</html:div>
|
||||
<html:div class="CardViewText" hide="true" id="cvCustom3">*</html:div>
|
||||
<html:div class="CardViewText" hide="true" id="cvCustom4">*</html:div>
|
||||
<html:div class="CardViewText" hide="true" id="cvNotes">*</html:div>
|
||||
<html:div class="CardViewText" hide="true" id="cvCustom1"/>
|
||||
<html:div class="CardViewText" hide="true" id="cvCustom2"/>
|
||||
<html:div class="CardViewText" hide="true" id="cvCustom3"/>
|
||||
<html:div class="CardViewText" hide="true" id="cvCustom4"/>
|
||||
<html:div class="CardViewText" hide="true" id="cvNotes"/>
|
||||
</box>
|
||||
</box>
|
||||
|
||||
|
@ -66,22 +67,22 @@ Rights Reserved.
|
|||
<box align="vertical" flex="1" style="width:200px">
|
||||
<box id="cvbPhone" class="cardViewGroup" align="vertical">
|
||||
<html:div class="CardViewHeading" hide="true" id="cvhPhone">&phone.heading;</html:div>
|
||||
<html:div class="CardViewText" hide="true" id="cvPhWork">*</html:div>
|
||||
<html:div class="CardViewText" hide="true" id="cvPhHome">*</html:div>
|
||||
<html:div class="CardViewText" hide="true" id="cvPhFax">*</html:div>
|
||||
<html:div class="CardViewText" hide="true" id="cvPhCellular">*</html:div>
|
||||
<html:div class="CardViewText" hide="true" id="cvPhPager">*</html:div>
|
||||
<html:div class="CardViewText" hide="true" id="cvPhWork"/>
|
||||
<html:div class="CardViewText" hide="true" id="cvPhHome"/>
|
||||
<html:div class="CardViewText" hide="true" id="cvPhFax"/>
|
||||
<html:div class="CardViewText" hide="true" id="cvPhCellular"/>
|
||||
<html:div class="CardViewText" hide="true" id="cvPhPager"/>
|
||||
</box>
|
||||
|
||||
<box id="cvbWork" class="cardViewGroup" align="vertical">
|
||||
<html:div class="CardViewHeading" hide="true" id="cvhWork">&work.heading;</html:div>
|
||||
<html:div class="CardViewText" hide="true" id="cvJobTitle">*</html:div>
|
||||
<html:div class="CardViewText" hide="true" id="cvDepartment">*</html:div>
|
||||
<html:div class="CardViewText" hide="true" id="cvCompany">*</html:div>
|
||||
<html:div class="CardViewText" hide="true" id="cvWorkAddress">*</html:div>
|
||||
<html:div class="CardViewText" hide="true" id="cvWorkAddress2">*</html:div>
|
||||
<html:div class="CardViewText" hide="true" id="cvWorkCityStZip">*</html:div>
|
||||
<html:div class="CardViewText" hide="true" id="cvWorkCountry">*</html:div>
|
||||
<html:div class="CardViewText" hide="true" id="cvJobTitle"/>
|
||||
<html:div class="CardViewText" hide="true" id="cvDepartment"/>
|
||||
<html:div class="CardViewText" hide="true" id="cvCompany"/>
|
||||
<html:div class="CardViewText" hide="true" id="cvWorkAddress"/>
|
||||
<html:div class="CardViewText" hide="true" id="cvWorkAddress2"/>
|
||||
<html:div class="CardViewText" hide="true" id="cvWorkCityStZip"/>
|
||||
<html:div class="CardViewText" hide="true" id="cvWorkCountry"/>
|
||||
</box>
|
||||
</box>
|
||||
|
||||
|
|
|
@ -163,6 +163,26 @@ Rights Reserved.
|
|||
</menupopup>
|
||||
</menu>
|
||||
<menuitem value="&showCardPane.label;" disabled="true" oncommand="AbShowCardPane()"/>
|
||||
<menuseparator/>
|
||||
<menu value="&menu_ShowNameAs.label;" accesskey="&menu_ShowNameAs.accesskey;">
|
||||
<menupopup>
|
||||
<menuitem type="radio" name="shownameas"
|
||||
id="firstLastCmd"
|
||||
value="&firstLastCmd.label;"
|
||||
accesskey="&firstLastCmd.accesskey;"
|
||||
oncommand="SetNameColumn('firstLastCmd')"/>
|
||||
<menuitem type="radio" name="shownameas"
|
||||
id="lastFirstCmd"
|
||||
value="&lastFirstCmd.label;"
|
||||
accesskey="&lastFirstCmd.accesskey;"
|
||||
oncommand="SetNameColumn('lastFirstCmd')"/>
|
||||
<menuitem type="radio" name="shownameas"
|
||||
id="displayNameCmd"
|
||||
value="&displayNameCmd.label;"
|
||||
accesskey="&displayNameCmd.accesskey;"
|
||||
oncommand="SetNameColumn('displayNameCmd')"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menu value="&sortMenu.label;">
|
||||
<menupopup>
|
||||
<menuitem value="&sortByNameCmd.label;"
|
||||
|
|
|
@ -60,6 +60,14 @@ Rights Reserved.
|
|||
<!-- LOCALIZATION NOTE (showAbToolbarCmd.accesskey) : DONT_TRANSLATE -->
|
||||
<!ENTITY showAbToolbarCmd.accesskey "o">
|
||||
<!ENTITY showCardPane.label ".Card Pane">
|
||||
<!ENTITY menu_ShowNameAs.label "Show Name As">
|
||||
<!ENTITY menu_ShowNameAs.accesskey "n">
|
||||
<!ENTITY firstLastCmd.label "First Last">
|
||||
<!ENTITY firstLastCmd.accesskey "f">
|
||||
<!ENTITY lastFirstCmd.label "Last, First">
|
||||
<!ENTITY lastFirstCmd.accesskey "l">
|
||||
<!ENTITY displayNameCmd.label "Display Name">
|
||||
<!ENTITY displayNameCmd.accesskey "d">
|
||||
<!ENTITY sortMenu.label "Sort">
|
||||
<!ENTITY sortByNameCmd.label "by Name">
|
||||
<!ENTITY sortByEmailCmd.label "by Email">
|
||||
|
|
Загрузка…
Ссылка в новой задаче