Permalink
Fetching contributors…
Cannot retrieve contributors at this time
133 lines (120 sloc) 6.76 KB
<!--
Copyright (C) 2016 Orbeon, Inc.
This program is free software; you can redistribute it and/or modify it under the terms of the
GNU Lesser General Public License as published by the Free Software Foundation; either version
2.1 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.
The full text of the license is available at http://www.gnu.org/copyleft/lesser.html
-->
<xbl:xbl xmlns:xh="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
xmlns:xbl="http://www.w3.org/ns/xbl"
xmlns:xxbl="http://orbeon.org/oxf/xml/xbl">
<!-- Later: Bind to `xf|select1[selection = open]`
See: https://github.com/orbeon/orbeon-forms/issues/2479 and
https://github.com/orbeon/orbeon-forms/issues/2394
-->
<xbl:binding
id="fr-open-select1"
element="fr|open-select1"
xxbl:container="span"
xxbl:mode="lhha binding value"
xxbl:label-for="select1">
<metadata xmlns="http://orbeon.org/oxf/xml/form-builder">
<display-name lang="en">Radio Buttons with "Other"</display-name>
<display-name lang="es">Botones de Radio con "Otros"</display-name>
<display-name lang="fi" todo="true">[Radio Buttons with "Other"]</display-name>
<display-name lang="fr">Boutons radio avec "Autre"</display-name>
<display-name lang="ru" todo="true">[Radio Buttons with "Other"]</display-name>
<display-name lang="de">Auswahl-Buttons mit "Andere"</display-name>
<display-name lang="it" todo="true">[Radio Buttons with "Other"]</display-name>
<display-name lang="nl" todo="true">[Radio Buttons with "Other"]</display-name>
<display-name lang="pt" todo="true">[Radio Buttons with "Other"]</display-name>
<display-name lang="sv">Enkelval med "Annat"</display-name>
<icon>
<small-icon>/forms/orbeon/builder/images/radio.png</small-icon>
<large-icon>/forms/orbeon/builder/images/radio.png</large-icon>
</icon>
<editors static-itemset="true" item-hint="true"/>
<templates>
<view>
<fr:open-select1 id="" ref="" xmlns="">
<xf:label ref=""/>
<xf:hint ref=""/>
<xf:help ref=""/>
<xf:alert ref=""/>
<xf:itemset ref="">
<xf:label ref="label"/>
<xf:value ref="value"/>
<xf:hint ref="hint"/>
</xf:itemset>
</fr:open-select1>
</view>
</templates>
</metadata>
<xbl:resources>
<xbl:style src="/xbl/orbeon/open-select1/open-select1.css"/>
</xbl:resources>
<xbl:template xxbl:transform="oxf:unsafe-xslt" xmlns:oxf="http://www.orbeon.com/oxf/processors">
<xsl:transform version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="oxf:/oxf/xslt/utils/copy-modes.xsl"/>
<xsl:import href="oxf:/oxf/xslt/utils/xbl.xsl"/>
<xsl:template match="/*">
<xf:group appearance="xxf:internal">
<xf:var name="binding" value="xxf:binding('fr-open-select1')"/>
<xf:select1 id="hidden-select1" ref="$binding" appearance="xxf:internal">
<!-- Copy user items -->
<xbl:content includes=":root > xf|itemset, :root > xf|item, :root > xf|choices"/>
</xf:select1>
<xf:var name="items" value="xxf:itemset('hidden-select1', 'xml')//item"/>
<xf:var name="closed-value" value="$binding/string() = $items/value/string()"/>
<xh:span class="fr-component-group">
<xf:select1
id = "select1"
ref = "$binding"
appearance = "full"
xbl:attr = "appearance xxf:encrypt-item-values"
class = "xxforms-events-mode-default">
<xf:itemset ref="$items">
<xf:label ref="label"/>
<xf:hint ref="hint"/>
<xf:value ref="value"/>
</xf:itemset>
<xf:item>
<xf:label ref="xxf:r('components.labels.other', '|fr-fr-resources|')"/>
<xf:value ref="if ($closed-value) then '' else ."/>
</xf:item>
<!-- Focus asynchronously because the input is not visible yet and a plain `setfocus` would fail -->
<xf:dispatch
event="xforms-select"
if="xxf:is-blank(event('xxf:item-value'))"
delay="0"
name="xforms-focus"
targetid="input"/>
</xf:select1>
<xsl:element
name="{
if (@type = ('integer', 'decimal')) then
'fr:number'
else
'xf:input'
}">
<xsl:attribute name="id">input</xsl:attribute>
<xsl:attribute name="ref">if ($closed-value) then '' else $binding</xsl:attribute>
<xsl:if test="@type = ('integer', 'decimal')">
<xsl:copy-of select="@prefix | @suffix"/>
</xsl:if>
<xf:label class="xforms-hidden" ref="xxf:r('components.labels.other', '|fr-fr-resources|')"/>
</xsl:element>
</xh:span>
</xf:group>
</xsl:template>
</xsl:transform>
</xbl:template>
</xbl:binding>
</xbl:xbl>