287 lines
8.8 KiB
XML
287 lines
8.8 KiB
XML
<?xml version="1.0"?>
|
|
|
|
<!-- ***** BEGIN LICENSE BLOCK *****
|
|
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
-
|
|
- The contents of this file are subject to the Mozilla Public License Version
|
|
- 1.1 (the "License"); you may not use this file except in compliance with
|
|
- the License. You may obtain a copy of the License at
|
|
- http://www.mozilla.org/MPL/
|
|
-
|
|
- Software distributed under the License is distributed on an "AS IS" basis,
|
|
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
- for the specific language governing rights and limitations under the
|
|
- License.
|
|
-
|
|
- The Original Code is Mozilla XForms support.
|
|
-
|
|
- The Initial Developer of the Original Code is
|
|
- Mozilla Foundation.
|
|
- Portions created by the Initial Developer are Copyright (C) 2007
|
|
- the Initial Developer. All Rights Reserved.
|
|
-
|
|
- Contributor(s):
|
|
- Alexander Surkov <surkov.alexander@gmail.com> (original author)
|
|
-
|
|
- Alternatively, the contents of this file may be used under the terms of
|
|
- either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
- in which case the provisions of the GPL or the LGPL are applicable instead
|
|
- of those above. If you wish to allow use of your version of this file only
|
|
- under the terms of either the GPL or the LGPL, and not to allow others to
|
|
- use your version of this file under the terms of the MPL, indicate your
|
|
- decision by deleting the provisions above and replace them with the notice
|
|
- and other provisions required by the GPL or the LGPL. If you do not delete
|
|
- the provisions above, a recipient may use your version of this file under
|
|
- the terms of any one of the MPL, the GPL or the LGPL.
|
|
-
|
|
- ***** END LICENSE BLOCK ***** -->
|
|
|
|
<bindings id="xformsSelectsNativeWidgetBindings"
|
|
xmlns="http://www.mozilla.org/xbl"
|
|
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
|
xmlns:xbl="http://www.mozilla.org/xbl">
|
|
|
|
<!-- SELECT, SELECT1 CONTROLS
|
|
The section contains xforms select and select1 controls implementations for
|
|
XUL. All controls are inherited from interface bindings realized in
|
|
'selectsnw.xml' file.
|
|
|
|
XXX: Element select of minimal appearance is not implemented (see bug 332928).
|
|
|
|
select/select1 of full appearance implementation uses a different approach
|
|
taken in 'selects.xml' file, their implementation is hosted in
|
|
'selects-xul.xml' file.
|
|
-->
|
|
|
|
<binding id="select"
|
|
extends="chrome://xforms/content/selectsnw.xml#select-base">
|
|
|
|
<content>
|
|
<children includes="label"/>
|
|
<xul:box anonid="nativewidget" xbl:inherits="style, accesskey"/>
|
|
<children/>
|
|
</content>
|
|
</binding>
|
|
|
|
|
|
<binding id="select1"
|
|
extends="chrome://xforms/content/selectsnw.xml#select1-base">
|
|
|
|
<content>
|
|
<children includes="label"/>
|
|
<xul:box anonid="nativewidget" xbl:inherits="style, accesskey"/>
|
|
<children/>
|
|
</content>
|
|
</binding>
|
|
|
|
<binding id="select1-minimal"
|
|
extends="#select1">
|
|
<implementation implements="nsIXFormsNSEditableElement">
|
|
|
|
<!-- nsIXFormsNSEditableElement -->
|
|
<property name="editor" readonly="true"
|
|
onget="return this.nativeWidget.editor;"/>
|
|
</implementation>
|
|
</binding>
|
|
|
|
|
|
<!-- CONTROL WIDGETS FOR SELECT CONTROLS
|
|
The section contains underlying widgets implementations needed for xforms
|
|
select controls. All underlying widgets implement the interface what base
|
|
widget for xforms select controls ask for. You can find interface description
|
|
in 'selectsnw.xml' file.
|
|
-->
|
|
|
|
<binding id="nativewidget-select1-minimal"
|
|
extends="chrome://xforms/content/selectsnw.xml#nativewidget-select">
|
|
<content>
|
|
<xul:menulist xbl:inherits="style, accesskey, disabled=readonly"
|
|
class="xf-value" anonid="control"/>
|
|
</content>
|
|
|
|
<implementation>
|
|
<method name="createGroupElm">
|
|
<parameter name="aXFLabel"/>
|
|
<body>
|
|
return null;
|
|
</body>
|
|
</method>
|
|
|
|
<method name="createItemElm">
|
|
<parameter name="aParentElm"/>
|
|
<parameter name="aNextElm"/>
|
|
<parameter name="aXFLabel"/>
|
|
<body>
|
|
return this.control.appendItem(aXFLabel ? aXFLabel.textValue : "");
|
|
</body>
|
|
</method>
|
|
|
|
<method name="setLabelForNative">
|
|
<parameter name="aElm"/>
|
|
<parameter name="aXFLabel"/>
|
|
<body>
|
|
aElm.setAttribute("label", aXFLabel ? aXFLabel.textValue : "");
|
|
</body>
|
|
</method>
|
|
|
|
<method name="isItemSelectedNative">
|
|
<parameter name="aItem"/>
|
|
<body>
|
|
return aItem.selected;
|
|
</body>
|
|
</method>
|
|
|
|
<method name="selectItemNative">
|
|
<parameter name="aItem"/>
|
|
<parameter name="aDoSelect"/>
|
|
<body>
|
|
this.control.selectedItem = aDoSelect ? aItem : null;
|
|
</body>
|
|
</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");
|
|
|
|
return aAllowed;
|
|
</body>
|
|
</method>
|
|
|
|
<method name="appendFreeEntryItem">
|
|
<parameter name="aValue"/>
|
|
<body>
|
|
if (this.control.getAttribute("editable") == "true")
|
|
this.control.value = aValue;
|
|
</body>
|
|
</method>
|
|
|
|
<property name="editor" readonly="true">
|
|
<getter>
|
|
if (!this.control.hasAttribute("editable"))
|
|
return null;
|
|
|
|
return this.control.editor;
|
|
</getter>
|
|
</property>
|
|
</implementation>
|
|
|
|
<handlers>
|
|
<handler event="input">
|
|
this.updateInstanceData(true);
|
|
</handler>
|
|
|
|
<handler event="command">
|
|
this.updateInstanceData(true);
|
|
</handler>
|
|
|
|
<handler event="blur" phase="capturing">
|
|
this.updateInstanceData(false);
|
|
</handler>
|
|
</handlers>
|
|
</binding>
|
|
|
|
|
|
<binding id="nativewidget-select-compact"
|
|
extends="chrome://xforms/content/selectsnw.xml#nativewidget-select">
|
|
<content>
|
|
<xul:listbox xbl:inherits="style, accesskey, disabled=readonly"
|
|
class="xf-value" seltype="multiple" rows="5"
|
|
anonid="control"/>
|
|
</content>
|
|
|
|
<implementation>
|
|
<method name="createGroupElm">
|
|
<parameter name="aXFLabel"/>
|
|
<body>
|
|
return null;
|
|
</body>
|
|
</method>
|
|
|
|
<method name="createItemElm">
|
|
<parameter name="aParentElm"/>
|
|
<parameter name="aNextElm"/>
|
|
<parameter name="aXFLabel"/>
|
|
<body>
|
|
var elm = this.ownerDocument.createElementNS(this.XUL_NS, "listitem");
|
|
if (aXFLabel)
|
|
elm.setAttribute("label", aXFLabel.textValue);
|
|
|
|
return aParentElm.insertBefore(elm, aNextElm);
|
|
</body>
|
|
</method>
|
|
|
|
<method name="setLabelForNative">
|
|
<parameter name="aElm"/>
|
|
<parameter name="aXFLabel"/>
|
|
<body>
|
|
aElm.setAttribute("label", aXFLabel.textValue);
|
|
</body>
|
|
</method>
|
|
|
|
<method name="isItemSelectedNative">
|
|
<parameter name="aItem"/>
|
|
<body>
|
|
return aItem.selected;
|
|
</body>
|
|
</method>
|
|
|
|
<method name="selectItemNative">
|
|
<parameter name="aItem"/>
|
|
<parameter name="aDoSelect"/>
|
|
<body>
|
|
this.control.setAttribute("suppressonselect", "true");
|
|
if (aDoSelect)
|
|
this.control.addItemToSelection(aItem);
|
|
else
|
|
this.control.removeItemFromSelection(aItem);
|
|
this.control.removeAttribute("suppressonselect");
|
|
</body>
|
|
</method>
|
|
|
|
<constructor>
|
|
// 'select' event is fired by 'listbox' binding and therefore it is
|
|
// not handled in 'handler' element until bug 350334 is fixed.
|
|
var selectHandler = {
|
|
control: this,
|
|
handleEvent: function() {
|
|
this.control.updateInstanceData(true);
|
|
}
|
|
};
|
|
this.addEventListener("select", selectHandler, false);
|
|
</constructor>
|
|
</implementation>
|
|
|
|
<handlers>
|
|
<handler event="blur" phase="capturing">
|
|
this.updateInstanceData(false);
|
|
</handler>
|
|
</handlers>
|
|
</binding>
|
|
|
|
|
|
<binding id="nativewidget-select1-compact"
|
|
extends="#nativewidget-select-compact">
|
|
<content>
|
|
<xul:listbox xbl:inherits="style, accesskey, disabled=readonly"
|
|
class="xf-value" seltype="single" rows="5"
|
|
anonid="control"/>
|
|
</content>
|
|
</binding>
|
|
|
|
</bindings>
|