home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-cocoon-addon-1.4.9-installer.exe / forms-advanced-field-styling.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-12  |  6.9 KB  |  165 lines

  1. <?xml version="1.0"?>
  2. <!--
  3.   Copyright 1999-2004 The Apache Software Foundation
  4.  
  5.   Licensed under the Apache License, Version 2.0 (the "License");
  6.   you may not use this file except in compliance with the License.
  7.   You may obtain a copy of the License at
  8.  
  9.       http://www.apache.org/licenses/LICENSE-2.0
  10.  
  11.   Unless required by applicable law or agreed to in writing, software
  12.   distributed under the License is distributed on an "AS IS" BASIS,
  13.   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.   See the License for the specific language governing permissions and
  15.   limitations under the License.
  16. -->
  17. <xsl:stylesheet version="1.0"
  18.                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  19.                 xmlns:fi="http://apache.org/cocoon/forms/1.0#instance"
  20.                 exclude-result-prefixes="fi">
  21.   <!--+
  22.       | This stylesheet is designed to be included by 'forms-samples-styling.xsl'.
  23.       | It extends the 'forms-field-styling.xsl' with additional stylings.
  24.       | The very specific advanced stylings as the calendar or htmlarea (both
  25.       | also need additional JS files) are separated out of this file.
  26.       +-->
  27.  
  28.   <xsl:import href="forms-field-styling.xsl"/>
  29.   <xsl:include href="forms-calendar-styling.xsl"/>
  30.   <xsl:include href="forms-htmlarea-styling.xsl"/>
  31.   <!-- Location of the resources directory, where JS libs and icons are stored -->
  32.   <xsl:param name="resources-uri">resources</xsl:param>
  33.  
  34.   <xsl:template match="head" mode="forms-field">
  35.     <xsl:apply-imports/>
  36.     <script src="{$resources-uri}/mattkruse-lib/AnchorPosition.js" type="text/javascript"/>
  37.     <script src="{$resources-uri}/mattkruse-lib/PopupWindow.js" type="text/javascript"/>
  38.     <script src="{$resources-uri}/mattkruse-lib/OptionTransfer.js" type="text/javascript"/>
  39.     <script src="{$resources-uri}/mattkruse-lib/selectbox.js" type="text/javascript"/>
  40.     <xsl:apply-templates select="." mode="forms-calendar"/>
  41.     <xsl:apply-templates select="." mode="forms-htmlarea"/>
  42.   </xsl:template>
  43.  
  44.   <xsl:template match="body" mode="forms-field">
  45.     <xsl:apply-imports/>
  46.     <xsl:apply-templates select="." mode="forms-calendar"/>
  47.     <xsl:apply-templates select="." mode="forms-htmlarea"/>
  48.   </xsl:template>
  49.  
  50.   <!--+ This template should not be necessary as this stylesheet "inherits"
  51.       | all templates from 'forms-field-styling.xsl', but without it, it does
  52.       | not work for me (using Xalan 2.5.1). It's like adding all methods of
  53.       | a superclass in a subclass and calling everywhere only the super
  54.       | implementation.
  55.       +-->
  56.   <xsl:template match="*">
  57.     <xsl:apply-imports/>
  58.   </xsl:template>
  59.  
  60.   <!--+
  61.       | Add fi:help to the common stuff.
  62.       +-->
  63.   <xsl:template match="fi:*" mode="common">
  64.     <xsl:apply-imports/>
  65.     <xsl:apply-templates select="fi:help"/>
  66.   </xsl:template>
  67.  
  68.   <!--+
  69.       | 
  70.       +-->
  71.   <xsl:template match="fi:help">
  72.     <xsl:variable name="id" select="generate-id()"/>
  73.     <div class="forms-help" id="help{$id}" style="visibility:hidden; position:absolute;">
  74.       <xsl:apply-templates select="node()"/>
  75.     </div>
  76.     <script type="text/javascript">
  77.       var helpWin<xsl:value-of select="$id"/> = forms_createPopupWindow('help<xsl:value-of select="$id"/>');
  78.     </script>
  79.     <a id="{$id}" name="{$id}" href="#" onclick="helpWin{$id}.showPopup('{$id}');return false;"><img border="0" src="{$resources-uri}/help.gif"/></a>
  80.   </xsl:template>
  81.  
  82.   <!--+
  83.       | fi:multivaluefield with list-type='double-listbox' styling
  84.       +-->
  85.   <xsl:template match="fi:multivaluefield[fi:styling/@list-type='double-listbox']">
  86.     <xsl:variable name="id" select="@id"/>
  87.     <xsl:variable name="values" select="fi:values/fi:value/text()"/>
  88.  
  89.     <span class="forms-doubleList" title="{fi:hint}">
  90.       <table>
  91.         <xsl:if test="fi:styling/fi:available-label|fi:styling/fi:selected-label">
  92.           <tr>
  93.             <th>
  94.               <xsl:copy-of select="fi:styling/fi:available-label/node()"/>
  95.             </th>
  96.             <th> </th>
  97.             <th>
  98.               <xsl:copy-of select="fi:styling/fi:selected-label/node()"/>
  99.             </th>
  100.           </tr>
  101.         </xsl:if>
  102.         <tr>
  103.           <td>
  104.             <!-- select for the unselected values -->
  105.             <select id="{@id}.unselected" name="{@id}.unselected" multiple="multiple"
  106.                     ondblclick="opt{generate-id()}.forms_transferRight()">
  107.               <xsl:apply-templates select="." mode="styling"/>
  108.               <xsl:for-each select="fi:selection-list/fi:item">
  109.                 <xsl:variable name="value" select="@value"/>
  110.                 <xsl:if test="not($values[. = $value])">
  111.                   <option value="{$value}">
  112.                     <xsl:copy-of select="fi:label/node()"/>
  113.                   </option>
  114.                 </xsl:if>
  115.               </xsl:for-each>
  116.             </select>
  117.           </td>
  118.           <td>
  119.             <!-- command buttons -->
  120.             <!-- strangely, IE adds an extra blank line if there only a button on a line. So we surround it with nbsp -->
  121.             <xsl:text> </xsl:text>
  122.             <input type="button" value=">" onclick="opt{generate-id()}.forms_transferRight()"/>
  123.             <xsl:text> </xsl:text>
  124.             <br/>
  125.             <xsl:text> </xsl:text>
  126.             <input type="button" value=">>" onclick="opt{generate-id()}.forms_transferAllRight()"/>
  127.             <xsl:text> </xsl:text>
  128.             <br/>
  129.             <xsl:text> </xsl:text>
  130.             <input type="button" value="<" onclick="opt{generate-id()}.forms_transferLeft()"/>
  131.             <xsl:text> </xsl:text>
  132.             <br/>
  133.             <xsl:text> </xsl:text>
  134.             <input type="button" value="<<" onclick="opt{generate-id()}.forms_transferAllLeft()"/>
  135.             <xsl:text> </xsl:text>
  136.             <br/>
  137.             <xsl:apply-templates select="." mode="common"/>
  138.           </td>
  139.           <td>
  140.             <!-- select for the selected values -->
  141.             <select id="{@id}" name="{@id}" multiple="multiple"
  142.                     ondblclick="opt{generate-id()}.forms_transferLeft()" >
  143.               <xsl:apply-templates select="." mode="styling"/>
  144.               <xsl:for-each select="fi:selection-list/fi:item">
  145.                 <xsl:variable name="value" select="@value"/>
  146.                 <xsl:if test="$values[. = $value]">
  147.                   <option value="{$value}">
  148.                     <xsl:copy-of select="fi:label/node()"/>
  149.                   </option>
  150.                 </xsl:if>
  151.               </xsl:for-each>
  152.             </select>
  153.           </td>
  154.         </tr>
  155.       </table>
  156.       <script type="text/javascript">
  157.         var opt<xsl:value-of select="generate-id()"/> = forms_createOptionTransfer('<xsl:value-of select="@id"/>', <xsl:value-of select="fi:styling/@submit-on-change = 'true'"/>);
  158.       </script>
  159.     </span>
  160.   </xsl:template>
  161.  
  162.   <xsl:template match="fi:multivaluefield/fi:styling[@list-type='double-listbox']/@submit-on-change" mode="styling"/>
  163.  
  164. </xsl:stylesheet>
  165.