update search widgets - add operator widget, and make generic abstract XUL widget which attribute and operator widgets inherit from

This commit is contained in:
alecf%netscape.com 2000-05-01 00:31:40 +00:00
Родитель c962aa894e
Коммит 8c5ae72619
1 изменённых файлов: 99 добавлений и 30 удалений

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

@ -4,13 +4,10 @@
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="searchattribute" extends="xul:box">
<binding id="search-menulist-abstract" extends="xul:box">
<content>
<xul:menulist flex="1">
<xul:menupopup>
<xul:menuitem value="contains"/>
<xul:menuitem value="doesn't contain"/>
</xul:menupopup>
<xul:menulist inherits="flex" oncommand="this.parentNode.onSelect(event)">
<xul:menupopup/>
</xul:menulist>
</content>
@ -20,37 +17,49 @@
Components.classes['mozilla.mail.search.validityManager.1'].getService(Components.interfaces.nsIMsgSearchValidityManager);
]]>
</property>
<property name="attributeBundle">
<![CDATA[
dump("Loading string bundle\n");
srGetStrBundle("chrome://messenger/locale/search-attributes.properties");
]]>
</property>
<property name="scope">
<property name="searchScope">
<!-- scope ID - retrieve the table -->
<setter>
<![CDATA[
this.setAttribute("scope", val);
var table = this.validityManager.getTable(val);
this.populateFromTable(table);
this.internalScope = val;
this.refreshList();
if (this.target) this.target.searchScope = val;
]]>
</setter>
<getter>
<![CDATA[
return this.getAttribute("scope");
return this.internalScope;
]]>
</getter>
</property>
<method name="populateFromTable">
<argument name="table"/>
<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="target" readonly="true">
<getter>
<![CDATA[
return document.getElementById(this.getAttribute("for"));
]]>
</getter>
</property>
<method name="refreshList">
<body>
<![CDATA[
dump("Populating table\n");
var attrNames = this.attributeBundle;
var len = new Object;
var attrs = table.getAvailableAttributes(len);
dump("refreshing <" + this.tagName + ">\n");
var menuItemIds = this.valueIds;
var menuItemStrings = this.valueStrings;
var menulist = this.anonymousContent[0];
var popup = menulist.firstChild;
@ -63,16 +72,15 @@
popup.removeChild(popup.lastChild);
var newSelection;
for (var i=0; i<attrs.length; i++) {
for (var i=0; i<menuItemIds.length; i++) {
// create the menuitem
var menuitem = document.createElement("menuitem");
menuitem.setAttribute("value",
attrNames.GetStringFromID(attrs[i]));
menuitem.setAttribute("data",attrs[i]);
menuitem.setAttribute("value", menuItemStrings[i]);
menuitem.setAttribute("data", menuItemIds[i]);
popup.appendChild(menuitem);
// try to restore the selection
if (!newSelection || oldData == attrs[i].toString()) {
if (!newSelection || oldData == menuItemIds[i].toString()) {
newSelection = menuitem;
}
}
@ -82,6 +90,67 @@
]]>
</body>
</method>
<method name="onSelect">
<argument name="event"/>
<body>
<![CDATA[
dump("onSelect!\n");
var menulist = this.anonymousContent[0];
if (this.target) this.target.searchAttribute = menulist.data;
]]>
</body>
</method>
</interface>
<handler type="command" value="dump('onCommand!\n');"/>
</binding>
<binding id="searchattribute"
extends="chrome://messenger/skin/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>
<binding id="searchoperator"
extends="chrome://messenger/skin/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="searchAttribute">
<setter>
<![CDATA[
this.internalSearchAttribute = val;
this.refreshList();
]]>
</setter>
<getter>
<![CDATA[
return this.internalSearchAttribute;
]]>
</getter>
</property>
</interface>
</binding>
</bindings>