508 lines
15 KiB
XML
508 lines
15 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
|
|
- Novell, Inc.
|
|
- Portions created by the Initial Developer are Copyright (C) 2005
|
|
- the Initial Developer. All Rights Reserved.
|
|
-
|
|
- Contributor(s):
|
|
- Allan Beaufour <abeaufour@novell.com>
|
|
- Olli Pettay <Olli.Pettay@helsinki.fi>
|
|
-
|
|
- 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 ***** -->
|
|
|
|
<!--
|
|
This file implements the "abstract" UI classes for XForms controls. They
|
|
all have "pure virtual" functions that they expect to be implemented by
|
|
concrete application and returned in the getElementControl() call. An example
|
|
is the controls for XHTML in xforms-xhtml.xml.
|
|
-->
|
|
|
|
<bindings id="xformsBindings"
|
|
xmlns="http://www.mozilla.org/xbl"
|
|
xmlns:html="http://www.w3.org/1999/xhtml"
|
|
xmlns:xbl="http://www.mozilla.org/xbl"
|
|
xmlns:xforms="http://www.w3.org/2002/xforms"
|
|
xmlns:mozType="http://www.mozilla.org/projects/xforms/2005/type"
|
|
xmlns:lazy="http://www.mozilla.org/projects/xforms/2005/lazy">
|
|
|
|
|
|
<!-- LAZY INSTANCE MODEL -->
|
|
<binding id="xforms-lazy-instance">
|
|
<content><xforms:instance lazy:lazy="true"/><children/></content>
|
|
</binding>
|
|
|
|
|
|
<!-- BASE BINDINGS
|
|
The next bindings are used as a base for xforms controls implementations.
|
|
-->
|
|
|
|
<!-- The binding provides utils interface and interface for anonymous content
|
|
work.
|
|
-->
|
|
<binding id="xformswidget-general">
|
|
<implementation>
|
|
|
|
<!-- utils interface -->
|
|
<property name="XFORMS_NS" readonly="true">
|
|
<getter>
|
|
return "http://www.w3.org/2002/xforms";
|
|
</getter>
|
|
</property>
|
|
|
|
<!-- Dispatch UI Event to the control itself -->
|
|
<method name="dispatchDOMUIEvent">
|
|
<parameter name="aType"/>
|
|
<body>
|
|
var ev = document.createEvent("UIEvents");
|
|
ev.initUIEvent(aType, true, true, window, 1);
|
|
this.dispatchEvent(ev);
|
|
return true;
|
|
</body>
|
|
</method>
|
|
|
|
<!--
|
|
Dispatch an _XForms notification event_ to a node.
|
|
See http://www.w3.org/TR/xforms/slice4.html#evt-notify
|
|
-->
|
|
<method name="dispatchXFormsNotificationEvent">
|
|
<parameter name="aEventName"/>
|
|
<parameter name="aTarget"/>
|
|
<body>
|
|
var ev = document.createEvent("Events");
|
|
ev.initEvent(aEventName, true, false);
|
|
aTarget.dispatchEvent(ev);
|
|
return true;
|
|
</body>
|
|
</method>
|
|
|
|
<!-- interface for anonymous content work -->
|
|
|
|
<!--
|
|
Return the native control widget that is the object with access for
|
|
visual representation of this xforms control.
|
|
-->
|
|
<property name="control" readonly="true">
|
|
<getter>
|
|
if (!this._control)
|
|
this._control = this.getControlElement();
|
|
return this._control;
|
|
</getter>
|
|
</property>
|
|
|
|
<!--
|
|
Each base binding for xforms widget assumes successors bindings will
|
|
override the method.
|
|
-->
|
|
<method name="getControlElement">
|
|
<body>
|
|
return null;
|
|
</body>
|
|
</method>
|
|
|
|
<!-- private -->
|
|
<destructor>
|
|
this._control = null;
|
|
</destructor>
|
|
|
|
<field name="_control">null</field>
|
|
</implementation>
|
|
</binding>
|
|
|
|
|
|
<!-- Base binding is for xforms controls that are able to bind to instance
|
|
data.
|
|
-->
|
|
<binding id="xformswidget-accessors" extends="#xformswidget-general">
|
|
<implementation>
|
|
<!-- interface -->
|
|
<property name="accessors" readonly="true">
|
|
<getter>
|
|
<![CDATA[
|
|
if (!this._accessors && this.delegate)
|
|
this._accessors = this.delegate.getXFormsAccessors();
|
|
return this._accessors;
|
|
]]>
|
|
</getter>
|
|
</property>
|
|
|
|
<property name="stringValue" readonly="true">
|
|
<getter>
|
|
var value = this.accessors.getValue();
|
|
return value != null ? value : "";
|
|
</getter>
|
|
</property>
|
|
|
|
<!-- private -->
|
|
<constructor>
|
|
this.delegate.widgetAttached();
|
|
</constructor>
|
|
|
|
<destructor>
|
|
this._delegate = null;
|
|
this._accessors = null;
|
|
</destructor>
|
|
|
|
<property name="delegate" readonly="true">
|
|
<getter>
|
|
if (!this._delegate) {
|
|
this._delegate =
|
|
this.QueryInterface(Components.interfaces.nsIXFormsDelegate);
|
|
}
|
|
return this._delegate;
|
|
</getter>
|
|
</property>
|
|
|
|
<field name="_delegate">null</field>
|
|
<field name="_accessors">null</field>
|
|
</implementation>
|
|
</binding>
|
|
|
|
|
|
<!--
|
|
Base binding is for xforms controls that implement nsIXFormsUIWidget
|
|
interface.
|
|
-->
|
|
<binding id="xformswidget-base" extends="#xformswidget-accessors">
|
|
<implementation implements="nsIXFormsUIWidget">
|
|
|
|
<!-- nsIXFormsUIWidget interface
|
|
Following methods are called from XTF part of XForms implementation and
|
|
thease methods should be overrided by successors bindings.
|
|
-->
|
|
|
|
<!-- Method is called when bound node was changed. -->
|
|
<method name="refresh">
|
|
<body>
|
|
return true;
|
|
</body>
|
|
</method>
|
|
|
|
<!-- Method is called when control should be disabled. -->
|
|
<method name="disable">
|
|
<parameter name="aDisable"/>
|
|
<body>
|
|
return true;
|
|
</body>
|
|
</method>
|
|
|
|
<!-- Method is called when control should be focused -->
|
|
<method name="focus">
|
|
<body>
|
|
return false;
|
|
</body>
|
|
</method>
|
|
</implementation>
|
|
</binding>
|
|
|
|
|
|
<!-- OUTPUT: <DEFAULT>
|
|
The output widget assumes successors bindings implement getElementControl()
|
|
method what returns the object:
|
|
{
|
|
set value(); // set "string" value
|
|
}
|
|
-->
|
|
<binding id="xformswidget-output-base"
|
|
extends="chrome://xforms/content/xforms.xml#xformswidget-base">
|
|
<implementation implements="nsIXFormsUIWidget">
|
|
<method name="refresh">
|
|
<body>
|
|
this.control.value = this.stringValue;
|
|
return true;
|
|
</body>
|
|
</method>
|
|
</implementation>
|
|
</binding>
|
|
|
|
|
|
<!-- LABEL: <DEFAULT>
|
|
The label widget assumes successors bindings implement getElementControl()
|
|
method what returns the object:
|
|
{
|
|
set value(); // set "string" value
|
|
get textValue() // return text representing label value
|
|
get nodeValue() // return document fragment representing label value
|
|
}
|
|
-->
|
|
<binding id="xformswidget-label-base"
|
|
extends="chrome://xforms/content/xforms.xml#xformswidget-base">
|
|
|
|
<implementation implements="nsIXFormsUIWidget">
|
|
<method name="refresh">
|
|
<body>
|
|
this.control.value = this.accessors.getValue();
|
|
return true;
|
|
</body>
|
|
</method>
|
|
|
|
<property name="textValue" readonly="true"
|
|
onget="return this.control.textValue;"/>
|
|
|
|
<property name="nodeValue" readonly="true"
|
|
onget="return this.control.nodeValue;"/>
|
|
</implementation>
|
|
</binding>
|
|
|
|
|
|
<!-- TRIGGER: <DEFAULT>
|
|
The trigger widget assumes successors bindings implement getElementControl()
|
|
method what returns the object:
|
|
{
|
|
set disabled(); // set disabled state
|
|
focus(); // set focus
|
|
}
|
|
-->
|
|
<binding id="xformswidget-trigger-base"
|
|
extends="chrome://xforms/content/xforms.xml#xformswidget-base">
|
|
|
|
<implementation implements="nsIXFormsUIWidget">
|
|
<method name="disable">
|
|
<parameter name="aDisable"/>
|
|
<body>
|
|
this.control.disabled = aDisable;
|
|
</body>
|
|
</method>
|
|
|
|
<method name="focus">
|
|
<body>
|
|
this.control.focus();
|
|
return true;
|
|
</body>
|
|
</method>
|
|
|
|
</implementation>
|
|
</binding>
|
|
|
|
|
|
<!-- TRIGGER: MINIMAL
|
|
We don't need in any special base binding for trigger[appearance="minimal"]
|
|
widget. All successors bindings should be extended from base binding for
|
|
default trigger widget.
|
|
-->
|
|
|
|
|
|
<!-- CASE: <DEFAULT> -->
|
|
<binding id="xformswidget-case-base" extends="#xformswidget-general">
|
|
<implementation implements="nsIXFormsCaseUIElement">
|
|
<constructor>
|
|
this.QueryInterface(Components.interfaces.nsIXFormsCaseElement).
|
|
widgetAttached();
|
|
</constructor>
|
|
|
|
<property name="control" readonly="true">
|
|
<getter>
|
|
if (!this._control)
|
|
this._control = this.getControlElement();
|
|
return this._control;
|
|
</getter>
|
|
</property>
|
|
|
|
<method name="caseSelected">
|
|
<parameter name="aEnable"/>
|
|
<body>
|
|
this.control.selected = aEnable;
|
|
return true;
|
|
</body>
|
|
</method>
|
|
</implementation>
|
|
</binding>
|
|
|
|
|
|
<!-- ALERT: <DEFAULT> -->
|
|
<binding id="inline-alert"
|
|
extends="chrome://xforms/content/xforms.xml#xformswidget-base">
|
|
<content>
|
|
<html:div anonid="container" class="-moz-xforms-message-container">
|
|
<html:div anonid="inlineData" style="display: inherit;">
|
|
<children/>
|
|
</html:div>
|
|
<html:div anonid="bindingData" style="display: inherit;"/>
|
|
</html:div>
|
|
</content>
|
|
|
|
<implementation>
|
|
|
|
<field name="_inlineData">null</field>
|
|
|
|
<property name="inlineData" readonly="true">
|
|
<getter>
|
|
if (!this._inlineData) {
|
|
this._inlineData = document.
|
|
getAnonymousElementByAttribute(this, "anonid", "inlineData");
|
|
}
|
|
return this._inlineData;
|
|
</getter>
|
|
</property>
|
|
|
|
<field name="_bindingData">null</field>
|
|
<property name="bindingData" readonly="true">
|
|
<getter>
|
|
if (!this._bindingData) {
|
|
this._bindingData = document.
|
|
getAnonymousElementByAttribute(this, "anonid", "bindingData");
|
|
}
|
|
return this._bindingData;
|
|
</getter>
|
|
</property>
|
|
|
|
<method name="refresh">
|
|
<body>
|
|
if (this.accessors.hasBoundNode()) {
|
|
this.bindingData.textContent = this.stringValue;
|
|
this.inlineData.style.display = "none";
|
|
this.bindingData.style.display = "inherit";
|
|
} else {
|
|
this.bindingData.style.display = "none";
|
|
this.inlineData.style.display = "inherit";
|
|
}
|
|
</body>
|
|
</method>
|
|
</implementation>
|
|
</binding>
|
|
|
|
|
|
<!-- MESSAGE: <DEFAULT>, reusing the content of inline-alert -->
|
|
<binding id="ephemeral-message"
|
|
extends="chrome://xforms/content/xforms.xml#inline-alert">
|
|
<implementation implements="nsIXFormsEphemeralMessageUI">
|
|
|
|
<field name="_container">null</field>
|
|
|
|
<property name="container" readonly="true">
|
|
<getter>
|
|
if (!this._container) {
|
|
this._container = document.
|
|
getAnonymousElementByAttribute(this, "anonid", "container");
|
|
}
|
|
return this._container;
|
|
</getter>
|
|
</property>
|
|
|
|
<method name="show">
|
|
<parameter name="x"/>
|
|
<parameter name="y"/>
|
|
<body>
|
|
this.container.style.visibility = "visible";
|
|
this.container.style.display = "inherit";
|
|
this.container.style.left = x + "px";
|
|
this.container.style.top = y + "px";
|
|
return true;
|
|
</body>
|
|
</method>
|
|
|
|
<method name="hide">
|
|
<body>
|
|
this.container.style.left = "0px";
|
|
this.container.style.top = "0px";
|
|
this.container.style.visibility = "hidden";
|
|
this.container.style.display = "none";
|
|
</body>
|
|
</method>
|
|
</implementation>
|
|
</binding>
|
|
|
|
|
|
<!-- UPLOAD: <DEFAULT>
|
|
The upload widget assumes successors bindings implement getElementControl()
|
|
method what returns the object:
|
|
{
|
|
set value(); // set "string" value
|
|
set readonly(); // set readonly state
|
|
focus(); // set focus
|
|
}
|
|
-->
|
|
<binding id="xformswidget-upload-base" extends="#xformswidget-base">
|
|
|
|
<implementation implements="nsIXFormsUIWidget, nsIXFormsUploadUIElement">
|
|
<method name="refresh">
|
|
<body>
|
|
this.control.readonly = this.accessors.isReadonly();
|
|
</body>
|
|
</method>
|
|
|
|
<method name="focus">
|
|
<body>
|
|
this.control.focus();
|
|
return true;
|
|
</body>
|
|
</method>
|
|
|
|
<property name="uploadElement" readonly="true">
|
|
<getter>
|
|
if (!this._uploadElement) {
|
|
this._uploadElement =
|
|
this.QueryInterface(Components.interfaces.nsIXFormsUploadElement);
|
|
}
|
|
return this._uploadElement;
|
|
</getter>
|
|
</property>
|
|
<field name="_uploadElement">null</field>
|
|
|
|
<method name="setFieldText">
|
|
<parameter name="aString"/>
|
|
<body>
|
|
this.control.value = aString;
|
|
</body>
|
|
</method>
|
|
</implementation>
|
|
</binding>
|
|
|
|
|
|
<!-- REPEAT -->
|
|
<binding id="xformswidget-repeat-base" extends="#xformswidget-accessors">
|
|
|
|
<implementation implements="nsIXFormsRepeatUIElement">
|
|
<property name="anonymousRepeatContent" readonly="true">
|
|
<getter>
|
|
if (!this._anonymousRepeatContent) {
|
|
this._anonymousRepeatContent =
|
|
document.getAnonymousElementByAttribute(this, "anonid", "insertion");
|
|
}
|
|
return this._anonymousRepeatContent;
|
|
|
|
</getter>
|
|
</property>
|
|
<field name="_anonymousRepeatContent">null</field>
|
|
</implementation>
|
|
</binding>
|
|
|
|
<!-- ATTRIBUTE-BASED REPEAT -->
|
|
<binding id="xformswidget-attr-repeat">
|
|
<content>
|
|
<xforms:repeat xbl:inherits="model=xforms:repeat-model,bind=xforms:repeat-bind,nodeset=xforms:repeat-nodeset,startindex=xforms:repeat-startindex,number=xforms:repeat-number"
|
|
mozType:attrBased="true">
|
|
<children/>
|
|
</xforms:repeat>
|
|
</content>
|
|
</binding>
|
|
|
|
</bindings>
|