diff --git a/mailnews/addrbook/resources/content/addressbook.js b/mailnews/addrbook/resources/content/addressbook.js
index 852388351aeb..572b585f33da 100644
--- a/mailnews/addrbook/resources/content/addressbook.js
+++ b/mailnews/addrbook/resources/content/addressbook.js
@@ -1,22 +1,4 @@
-function GetDirectoryTree()
-{
- var directoryTree = frames[0].frames[0].document.getElementById('dirTree');
- return directoryTree;
-}
-
-function GetResultTree()
-{
- var cardTree = frames[0].frames[1].document.getElementById('resultTree');
- return cardTree;
-}
-
-function GetResultTreeDirectory()
-{
- var tree = GetResultTree();
- return tree.childNodes[5];
-}
-
-function AbNewCard()
+function AbNewCardDialog()
{
var dialog = window.openDialog("chrome://addressbook/content/newcardDialog.xul",
"abNewCard",
@@ -24,13 +6,12 @@ function AbNewCard()
return dialog;
}
-
-function AbEditCard(card)
+function AbEditCardDialog(card, okCallback)
{
var dialog = window.openDialog("chrome://addressbook/content/editcardDialog.xul",
"abEditCard",
"chrome",
- {card:card});
+ {card:card, okCallback:okCallback});
return dialog;
}
@@ -41,7 +22,8 @@ function AbDelete()
addressbook = addressbook.QueryInterface(Components.interfaces.nsIAddressBook);
dump("\AbDelete from XUL\n");
var tree = GetResultTree();
- if(tree) {
+ if( tree )
+ {
dump("tree is valid\n");
//get the selected elements
var cardList = tree.getElementsByAttribute("selected", "true");
@@ -51,3 +33,105 @@ function AbDelete()
addressbook.DeleteCards(tree, srcDirectory, cardList);
}
}
+
+
+function GetDirectoryTree()
+{
+ var directoryTree = frames["directoryFrame"].document.getElementById('dirTree');
+ return directoryTree;
+}
+
+function GetResultTree()
+{
+ var cardTree = frames["resultsFrame"].document.getElementById('resultTree');
+ return cardTree;
+}
+
+function GetResultTreeDirectory()
+{
+ var tree = GetResultTree();
+ var treechildrenList = tree.getElementsByTagName('treechildren');
+
+ if ( treechildrenList.length == 1 )
+ return(treechildrenList[0]);
+}
+
+
+function EditCard()
+{
+ var rdf = Components.classes["component://netscape/rdf/rdf-service"].getService();
+ rdf = rdf.QueryInterface(Components.interfaces.nsIRDFService);
+
+ var resultsDoc = frames["resultsFrame"].document;
+ var selArray = resultsDoc.getElementsByAttribute('selected', 'true');
+
+ if ( selArray && selArray.length == 1 )
+ {
+ var uri = selArray[0].getAttribute('id');
+ var card = rdf.GetResource(uri);
+ card = card.QueryInterface(Components.interfaces.nsIAbCard);
+ AbEditCardDialog(card, UpdateCardView);
+ }
+}
+
+function UpdateCardView()
+{
+ var resultsDoc = frames["resultsFrame"].document;
+ var selArray = resultsDoc.getElementsByAttribute('selected', 'true');
+ dump("UpdateCardView -- selArray = " + selArray + "\n");
+
+ if ( selArray && selArray.length == 1 )
+ DisplayCardViewPane(selArray[0]);
+}
+
+function AbNewMessage()
+{
+ var msgComposeService = Components.classes["component://netscape/messengercompose"].getService();
+ msgComposeService = msgComposeService.QueryInterface(Components.interfaces.nsIMsgComposeService);
+
+ msgComposeService.OpenComposeWindowWithValues(null, 0, GetSelectedAddresses(), null, null,
+ null, null, null);
+}
+
+function GetSelectedAddresses()
+{
+ var item, uri, rdf, cardResource, card;
+ var selectedAddresses = "";
+
+ var resultsDoc = frames["resultsFrame"].document;
+ var bucketDoc = frames["directoryFrame"].document;
+
+ rdf = Components.classes["component://netscape/rdf/rdf-service"].getService();
+ rdf = rdf.QueryInterface(Components.interfaces.nsIRDFService);
+
+ var selArray = resultsDoc.getElementsByAttribute('selected', 'true');
+ if ( selArray && selArray.length )
+ {
+ for ( item = 0; item < selArray.length; item++ )
+ {
+ uri = selArray[item].getAttribute('id');
+ cardResource = rdf.GetResource(uri);
+ card = cardResource.QueryInterface(Components.interfaces.nsIAbCard);
+ if ( selectedAddresses )
+ selectedAddresses += ",";
+ selectedAddresses += "\"" + card.DisplayName + "\" <" + card.PrimaryEmail + ">";
+ }
+ }
+ dump("selectedAddresses = " + selectedAddresses + "\n");
+ return selectedAddresses;
+}
+
+function AbExit()
+{
+ var editorShell = Components.classes["component://netscape/editor/editorshell"].createInstance();
+ editorShell = editorShell.QueryInterface(Components.interfaces.nsIEditorShell);
+
+ if ( editorShell )
+ editorShell.Exit();
+}
+
+function AbClose()
+{
+ top.window.close();
+}
+
diff --git a/mailnews/addrbook/resources/content/addressbook.xul b/mailnews/addrbook/resources/content/addressbook.xul
index b36da58ffa08..c79aaf3ff2b3 100644
--- a/mailnews/addrbook/resources/content/addressbook.xul
+++ b/mailnews/addrbook/resources/content/addressbook.xul
@@ -9,96 +9,100 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
-
-
+
+
+
+
]>
@@ -118,126 +122,129 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
-
-
-
+
+ &showNames.label;
+
+
diff --git a/mailnews/addrbook/resources/content/editcard.js b/mailnews/addrbook/resources/content/editcard.js
index 68cf1cac575c..4880effc91e3 100644
--- a/mailnews/addrbook/resources/content/editcard.js
+++ b/mailnews/addrbook/resources/content/editcard.js
@@ -1,10 +1,12 @@
var card;
var newCard = -1;
+var okCallback;
var editCardTitlePrefix = "Card for ";
function OnLoadNewCard()
{
top.card = newCard;
+ top.okCallback = 0;
}
@@ -14,14 +16,13 @@ function OnLoadEditCard()
if (window.arguments && window.arguments[0])
{
if ( window.arguments[0].card )
- {
- // keep card in global for later
top.card = window.arguments[0].card;
+ if ( window.arguments[0].okCallback )
+ top.okCallback = window.arguments[0].okCallback;
- GetCardValues(top.card, frames["browser.editcard"].document);
-
- //top.window.setAttribute('title', editCardTitlePrefix + top.card.DisplayName);
- }
+ GetCardValues(top.card, frames["browser.editcard"].document);
+
+ //top.window.setAttribute('title', editCardTitlePrefix + top.card.DisplayName);
}
}
@@ -47,15 +48,17 @@ function EditCardOKButton()
{
SetCardValues(top.card, frames["browser.editcard"].document);
- // Need to commit changes here Candice.
top.card.EditCardToDatabase();
+ // callback to allow caller to update
+ if ( top.okCallback )
+ top.okCallback();
+
top.window.close();
}
// Move the data from the cardproperty to the dialog
-
function GetCardValues(cardproperty, doc)
{
if ( cardproperty )
@@ -104,7 +107,6 @@ function GetCardValues(cardproperty, doc)
// Move the data from the dialog to the cardproperty to be stored in the database
-
function SetCardValues(cardproperty, doc)
{
if (cardproperty)
diff --git a/mailnews/addrbook/resources/content/selectaddress.js b/mailnews/addrbook/resources/content/selectaddress.js
index d24a1b34bd41..88096648b1b3 100644
--- a/mailnews/addrbook/resources/content/selectaddress.js
+++ b/mailnews/addrbook/resources/content/selectaddress.js
@@ -1,3 +1,119 @@
+var composeWindow = 0;
+var msgCompFields = 0;
+
+// localization strings
+var prefixTo = "To: ";
+var prefixCc = "Cc: ";
+var prefixBcc = "Bcc: ";
+
+function OnLoadSelectAddress()
+{
+ var toAddress="", ccAddress="", bccAddress="";
+
+ // look in arguments[0] for parameters
+ if (window.arguments && window.arguments[0])
+ {
+ // keep parameters in global for later
+ if ( window.arguments[0].composeWindow )
+ top.composeWindow = window.arguments[0].composeWindow;
+ if ( window.arguments[0].msgCompFields )
+ top.msgCompFields = window.arguments[0].msgCompFields;
+ if ( window.arguments[0].toAddress )
+ toAddress = window.arguments[0].toAddress;
+ if ( window.arguments[0].ccAddress )
+ ccAddress = window.arguments[0].ccAddress;
+ if ( window.arguments[0].bccAddress )
+ bccAddress = window.arguments[0].bccAddress;
+
+ dump("onload top.composeWindow: " + top.composeWindow + "\n");
+ dump("onload toAddress: " + toAddress + "\n");
+
+ // put the addresses into the bucket
+ AddAddressFromComposeWindow(toAddress, prefixTo);
+ AddAddressFromComposeWindow(ccAddress, prefixCc);
+ AddAddressFromComposeWindow(bccAddress, prefixBcc);
+ }
+}
+
+function AddAddressFromComposeWindow(addresses, prefix)
+{
+ if ( addresses )
+ {
+ var bucketDoc = frames["browser.addressbucket"].document;
+ var addressArray = addresses.split(",");
+
+ for ( var index = 0; index < addressArray.length; index++ )
+ {
+ // remove leading spaces
+ while ( addressArray[index][0] == " " )
+ addressArray[index] = addressArray[index].substring(1, addressArray[index].length);
+
+ AddAddressIntoBucket(bucketDoc, prefix + addressArray[index]);
+ }
+ }
+}
+
+
+function SelectAddressOKButton()
+{
+ var bucketDoc = frames["browser.addressbucket"].document;
+ var body = bucketDoc.getElementById('bucketBody');
+ var item, row, cell, text, colon;
+ var toAddress="", ccAddress="", bccAddress="";
+
+ for ( var index = 0; index < body.childNodes.length; index++ )
+ {
+ item = body.childNodes[index];
+ if ( item.childNodes && item.childNodes.length )
+ {
+ row = item.childNodes[0];
+ if ( row.childNodes && row.childNodes.length )
+ {
+ cell = row.childNodes[0];
+ if ( cell.childNodes && cell.childNodes.length )
+ {
+ text = cell.childNodes[0];
+ if ( text && text.data && text.data.length )
+ {
+ switch ( text.data[0] )
+ {
+ case prefixTo[0]:
+ if ( toAddress )
+ toAddress += ", ";
+ toAddress += text.data.substring(prefixTo.length, text.data.length);
+ break;
+ case prefixCc[0]:
+ if ( ccAddress )
+ ccAddress += ", ";
+ ccAddress += text.data.substring(prefixCc.length, text.data.length);
+ break;
+ case prefixBcc[0]:
+ if ( bccAddress )
+ bccAddress += ", ";
+ bccAddress += text.data.substring(prefixBcc.length, text.data.length);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // reset the UI in compose window
+ msgCompFields.SetTo(toAddress);
+ msgCompFields.SetCc(ccAddress);
+ msgCompFields.SetBcc(bccAddress);
+ top.composeWindow.CompFields2Recipients(top.msgCompFields);
+
+ top.window.close();
+}
+
+function SelectAddressCancelButton()
+{
+ top.window.close();
+}
+
+
function saChangeDirectoryByDOMNode(dirNode)
{
var uri = dirNode.getAttribute('id');
@@ -21,33 +137,22 @@ function saChangeDirectoryByURI(uri)
function SelectAddressToButton()
{
- AddSelectedAddressesIntoBucket("To: ");
+ AddSelectedAddressesIntoBucket(prefixTo);
}
function SelectAddressCcButton()
{
- AddSelectedAddressesIntoBucket("Cc: ");
+ AddSelectedAddressesIntoBucket(prefixCc);
}
function SelectAddressBccButton()
{
- AddSelectedAddressesIntoBucket("Bcc: ");
+ AddSelectedAddressesIntoBucket(prefixBcc);
}
-function SelectAddressOKButton()
-{
- top.window.close();
-}
-
-function SelectAddressCancelButton()
-{
- top.window.close();
-}
-
-
function SelectAddressNewButton()
{
- AbNewCard();
+ AbNewCardDialog();
}
function SelectAddressEditButton()
@@ -63,7 +168,7 @@ function SelectAddressEditButton()
var uri = selArray[0].getAttribute('id');
var card = rdf.GetResource(uri);
card = card.QueryInterface(Components.interfaces.nsIAbCard);
- AbEditCard(card);
+ AbEditCardDialog(card, 0);
}
}
diff --git a/mailnews/addrbook/resources/content/selectaddress.xul b/mailnews/addrbook/resources/content/selectaddress.xul
index 22c9dacfdc0a..0a16e0f01d35 100644
--- a/mailnews/addrbook/resources/content/selectaddress.xul
+++ b/mailnews/addrbook/resources/content/selectaddress.xul
@@ -37,7 +37,7 @@ Rights Reserved.
-
+
@@ -58,16 +58,19 @@ Rights Reserved.
class="dialog"
width="640" height="480"
style="width:100%; height:100%; padding:0px"
+ onload="OnLoadSelectAddress()"
align="vertical">
+
+
-
-
+
+
&search.label;
@@ -75,7 +78,7 @@ Rights Reserved.
-
+
diff --git a/mailnews/compose/resources/content/MsgComposeCommands.js b/mailnews/compose/resources/content/MsgComposeCommands.js
index 5a89f0b0ebcd..056bdb9af58c 100644
--- a/mailnews/compose/resources/content/MsgComposeCommands.js
+++ b/mailnews/compose/resources/content/MsgComposeCommands.js
@@ -18,7 +18,7 @@
* Rights Reserved.
*/
-var msgComposeService = Components.classes['component://netscape/messengercompose'].getService();
+var msgComposeService = Components.classes["component://netscape/messengercompose"].getService();
msgComposeService = msgComposeService.QueryInterface(Components.interfaces.nsIMsgComposeService);
var msgCompose = null;
var MAX_RECIPIENTS = 0;
@@ -113,12 +113,27 @@ function ComposeStartup()
// Now that we have an Editor AppCore, we can finish to initialize the Compose AppCore
msgCompose.editor = window.editorShell;
- //Now we are ready to load all the fields (to, cc, subject, body, etc...)
- msgCompose.LoadFields();
var msgCompFields = msgCompose.compFields;
if (msgCompFields)
{
+ if (args.body) //We need to set the body before calling LoadFields();
+ msgCompFields.SetBody(args.body);
+
+ //Now we are ready to load all the fields (to, cc, subject, body, etc...) depending of the type of the message
+ msgCompose.LoadFields();
+
+ if (args.to)
+ msgCompFields.SetTo(args.to);
+ if (args.cc)
+ msgCompFields.SetCc(args.cc);
+ if (args.bcc)
+ msgCompFields.SetBcc(args.bcc);
+ if (args.newsgroups)
+ msgCompFields.SetNewsgroups(args.newsgroups);
+ if (args.subject)
+ msgCompFields.SetSubject(args.subject);
+
CompFields2Recipients(msgCompFields);
var subjectValue = msgCompFields.GetSubject();
if (subjectValue != "")
@@ -220,9 +235,24 @@ function SaveAsTemplate()
function SelectAddress()
{
+ var msgCompFields = msgCompose.compFields;
+
+ Recipients2CompFields(msgCompFields);
+
+ var toAddress = msgCompFields.GetTo();
+ var ccAddress = msgCompFields.GetCc();
+ var bccAddress = msgCompFields.GetBcc();
+
+ dump("toAddress: " + toAddress + "\n");
var dialog = window.openDialog("chrome://addressbook/content/selectaddress.xul",
"selectAddress",
- "chrome");
+ "chrome",
+ {composeWindow:top.window,
+ msgCompFields:msgCompFields,
+ toAddress:toAddress,
+ ccAddress:ccAddress,
+ bccAddress:bccAddress});
+
return dialog;
}
@@ -285,8 +315,9 @@ function FillRecipientTypeCombobox()
for (var j = 0; j < originalCombo.length; j ++)
combo.add(new Option(originalCombo.options[j].text,
originalCombo.options[j].value), null);
- MAX_RECIPIENTS ++;
+ MAX_RECIPIENTS++;
}
+ MAX_RECIPIENTS--;
}
}
@@ -361,9 +392,14 @@ function CompFields2Recipients(msgCompFields)
if (fieldValue != "" && i <= MAX_RECIPIENTS)
{
document.getElementById("msgRecipient#" + i).value = fieldValue;
- document.getElementById("msgRecipientType#" + i).value = "addr_newsgroup";
+ document.getElementById("msgRecipientType#" + i).value = "addr_newsgroups";
i ++;
}
+
+ for (; i <= MAX_RECIPIENTS; i++)
+ {
+ document.getElementById("msgRecipient#" + i).value = "";
+ document.getElementById("msgRecipientType#" + i).value = "addrTo";
+ }
}
}
-
diff --git a/mailnews/compose/resources/content/messengercompose.xul b/mailnews/compose/resources/content/messengercompose.xul
index 85b52f84ddf3..b0e5976c1c5d 100644
--- a/mailnews/compose/resources/content/messengercompose.xul
+++ b/mailnews/compose/resources/content/messengercompose.xul
@@ -116,8 +116,8 @@ Rights Reserved.
-
-
+
+
@@ -263,16 +263,43 @@ Rights Reserved.
+
+
+
+
+
+
-
+
-
+
-
+
+
+
+
+
+
+