sylvain 2003/11/05 05:36:03
Modified: src/blocks/woody/samples/resources woody-field-styling.xsl
woody-page-styling.xsl
Log:
Discovered the <label> tag today, which allows to associate text to an input,
and gives focus to the input when clicked.
Very usefull, especially for small checkboxes.
Revision Changes Path
1.6 +12 -12
cocoon-2.1/src/blocks/woody/samples/resources/woody-field-styling.xsl
Index: woody-field-styling.xsl
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/woody/samples/resources/woody-field-styling.xsl,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- woody-field-styling.xsl 3 Nov 2003 17:15:14 -0000 1.5
+++ woody-field-styling.xsl 5 Nov 2003 13:36:02 -0000 1.6
@@ -58,7 +58,7 @@
Generic wi:field : produce an <input>
-->
<xsl:template match="wi:field">
- <input name="[EMAIL PROTECTED]" value="{wi:value}" title="{wi:hint}">
+ <input name="[EMAIL PROTECTED]" id="[EMAIL PROTECTED]"
value="{wi:value}" title="{wi:hint}">
<xsl:if test="wi:styling">
<xsl:copy-of select="wi:styling/@*"/>
</xsl:if>
@@ -99,7 +99,7 @@
<xsl:variable name="id" select="@id"/>
<xsl:for-each select="wi:selection-list/wi:item">
<xsl:if test="$vertical and position() != 1"><br/></xsl:if>
- <input type="radio" name="{$id}" value="[EMAIL PROTECTED]">
+ <input type="radio" id="{generate-id()}" name="{$id}"
value="[EMAIL PROTECTED]">
<xsl:if test="@value = $value">
<xsl:attribute name="checked">true</xsl:attribute>
</xsl:if>
@@ -107,13 +107,13 @@
<xsl:attribute
name="onchange">woody_submitForm(this)</xsl:attribute>
</xsl:if>
</input>
- <xsl:copy-of select="wi:label/node()"/>
+ <label for="{generate-id()}"><xsl:copy-of
select="wi:label/node()"/></label>
</xsl:for-each>
</span>
</xsl:when>
<!-- dropdown or listbox -->
<xsl:otherwise>
- <select title="{wi:hint}" name="[EMAIL PROTECTED]">
+ <select title="{wi:hint}" id="[EMAIL PROTECTED]" name="[EMAIL
PROTECTED]">
<xsl:if test="wi:styling/@submit-on-change='true'">
<xsl:attribute
name="onchange">woody_submitForm(this)</xsl:attribute>
</xsl:if>
@@ -147,7 +147,7 @@
wi:field with @type 'textarea'
-->
<xsl:template match="wi:field[wi:[EMAIL PROTECTED]'textarea']]">
- <textarea name="[EMAIL PROTECTED]" title="{wi:hint}">
+ <textarea id="[EMAIL PROTECTED]" name="[EMAIL PROTECTED]"
title="{wi:hint}">
<xsl:if test="wi:styling/@submit-on-change='true'">
<xsl:attribute name="onchange">woody_submitForm(this)</xsl:attribute>
</xsl:if>
@@ -175,7 +175,7 @@
<xsl:otherwise>yyyy-MM-dd</xsl:otherwise>
</xsl:choose>
</xsl:variable>
- <input name="[EMAIL PROTECTED]" value="{wi:value}">
+ <input id="[EMAIL PROTECTED]" name="[EMAIL PROTECTED]"
value="{wi:value}">
<xsl:if test="wi:styling/@submit-on-change='true'">
<xsl:attribute name="onchange">woody_submitForm(this)</xsl:attribute>
</xsl:if>
@@ -196,7 +196,7 @@
wi:booleanfield : produce a checkbox
-->
<xsl:template match="wi:booleanfield">
- <input type="checkbox" value="true" name="[EMAIL PROTECTED]"
title="{wi:hint}">
+ <input id="[EMAIL PROTECTED]" type="checkbox" value="true" name="[EMAIL
PROTECTED]" title="{wi:hint}">
<xsl:if test="wi:styling/@submit-on-change='true'">
<xsl:attribute name="onchange">woody_submitForm(this)</xsl:attribute>
</xsl:if>
@@ -211,7 +211,7 @@
wi:action
-->
<xsl:template match="wi:action">
- <input type="submit" name="[EMAIL PROTECTED]" title="{wi:hint}">
+ <input id="[EMAIL PROTECTED]" type="submit" name="[EMAIL PROTECTED]"
title="{wi:hint}">
<xsl:attribute name="value"><xsl:value-of
select="wi:label/node()"/></xsl:attribute>
<xsl:copy-of select="wi:styling/@*"/>
</input>
@@ -245,18 +245,18 @@
<xsl:when test="$liststyle = 'checkbox'">
<xsl:for-each select="wi:selection-list/wi:item">
<xsl:variable name="value" select="@value"/>
- <input type="checkbox" value="[EMAIL PROTECTED]" name="{$id}">
+ <input id="{generate-id()}" type="checkbox" value="[EMAIL
PROTECTED]" name="{$id}">
<xsl:if test="$values[. = $value]">
<xsl:attribute name="checked">true</xsl:attribute>
</xsl:if>
</input>
- <xsl:copy-of select="wi:label/node()"/>
+ <label for="{generate-id()}"><xsl:copy-of
select="wi:label/node()"/></label>
<br/>
</xsl:for-each>
</xsl:when>
<!-- listbox -->
<xsl:otherwise>
- <select name="{$id}" multiple="multiple">
+ <select id="[EMAIL PROTECTED]" name="{$id}" multiple="multiple">
<xsl:attribute name="size">
<xsl:choose>
<xsl:when test="wi:styling/@listbox-size">
@@ -366,7 +366,7 @@
</xsl:template>
<xsl:template match="wi:aggregatefield">
- <input name="[EMAIL PROTECTED]" value="{wi:value}" title="{wi:hint}">
+ <input id="[EMAIL PROTECTED]" name="[EMAIL PROTECTED]"
value="{wi:value}" title="{wi:hint}">
<xsl:if test="wi:styling/@submit-on-change='true'">
<xsl:attribute name="onchange">woody_submitForm(this)</xsl:attribute>
</xsl:if>
1.3 +2 -2
cocoon-2.1/src/blocks/woody/samples/resources/woody-page-styling.xsl
Index: woody-page-styling.xsl
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/woody/samples/resources/woody-page-styling.xsl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- woody-page-styling.xsl 24 Oct 2003 14:13:50 -0000 1.2
+++ woody-page-styling.xsl 5 Nov 2003 13:36:02 -0000 1.3
@@ -207,7 +207,7 @@
-->
<xsl:template match="wi:*" mode="group-columns-content">
<tr>
- <td valign="top"><span title="{wi:hint}"><xsl:copy-of
select="wi:label/node()"/></span></td>
+ <td valign="top"><label for="[EMAIL PROTECTED]"
title="{wi:hint}"><xsl:copy-of select="wi:label/node()"/></label></td>
<td><xsl:apply-templates select="."/></td>
</tr>
</xsl:template>
@@ -215,7 +215,7 @@
<!-- boolean field : checkbox and label on a single line -->
<xsl:template match="wi:booleanfield" mode="group-columns-content">
<tr>
- <td colspan="2"><xsl:apply-templates select="."/> <xsl:copy-of
select="wi:label/node()"/></td>
+ <td colspan="2"><xsl:apply-templates select="."/> <label for="[EMAIL
PROTECTED]"><xsl:copy-of select="wi:label/node()"/></label></td>
</tr>
</xsl:template>