dialoglogic.xslt 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: cpscrn
  5. (C) Copyright IBM Corp. 2005, 2011
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <!--
  9. Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
  10. Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  11. -->
  12. <xsl:stylesheet version="1.0"
  13. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  14. xmlns:dp="http://developer.cognos.com/schemas/cps/portlets/logicsheets/dialog/presentation/1/"
  15. xmlns:out="dummy-uri"
  16. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  17. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  18. exclude-result-prefixes="dp xtsext xts">
  19. <xsl:output method="xml" encoding="UTF-8" indent="no"/>
  20. <xsl:namespace-alias stylesheet-prefix="out" result-prefix="xsl"/>
  21. <!--
  22. dp:button
  23. -->
  24. <!--
  25. THIS CODE WAS STOLEN FROM /logicsheets/presentation/dialog/presentation.xslt
  26. -->
  27. <xsl:variable name="dp-namespace-uri" select="'http://developer.cognos.com/schemas/cps/portlets/logicsheets/dialog/presentation/1/'"/>
  28. <xsl:template match="dp:variables">
  29. <!-- Request variables -->
  30. <out:variable name="user-agent" select="translate(string(/root/userAgent), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/>
  31. <out:variable name="browser">
  32. <out:choose>
  33. <out:when test="contains($user-agent , 'msie')">ie</out:when> <!-- IE 4.xx and above -->
  34. <out:when test="contains($user-agent , 'safari/5') and not(contains($user-agent , 'chrome'))">safari</out:when> <!-- Safari user-agent does not contain Chrome -->
  35. <out:when test="contains($user-agent , 'chrome')">chrome</out:when> <!-- Chrome user-agent contains Safari also -->
  36. <out:when test="contains($user-agent , 'mozilla/5.0')">moz</out:when> <!-- NS 6.xx and 7.xx -->
  37. <out:when test="contains($user-agent , 'mozilla/4.')">ns4</out:when> <!-- NS 4.xx -->
  38. <out:when test="string-length($user-agent) = 0">undefined</out:when>
  39. <out:otherwise>other</out:otherwise>
  40. </out:choose>
  41. </out:variable>
  42. </xsl:template>
  43. <xsl:template match="dp:simpleFooter">
  44. <table width="100%" border="0" cellpadding="0" cellspacing="0" class="">
  45. <out:attribute name="class">
  46. <xsl:choose>
  47. <xsl:when test="@class"><xsl:value-of select="@class"/></xsl:when>
  48. <xsl:otherwise>dialogButtonBar</xsl:otherwise>
  49. </xsl:choose>
  50. </out:attribute>
  51. <!-- show the buttons -->
  52. <tr>
  53. <out:choose>
  54. <out:when test="$browser='moz'">
  55. <td width="2" valign="middle">
  56. <img width="2" alt="">
  57. <xsl:attribute name="src"><xsl:value-of select="'{$webcontent}'"/>/images/space.gif</xsl:attribute>
  58. </img>
  59. </td>
  60. </out:when>
  61. <out:otherwise>
  62. <td width="5" valign="middle">
  63. <img width="5" alt="">
  64. <xsl:attribute name="src"><xsl:value-of select="'{$webcontent}'"/>/images/space.gif</xsl:attribute>
  65. </img>
  66. </td>
  67. </out:otherwise>
  68. </out:choose>
  69. <td valign="middle">
  70. <table border="0" cellpadding="1" cellspacing="0">
  71. <tr>
  72. <xsl:apply-templates/>
  73. </tr>
  74. </table>
  75. </td>
  76. <td width="100%">&#160;</td>
  77. </tr>
  78. </table>
  79. </xsl:template>
  80. <!--
  81. dp:button - buttons, usually in the dp:footer
  82. -->
  83. <xsl:template match="dp:button">
  84. <td>
  85. <table cellpadding="0" cellspacing="0">
  86. <!-- Add event handlers for "active buttons" -->
  87. <xsl:choose>
  88. <xsl:when test="@id">
  89. <xsl:attribute name="id"><xsl:value-of select="@id"/>_button</xsl:attribute>
  90. <xsl:attribute name="onmouseover"><xsl:value-of select="@id"/>_mouseaction(this, 'over')</xsl:attribute>
  91. <xsl:attribute name="onmouseout"><xsl:value-of select="@id"/>_mouseaction(this, 'out')</xsl:attribute>
  92. <xsl:attribute name="onmousedown"><xsl:value-of select="@id"/>_mouseaction(this, 'down')</xsl:attribute>
  93. <script language="JavaScript">
  94. var <xsl:value-of select="@id"/>_enabled = true;
  95. function <xsl:value-of select="@id"/>_enable()
  96. {
  97. <xsl:value-of select="@id"/>_enabled = true;
  98. document.getElementById('<xsl:value-of select="@id"/>').className = "commandButtonActive";
  99. }
  100. function <xsl:value-of select="@id"/>_disable()
  101. {
  102. <xsl:value-of select="@id"/>_enabled = false;
  103. document.getElementById('<xsl:value-of select="@id"/>').className = "commandButtonInactive";
  104. }
  105. function <xsl:value-of select="@id"/>_isEnabled()
  106. {
  107. return <xsl:value-of select="@id"/>_enabled;
  108. }
  109. function <xsl:value-of select="@id"/>_mouseaction(obj, action)
  110. {
  111. var isEnabled = <xsl:value-of select="@id"/>_enabled;
  112. if (isEnabled)
  113. {
  114. switch (action)
  115. {
  116. case "over": obj.className = 'commandButtonOver'; break;
  117. case "out": obj.className = 'commandButton'; break;
  118. case "down": obj.className = 'commandButtonDown'; break;
  119. default:
  120. }
  121. }
  122. }
  123. </script>
  124. </xsl:when>
  125. <xsl:when test="not(@id) and not(@state='inactive')">
  126. <xsl:attribute name="onmouseover">this.className = 'commandButtonOver'</xsl:attribute>
  127. <xsl:attribute name="onmouseout">this.className = 'commandButton'</xsl:attribute>
  128. <xsl:attribute name="onmousedown">this.className = 'commandButtonDown'</xsl:attribute>
  129. </xsl:when>
  130. </xsl:choose>
  131. <!-- Style the button according to state -->
  132. <xsl:choose>
  133. <xsl:when test="@state = 'inactive'">
  134. <xsl:attribute name="class">commandButtonInactive</xsl:attribute>
  135. <out:choose>
  136. <out:when test="$browser = 'ie'">
  137. <out:attribute name="style">padding-right:10px; padding-left:10px; padding-top:2px; padding-bottom:3px;</out:attribute>
  138. </out:when>
  139. <out:otherwise>
  140. <out:attribute name="style">padding-right:5px; padding-left:5px; padding-top:2px; padding-bottom:3px;</out:attribute>
  141. </out:otherwise>
  142. </out:choose>
  143. </xsl:when>
  144. <xsl:otherwise>
  145. <xsl:attribute name="class">commandButton</xsl:attribute>
  146. <out:if test="$browser != 'ie'">
  147. <out:attribute name="style">padding-right:10px; padding-left:10px; padding-top:2px; padding-bottom:3px;</out:attribute>
  148. </out:if>
  149. </xsl:otherwise>
  150. </xsl:choose>
  151. <tr>
  152. <td valign="middle" align="center" nowrap="nowrap">
  153. <!-- minimum button width as specified by STAN -->
  154. <out:variable name="style">
  155. <out:choose>
  156. <out:when test="$browser = 'ie'">
  157. <xsl:choose>
  158. <xsl:when test="@state = 'inactive'"> <!-- The width fixing image size depends on whether or not the button is active, as the 10px padding applies to different elements in each case -->
  159. <out:value-of select="'width:50px;'"/>
  160. </xsl:when>
  161. <xsl:otherwise>
  162. <out:value-of select="'width:70px;'"/>
  163. </xsl:otherwise>
  164. </xsl:choose>
  165. </out:when>
  166. <out:otherwise>
  167. <out:value-of select="'width:55px;'"/>
  168. </out:otherwise>
  169. </out:choose>
  170. </out:variable>
  171. <div>
  172. <out:attribute name="style"><out:value-of select="$style"/></out:attribute>
  173. <!--
  174. The OK button is a bit unique on none ie browsers.
  175. We like to add extra padding on anchors that wrap 'OK' to beef up the hot spot area.
  176. -->
  177. <out:variable name="OKButton">
  178. <xsl:copy-of select=".//dp:buttonText/child::node()"/>
  179. </out:variable>
  180. <xsl:if test="not(@id)">
  181. <out:attribute name="id">
  182. <out:choose>
  183. <out:when test="$browser = 'ie'">btnAnchorIE</out:when>
  184. <out:when test="$OKButton = 'OK'">btnAnchorWide</out:when>
  185. <out:otherwise>btnAnchor</out:otherwise>
  186. </out:choose>
  187. </out:attribute>
  188. </xsl:if>
  189. <!-- Insert the button content text/images -->
  190. <xsl:apply-templates/>
  191. </div>
  192. </td>
  193. </tr>
  194. </table>
  195. </td>
  196. <td>
  197. <img height="1" width="10" alt="" src="{'{$webcontent}'}/images/space.gif"/>
  198. </td>
  199. </xsl:template>
  200. <!--
  201. dp:buttonText
  202. -->
  203. <xsl:template match="dp:buttonText">
  204. <xsl:apply-templates/>
  205. </xsl:template>
  206. <!--
  207. * - This next template is required to copy all other elements into the result.
  208. -->
  209. <xsl:template match="*">
  210. <xsl:copy>
  211. <xsl:copy-of select="@*"/>
  212. <xsl:apply-templates/>
  213. </xsl:copy>
  214. </xsl:template>
  215. </xsl:stylesheet>