458 lines
14 KiB
XML
458 lines
14 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
|
|
- Alexander Surkov.
|
|
- Portions created by the Initial Developer are Copyright (C) 2006
|
|
- the Initial Developer. All Rights Reserved.
|
|
-
|
|
- Contributor(s):
|
|
- Alexander Surkov <surkov@dc.baikal.ru>
|
|
-
|
|
- 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 contains xforms controls implementation for XUL. All controls
|
|
are inherited from interface bindings realized in xforms.xml.
|
|
-->
|
|
|
|
<bindings id="xformsBindings"
|
|
xmlns="http://www.mozilla.org/xbl"
|
|
xmlns:xbl="http://www.mozilla.org/xbl"
|
|
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
|
xmlns:mozType="http://www.mozilla.org/projects/xforms/2005/type">
|
|
|
|
<!-- OUTPUT: <DEFAULT> -->
|
|
<binding id="xformswidget-output"
|
|
extends="chrome://xforms/content/xforms.xml#xformswidget-output-base">
|
|
<content>
|
|
<children includes="label"/>
|
|
<xul:description class="xf-value" anonid="control"/>
|
|
<children/>
|
|
</content>
|
|
|
|
<implementation>
|
|
<method name="getControlElement">
|
|
<body>
|
|
return {
|
|
__proto__: this.ownerDocument.
|
|
getAnonymousElementByAttribute(this, 'anonid', 'control'),
|
|
|
|
set value(val) {
|
|
this.textContent = val;
|
|
}
|
|
};
|
|
</body>
|
|
</method>
|
|
</implementation>
|
|
</binding>
|
|
|
|
|
|
<!-- OUTPUT: <DATE, APPEARANCE='FULL'> -->
|
|
<binding id="xformswidget-output-date-full"
|
|
extends="chrome://xforms/content/xforms.xml#xformswidget-output-base">
|
|
<content>
|
|
<children includes="label"/>
|
|
<xul:box mozType:calendar="true" anonid="control" readonly="true"/>
|
|
<children/>
|
|
</content>
|
|
|
|
<implementation>
|
|
<method name="getControlElement">
|
|
<body>
|
|
return this.ownerDocument.
|
|
getAnonymousElementByAttribute(this, "anonid", "control");
|
|
</body>
|
|
</method>
|
|
</implementation>
|
|
</binding>
|
|
|
|
|
|
<!-- OUTPUT: <MEDIATYPE="image/*", TYPE="xsd:anyURI"> -->
|
|
<binding id="xformswidget-output-mediatype-anyURI"
|
|
extends="chrome://xforms/content/xforms.xml#xformswidget-output-base">
|
|
<content>
|
|
<children includes="label"/>
|
|
<xul:image class="xf-value" anonid="control"/>
|
|
<children/>
|
|
</content>
|
|
|
|
<implementation>
|
|
<method name="getControlElement">
|
|
<body>
|
|
return {
|
|
__proto__: this.ownerDocument.
|
|
getAnonymousElementByAttribute(this, "anonid", "control"),
|
|
|
|
set value(val) {
|
|
this.src = val;
|
|
}
|
|
};
|
|
</body>
|
|
</method>
|
|
</implementation>
|
|
</binding>
|
|
|
|
|
|
<!-- OUTPUT: <MEDIATYPE="image/*", TYPE="xsd:base64Binary"> -->
|
|
<binding id="xformswidget-output-mediatype-base64Binary"
|
|
extends="chrome://xforms/content/xforms.xml#xformswidget-output-base">
|
|
<content>
|
|
<children includes="label"/>
|
|
<xul:image class="xf-value" anonid="control"/>
|
|
<children/>
|
|
</content>
|
|
|
|
<implementation>
|
|
<method name="getControlElement">
|
|
<body>
|
|
return {
|
|
__proto__: this.ownerDocument.
|
|
getAnonymousElementByAttribute(this, "anonid", "control"),
|
|
|
|
set value(val) {
|
|
this.src = "data:[image/*][;base64]," + val;
|
|
}
|
|
};
|
|
</body>
|
|
</method>
|
|
</implementation>
|
|
</binding>
|
|
|
|
|
|
<!-- LABEL: <DEFAULT> -->
|
|
<binding id="xformswidget-label"
|
|
extends="chrome://xforms/content/xforms.xml#xformswidget-label-base">
|
|
<content>
|
|
<xul:deck anonid="contentswitcher" flex="1" selectedIndex="1">
|
|
<xul:label anonid="implicitcontent"/>
|
|
<xul:label><children/></xul:label>
|
|
</xul:deck>
|
|
</content>
|
|
|
|
<implementation>
|
|
<method name="getControlElement">
|
|
<body>
|
|
return {
|
|
_contentSwitcher: this.ownerDocument.
|
|
getAnonymousElementByAttribute(this, 'anonid', 'contentswitcher'),
|
|
_implicitContent: this.ownerDocument.
|
|
getAnonymousElementByAttribute(this, 'anonid', 'implicitcontent'),
|
|
__proto__: this,
|
|
|
|
set value(val) {
|
|
if (val != null) {
|
|
this._implicitContent.textContent = val;
|
|
this._contentSwitcher.selectedIndex = 0;
|
|
} else {
|
|
this._implicitContent.textContent = '';
|
|
this._contentSwitcher.selectedIndex = 1;
|
|
}
|
|
},
|
|
|
|
get textValue() {
|
|
if (this._contentSwitcher.selectedIndex == '0')
|
|
return this._implicitContent.textContent;
|
|
return this.textContent;
|
|
},
|
|
get nodeValue() {
|
|
var fragment = this.ownerDocument.createDocumentFragment();
|
|
|
|
var container = null;
|
|
if (this._contentSwitcher.selectedIndex == '0')
|
|
container = this._implicitContent;
|
|
else
|
|
container = this;
|
|
|
|
for (var node = container.firstChild; node; node = node.nextSibling) {
|
|
fragment.appendChild(node.cloneNode(true));
|
|
}
|
|
var rep = new XMLSerializer().serializeToString(fragment);
|
|
return fragment;
|
|
}
|
|
};
|
|
</body>
|
|
</method>
|
|
|
|
</implementation>
|
|
</binding>
|
|
|
|
|
|
<!-- TRIGGER: base widget for triggers -->
|
|
<binding id="xformswidget-trigger-base"
|
|
extends="chrome://xforms/content/xforms.xml#xformswidget-trigger-base">
|
|
|
|
<handlers>
|
|
<handler event="focus" phase="capturing">
|
|
if (event.originalTarget == this.control) {
|
|
this.dispatchDOMUIEvent("DOMFocusIn");
|
|
}
|
|
</handler>
|
|
|
|
<handler event="blur" phase="capturing">
|
|
if (event.originalTarget == this.control) {
|
|
this.dispatchDOMUIEvent("DOMFocusOut");
|
|
}
|
|
</handler>
|
|
</handlers>
|
|
|
|
</binding>
|
|
|
|
|
|
<!-- TRIGGER: <DEFAULT> -->
|
|
<binding id="xformswidget-trigger"
|
|
extends="#xformswidget-trigger-base">
|
|
<content>
|
|
<xul:button anonid="control" xbl:inherits="accesskey" flex="1">
|
|
<children/>
|
|
</xul:button>
|
|
</content>
|
|
|
|
<implementation>
|
|
<method name="getControlElement">
|
|
<body>
|
|
return this.ownerDocument.
|
|
getAnonymousElementByAttribute(this, 'anonid', 'control');
|
|
</body>
|
|
</method>
|
|
</implementation>
|
|
|
|
<handlers>
|
|
<handler event="command">
|
|
// XXX: we need to fire 'DOMActivate' event to get xforms:submit to
|
|
// work, since xul:button do not do it (see a bug 323005
|
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=323005).
|
|
this.dispatchDOMUIEvent("DOMActivate");
|
|
</handler>
|
|
</handlers>
|
|
</binding>
|
|
|
|
|
|
<!-- TRIGGER: MINIMAL -->
|
|
<binding id="xformswidget-trigger-minimal"
|
|
extends="#xformswidget-trigger-base">
|
|
<content>
|
|
<xul:box tabindex="0" anonid="control" flex="1"
|
|
xbl:inherits="accesskey, orient">
|
|
<children/>
|
|
</xul:box>
|
|
</content>
|
|
|
|
<implementation>
|
|
<method name="getControlElement">
|
|
<body>
|
|
return {
|
|
__proto__: this.ownerDocument.
|
|
getAnonymousElementByAttribute(this, 'anonid', 'control'),
|
|
|
|
set disabled(val) {
|
|
this.isDisabled = val;
|
|
},
|
|
isDisabled: false
|
|
}
|
|
</body>
|
|
</method>
|
|
</implementation>
|
|
|
|
<handlers>
|
|
<handler event="click">
|
|
if (!this.control.isDisabled)
|
|
this.dispatchDOMUIEvent("DOMActivate");
|
|
</handler>
|
|
</handlers>
|
|
</binding>
|
|
|
|
|
|
<!-- SWITCH -->
|
|
<binding id="xformswidget-switch"
|
|
extends="chrome://xforms/content/xforms.xml#xformswidget-accessors">
|
|
<content>
|
|
<xul:deck flex="1" anonid="deck">
|
|
<children/>
|
|
</xul:deck>
|
|
</content>
|
|
|
|
<implementation>
|
|
<property name="selectedCase"
|
|
onget="return this.deck.selectedPanel;"
|
|
onset="this.deck.selectedPanel = val;"/>
|
|
|
|
<property name="deck">
|
|
<getter>
|
|
if (!this._deck) {
|
|
this._deck = this.ownerDocument.
|
|
getAnonymousElementByAttribute(this, "anonid", "deck");
|
|
}
|
|
return this._deck;
|
|
</getter>
|
|
</property>
|
|
<field name="_deck">null</field>
|
|
</implementation>
|
|
</binding>
|
|
|
|
|
|
<!-- CASE -->
|
|
<binding id="xformswidget-case"
|
|
extends="chrome://xforms/content/xforms.xml#xformswidget-case-base">
|
|
<content>
|
|
<xul:box flex="1">
|
|
<children/>
|
|
</xul:box>
|
|
</content>
|
|
|
|
<implementation>
|
|
<method name="getControlElement">
|
|
<body>
|
|
<![CDATA[
|
|
var switchElm = this.parentNode;
|
|
while (switchElm && switchElm.namespaceURI != this.XFORMS_NS &&
|
|
switchElm.nodeName != "switch") {
|
|
switchElm = switchElm.parentNode;
|
|
}
|
|
|
|
return {
|
|
caseElm: this,
|
|
switchElm: switchElm,
|
|
|
|
set selected(val) {
|
|
this.switchElm.selectedCase = this.caseElm;
|
|
}
|
|
};
|
|
]]>
|
|
</body>
|
|
</method>
|
|
</implementation>
|
|
</binding>
|
|
|
|
|
|
<!-- ALERT: <DEFAULT> -->
|
|
<binding id="xformswidget-alert"
|
|
extends="chrome://xforms/content/xforms.xml#xformswidget-alert-base">
|
|
<content>
|
|
<xul:deck anonid="contentswitcher" flex="1" selectedIndex="1">
|
|
<xul:label anonid="implicitcontent" xbl:inherits="orient"/>
|
|
<xul:label xbl:inherits="orient"><children/></xul:label>
|
|
</xul:deck>
|
|
</content>
|
|
|
|
<implementation>
|
|
<method name="getControlElement">
|
|
<body>
|
|
return {
|
|
_contentSwitcher: this.ownerDocument.
|
|
getAnonymousElementByAttribute(this, 'anonid', 'contentswitcher'),
|
|
_implicitContent: this.ownerDocument.
|
|
getAnonymousElementByAttribute(this, 'anonid', 'implicitcontent'),
|
|
|
|
setValue: function setValue(aUseInlineValue, aValue) {
|
|
if (aUseInlineValue) {
|
|
this._contentSwitcher.selectedIndex = 1;
|
|
} else {
|
|
this._implicitContent.textContent = aValue;
|
|
this._contentSwitcher.selectedIndex = 0;
|
|
}
|
|
}
|
|
};
|
|
</body>
|
|
</method>
|
|
</implementation>
|
|
</binding>
|
|
|
|
|
|
<!-- MESSAGE: EPHEMERAL, HINT: <DEFAULT> -->
|
|
<binding id="xformswidget-ephemeral-message"
|
|
extends="#xformswidget-alert">
|
|
|
|
<content>
|
|
<xul:tooltip anonid="popup">
|
|
<xul:deck anonid="contentswitcher" flex="1" selectedIndex="1">
|
|
<xul:label anonid="implicitcontent" xbl:inherits="orient"/>
|
|
<xul:label xbl:inherits="orient"><children/></xul:label>
|
|
</xul:deck>
|
|
</xul:tooltip>
|
|
</content>
|
|
|
|
<implementation implements="nsIXFormsEphemeralMessageUI">
|
|
<method name="show">
|
|
<parameter name="aPosX"/>
|
|
<parameter name="aPosY"/>
|
|
<body>
|
|
// Since the method gets coordinates relative document but tooltip can
|
|
// be shown relative screen then we should do the following magic.
|
|
// We use passed coordinates to save the logic of xtf part of
|
|
// message. Also we substract 21 from y coordinate to revoke tooltip
|
|
// logic.
|
|
|
|
var boxObject = this.ownerDocument.getBoxObjectFor(this.parentNode);
|
|
var deltaX = aPosX - boxObject.x;
|
|
var deltaY = aPosY - boxObject.y;
|
|
|
|
aPosX = boxObject.screenX + deltaX;
|
|
aPosY = boxObject.screenY + deltaY - 21;
|
|
|
|
this.popup.showPopup(this.ownerDocument.documentElement,
|
|
aPosX, aPosY, "tooltip", null, null);
|
|
</body>
|
|
</method>
|
|
|
|
<method name="hide">
|
|
<body>
|
|
this.popup.hidePopup();
|
|
</body>
|
|
</method>
|
|
|
|
<!-- internal -->
|
|
<property name="popup" readonly="true">
|
|
<getter>
|
|
if (!this._popup) {
|
|
this._popup = this.ownerDocument.
|
|
getAnonymousElementByAttribute(this, "anonid", "popup");
|
|
}
|
|
return this._popup;
|
|
</getter>
|
|
</property>
|
|
<field name="_popup"/>
|
|
</implementation>
|
|
</binding>
|
|
|
|
|
|
<!-- REPEAT -->
|
|
<binding id="xformswidget-repeat"
|
|
extends="chrome://xforms/content/xforms.xml#xformswidget-repeat-base">
|
|
<content>
|
|
<xul:box hidden="true">
|
|
<children/>
|
|
</xul:box>
|
|
<xul:vbox anonid="insertion" flex="1"/>
|
|
</content>
|
|
</binding>
|
|
|
|
</bindings>
|