Added dynamic addressing widget to mail compose window. It still needs work, mainly waiting on XP bugs. Hook?=sspitzer

This commit is contained in:
hangas%netscape.com 1999-08-19 22:22:44 +00:00
Родитель 189e9b728d
Коммит 7ec091056e
5 изменённых файлов: 387 добавлений и 311 удалений

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

@ -390,16 +390,14 @@ function SelectAddress()
var bccAddress = msgCompFields.GetBcc();
dump("toAddress: " + toAddress + "\n");
var dialog = window.openDialog("chrome://addressbook/content/abSelectAddressesDialog.xul",
"",
"chrome",
{composeWindow:top.window,
msgCompFields:msgCompFields,
toAddress:toAddress,
ccAddress:ccAddress,
bccAddress:bccAddress});
return dialog;
window.openDialog("chrome://addressbook/content/abSelectAddressesDialog.xul",
"",
"chrome,resizable",
{composeWindow:top.window,
msgCompFields:msgCompFields,
toAddress:toAddress,
ccAddress:ccAddress,
bccAddress:bccAddress});
}
function queryISupportsArray(supportsArray, iid) {

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

@ -12,12 +12,16 @@ var AddressAutoCompleteListener = {
}
};
function AutoCompleteAddress(select_doc_id, doc_id)
function AutoCompleteAddress(inputElement)
{
dump("select_doc_id = " + select_doc_id + "\n");
dump("doc_id = " + doc_id + "\n");
///////////// (select_doc_id, doc_id)
var select = document.getElementById(select_doc_id);
dump("inputElement = " + inputElement + "\n");
var row = awGetRowByInputElement(inputElement);
var select = awGetPopupElement(row);
dump("select = " + select + "\n");
dump("select.value = " + select.value + "\n");
@ -27,14 +31,12 @@ function AutoCompleteAddress(select_doc_id, doc_id)
}
var ac = Components.classes['component://netscape/messenger/autocomplete&type=addrbook'];
if (ac) {
ac = ac.getService();
}
if (ac) {
ac = ac.QueryInterface(Components.interfaces.nsIAutoCompleteSession);
}
if (ac) {
ac = ac.getService();
}
if (ac) {
ac = ac.QueryInterface(Components.interfaces.nsIAutoCompleteSession);
}
var field = document.getElementById(doc_id);
ac.AutoComplete(doc_id, field.value, AddressAutoCompleteListener);
ac.AutoComplete(inputElement.getAttribute('id'), inputElement.value, AddressAutoCompleteListener);
}

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

@ -1,17 +1,31 @@
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
function FillRecipientTypeCombobox()
{
originalCombo = document.getElementById("msgRecipientType#1");
if (originalCombo)
top.MAX_RECIPIENTS = 1;
var body;
for ( var row = 2; row <= top.MAX_RECIPIENTS; row++ )
{
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++;
}
MAX_RECIPIENTS--;
body = document.getElementById('addressWidgetBody');
awCopyNode(awGetTreeItem(1), body, 0);
}
}
@ -34,12 +48,12 @@ function Recipients2CompFields(msgCompFields)
var ng_Sep = "";
var follow_Sep = "";
while ((inputField = document.getElementById("msgRecipient#" + i)))
while ((inputField = awGetInputElement(i)))
{
fieldValue = inputField.value;
if (fieldValue != "")
{
switch (document.getElementById("msgRecipientType#" + i).value)
switch (awGetPopupElement(i).value)
{
case "addr_to" : addrTo += to_Sep + fieldValue; to_Sep = ","; break;
case "addr_cc" : addrCc += cc_Sep + fieldValue; cc_Sep = ","; break;
@ -47,7 +61,7 @@ function Recipients2CompFields(msgCompFields)
case "addr_reply" : addrReply += reply_Sep + fieldValue; reply_Sep = ","; break;
case "addr_newsgroups" : addrNg += ng_Sep + fieldValue; ng_Sep = ","; break;
case "addr_followup" : addrFollow += follow_Sep + fieldValue; follow_Sep = ","; break;
case "addr_other" : addrOther += other_header + ": " + fieldValue + "\n"; break;
case "addr_other" : addrOther += other_header + ": " + fieldValue + "\n"; break;
}
}
i ++;
@ -68,72 +82,300 @@ 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.GetReplyTo();
if (fieldValue != "" && i <= MAX_RECIPIENTS)
{
document.getElementById("msgRecipient#" + i).value = fieldValue;
document.getElementById("msgRecipientType#" + i).value = "addr_reply";
i ++;
}
fieldValue = msgCompFields.GetOtherRandomHeaders();
if (fieldValue != "")
{
document.getElementById("msgRecipient#" + i).value = fieldValue;
document.getElementById("msgRecipientType#" + i).value = "addr_other";
i ++;
}
fieldValue = msgCompFields.GetNewsgroups();
if (fieldValue != "" && i <= MAX_RECIPIENTS)
{
document.getElementById("msgRecipient#" + i).value = fieldValue;
document.getElementById("msgRecipientType#" + i).value = "addr_newsgroups";
i ++;
}
var row = 1;
fieldValue = msgCompFields.GetFollowupTo();
if (fieldValue != "" && i <= MAX_RECIPIENTS)
{
document.getElementById("msgRecipient#" + i).value = fieldValue;
document.getElementById("msgRecipientType#" + i).value = "addr_followup";
i ++;
}
for (; i <= MAX_RECIPIENTS; i++)
{
document.getElementById("msgRecipient#" + i).value = "";
document.getElementById("msgRecipientType#" + i).value = "addrTo";
}
row = awSetInputAndPopup(row, msgCompFields.GetTo(), "addr_to");
row = awSetInputAndPopup(row, msgCompFields.GetCc(), "addr_cc");
row = awSetInputAndPopup(row, msgCompFields.GetBcc(), "addr_bcc");
row = awSetInputAndPopup(row, msgCompFields.GetReplyTo(), "addr_reply");
row = awSetInputAndPopup(row, msgCompFields.GetOtherRandomHeaders(), "addr_other");
row = awSetInputAndPopup(row, msgCompFields.GetNewsgroups(), "addr_newsgroups");
row = awSetInputAndPopup(row, msgCompFields.GetFollowupTo(), "addr_followup");
if ( row > 1 ) row--;
// remove extra rows
while ( top.MAX_RECIPIENTS > row )
awRemoveRow(top.MAX_RECIPIENTS);
}
}
function AddressingWidgetClick()
function awSetInputAndPopup(firstRow, inputValue, popupValue)
{
dump("AddressingWidgetClick\n");
var row = firstRow;
if ( inputValue && popupValue )
{
var addressArray = inputValue.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);
// we can add one row if trying to add just beyond current size
if ( row == (top.MAX_RECIPIENTS + 1))
{
var body = document.getElementById('addressWidgetBody');
awCopyNode(awGetTreeItem(1), body, 0);
top.MAX_RECIPIENTS++;
}
// if row is legal then set the values
if ( row <= top.MAX_RECIPIENTS )
{
awGetInputElement(row).value = addressArray[index];
awGetPopupElement(row).value = popupValue;
row++;
}
}
return(row);
}
return(firstRow);
}
function awClickRow()
{
dump("awClickRow\n");
return false;
}
function awClickEmptySpace()
{
// FIX ME - not currently using this because of a bug in the tree
var lastInput = awGetInputElement(top.MAX_RECIPIENTS);
if ( lastInput && lastInput.value )
{
awAppendNewRow();
}
else
lastInput.focus();
}
function awReturnHit(inputElement)
{
var row = awGetRowByInputElement(inputElement);
if ( inputElement.value )
{
var nextInput = awGetInputElement(row+1);
if ( !nextInput )
awAppendNewRow();
else
nextInput.focus();
}
else
{
// FIX ME - should tab to next field after addressing widget...probably subjec
}
}
function awAppendNewRow()
{
var body = document.getElementById('addressWidgetBody');
var treeitem1 = awGetTreeItem(1);
if ( body && treeitem1 )
{
awCopyNode(treeitem1, body, 0);
top.MAX_RECIPIENTS++;
// focus on new input widget
var newInput = awGetInputElement(top.MAX_RECIPIENTS);
if ( newInput )
newInput.focus();
}
}
// functions for accessing the elements in the addressing widget
function awGetPopupElement(row)
{
var treerow = awGetTreeRow(row);
if ( treerow )
{
var popup = treerow.getElementsByTagName('SELECT');
if ( popup && popup.length == 1 )
return popup[0];
}
return 0;
}
function awGetInputElement(row)
{
var treerow = awGetTreeRow(row);
if ( treerow )
{
var input = treerow.getElementsByTagName('INPUT');
if ( input && input.length == 1 )
return input[0];
}
return 0;
}
function awGetTreeRow(row)
{
var body = document.getElementById('addressWidgetBody');
if ( body && row > 0)
{
var treerows = body.getElementsByTagName('treerow');
if ( treerows && treerows.length >= row )
return treerows[row-1];
}
return 0;
}
function awGetTreeItem(row)
{
var body = document.getElementById('addressWidgetBody');
if ( body && row > 0)
{
var treeitems = body.getElementsByTagName('treeitem');
if ( treeitems && treeitems.length >= row )
return treeitems[row-1];
}
return 0;
}
function awGetRowByInputElement(inputElement)
{
if ( inputElement )
{
var treerow;
var inputElementTreerow = inputElement.parentNode.parentNode;
if ( inputElementTreerow )
{
for ( var row = 1; (treerow = awGetTreeRow(row)); row++ )
{
if ( treerow == inputElementTreerow )
return row;
}
}
}
return 0;
}
// Copy Node - copy this node and insert ahead of the (before) node. Append to end if before=0
function awCopyNode(node, parentNode, beforeNode)
{
dump("awCopyNode\n");
var newNode = awCopyNodeAndChildren(node);
if ( beforeNode )
parentNode.insertBefore(newNode, beforeNode);
else
parentNode.appendChild(newNode);
}
function awCopyNodeAndChildren(node)
{
var newNode;
if ( node.nodeName == "#text" )
{
// create new text node
newNode = document.createTextNode(node.data);
}
else
{
// create new node
if ( node.nodeName[0] >= 'A' && node.nodeName[0] <= 'Z' )
newNode = createHTML(node.nodeName);
else
newNode = document.createElement(node.nodeName);
var attributes = node.attributes;
if ( attributes && attributes.length )
{
var attrNode, name, value;
// copy attributes into new node
for ( var index = 0; index < attributes.length; index++ )
{
attrNode = attributes.item(index);
name = attrNode.nodeName;
value = attrNode.nodeValue;
if ( name != 'id' )
newNode.setAttribute(name, value);
}
}
if ( node.nodeName == "SELECT" )
{
// copy options inside of SELECT
if ( newNode )
{
for ( var index = 0; index < node.options.length; index++ )
{
var option = new Option(node.options.item(index).text,
node.options.item(index).value)
newNode.add(option, null);
}
}
}
else
{
// children of nodes
if ( node.childNodes )
{
var childNode;
for ( var child = 0; child < node.childNodes.length; child++ )
{
childNode = awCopyNodeAndChildren(node.childNodes[child]);
newNode.appendChild(childNode);
}
}
}
}
return newNode;
}
function createHTML(tag)
{
return document.createElementWithNameSpace(tag, "http://www.w3.org/TR/REC-html40");
}
// remove row
function awRemoveRow(row)
{
var body = document.getElementById('addressWidgetBody');
awRemoveNodeAndChildren(body, awGetTreeItem(row));
top.MAX_RECIPIENTS--;
}
function awRemoveNodeAndChildren(parent, nodeToRemove)
{
// children of nodes
var childNode;
while ( nodeToRemove.childNodes && nodeToRemove.childNodes.length )
{
childNode = nodeToRemove.childNodes[0];
awRemoveNodeAndChildren(nodeToRemove, childNode);
}
parent.removeChild(nodeToRemove);
}

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

@ -33,13 +33,12 @@ Rights Reserved.
<!-- Addressing Widget -->
<box id="addressingWidget"
align="vertical"
onclick="AddressingWidgetClick()"
style="border:solid black 1px">
<!-- for fixed height: height:5em; -->
<tree id="addressingWidgetTree"
class="addressingWidget"
style="background-color:inherit">
class="addressingWidget"
onclick="awClickRow()">
<treecol style="width:15%"/>
<treecol style="width:3%"/>
@ -47,7 +46,7 @@ Rights Reserved.
<treechildren id="addressWidgetBody">
<treeitem>
<treerow>
<treerow style="border-bottom:solid black 1px">
<treecell treeallowevents="true">
<html:select id="msgRecipientType#1">
<html:option value="addr_to">&toAddr.label;</html:option>
@ -58,200 +57,24 @@ Rights Reserved.
<html:option value="addr_followup">&followupAddr.label;</html:option>
</html:select>
</treecell>
<treecell><titledbutton/></treecell>
<treecell>
<titledbutton/>
</treecell>
<treecell treeallowevents="true">
<html:input type="text" id="msgRecipient#1" style="width:90%"
onkeyup="if (event.which == 13)
{ AutoCompleteAddress('msgRecipientType#1',
'msgRecipient#1'); }"/>
<html:input id="msgRecipient#1"
class="addressingWidget"
type="text"
onkeypress="if (event.which == 13)
{ AutoCompleteAddress(this); awReturnHit(this); }"/>
</treecell>
</treerow>
</treeitem>
<treeitem>
<treerow>
<treecell treeallowevents="true">
<html:select id="msgRecipientType#2"/>
</treecell>
<treecell><titledbutton/></treecell>
<treecell treeallowevents="true">
<html:input type="text" id="msgRecipient#2" style="width:90%"
onkeyup="if (event.which == 13)
{ AutoCompleteAddress('msgRecipientType#2',
'msgRecipient#2'); }"/>
</treecell>
</treerow>
</treeitem>
<treeitem>
<treerow>
<treecell treeallowevents="true">
<html:select id="msgRecipientType#3"/>
</treecell>
<treecell><titledbutton/></treecell>
<treecell treeallowevents="true">
<html:input type="text" id="msgRecipient#3" style="width:90%"
onkeyup="if (event.which == 13)
{ AutoCompleteAddress('msgRecipientType#3',
'msgRecipient#3'); }"/>
</treecell>
</treerow>
</treeitem>
<treeitem>
<treerow>
<treecell treeallowevents="true">
<html:select id="msgRecipientType#4"/>
</treecell>
<treecell><titledbutton/></treecell>
<treecell treeallowevents="true">
<html:input type="text" id="msgRecipient#4" style="width:90%"
onkeyup="if (event.which == 13)
{ AutoCompleteAddress('msgRecipientType#4',
'msgRecipient#4'); }"/>
</treecell>
</treerow>
</treeitem>
<treeitem>
<treerow>
<treecell treeallowevents="true">
<html:select id="msgRecipientType#5"/>
</treecell>
<treecell><titledbutton/></treecell>
<treecell treeallowevents="true">
<html:input type="text" id="msgRecipient#5" style="width:90%"
onkeyup="if (event.which == 13)
{ AutoCompleteAddress('msgRecipientType#5',
'msgRecipient#5'); }"/>
</treecell>
</treerow>
</treeitem>
<!--
<treeitem>
<treerow>
<treecell>
<html:select id="msgRecipientType#6"/>
</treecell>
<treecell>
<html:input type="text" id="msgRecipient#6" style="width:90%"
onkeyup="if (event.which == 13)
{ AutoCompleteAddress('msgRecipientType#6',
'msgRecipient#6'); }"/>
</treecell>
</treerow>
</treeitem>
<treeitem>
<treerow>
<treecell>
<html:select id="msgRecipientType#7"/>
</treecell>
<treecell>
<html:input type="text" id="msgRecipient#7" style="width:90%"
onkeyup="if (event.which == 13)
{ AutoCompleteAddress('msgRecipientType#7',
'msgRecipient#7'); }"/>
</treecell>
</treerow>
</treeitem>
<treeitem>
<treerow>
<treecell>
<html:select id="msgRecipientType#8"/>
</treecell>
<treecell>
<html:input type="text" id="msgRecipient#8" style="width:90%"
onkeyup="if (event.which == 13)
{ AutoCompleteAddress('msgRecipientType#8',
'msgRecipient#8'); }"/>
</treecell>
</treerow>
</treeitem>
<treeitem>
<treerow>
<treecell>
<html:select id="msgRecipientType#9"/>
</treecell>
<treecell>
<html:input type="text" id="msgRecipient#9" style="width:90%"
onkeyup="if (event.which == 13)
{ AutoCompleteAddress('msgRecipientType#9',
'msgRecipient#9'); }"/>
</treecell>
</treerow>
</treeitem>
-->
</treechildren>
</tree>
</box>
<!--
<box align="horizontal" flex="100%">
<box align="vertical">
<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_reply">&replyAddr.label;</html:option>
<html:option value="addr_newsgroups">&newsgroupsAddr.label;</html:option>
<html:option value="addr_followup">&followupAddr.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 align="vertical" flex="100%">
<html:select id="msgRecipientType#4" flex="100%"/>
</box>
<box align="vertical" flex="100%">
<html:select id="msgRecipientType#5" flex="100%"/>
</box>
</box>
<box align="vertical" flex="100%">
<box align="vertical" flex="100%">
<html:input type="text" id="msgRecipient#1" flex="100%"
onkeyup="if (event.which == 13)
{ AutoCompleteAddress('msgRecipientType#1',
'msgRecipient#1'); }"/>
</box>
<box align="vertical" flex="100%">
<html:input type="text" id="msgRecipient#2" flex="100%"
onkeyup="if (event.which == 13)
{ AutoCompleteAddress('msgRecipientType#2',
'msgRecipient#2'); }"/>
</box>
<box align="vertical" flex="100%">
<html:input type="text" id="msgRecipient#3" flex="100%"
onkeyup="if (event.which == 13)
{ AutoCompleteAddress('msgRecipientType#3',
'msgRecipient#3'); }"/>
</box>
<box align="vertical" flex="100%">
<html:input type="text" id="msgRecipient#4" flex="100%"
onkeyup="if (event.which == 13)
{ AutoCompleteAddress('msgRecipientType#4',
'msgRecipient#4'); }"/>
</box>
<box align="vertical" flex="100%">
<html:input type="text" id="msgRecipient#5" flex="100%"
onkeyup="if (event.which == 13)
{ AutoCompleteAddress('msgRecipientType#5',
'msgRecipient#5'); }"/>
</box>
</box>
</box>
-->
</overlay>

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

@ -1,33 +1,40 @@
spring.spacer {
width: 5px;
height: 5px;
width: 5px;
height: 5px;
}
box.cleanborder {
margin: 10px;
padding: 10px;
border: 2px groove white;
width: 100%;
margin: 10px;
padding: 10px;
border: 2px groove white;
width: 100%;
}
box.padded {
margin: 10px;
width: 100%;
margin: 10px;
width: 100%;
}
tree[class="attachment"] treeitem > treerow > treecell > titledbutton {
vertical-align: bottom;
min-height: 1px;
min-width: 1px;
height: 1em;
width: 1em;
margin:0px;
padding:0px;
border:2px groove black;
list-style-image: url("chrome://addressbook/skin/myaddrbk.gif");
vertical-align: bottom;
min-height: 1px;
min-width: 1px;
height: 1em;
width: 1em;
margin:0px;
padding:0px;
border:2px groove black;
list-style-image: url("chrome://addressbook/skin/myaddrbk.gif");
}
titledbutton#Throbber
{
list-style-image:url(chrome://navigator/skin/animthrob_single.gif);
}
/* addressing widget */
tree[class="addressingWidget"] treeitem > treerow > treecell > titledbutton {
vertical-align: middle;
min-height: 1px;
@ -41,7 +48,11 @@ tree[class="addressingWidget"] treeitem > treerow > treecell > titledbutton {
color:inherit;
}
titledbutton#Throbber
{
list-style-image:url(chrome://navigator/skin/animthrob_single.gif);
input[class="addressingWidget"] {
width: 90%;
border: none;
margin: 0px;
padding: 0px;
background-color: inherit;
}