mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-08 12:37:37 +00:00
869d7aeb19
- fixes #41711, #48698, #48238 among other things - moves some XBL into straight JS where it belongs - fixes bad XBL setters to return the value that comes in - fire more notification when filter attributes/operators change
367 lines
14 KiB
XML
367 lines
14 KiB
XML
<?xml version="1.0"?>
|
|
|
|
<bindings id="mailBindings"
|
|
xmlns="http://www.mozilla.org/xbl"
|
|
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
|
|
|
<!-- dummy widget to force this file to load -->
|
|
<binding id="dummy" extends="xul:box"/>
|
|
<!-- Message Pane Widgets -->
|
|
<binding id="mail-emailaddress" extends="xul:box">
|
|
<content>
|
|
<xul:box inherits="orient" autostretch="never" flex="1">
|
|
<xul:text class="emailDisplayButton" popup="emailAddressPopup" context="emailAddressPopup" inherits="value,crop"/>
|
|
<xul:image class="emailDisplayImage"/>
|
|
</xul:box>
|
|
</content>
|
|
|
|
<interface>
|
|
<property name="value" onset="return document.getAnonymousNodes(this)[0].firstChild.setAttribute('value',val);"
|
|
onget="return document.getAnonymousNodes(this)[0].firstChild.getAttribute('value');"/>
|
|
<property name="crop" onset="return document.getAnonymousNodes(this)[0].firstChild.setAttribute('crop',val);"
|
|
onget="return document.getAnonymousNodes(this)[0].firstChild.getAttribute('crop');"/>
|
|
<property name="disabled" onset="return document.getAnonymousNodes(this)[0].firstChild.setAttribute('disabled',val);"
|
|
onget="return document.getAnonymousNodes(this)[0].firstChild.getAttribute('disabled');"/>
|
|
<property name="src" onset="return document.getAnonymousNodes(this)[0].childNodes[1].setAttribute('src',val);"
|
|
onget="return document.getAnonymousNodes(this)[0].childNodes[1].getAttribute('src');"/>
|
|
<property name="imgalign" onset="return document.getAnonymousNodes(this)[0].childNodes[1].setAttribute('imgalign',val);"
|
|
onget="return document.getAnonymousNodes(this)[0].childNodes[1].getAttribute('imgalign');"/>
|
|
<method name="setTextAttribute">
|
|
<argument name="attributeName"/>
|
|
<argument name="attributeValue"/>
|
|
<body>
|
|
<![CDATA[
|
|
var textNode = document.getAnonymousNodes(this)[0].firstChild;
|
|
textNode.setAttribute(attributeName, attributeValue);
|
|
]]>
|
|
</body>
|
|
</method>
|
|
|
|
<method name="getTextAttribute">
|
|
<argument name="attributeName"/>
|
|
<argument name="attributeValue"/>
|
|
<body>
|
|
<![CDATA[
|
|
var textNode = document.getAnonymousNodes(this)[0].firstChild;
|
|
return textNode.getAttribute(attributeName, attributeValue);
|
|
]]>
|
|
</body>
|
|
</method>
|
|
</interface>
|
|
</binding>
|
|
|
|
<binding id="search-menulist-abstract" name="searchMenulistAbstract" extends="xul:box">
|
|
<content>
|
|
<xul:menulist class="search-menulist" inherits="flex" oncommand="this.parentNode.onSelect(event)">
|
|
<xul:menupopup class="search-menulist-popup"/>
|
|
</xul:menulist>
|
|
</content>
|
|
|
|
<interface>
|
|
<property readonly="true" name="validityManager">
|
|
<![CDATA[
|
|
Components.classes['mozilla.mail.search.validityManager.1'].getService(Components.interfaces.nsIMsgSearchValidityManager);
|
|
]]>
|
|
</property>
|
|
<property name="searchScope" onget="return this.internalScope;">
|
|
<!-- scope ID - retrieve the table -->
|
|
<setter>
|
|
<![CDATA[
|
|
// if scope isn't changing this is a noop
|
|
if (this.internalScope == val) return val;
|
|
|
|
this.internalScope = val;
|
|
//dump("\trefreshList via .searchScope setter\n");
|
|
this.refreshList();
|
|
var targets = this.targets;
|
|
if (targets) {
|
|
for (var i=0; i< targets.length; i++) {
|
|
targets[i].searchScope = val;
|
|
}
|
|
}
|
|
return val;
|
|
]]>
|
|
</setter>
|
|
</property>
|
|
|
|
<property name="validityTable" readonly="true" onget="return this.validityManager.getTable(this.searchScope)"/>
|
|
|
|
<property name="valueStrings" readonly="true">
|
|
<getter>
|
|
<![CDATA[
|
|
var strings = new Array;
|
|
var ids = this.valueIds;
|
|
var bundle = this.stringBundle;
|
|
for (var i=0; i<ids.length; i++)
|
|
strings[i] = this.stringBundle.GetStringFromID(ids[i]);
|
|
return strings;
|
|
]]>
|
|
</getter>
|
|
</property>
|
|
<property name="targets" readonly="true">
|
|
<getter>
|
|
<![CDATA[
|
|
var forAttrs = this.getAttribute("for");
|
|
if (!forAttrs) return null;
|
|
var targetIds = forAttrs.split(",");
|
|
if (targetIds.length == 0) return null;
|
|
|
|
var targets = new Array;
|
|
var j=0;
|
|
for (var i=0; i<targetIds.length;i++) {
|
|
var target = document.getElementById(targetIds[i]);
|
|
if (target) targets[j++] = target;
|
|
}
|
|
return targets;
|
|
]]>
|
|
</getter>
|
|
</property>
|
|
|
|
<!-- value forwards to the internal menulist's "data" attribute -->
|
|
<property name="value" onget="return document.getAnonymousNodes(this)[0].selectedItem.getAttribute('data');">
|
|
<setter>
|
|
<![CDATA[
|
|
dump("\tsetting value on id=" + this.id + "\n");
|
|
var menulist = document.getAnonymousNodes(this)[0];
|
|
var dataItems = menulist.getElementsByAttribute("data", val);
|
|
if (dataItems.length > 0)
|
|
menulist.selectedItem = dataItems[0];
|
|
|
|
// now notify targets of new parent's value
|
|
var targets = this.targets;
|
|
if (targets) {
|
|
for (var i=0; i< targets.length; i++) {
|
|
//dump("setting parentValue via abstract .value on <" + this.localName +">\n");
|
|
targets[i].parentValue = val;
|
|
}
|
|
} else {
|
|
//dump("Doh! No targets!\n");
|
|
}
|
|
return val;
|
|
]]>
|
|
</setter>
|
|
</property>
|
|
<method name="refreshList">
|
|
<body>
|
|
<![CDATA[
|
|
var menuItemIds = this.valueIds;
|
|
var menuItemStrings = this.valueStrings;
|
|
|
|
var menulist = document.getAnonymousNodes(this)[0];
|
|
var popup = menulist.firstChild;
|
|
|
|
// save our old "data" so we can restore it later
|
|
var oldData = menulist.data;
|
|
|
|
// remove the old popup children
|
|
while (popup.hasChildNodes())
|
|
popup.removeChild(popup.lastChild);
|
|
|
|
var newSelection;
|
|
for (var i=0; i<menuItemIds.length; i++) {
|
|
// create the menuitem
|
|
var menuitem = document.createElement("menuitem");
|
|
menuitem.setAttribute("value", menuItemStrings[i]);
|
|
menuitem.setAttribute("data", menuItemIds[i]);
|
|
popup.appendChild(menuitem);
|
|
|
|
// try to restore the selection
|
|
if (!newSelection || oldData == menuItemIds[i].toString()) {
|
|
newSelection = menuitem;
|
|
}
|
|
}
|
|
|
|
// now restore the selection
|
|
menulist.selectedItem = newSelection
|
|
]]>
|
|
</body>
|
|
</method>
|
|
<method name="onSelect">
|
|
<argument name="event"/>
|
|
<body>
|
|
<![CDATA[
|
|
var menulist = document.getAnonymousNodes(this)[0];
|
|
|
|
// notify targets
|
|
var targets = this.targets;
|
|
if (targets) {
|
|
for (var i=0; i< targets.length; i++) {
|
|
targets[i].parentValue = menulist.data;
|
|
}
|
|
}
|
|
]]>
|
|
</body>
|
|
</method>
|
|
</interface>
|
|
</binding>
|
|
|
|
<!-- searchattribute - Subject, Sender, To, CC, etc. -->
|
|
<binding id="searchattribute" name="searchAttribute"
|
|
extends="chrome://messenger/content/mailWidgets.xml#search-menulist-abstract">
|
|
<interface>
|
|
<property name="stringBundle">
|
|
<![CDATA[
|
|
srGetStrBundle("chrome://messenger/locale/search-attributes.properties");
|
|
]]>
|
|
</property>
|
|
<property name="valueIds" readonly="true">
|
|
<getter>
|
|
<![CDATA[
|
|
var length = new Object;
|
|
return this.validityTable.getAvailableAttributes(length);
|
|
]]>
|
|
</getter>
|
|
</property>
|
|
</interface>
|
|
</binding>
|
|
|
|
<!-- searchoperator - Contains, Is Less than, etc -->
|
|
<binding id="searchoperator" name="searchOperator"
|
|
extends="chrome://messenger/content/mailWidgets.xml#search-menulist-abstract">
|
|
<interface>
|
|
<property name="stringBundle">
|
|
<![CDATA[
|
|
srGetStrBundle("chrome://messenger/locale/search-operators.properties");
|
|
]]>
|
|
</property>
|
|
<property name="valueIds" readonly="true">
|
|
<getter>
|
|
<![CDATA[
|
|
var length = new Object;
|
|
return this.validityTable.getAvailableOperators(this.searchAttribute,length);
|
|
]]>
|
|
</getter>
|
|
</property>
|
|
<property name="parentValue">
|
|
<setter>
|
|
<![CDATA[
|
|
if (this.searchAttribute == val) return val;
|
|
this.searchAttribute = val;
|
|
//dump("\trefreshList via .parentValue on " + this.localName + "\n");
|
|
this.refreshList();
|
|
return val;
|
|
]]>
|
|
</setter>
|
|
<getter>
|
|
<![CDATA[
|
|
return this.searchAttribute;
|
|
]]>
|
|
</getter>
|
|
</property>
|
|
</interface>
|
|
</binding>
|
|
|
|
<!-- searchvalue - a widget which dynamically changes it's user interface
|
|
depending on what type of data it's supposed to be showing
|
|
currently handles arbitrary text entry, and menulists for priority and
|
|
status
|
|
-->
|
|
<binding id="searchvalue" name="searchValue" extends="xul:deck">
|
|
<!-- yeah yeah, this stuff needs to be localized. I'm working on it! -->
|
|
<content>
|
|
<xul:textfield flex="1" class="search-value-textfield"/>
|
|
<xul:menulist flex="1" class="search-value-menulist">
|
|
<xul:menupopup class="search-value-popup">
|
|
<xul:menuitem data="2" value="Lowest" class="search-value-menuitem"/>
|
|
<xul:menuitem data="3" value="Low" class="search-value-menuitem"/>
|
|
<xul:menuitem data="4" value="Normal" class="search-value-menuitem"/>
|
|
<xul:menuitem data="5" value="High" class="search-value-menuitem"/>
|
|
<xul:menuitem data="6" value="Highest" class="search-value-menuitem"/>
|
|
</xul:menupopup>
|
|
</xul:menulist>
|
|
<xul:menulist flex="1" class="search-value-menulist">
|
|
<xul:menupopup class="search-value-popup">
|
|
<xul:menuitem value="read" class="search-value-menuitem"/>
|
|
<xul:menuitem value="replied" class="search-value-menuitem"/>
|
|
</xul:menupopup>
|
|
</xul:menulist>
|
|
</content>
|
|
<interface>
|
|
<!-- parentValue forwards to the attribute -->
|
|
<property name="parentValue" onset="return this.searchAttribute=val;"
|
|
onget="return this.searchAttribute;"/>
|
|
<property name="searchAttribute" onget="return this.internalAttribute;">
|
|
<setter>
|
|
<![CDATA[
|
|
// noop if we're not changing it
|
|
if (this.internalAttribute == val) return val;
|
|
this.internalAttribute = val;
|
|
// we inherit from a deck, so just use it's index attribute
|
|
// to hide/show widgets
|
|
if (val == Components.interfaces.nsMsgSearchAttrib.Priority)
|
|
this.setAttribute("index", "1");
|
|
else if (val == Components.interfaces.nsMsgSearchAttrib.MsgStatus)
|
|
this.setAttribute("index", "2");
|
|
else
|
|
this.setAttribute("index", "0");
|
|
return val;
|
|
]]>
|
|
</setter>
|
|
</property>
|
|
<property name="value" onget="return this.internalValue;">
|
|
<setter>
|
|
<![CDATA[
|
|
dump("\tsetting value on id=" + this.id + "\n");
|
|
// val is a nsIMsgSearchValue object
|
|
this.internalValue = val;
|
|
var attrib = val.attrib;
|
|
var nsMsgSearchAttrib = Components.interfaces.nsMsgSearchAttrib;
|
|
var children = document.getAnonymousNodes(this);
|
|
this.searchAttribute = attrib;
|
|
if (attrib == nsMsgSearchAttrib.Priority) {
|
|
dump("Setting priority to " + val.priority + "..\n");
|
|
var matchingPriority =
|
|
children[1].getElementsByAttribute("data", val.priority);
|
|
dump("found " + matchingPriority.length + " matching priority nodes\n");
|
|
if (matchingPriority.length > 0)
|
|
children[1].selectedItem = matchingPriority[0];
|
|
}
|
|
else if (attrib == nsMsgSearchAttrib.MsgStatus) {
|
|
var matchingStatus =
|
|
children[2].getElementsByAttribute("data", val.status);
|
|
if (matchingStatus.length > 0)
|
|
children[2].selectedItem = matchingStatus[0];
|
|
}
|
|
else if (attrib == nsMsgSearchAttrib.AgeInDays)
|
|
children[0].value = val.age;
|
|
else
|
|
children[0].value = val.str;
|
|
return val;
|
|
]]>
|
|
</setter>
|
|
</property>
|
|
<method name="save">
|
|
<body>
|
|
<![CDATA[
|
|
var searchValue = this.value;
|
|
var searchAttribute = this.searchAttribute;
|
|
var nsMsgSearchAttrib = Components.interfaces.nsMsgSearchAttrib;
|
|
var children = document.getAnonymousNodes(this);
|
|
|
|
searchValue.attrib = searchAttribute;
|
|
if (searchAttribute == nsMsgSearchAttrib.Priority) {
|
|
dump("\tSaving priority " + children[1].selectedItem.data + "\n");
|
|
searchValue.priority = children[1].selectedItem.data;
|
|
}
|
|
else if (searchAttribute == nsMsgSearchAttrib.MsgStatus)
|
|
searchValue.status = children[2].selectedItem.data;
|
|
else if (searchAttribute == nsMsgSearchAttrib.AgeInDays)
|
|
searchValue.age = children[0].value;
|
|
else
|
|
searchValue.str = children[0].value;
|
|
]]>
|
|
</body>
|
|
</method>
|
|
<method name="saveTo">
|
|
<argument name="searchValue"/>
|
|
<body>
|
|
<![CDATA[
|
|
this.internalValue = searchValue;
|
|
this.save();
|
|
]]>
|
|
</body>
|
|
</method>
|
|
</interface>
|
|
</binding>
|
|
</bindings>
|