[XForms] support @selection="open" for xf:select1[appearance="minimal"] for xul. Bug 332197, r=aaronr+doronr, patch by surkov@dc.baikal.ru

This commit is contained in:
allan%beaufour.dk 2006-05-15 14:10:29 +00:00
Родитель 113557f3d9
Коммит 812abbe9e8
2 изменённых файлов: 100 добавлений и 13 удалений

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

@ -442,9 +442,42 @@
return aItem.getAttribute("selected") == "true"; return aItem.getAttribute("selected") == "true";
</body> </body>
</method> </method>
<method name="getFreeEntryValues">
<body>
if (this.control.getAttribute("editable") == "true") {
if (!this.control.selectedItem)
return this.control.value;
return "";
}
</body>
</method>
<method name="allowFreeEntry">
<parameter name="aAllowed"/>
<body>
if (aAllowed)
this.control.setAttribute("editable", "true");
else
this.control.removeAttribute("editable");
</body>
</method>
<method name="appendFreeEntryItem">
<parameter name="aValue"/>
<body>
if (this.control.getAttribute("editable") == "true") {
this.control.value = aValue;
}
</body>
</method>
</implementation> </implementation>
<handlers> <handlers>
<handler event="input">
this.updateInstanceData(true);
</handler>
<handler event="focus" phase="capturing"> <handler event="focus" phase="capturing">
this.dispatchDOMUIEvent("DOMFocusIn"); this.dispatchDOMUIEvent("DOMFocusIn");
</handler> </handler>
@ -460,9 +493,10 @@
<!-- <!--
XXX: Since xforms:label can include arbitrary elements then 'focus', XXX: Since xforms:label can include arbitrary elements then 'focus',
'blur' and 'command' events should be listen from 'xul:menulist' 'blur', 'command' and 'input' events should be listen from
element only. The described problem is not actual now. Note we will 'xul:menulist' element only. The described problem is not actual now.
get it when we will use node instead of text content for a label. Note we will get it when we will use node instead of text content for
a label.
--> -->
</handlers> </handlers>
</binding> </binding>

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

@ -73,6 +73,14 @@
isItemSelected(item) - return true if item is selected isItemSelected(item) - return true if item is selected
@param item - item control returned by appendItem() @param item - item control returned by appendItem()
getFreeEntryValues() - return space delimited list of free entry items values
allowFreeEntry(allowed) - enable/disable free entry
@param allowed - boolean value
appendFreeEntryItem(value) - append and select free entry item
@param value - item value
--> -->
<bindings id="xformsSelectBindings" <bindings id="xformsSelectBindings"
@ -185,9 +193,19 @@
</getter> </getter>
</property> </property>
<property name="selection" <property name="selection">
onget="return this.getAttribute('selection'); " <getter>
onset="this.setAttribute('selection', val); "/> return this.getAttribute("selection");
</getter>
<setter>
this.setAttribute("selection", val);
if (val == "open")
this.control.allowFreeEnry(true);
else
this.control.allowFreeEnry(false);
</setter>
</property>
<method name="_buildSelect"> <method name="_buildSelect">
<body> <body>
@ -230,8 +248,7 @@
for (var index in this._defaultHash) { for (var index in this._defaultHash) {
if (this._defaultHash[index].hits == 0) { if (this._defaultHash[index].hits == 0) {
if (this.selection == 'open') { if (this.selection == 'open') {
// XXX: If the select is open, the missing elements should be added this.control.appendFreeEntryItem(index);
// and selected per 8.1.10 in the spec.
} else { } else {
// XXX: some of default values not found, we need to throw an // XXX: some of default values not found, we need to throw an
// xforms-out-of-range event, but only if the select is 'closed'. // xforms-out-of-range event, but only if the select is 'closed'.
@ -594,11 +611,6 @@
<parameter name="aIsACopyItemSelectedOrDeselected"/> <parameter name="aIsACopyItemSelectedOrDeselected"/>
<body> <body>
<![CDATA[ <![CDATA[
var selectedValues = "";
// select if found, unselect if not
var options = this._controlArray;
if (aIsACopyItemSelectedOrDeselected) { if (aIsACopyItemSelectedOrDeselected) {
aIsACopyItemSelectedOrDeselected.value = false; aIsACopyItemSelectedOrDeselected.value = false;
} }
@ -621,6 +633,13 @@
this._dispatchSelectEvents(); this._dispatchSelectEvents();
return; return;
} }
var selectedValues = "";
if (this.selection == "open") {
selectedValues = this.control.getFreeEntryValues();
}
var options = this._controlArray;
var boundType = boundNode.nodeType; var boundType = boundNode.nodeType;
var copyNode; var copyNode;
@ -871,6 +890,33 @@
</body> </body>
</method> </method>
<!-- Return values of free entry. The method is a stub and it should
be removed when all native controls will support @selection="open".
-->
<method name="getFreeEntryValues">
<body>
return "";
</body>
</method>
<!-- Allow free entry. The method is a stub and it should be removed when
all native controls will support @selection="open".
-->
<method name="allowFreeEntry">
<parameter name="aAllowed"/>
<body>
</body>
</method>
<!-- Append and select free entry item. The method is a stub and it should
be removed when all native controls will support @selection="open".
-->
<method name="appendFreeEntryItem">
<parameter name="aValue"/>
<body>
</body>
</method>
<property name="XFORMS_NS" readonly="true" <property name="XFORMS_NS" readonly="true"
onget="return 'http://www.w3.org/2002/xforms';"/> onget="return 'http://www.w3.org/2002/xforms';"/>
@ -883,6 +929,13 @@
<property name="XBL_NS" readonly="true" <property name="XBL_NS" readonly="true"
onget="return 'http://www.mozilla.org/xbl';"/> onget="return 'http://www.mozilla.org/xbl';"/>
<constructor>
if (this.parentControl.selection == "open")
this.allowFreeEntry(true);
else
this.allowFreeEntry(false);
</constructor>
</implementation> </implementation>
</binding> </binding>