зеркало из https://github.com/mozilla/pjs.git
Bug #109931 --> delay construction of the long email address view
until the user actually puts us in expanded email addresses mode. r=bienvenu sr=sspitzer
This commit is contained in:
Родитель
c0186ec7ef
Коммит
ce80f699b3
|
@ -83,12 +83,115 @@
|
|||
</content>
|
||||
|
||||
<implementation>
|
||||
<constructor>
|
||||
<![CDATA[
|
||||
this.mLongViewCreated = false;
|
||||
this.mAddresses = new Array;
|
||||
]]>
|
||||
</constructor>
|
||||
|
||||
<field name="mLongViewCreated"/>
|
||||
<field name="mAddresses"/>
|
||||
|
||||
<!-- addAddressView: a public method used to add an address to this widget.
|
||||
aAddresses is an object with 3 properties: displayName, emailAddress and fullAddress
|
||||
-->
|
||||
<method name="addAddressView">
|
||||
<parameter name="aAddress"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
this.mAddresses.push(aAddress);
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<!-- updateEmailAddressNode: private method used to set properties on an address node -->
|
||||
<method name="updateEmailAddressNode">
|
||||
<parameter name="aEmailNode"/>
|
||||
<parameter name="aAddress"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
aEmailNode.setAttribute("label", aAddress.fullAddress);
|
||||
aEmailNode.setTextAttribute("emailAddress", aAddress.emailAddress);
|
||||
aEmailNode.setTextAttribute("fullAddress", aAddress.fullAddress);
|
||||
aEmailNode.setTextAttribute("displayName", aAddress.displayName);
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<!-- fillAddressesNode: private method used to create email address nodes for either our short
|
||||
or long view. aAddressesNode: the div we want to add addresses too.
|
||||
aNumAddressesToShow: number of addresses to put into the list -->
|
||||
<method name="fillAddressesNode">
|
||||
<parameter name="aAddressesNode"/>
|
||||
<parameter name="aNumAddressesToShow"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
var numAddresses = this.mAddresses.length;
|
||||
if (aNumAddressesToShow <= 0) // then show all
|
||||
aNumAddressesToShow = numAddresses;
|
||||
|
||||
var index = 0;
|
||||
while (index < numAddresses && index < aNumAddressesToShow)
|
||||
{
|
||||
var newAddressNode= document.createElement("mail-emailaddress");
|
||||
if (index)
|
||||
{
|
||||
var textNode = document.createElement("text");
|
||||
textNode.setAttribute("value", ", ");
|
||||
textNode.setAttribute("class", "emailSeparator");
|
||||
aAddressesNode.appendChild(textNode);
|
||||
}
|
||||
|
||||
var itemInDocument = aAddressesNode.appendChild(newAddressNode);
|
||||
this.updateEmailAddressNode(itemInDocument, this.mAddresses[index]);
|
||||
index++;
|
||||
}
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<property name="emailAddresses" onget="return document.getAnonymousElementByAttribute(this, 'anonid', 'emailAddresses');"
|
||||
readonly="true"/>
|
||||
<property name="longEmailAddresses" onget="return document.getAnonymousElementByAttribute(this, 'anonid', 'longEmailAddresses');"
|
||||
readonly="true"/>
|
||||
<property name="toggleIcon" onget="return document.getAnonymousElementByAttribute(this, 'anonid', 'toggleIcon');"
|
||||
readonly="true"/>
|
||||
readonly="true"/>
|
||||
|
||||
<!-- buildView: public method used by callers when they are done adding all the email addresses to the widget
|
||||
aNumAddressesToShow: total # of addresses to show in the short view -->
|
||||
<method name="buildViews">
|
||||
<parameter name="aNumAddressesToShow"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
// always build the short view...its cheap...
|
||||
this.fillAddressesNode(this.emailAddresses, aNumAddressesToShow);
|
||||
// if we are currently toggled to show all the email addresses, build the long one too...
|
||||
if (this.emailAddresses.getAttribute("collapsed") == "true")
|
||||
this.buildLongView();
|
||||
|
||||
// make sure the icon is always visible if we have more than the # of addresses to show
|
||||
if (this.mAddresses.length > aNumAddressesToShow)
|
||||
this.toggleIcon.removeAttribute('collapsed');
|
||||
else
|
||||
this.toggleIcon.setAttribute('collapsed', true);
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<!-- buildLongView: private method used for delayed construction of the long view -->
|
||||
<method name="buildLongView">
|
||||
<body>
|
||||
<![CDATA[
|
||||
if (!this.mLongViewCreated)
|
||||
{
|
||||
this.fillAddressesNode(this.longEmailAddresses, -1);
|
||||
this.mLongViewCreated = true;
|
||||
}
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="toggleAddressView">
|
||||
<body>
|
||||
<![CDATA[
|
||||
|
@ -104,6 +207,7 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
this.buildLongView();
|
||||
shortNode.setAttribute("collapsed", true);
|
||||
longNode.removeAttribute("collapsed");
|
||||
imageNode.setAttribute("class", "showFewerAddressesButton");
|
||||
|
@ -126,6 +230,10 @@
|
|||
<method name="clearEmailAddresses">
|
||||
<body>
|
||||
<![CDATA[
|
||||
// clear out our local state
|
||||
this.mAddresses = new Array;
|
||||
this.mLongViewCreated = false;
|
||||
|
||||
// remove anything inside of each of our labels....
|
||||
var parentLabel = this.emailAddresses;
|
||||
if (parentLabel)
|
||||
|
|
|
@ -134,7 +134,10 @@ function createHeaderEntry(prefix, headerListInfo)
|
|||
this.useToggle = false;
|
||||
|
||||
if ("useShortView" in headerListInfo)
|
||||
{
|
||||
this.useShortView = headerListInfo.useShortView;
|
||||
this.enclosingBox.emailAddressNode = this.textNode;
|
||||
}
|
||||
else
|
||||
this.useShortView = false;
|
||||
|
||||
|
@ -583,30 +586,26 @@ function OutputEmailAddresses(headerEntry, emailAddresses)
|
|||
// if we want to include short/long toggle views and we have a long view, always add it.
|
||||
// if we aren't including a short/long view OR if we are and we haven't parsed enough
|
||||
// addresses to reach the cutoff valve yet then add it to the default (short) div.
|
||||
if (headerEntry.useToggle && headerEntry.longTextNode)
|
||||
if (headerEntry.useToggle)
|
||||
{
|
||||
InsertEmailAddressUnderEnclosingBox(headerEntry, headerEntry.longTextNode, emailAddress, fullAddress, name);
|
||||
var addresses = {};
|
||||
addresses.emailAddress = emailAddress;
|
||||
addresses.fullAddress = fullAddress;
|
||||
addresses.displayName = name;
|
||||
|
||||
headerEntry.enclosingBox.addAddressView(addresses);
|
||||
}
|
||||
if (!headerEntry.useToggle && !headerEntry.useShortView)
|
||||
else
|
||||
{
|
||||
updateEmailAddressNode(headerEntry.enclosingBox.emailAddressNode, emailAddress, fullAddress, name, headerEntry.useShortView);
|
||||
}
|
||||
else if (!headerEntry.useToggle || (numAddressesParsed < gNumAddressesToShow))
|
||||
{
|
||||
InsertEmailAddressUnderEnclosingBox(headerEntry, headerEntry.textNode, emailAddress, fullAddress, name);
|
||||
}
|
||||
|
||||
numAddressesParsed++;
|
||||
}
|
||||
} // if enumerator
|
||||
|
||||
if (headerEntry.useToggle && headerEntry.toggleIcon)
|
||||
{
|
||||
if (numAddressesParsed > gNumAddressesToShow) // make sure the icon is always visible if we have more than the # of addresses to show
|
||||
headerEntry.toggleIcon.removeAttribute('collapsed');
|
||||
else
|
||||
headerEntry.toggleIcon.setAttribute('collapsed', true);
|
||||
}
|
||||
|
||||
if (headerEntry.useToggle)
|
||||
headerEntry.enclosingBox.buildViews(gNumAddressesToShow);
|
||||
} // if msgheader parser
|
||||
}
|
||||
|
||||
|
@ -624,39 +623,6 @@ function updateEmailAddressNode(emailAddressNode, emailAddress, fullAddress, dis
|
|||
AddExtraAddressProcessing(emailAddress, emailAddressNode);
|
||||
}
|
||||
|
||||
/* InsertEmailAddressUnderEnclosingBox --> right now all email addresses are borderless titled buttons
|
||||
with formatting to make them look like html anchors. When you click on the button,
|
||||
you are prompted with a popup asking you what you want to do with the email address
|
||||
useShortView --> only show the name (if present) instead of the name + email address
|
||||
*/
|
||||
|
||||
function InsertEmailAddressUnderEnclosingBox(headerEntry, parentNode,
|
||||
emailAddress, fullAddress, displayName)
|
||||
{
|
||||
var itemInDocument = parentNode;
|
||||
// if this header uses a toggle then it can contain multiple email addresses. In this case,
|
||||
// parentNode is really an HTML div. we need to create an emailaddress element and insert it into
|
||||
// the html div.
|
||||
if ( headerEntry.useToggle)
|
||||
{
|
||||
var item = document.createElement("mail-emailaddress");
|
||||
if (item && parentNode)
|
||||
{
|
||||
if (parentNode.childNodes.length >= 1)
|
||||
{
|
||||
var textNode = document.createElement("text");
|
||||
textNode.setAttribute("value", ", ");
|
||||
textNode.setAttribute("class", "emailSeparator");
|
||||
parentNode.appendChild(textNode);
|
||||
}
|
||||
|
||||
itemInDocument = parentNode.appendChild(item);
|
||||
}
|
||||
}
|
||||
|
||||
updateEmailAddressNode(itemInDocument, emailAddress, fullAddress, displayName, headerEntry.useShortView);
|
||||
}
|
||||
|
||||
function AddNodeToAddressBook (emailAddressNode)
|
||||
{
|
||||
if (emailAddressNode)
|
||||
|
|
Загрузка…
Ссылка в новой задаче