Implement new UI with dynamic recipients list (blocked to 3 fields for now)

This commit is contained in:
ducarroz%netscape.com 1999-07-03 21:40:41 +00:00
Родитель faee0f3324
Коммит 499f9af92e
2 изменённых файлов: 214 добавлений и 61 удалений

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

@ -21,6 +21,7 @@
var msgComposeService = Components.classes['component://netscape/messengercompose'].getService();
msgComposeService = msgComposeService.QueryInterface(Components.interfaces.nsIMsgComposeService);
var msgCompose = null;
var MAX_RECIPIENTS = 0;
function GetArgs()
{
@ -54,6 +55,15 @@ function ComposeStartup()
dump("[format=" + args.format + "]\n");
dump("[originalMsg=" + args.originalMsg + "]\n");
// fill in Identity combobox
var identitySelect = document.getElementById("msgIdentity");
if (identitySelect) {
fillIdentitySelect(identitySelect);
}
// fill in Recipient type combobox
FillRecipientTypeCombobox();
if (msgComposeService)
{
msgCompose = msgComposeService.InitCompose(window, args.originalMsg, args.type, args.format);
@ -105,16 +115,19 @@ function ComposeStartup()
//Now we are ready to load all the fields (to, cc, subject, body, etc...)
msgCompose.LoadFields();
document.getElementById("msgTo").focus();
var msgCompFields = msgCompose.compFields;
if (msgCompFields)
{
CompFields2Recipients(msgCompFields);
var subjectValue = msgCompFields.GetSubject();
if (subjectValue != "")
document.getElementById("msgSubject").value = subjectValue;
}
document.getElementById("msgRecipient#1").focus();
}
}
// fill in Identity combobox
var identitySelect = document.getElementById("msgIdentity");
if (identitySelect) {
fillIdentitySelect(identitySelect);
}
}
@ -153,7 +166,16 @@ function SendMessage()
dump("Identity = " + getCurrentIdentity() + "\n");
if (msgCompose != null)
msgCompose.SendMsg(0, getCurrentIdentity(), null);
{
var msgCompFields = msgCompose.compFields;
if (msgCompFields)
{
Recipients2CompFields(msgCompFields);
msgCompFields.SetSubject(document.getElementById("msgSubject").value);
msgCompose.SendMsg(0, getCurrentIdentity(), null);
}
}
else
dump("###SendMessage Error: composeAppCore is null!\n");
}
@ -187,22 +209,22 @@ function GetIdentities()
return identities;
}
function fillIdentitySelect(selectElement) {
function fillIdentitySelect(selectElement)
{
var identities = GetIdentities();
for (var i=0; i<identities.length; i++) {
var identity = identities[i];
var opt = new Option(identity.identityName, identity.key);
for (var i=0; i<identities.length; i++)
{
var identity = identities[i];
var opt = new Option(identity.identityName, identity.key);
selectElement.add(opt, null);
selectElement.add(opt, null);
}
}
function getCurrentIdentity() {
function getCurrentIdentity()
{
var msgService = Components.classes['component://netscape/messenger/services/session'].getService(Components.interfaces.nsIMsgMailSession);
var accountManager = msgService.accountManager;
// fill in Identity combobox
@ -213,3 +235,96 @@ function getCurrentIdentity() {
return identity;
}
function FillRecipientTypeCombobox()
{
originalCombo = document.getElementById("msgRecipientType#1");
if (originalCombo)
{
MAX_RECIPIENTS = 2;
while ((combo = document.getElementById("msgRecipientType#" + MAX_RECIPIENTS)))
{
for (var j = 0; j < originalCombo.length; j ++)
combo.add(new Option(originalCombo.options[j].text,
originalCombo.options[j].value), null);
MAX_RECIPIENTS ++;
}
}
}
function Recipients2CompFields(msgCompFields)
{
if (msgCompFields)
{
var i = 1;
var addrTo = "";
var addrCc = "";
var addrBcc = "";
var addrNg = "";
var to_Sep = "";
var cc_Sep = "";
var bcc_Sep = "";
var ng_Sep = "";
while ((inputField = document.getElementById("msgRecipient#" + i)))
{
fieldValue = inputField.value;
if (fieldValue != "")
{
switch (document.getElementById("msgRecipientType#" + i).value)
{
case "addr_to" : addrTo += to_Sep + fieldValue; to_Sep = ","; break;
case "addr_cc" : addrCc += cc_Sep + fieldValue; cc_Sep = ","; break;
case "addr_bcc" : addrBcc += bcc_Sep + fieldValue; bcc_Sep = ","; break;
case "addr_newsgroups" : addrNg += ng_Sep + fieldValue; ng_Sep = ","; break;
}
}
i ++;
}
msgCompFields.SetTo(addrTo);
msgCompFields.SetCc(addrCc);
msgCompFields.SetBcc(addrBcc);
msgCompFields.SetNewsgroups(addrNg);
}
else
dump("Message Compose Error: msgCompFields is null (ExtractRecipients)");
}
function CompFields2Recipients(msgCompFields)
{
if (msgCompFields)
{
var i = 1;
var fieldValue = msgCompFields.GetTo();
if (fieldValue != "" && i <= MAX_RECIPIENTS)
{
document.getElementById("msgRecipient#" + i).value = fieldValue;
document.getElementById("msgRecipientType#" + i).value = "addr_to";
i ++;
}
fieldValue = msgCompFields.GetCc();
if (fieldValue != "" && i <= MAX_RECIPIENTS)
{
document.getElementById("msgRecipient#" + i).value = fieldValue;
document.getElementById("msgRecipientType#" + i).value = "addr_cc";
i ++;
}
fieldValue = msgCompFields.GetBcc();
if (fieldValue != "" && i <= MAX_RECIPIENTS)
{
document.getElementById("msgRecipient#" + i).value = fieldValue;
document.getElementById("msgRecipientType#" + i).value = "addr_bcc";
i ++;
}
fieldValue = msgCompFields.GetNewsgroups();
if (fieldValue != "" && i <= MAX_RECIPIENTS)
{
document.getElementById("msgRecipient#" + i).value = fieldValue;
document.getElementById("msgRecipientType#" + i).value = "addr_newsgroup";
i ++;
}
}
}

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

@ -14,6 +14,9 @@
<!ENTITY bccAddr.label "Bcc:">
<!ENTITY newsgroupsAddr.label "Newsgroups:">
<!ENTITY subject.label "Subject:">
<!-- *** AS I DON't KNOW HOW TO ACCESS THOSE ADDRESS VALUES FROM MsgComposeCommands.js, -->
<!-- I HAVE HARDCODED THEM DIRECTLY IN THE SCRIPT *** -->
<!-- menu items: the . means that the menu item isn't implemented yet -->
@ -78,13 +81,19 @@
<!ENTITY throbberButton.img "resource:/res/throbber/anims00.gif">
<!ENTITY throbberButton.url "http://www.mozilla.org/">
<!-- Toolbar items, imported from editorAppShell.xul -->
<!ENTITY formatToolbar.boldChar "B">
<!ENTITY formatToolbar.italicChar "I">
<!ENTITY formatToolbar.underlineChar "U">
]>
<window xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onunload="ComposeUnload()"
title="&msgComposeWindow.title;"
style="width:100%;height:100%">
style="width:100%;height:100%"
align="vertical"
>
<html:script language="JavaScript" src="chrome://editor/content/EditorCommands.js"/>
@ -195,7 +204,7 @@
</menu>
</menubar>
<box id="toolbar" align="vertical" style="width:100%;height:100%">
<!-- box id="toolbar" align="vertical" style="width:100%;height:100%" -->
<toolbox>
<toolbar>
<titledbutton src="&sendButton.img;" align="bottom" value="&sendButton.label;" onClick="SendMessage()"/>
@ -210,57 +219,86 @@
</toolbar>
<toolbar>
<html:div flex="10%">&fromAddr.label;</html:div>
<html:select id="msgIdentity" flex="90%"/>
</toolbar>
<toolbar>
<html:div flex="10%">&toAddr.label;</html:div>
<html:input id="msgTo" type="text" flex="90%"/>
</toolbar>
<toolbar>
<html:div flex="10%">&ccAddr.label;</html:div>
<html:input id="msgCc" type="text" flex="90%"/>
</toolbar>
<toolbar>
<html:div flex="10%">&bccAddr.label;</html:div>
<html:input id="msgBcc" type="text" flex="90%"/>
</toolbar>
<toolbar>
<html:div flex="10%">&newsgroupsAddr.label;</html:div>
<html:input id="msgNewsgroup" type="text" flex="90%"/>
<box align="horizontal" flex="100%">
<box align="vertical" flex="60%">
<box align="horizontal" flex="100%">
<html:div flex="20%">&fromAddr.label;</html:div>
<html:select id="msgIdentity" flex="80%"/>
</box>
<spring style="height:0.5em"/>
<box align="horizontal" flex="100%">
<box align="vertical" flex="20%">
<box align="vertical" flex="100%">
<html:select id="msgRecipientType#1" flex="100%">
<html:option value="addr_to">&toAddr.label;</html:option>
<html:option value="addr_cc">&ccAddr.label;</html:option>
<html:option value="addr_bcc">&bccAddr.label;</html:option>
<html:option value="addr_newsgroups">&newsgroupsAddr.label;</html:option>
</html:select>
</box>
<box align="vertical" flex="100%">
<html:select id="msgRecipientType#2" flex="100%"/>
</box>
<box align="vertical" flex="100%">
<html:select id="msgRecipientType#3" flex="100%"/>
</box>
</box>
<box align="vertical" flex="80%">
<box align="vertical" flex="100%">
<html:input type="text" id="msgRecipient#1" flex="100%"/>
</box>
<box align="vertical" flex="100%">
<html:input type="text" id="msgRecipient#2" flex="100%"/>
</box>
<box align="vertical" flex="100%">
<html:input type="text" id="msgRecipient#3" flex="100%"/>
</box>
</box>
</box>
<box align="honrizontal" flex="100%">
<html:div flex="20%">&subject.label;</html:div>
<html:input id="msgSubject" type="text" flex="80%"/>
</box>
</box>
<box align="vertical" flex="40%">
<html:div flex="100%">[attachment box]</html:div>
</box>
</box>
</toolbar>
<toolbar>
<html:div flex="10%">&subject.label;</html:div>
<html:input id="msgSubject" type="text" flex="90%"/>
</toolbar>
<!-- The Following toolbar has been imported from editorAppShell.xul -->
<toolbar>
<titledbutton id="ParagraphPopup" value="Paragraph" class="popup" align="left" popup="ParagraphMenu"/>
<titledbutton id="FontFacePopup" value="Font" class="popup" align="left" popup="FontFaceMenu"/>
<titledbutton id="FontSizePopup" value="Size" class="popup" align="left" popup="FontSizeMenu"/>
<titledbutton id="TextColorPopup" src="chrome://editor/skin/images/ED_TextColor.gif" class="popup" popup="TextColorMenu"/>
<titledbutton id="BackColorPopup" src="chrome://editor/skin/images/ED_BackColor.gif" class="popup" popup="BackColorMenu"/>
<toolbar id="FormatToolbar">
<titledbutton id="ParagraphPopup" value="Paragraph" class="popup" align="left" popup="ParagraphMenu" popupanchor="bottomleft"/>
<titledbutton id="FontFacePopup" value="Font" class="popup" align="left" popup="FontFaceMenu" popupanchor="bottomleft"/>
<titledbutton id="FontSizePopup" value="Size" class="popup" align="left" popup="FontSizeMenu" popupanchor="bottomleft"/>
<titledbutton id="TextColorPopup" src="chrome://editor/skin/images/ED_TextColor.gif" class="popup" popup="TextColorMenu" popupanchor="bottomleft"/>
<titledbutton id="BackColorPopup" src="chrome://editor/skin/images/ED_BackColor.gif" class="popup" popup="BackColorMenu" popupanchor="bottomleft"/>
<titledbutton id="BoldButton" value="&formatToolbar.boldChar;" onclick="EditorApplyStyle('b')">
<observes element="Editor:Style:IsBold" attribute="bold" onchange="onBoldChange()"/>
</titledbutton>
<titledbutton id="ItalicButton" value="&formatToolbar.italicChar;" onclick="EditorApplyStyle('i')"/>
<titledbutton id="UnderlineButton" value="&formatToolbar.underlineChar;" onclick="EditorApplyStyle('u')"/>
<!--
<titledbutton id="BoldButton" src="chrome://editor/skin/images/ED_Bold.gif" align="bottom" onclick="EditorApplyStyle('b')">
<observes element="Editor:Style:IsBold" attribute="bold" onchange="onBoldChange()"/>
</titledbutton>
<titledbutton src="chrome://editor/skin/images/ED_Italic.gif" align="bottom" onclick="EditorApplyStyle('i')"/>
<titledbutton src="chrome://editor/skin/images/ED_Underline.gif" align="bottom" onclick="EditorApplyStyle('u')"/>
<titledbutton src="chrome://editor/skin/images/ED_ClearStyle.gif" align="bottom" onclick="EditorRemoveStyle('all')"/>
<titledbutton id="ItalicButton" src="chrome://editor/skin/images/ED_Italic.gif" align="bottom" onclick="EditorApplyStyle('i')"/>
<titledbutton id="UnderlineButton" src="chrome://editor/skin/images/ED_Underline.gif" align="bottom" onclick="EditorApplyStyle('u')"/>
-->
<titledbutton src="chrome://editor/skin/images/ED_Bullets.gif" align="bottom" onclick="EditorInsertList('ul')"/>
<titledbutton src="chrome://editor/skin/images/ED_Numbers.gif" align="bottom" onclick="EditorInsertList('ol')"/>
<titledbutton src="chrome://editor/skin/images/ED_Outdent.gif" align="bottom" onclick="EditorIndent('outdent')"/>
<titledbutton src="chrome://editor/skin/images/ED_Indent.gif" align="bottom" onclick="EditorIndent('indent')"/>
<titledbutton src="chrome://editor/skin/images/ED_Align.gif" align="bottom" class="popup" popup="AlignmentMenu"/>
<titledbutton src="chrome://editor/skin/images/ED_Link.gif" align="bottom" onclick="EditorInsertLink()"/>
<titledbutton src="chrome://editor/skin/images/ED_Image.gif" align="bottom" onclick= "EditorInsertImage()"/>
<titledbutton src="chrome://editor/skin/images/ED_HLine.gif" align="bottom" onclick= "EditorInsertHLine()"/>
<titledbutton src="chrome://editor/skin/images/ED_Spell.gif" align="bottom" class="popup" onclick="CheckSpelling()"/>
</toolbar>
<titledbutton src="chrome://editor/skin/images/ED_Align.gif" align="bottom" class="popup" popup="AlignmentWindow" popupanchor="bottomleft"/>
<titledbutton src="chrome://editor/skin/images/ED_Link.gif" align="bottom" value="Link" onclick="EditorInsertLink()"/>
<titledbutton src="chrome://editor/skin/images/ED_Image.gif" align="bottom" value="Image" onclick="EditorInsertImage()"/>
<titledbutton src="chrome://editor/skin/images/ED_Target.gif" align="bottom" value="Anchor" onclick="EditorInsertNamedAnchor()"/>
<titledbutton src="chrome://editor/skin/images/ED_HLine.gif" align="bottom" value="H.Line" onclick="EditorInsertHLine()"/>
<titledbutton src="chrome://editor/skin/images/ED_Spell.gif" align="bottom" value="Spell" class="popup" onclick="CheckSpelling()"/>
<spring flex="100%"/>
</toolbar>
</toolbox>
<!-- The main mail three pane frame -->
@ -281,6 +319,6 @@
</titledbutton>
</box>
</box>
<!-- /box -->
</window>