Changed new card and edit card to be usable from components outside of address book.

This commit is contained in:
hangas%netscape.com 1999-08-27 07:07:34 +00:00
parent accaff242d
commit 2252c76b07
10 changed files with 64 additions and 133 deletions

View File

@ -17,22 +17,22 @@ function OnLoadNewCard()
if (window.arguments && window.arguments[0])
{
if ( window.arguments[0].GetAddressBooksAndURIs )
editCard.GetAddressBooksAndURIs = window.arguments[0].GetAddressBooksAndURIs;
if ( window.arguments[0].selectedAB )
editCard.selectedAB = window.arguments[0].selectedAB;
}
var abArray = new Array();
var uriArray = new Array();
var selected = editCard.GetAddressBooksAndURIs(abArray, uriArray);
// fill popup with address book names
var popup = document.getElementById('chooseAddressBook');
for ( var index = 0; index < abArray.length; index++ )
{
var option = new Option(abArray[index], uriArray[index]);
popup.add(option, null);
}
popup.value = uriArray[selected];
// set popup with address book names
var abPopup = document.getElementById('abPopup');
if ( editCard.selectedAB )
abPopup.value = editCard.selectedAB;
//// FIX ME - looks like we need to focus on both the text field and the tab widget
//// probably need to do the same in the addressing widget
// focus on first name
var firstName = document.getElementById('FirstName');
if ( firstName )
firstName.focus();
}
@ -106,7 +106,7 @@ function InitEditCard()
function NewCardOKButton()
{
var popup = document.getElementById('chooseAddressBook');
var popup = document.getElementById('abPopup');
if ( popup )
{
var uri = popup.value;

View File

@ -1,68 +1,16 @@
// functions needed from abMainWindow and abSelectAddresses
function AbNewCardDialog()
function AbNewCard()
{
window.openDialog("chrome://addressbook/content/abNewCardDialog.xul",
"",
"chrome,resizeable=no,modal",
{GetAddressBooksAndURIs:GetAddressBooksAndURIs});
}
function GetAddressBooksAndURIs(abArray, uriArray)
{
var numAddressBooks = 0;
var selected = 0;
var selectedAB = 0;
var tree = document.getElementById('dirTree');
if ( tree )
{
var body = document.getElementById('dirTreeBody')
if ( body )
{
var treeitems = body.getElementsByTagName('treeitem');
if ( treeitems )
{
var name, uri, item, selectedItem = 0;
if ( tree.selectedItems && (tree.selectedItems.length == 1) )
selectedItem = tree.selectedItems[0];
for ( var index = 0; index < treeitems.length; index++ )
{
item = treeitems[index];
uri = item.getAttribute('id');
if ( item == selectedItem )
selected = numAddressBooks;
var buttons = item.getElementsByTagName('titledbutton');
if ( uri && buttons && buttons.length == 1 )
{
name = buttons[0].getAttribute('value');
if ( name )
{
abArray[numAddressBooks] = name;
uriArray[numAddressBooks] = uri;
numAddressBooks++;
}
}
}
}
}
}
return selected;
if ( tree && tree.selectedItems && (tree.selectedItems.length == 1) )
selectedAB = tree.selectedItems[0].getAttribute('id');
goNewCardDialog(selectedAB);
}
function AbEditCardDialog(card, okCallback)
{
var dialog = window.openDialog("chrome://addressbook/content/abEditCardDialog.xul",
"",
"chrome,resizeable=no,modal",
{abURI:document.getElementById('resultsTree').getAttribute('ref'),
card:card, okCallback:okCallback});
return dialog;
}
function EditCard()
function AbEditCard()
{
var rdf = Components.classes["component://netscape/rdf/rdf-service"].getService();
rdf = rdf.QueryInterface(Components.interfaces.nsIRDFService);
@ -74,7 +22,11 @@ function EditCard()
var uri = resultsTree.selectedItems[0].getAttribute('id');
var card = rdf.GetResource(uri);
card = card.QueryInterface(Components.interfaces.nsIAbCard);
AbEditCardDialog(card, UpdateCardView);
var editCardCallback = 0;
if ( top.addressbook && top.addressbook.editCardCallback )
editCardCallback = top.addressbook.editCardCallback;
goEditCardDialog(document.getElementById('resultsTree').getAttribute('ref'),
card, editCardCallback);
}
}

View File

@ -39,12 +39,9 @@ Rights Reserved.
<rule>
<treechildren>
<treeitem uri="...">
<treerow >
<treecell>
<treeindentation />
<titledbutton value="rdf:http://home.netscape.com/NC-rdf#DirName" align="left" />
</treecell>
</treerow>
<treerow >
<treecell indent="true" value="rdf:http://home.netscape.com/NC-rdf#DirName"/>
</treerow>
</treeitem>
</treechildren>
</rule>

View File

@ -36,24 +36,24 @@ Rights Reserved.
style="padding:0px"
align="vertical">
<!--html:script language="JavaScript" src="resource:/res/samples/DumpDOM.js"/-->
<html:script language="JavaScript" src="resource:/res/samples/DumpDOM.js"/>
<!--box align="horizontal">
<html:label for="abPopup">Test: </html:label>
<box align="horizontal">
<html:label for="abPopup">&chooseAddressBook.label;</html:label>
<html:select id="abPopup" ref="abdirectory://" datasources="rdf:addressdirectory">
<template>
<html:option uri="..."
value="rdf:http://home.netscape.com/NC-rdf#DirName"
name="rdf:http://home.netscape.com/NC-rdf#URL"/>
<html:option uri="..." value="...">
<text value="rdf:http://home.netscape.com/NC-rdf#DirName"/>
</html:option>
</template>
</html:select>
</box-->
</box>
<box align="horizontal">
<!--box align="horizontal">
<html:label for="chooseAddressBook">&chooseAddressBook.label;</html:label>
<html:select id="chooseAddressBook">
</html:select>
</box>
</box-->
<spring style="height:1em"/>

View File

@ -33,7 +33,7 @@ Rights Reserved.
flex="100%"
rdf:datasources="rdf:addressdirectory rdf:addresscard"
onselect="top.ResultsPaneSelectionChange()"
ondblclick="top.EditCard()"
ondblclick="top.AbEditCard()"
rdf:containment="http://home.netscape.com/NC-rdf#CardChild">
<template>
@ -41,16 +41,9 @@ Rights Reserved.
<treechildren>
<treeitem uri="...">
<treerow >
<treecell>
<treeindentation />
<titledbutton value="rdf:http://home.netscape.com/NC-rdf#DisplayName" align="left" />
</treecell>
<treecell>
<titledbutton value="rdf:http://home.netscape.com/NC-rdf#PrimaryEmail" align="right" style="list-style-image: none;" />
</treecell>
<treecell>
<titledbutton value="rdf:http://home.netscape.com/NC-rdf#WorkPhone" align="right" style="list-style-image: none;" />
</treecell>
<treecell indent="true" value="rdf:http://home.netscape.com/NC-rdf#DisplayName"/>
<treecell value="rdf:http://home.netscape.com/NC-rdf#PrimaryEmail"/>
<treecell value="rdf:http://home.netscape.com/NC-rdf#WorkPhone"/>
</treerow>
</treeitem>
</treechildren>

View File

@ -123,11 +123,6 @@ function SelectAddressBccButton()
AddSelectedAddressesIntoBucket(prefixBcc);
}
function SelectAddressNewButton()
{
AbNewCardDialog();
}
function AddSelectedAddressesIntoBucket(prefix)
{
var item, uri, rdf, cardResource, card, address;

View File

@ -41,6 +41,7 @@ Rights Reserved.
<html:script language="JavaScript" src="chrome://addressbook/content/abCommon.js"/>
<html:script language="JavaScript" src="chrome://addressbook/content/abSelectAddressesDialog.js"/>
<html:script language="JavaScript" src="chrome://messengercompose/content/MsgComposeCommands.js"/>
<html:script language="JavaScript" src="chrome://global/content/globalOverlay.js"/>
<!--
<html:script language="JavaScript" src="resource:/res/samples/DumpDOM.js"/>
-->
@ -117,9 +118,9 @@ Rights Reserved.
<box align="vertical" style="padding: .5em; padding-right: 0px">
<box align="vertical" flex="50%">
<spring style="height:10px"/>
<titledbutton id="new" value="&newButton.label;" class="push" onclick="SelectAddressNewButton()"/>
<titledbutton id="new" value="&newButton.label;" class="push" onclick="AbNewCard()"/>
<spring style="height:10px"/>
<titledbutton id="edit" value="&editButton.label;" class="push" onclick="SelectAddressEditButton()"/>
<titledbutton id="edit" value="&editButton.label;" class="push" onclick="AbEditCard()"/>
<spring style="height:10px"/>
<titledbutton id="view" value="&viewButton.label;" class="push" onclick="SelectAddressViewButton()"/>
<spring flex="100%"/>

View File

@ -9,6 +9,7 @@ function OnLoadAddressBook()
top.addressbook = Components.classes["component://netscape/addressbook"].createInstance();
top.addressbook = top.addressbook.QueryInterface(Components.interfaces.nsIAddressBook);
top.addressbook.editCardCallback = UpdateCardView;
try {
top.addressbook.SetWebShellWindow(window)
@ -16,6 +17,14 @@ function OnLoadAddressBook()
catch (ex) {
dump("failed to set webshell window\n");
}
document.commandDispatcher.addCommand(document.getElementById('CommandUpdate_AddressBook'));
}
function CommandUpdate_AddressBook()
{
dump("CommandUpdate_AddressBook\n");
}

View File

@ -44,6 +44,8 @@ Rights Reserved.
<!--
<html:script language="JavaScript" src="resource:/res/samples/DumpDOM.js"/>
-->
<broadcaster id="CommandUpdate_AddressBook" onchange="CommandUpdate_AddressBook()"/>
<broadcaster id="cmd_NewMessage"/>
<toolbox>
<menubar>
@ -55,7 +57,7 @@ Rights Reserved.
<menuitem value="&newMessageCmd.label;" oncommand="AbNewMessage();"/>
</menupopup>
</menu>
<menuitem value="&newCardCmd.label;" oncommand="AbNewCardDialog()"/>
<menuitem value="&newCardCmd.label;" oncommand="AbNewCard()"/>
<menuitem value="&newListCmd.label;" oncommand="AbNewList()"/>
<menuitem value="&newAddressBookCmd.label;" oncommand="AbNewAddressBook()"/>
<menuitem value="&newDirectoryCmd.label;" oncommand="AbNewDirectoryt()"/>
@ -86,7 +88,7 @@ Rights Reserved.
<menuitem value="&searchCmd.label;" oncommand="AbSearch();"/>
<menuseparator/>
<menuitem value="&htmlDomainCmd.label;" oncommand="AbHTMLDomain();"/>
<menuitem value="&abPropsCmd.label;" oncommand="EditCard();"/>
<menuitem value="&abPropsCmd.label;" oncommand="AbEditCard();"/>
<menuseparator/>
<menuitem value="&prefsCmd.label;" oncommand="MsgPreferences();"/>
</menupopup>
@ -122,9 +124,9 @@ Rights Reserved.
<spring flex="100%"/>
</menubar>
<toolbar>
<titledbutton src="&newcardButton.img;" align="top" value="&newcardButton.label;" onclick="AbNewCardDialog()"/>
<titledbutton src="&newcardButton.img;" align="top" value="&newcardButton.label;" onclick="AbNewCard()"/>
<titledbutton src="&newlistButton.img;" align="top" value="&newlistButton.label;" onclick="AbNewList()"/>
<titledbutton src="&editButton.img;" align="top" value="&editButton.label;" onclick="EditCard()"/>
<titledbutton src="&editButton.img;" align="top" value="&editButton.label;" onclick="AbEditCard()"/>
<titledbutton src="&newmsgButton.img;" align="top" value="&newmsgButton.label;" onclick="AbNewMessage()"/>
<titledbutton src="&deleteButton.img;" align="top" value="&deleteButton.label;" onclick="AbDelete()"/>

View File

@ -67,30 +67,12 @@ box[class="CardView"] {
/* Custom Trees */
tree[class="abDirectory"] treeitem > treerow > treecell > titledbutton {
vertical-align: bottom;
min-height: 1px;
min-width: 1px;
height: 1em;
width: 1em;
margin:0px;
padding:0px;
border:none;
list-style-image: url("chrome://addressbook/skin/myaddrbk.gif");
color:inherit;
tree[class="abDirectory"] treeitem > treerow > treecell > .tree-icon {
list-style-image: url("chrome://addressbook/skin/myaddrbk.gif");
}
tree[class="abResults"] treeitem > treerow > treecell > titledbutton {
vertical-align: middle;
min-height: 1px;
min-width: 1px;
height: 1em;
width: 2em;
margin:0px;
padding:0px;
border:none;
tree[class="abResults"] treeitem > treerow > treecell > .tree-icon {
list-style-image: url("chrome://addressbook/skin/person.gif");
color:inherit;
}