sylvain 2003/11/19 08:54:02
Modified: src/blocks/woody/samples/forms form1_template_action.xml
src/blocks/woody/samples/resources woody-field-styling.xsl
woody-lib.js woody-page-styling.xsl
Added: src/blocks/woody/samples/messages OtherMessages_fr.xml
WoodyMessages_fr.xml
Log:
- new "double-listbox" styling for multivaluefields
- french translations
Revision Changes Path
1.8 +1 -1 cocoon-2.1/src/blocks/woody/samples/forms/form1_template_action.xml
Index: form1_template_action.xml
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/samples/forms/form1_template_action.xml,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- form1_template_action.xml 15 Oct 2003 13:08:47 -0000 1.7
+++ form1_template_action.xml 19 Nov 2003 16:54:01 -0000 1.8
@@ -52,7 +52,7 @@
<wi:items>
<wt:widget id="somebool"/>
<wt:widget id="drinks">
- <wi:styling list-type="checkbox"/>
+ <wi:styling list-type="double-listbox"/>
</wt:widget>
</wi:items>
</wi:group>
1.1 cocoon-2.1/src/blocks/woody/samples/messages/OtherMessages_fr.xml
Index: OtherMessages_fr.xml
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<catalogue>
<message key="org.apache.cocoon.woody.samples.Sex.FEMALE">féminin</message>
<message key="org.apache.cocoon.woody.samples.Sex.MALE">masculin</message>
</catalogue>
1.1 cocoon-2.1/src/blocks/woody/samples/messages/WoodyMessages_fr.xml
Index: WoodyMessages_fr.xml
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- This catalogue file contains translations for built-in Woody messages. -->
<catalogue>
<message key="general.field-required">Cette donnée est obligatoire.</message>
<message key="datatype.conversion-failed">N'est pas un(e) {0}.</message>
<message key="datatype.long">nombre entier</message>
<message key="datatype.date">date</message>
<message key="validation.string.exact-length">Doit avoir exactement {0} caractères.</message>
<message key="validation.string.range-length">Doit avoir entre {0} et {1} caractères.</message>
<message key="validation.string.min-length">Doit avoir au moins {0} caractères.</message>
<message key="validation.string.max-length">Doit avoir au plus {0} caractères.</message>
<message key="validation.string.regexp">Ne correspond pas à l'expression régulière
: {0}</message>
<message key="validation.string.invalidemail">N'est pas une adresse mail correcte.</message>
<message key="validation.array.exact-valuecount">{0} éléments doivent être séléctionnés.</message>
<message key="validation.array.range-valuecount">Entre {0} et {1} éléments doivent
être sélectionnés.</message>
<message key="validation.array.min-valuecount">Au moins {0} éléments doivent être
séléctionnés.</message>
<message key="validation.array.max-valuecount">Au plus {0} éléments peuvent être
séléctionnés.</message>
<message key="multivaluefield.conversionfailed">Un des éléments séléctionnées a
un type incorrect.</message>
<message key="validation.numeric.range">Doit être compris entre {0} et {1}.</message>
<message key="validation.numeric.min">Doit être supérieur ou égal à {0}.</message>
<message key="validation.numeric.max">Doit être inférieur ou égal à {0}.</message>
<message key="validation.mod10">Numéro de carte incorrect.</message>
<message key="aggregatedfield.split-failed">Ne correspond pas à l'expression régulière:
{0}</message>
<message key="upload.invalid-type">Type de fichier incorrect.</message>
</catalogue>
1.18 +133 -41 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.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- woody-field-styling.xsl 18 Nov 2003 22:45:28 -0000 1.17
+++ woody-field-styling.xsl 19 Nov 2003 16:54:02 -0000 1.18
@@ -10,7 +10,16 @@
<xsl:param name="uri" select="'resources'"/>
<xsl:param name="div">woody_calendarDiv</xsl:param>
+ <!-- use this for debugging
+ <script src="{$uri}/mattkruse-lib/AnchorPosition.js" language="JavaScript"></script>
+ <script src="{$uri}/mattkruse-lib/CalendarPopup.js" language="JavaScript"></script>
+ <script src="{$uri}/mattkruse-lib/date.js" language="JavaScript"></script>
+ <script src="{$uri}/mattkruse-lib/OptionTransfer.js" language="JavaScript"></script>
+ <script src="{$uri}/mattkruse-lib/PopupWindow.js" language="JavaScript"></script>
+ <script src="{$uri}/mattkruse-lib/selectbox.js" language="JavaScript"></script>
+ -->
<script src="{$uri}/mattkruse-lib.js" language="JavaScript"></script>
+
<script src="{$uri}/woody-lib.js" language="JavaScript"></script>
<script language="JavaScript">
// Setup calendar
@@ -32,11 +41,11 @@
<!-- must be called in <head> to load calendar script and setup the CSS -->
<xsl:template name="woody-field-body">
- <xsl:attribute name="onload">woody_init(); <xsl:value-of select="@onload"/></xsl:attribute>
- <script language="JavaScript">
+ <xsl:attribute name="onload">woody_onload(); <xsl:value-of select="@onload"/></xsl:attribute>
+ <!--script language="JavaScript">
// Register woody startup function
document.body.onload = woody_init;
- </script>
+ </script-->
<div id="woody_calendarDiv" style="position:absolute;visibility:hidden;background-color:white;layer-background-color:white;"/>
</xsl:template>
@@ -281,57 +290,139 @@
</xsl:template>
<!--
- wi:multivaluefield : produce a list of checkboxes or a multiple selection-lists
+ wi:multivaluefield : produce a list of checkboxes
+ -->
+
+ <xsl:template match="wi:multivaluefield[wi:styling[@list-type='checkbox']]">
+ <xsl:variable name="id" select="@id"/>
+ <xsl:variable name="values" select="wi:values/wi:value/text()"/>
+
+ <span title="{wi:hint}">
+ <xsl:for-each select="wi:selection-list/wi:item">
+ <xsl:variable name="value" select="@value"/>
+ <input id="{generate-id()}" type="checkbox" value="{@value}" name="{$id}">
+ <xsl:if test="$values[. = $value]">
+ <xsl:attribute name="checked">true</xsl:attribute>
+ </xsl:if>
+ </input>
+ <label for="{generate-id()}"><xsl:copy-of select="wi:label/node()"/></label>
+ <br/>
+ </xsl:for-each>
+ </span>
+ <xsl:apply-templates select="." mode="common"/>
+ </xsl:template>
+
+ <!--
+ wi:multivaluefield : produce a multiple-selection list
-->
+
<xsl:template match="wi:multivaluefield">
<xsl:variable name="id" select="@id"/>
<xsl:variable name="values" select="wi:values/wi:value/text()"/>
- <xsl:variable name="liststyle" select="wi:styling/@list-type"/>
<span title="{wi:hint}">
+ <select id="{@id}" name="{$id}" multiple="multiple">
+ <xsl:attribute name="size">
+ <xsl:choose>
+ <xsl:when test="wi:styling/@listbox-size">
+ <xsl:value-of select="wi:styling/@listbox-size"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>5</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ <xsl:for-each select="wi:selection-list/wi:item">
+ <xsl:variable name="value" select="@value"/>
+ <option value="{$value}">
+ <xsl:if test="$values[. = $value]">
+ <xsl:attribute name="selected">selected</xsl:attribute>
+ </xsl:if>
+ <xsl:copy-of select="wi:label/node()"/>
+ </option>
+ </xsl:for-each>
+ </select>
+ </span>
+ <xsl:apply-templates select="." mode="common"/>
+ </xsl:template>
+
+ <!--
+ wi:multivaluefield : produce a double selection list
+ -->
+
+ <xsl:template match="wi:multivaluefield[wi:styling[@list-type='double-listbox']]">
+ <xsl:variable name="id" select="@id"/>
+ <xsl:variable name="values" select="wi:values/wi:value/text()"/>
+ <xsl:variable name="size">
<xsl:choose>
- <!-- checkbox -->
- <xsl:when test="$liststyle = 'checkbox'">
- <xsl:for-each select="wi:selection-list/wi:item">
- <xsl:variable name="value" select="@value"/>
- <input id="{generate-id()}" type="checkbox" value="{@value}" name="{$id}">
- <xsl:if test="$values[. = $value]">
- <xsl:attribute name="checked">true</xsl:attribute>
- </xsl:if>
- </input>
- <label for="{generate-id()}"><xsl:copy-of select="wi:label/node()"/></label>
- <br/>
- </xsl:for-each>
+ <xsl:when test="wi:styling/@listbox-size">
+ <xsl:value-of select="wi:styling/@listbox-size"/>
</xsl:when>
- <!-- listbox -->
<xsl:otherwise>
- <select id="{@id}" name="{$id}" multiple="multiple">
- <xsl:attribute name="size">
- <xsl:choose>
- <xsl:when test="wi:styling/@listbox-size">
- <xsl:value-of select="wi:styling/@listbox-size"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>5</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- <xsl:for-each select="wi:selection-list/wi:item">
- <xsl:variable name="value" select="@value"/>
- <option value="{$value}">
- <xsl:if test="$values[. = $value]">
- <xsl:attribute name="selected">selected</xsl:attribute>
- </xsl:if>
- <xsl:copy-of select="wi:label/node()"/>
- </option>
- </xsl:for-each>
- </select>
+ <xsl:text>5</xsl:text>
</xsl:otherwise>
</xsl:choose>
+ </xsl:variable>
+
+ <span title="{wi:hint}">
+ <table>
+ <tr>
+ <td>
+ <!-- select for the unselected values -->
+ <select id="{@id}.unselected" name="{@id}.unselected" size="{$size}" multiple="multiple">
+ <xsl:for-each select="wi:selection-list/wi:item">
+ <xsl:variable name="value" select="@value"/>
+ <xsl:if test="not($values[. = $value])">
+ <option value="{$value}">
+ <xsl:copy-of select="wi:label/node()"/>
+ </option>
+ </xsl:if>
+ </xsl:for-each>
+ </select>
+</td>
+ <td align="center" valign="middle">
+ <!-- command buttons -->
+ <!-- strangely, IE adds an extra blank line if there only a button on a line.
So we surround it with nbsp -->
+ <xsl:text> </xsl:text>
+ <input type="button" value=" > " onclick="opt{generate-id()}.transferRight()"/>
+ <xsl:text> </xsl:text>
+ <br/>
+ <xsl:text> </xsl:text>
+ <input type="button" value=">>" onclick="opt{generate-id()}.transferAllRight()"/>
+ <xsl:text> </xsl:text>
+ <br/>
+ <xsl:text> </xsl:text>
+ <input type="button" value=" < " onclick="opt{generate-id()}.transferLeft()"/>
+ <xsl:text> </xsl:text>
+ <br/>
+ <xsl:text> </xsl:text>
+ <input type="button" value="<<" onclick="opt{generate-id()}.transferAllLeft()"/>
+ <xsl:text> </xsl:text>
+ <br/>
+ <xsl:apply-templates select="." mode="common"/>
+ </td>
+ <td>
+ <!-- select for the selected values -->
+ <select id="{@id}" name="{@id}" size="{$size}" multiple="multiple">
+ <xsl:for-each select="wi:selection-list/wi:item">
+ <xsl:variable name="value" select="@value"/>
+ <xsl:if test="$values[. = $value]">
+ <option value="{$value}">
+ <xsl:copy-of select="wi:label/node()"/>
+ </option>
+ </xsl:if>
+ </xsl:for-each>
+ </select>
+</td>
+ </tr>
+ </table>
+ <script language="JavaScript">
+ var opt<xsl:value-of select="generate-id()"/> = woody_createOptionTransfer('<xsl:value-of
select="@id"/>');
+ </script>
</span>
- <xsl:apply-templates select="." mode="common"/>
+
</xsl:template>
-
+
<!--
wi:upload
-->
@@ -391,6 +482,7 @@
<xsl:template match="wi:form-template">
<form>
<xsl:copy-of select="@*"/>
+ <xsl:attribute name="onsubmit">woody_onsubmit(); <xsl:value-of select="@onsubmit"/></xsl:attribute>
<!-- hidden field to store the submit id -->
<input type="hidden" name="woody_submit_id"/>
<xsl:apply-templates/>
1.2 +62 -19 cocoon-2.1/src/blocks/woody/samples/resources/woody-lib.js
Index: woody-lib.js
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/samples/resources/woody-lib.js,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- woody-lib.js 18 Nov 2003 22:45:28 -0000 1.1
+++ woody-lib.js 19 Nov 2003 16:54:02 -0000 1.2
@@ -5,22 +5,32 @@
* @version CVS $Id$
*/
-var woody_initHandlers = new Array();
+// Handlers that are to be called in the document's "onload" event
+var woody_onloadHandlers = new Array();
-function woody_init() {
- for (var i = 0; i < woody_initHandlers.length; i++) {
- woody_initHandlers[i].handle();
+function woody_onload() {
+ for (var i = 0; i < woody_onloadHandlers.length; i++) {
+ woody_onloadHandlers[i].woody_onload();
}
+ // Clear it (we no more need them)
+ woody_onloadHandlers = null;
}
-/**
- * Crawl the parents of an element up to finding a form.
- */
-function woody_getForm(element) {
- while(element != null && element.tagName != "FORM") {
- element = element.parentNode;
+// Handlers that are to be called in form's "onsubmit" event
+//FIXME: this single var implies only one woody form per page, and needs to be
+// visited if we decide to support several forms per page.
+var woody_onsubmitHandlers = new Array();
+
+function woody_onsubmit() {
+ if (woody_onsubmitHandlers == null) {
+ alert("onsubmit called twice!");
}
- return element;
+
+ for (var i = 0; i < woody_onsubmitHandlers.length; i++) {
+ woody_onsubmitHandlers[i].woody_onsubmit();
+ }
+ // clear it
+ woody_onsubmitHandlers = null;
}
/**
@@ -37,11 +47,23 @@
alert("Cannot find form for " + element);
} else {
form["woody_submit_id"].value = name;
+ // FIXME: programmatically submitting the form doesn't trigger onsubmit ? (both
in IE and Moz)
+ woody_onsubmit();
form.submit();
}
}
/**
+ * Crawl the parents of an element up to finding a form.
+ */
+function woody_getForm(element) {
+ while(element != null && element.tagName != "FORM") {
+ element = element.parentNode;
+ }
+ return element;
+}
+
+/**
* Move a named element as an immediate child of the <body> element.
* This is required for help popups inside <wi:group> tabs. The reason is that CSS
positioning
* properties ("left" and "top") on a block with a "position: absolute" are actually relative
to
@@ -60,20 +82,41 @@
* @param id the ID of the element to make a popup with.
*/
function woody_createPopupWindow(id) {
- woody_initHandlers.push(new woody_moveInBodyHandler(id));
var result = new PopupWindow(id);
result.autoHide();
+ // add to onload handlers
+ result.woody_id = id;
+ result.woody_onload = function() {
+ woody_moveInBody(document.getElementById(this.woody_id));
+ }
+ woody_onloadHandlers.push(result);
return result;
}
-function woody_moveInBodyHandler(id) {
- this.id = id;
- this.handle = function() {
- var element = document.getElementById(this.id);
- element.parentNode.removeChild(element);
- document.body.appendChild(element);
+
+function woody_createOptionTransfer(id) {
+ var result = new OptionTransfer(id + ".unselected", id);
+ result.setAutoSort(true);
+ // add to onload handlers
+ result.woody_id = id;
+ result.woody_onload = function() {
+ var form = woody_getForm(document.getElementById(this.woody_id));
+ this.init(form);
+ sortSelect(this.left);
+ sortSelect(this.right);
+ }
+ woody_onloadHandlers.push(result);
+
+ // add to onsubmit handlers
+ result.woody_onsubmit = function() {
+ // Select all options in the "selected" list to that
+ // its values are sent.
+ selectAllOptions(this.right);
}
+ woody_onsubmitHandlers.push(result);
+ return result;
}
+
/**
* Show a tab in a <wi:group>
1.6 +10 -0 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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- woody-page-styling.xsl 18 Nov 2003 22:45:28 -0000 1.5
+++ woody-page-styling.xsl 19 Nov 2003 16:54:02 -0000 1.6
@@ -200,6 +200,16 @@
</tr>
</xsl:template>
+ <!-- double-list multivaluefield : lists under the label -->
+ <xsl:template match="wi:multivaluefield[wi:styling/@list-type='double-listbox']" mode="group-columns-content">
+ <tr align="center">
+ <td colspan="2"><label for="{@id}"><xsl:copy-of select="wi:label/node()"/></label></td>
+ </tr>
+ <tr align="center">
+ <td colspan="2"><xsl:apply-templates select="."/></td>
+ </tr>
+ </xsl:template>
+
<!-- nested group -->
<xsl:template match="wi:group" mode="group-columns-content">
<tr>
|