dynamicExpandArea.xslt 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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:out="dummy-uri"
  15. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  16. xmlns:layout="http://developer.cognos.com/common/layout"
  17. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" exclude-result-prefixes="xsl layout xtsext">
  18. <xsl:output method="xml" encoding="UTF-8" indent="no"/>
  19. <xsl:namespace-alias stylesheet-prefix="out" result-prefix="xsl"/>
  20. <xsl:template match="layout:dynamicexpandcontrol">
  21. <xsl:variable name="decNameAttr" select="string(@name)"/>
  22. <xsl:variable name="decName">
  23. <xsl:choose>
  24. <xsl:when test="starts-with(string($decNameAttr),'_THIS_')">
  25. <xsl:value-of select="substring-after(string($decNameAttr),'_THIS_')"/>
  26. </xsl:when>
  27. <xsl:otherwise><xsl:value-of select="$decNameAttr"/></xsl:otherwise>
  28. </xsl:choose>
  29. </xsl:variable>
  30. <xsl:variable name="decFormname">
  31. <xsl:choose>
  32. <xsl:when test="./layout:controlparameters/formname">
  33. <xsl:value-of select="./layout:controlparameters/formname"/></xsl:when>
  34. <xsl:when test="ancestor::layout:form/@name">
  35. <xsl:value-of select="ancestor::layout:form/@name"/>
  36. </xsl:when>
  37. <xsl:otherwise>pform</xsl:otherwise>
  38. </xsl:choose>
  39. </xsl:variable>
  40. <xsl:variable name="decShortName">
  41. <xsl:choose>
  42. <xsl:when test="starts-with(string($decFormname),'_THIS_')">
  43. <xsl:value-of select="substring-after(string($decFormname),'_THIS_')"/>
  44. </xsl:when>
  45. <xsl:otherwise><xsl:value-of select="$decFormname"/></xsl:otherwise>
  46. </xsl:choose>
  47. <xsl:value-of select="$decName"/>
  48. </xsl:variable>
  49. <xsl:variable name="decId">
  50. <xsl:choose>
  51. <xsl:when test="starts-with(string($decFormname),'_THIS_')">
  52. <xsl:value-of select="$decFormname"/>
  53. </xsl:when>
  54. <xsl:otherwise><xsl:value-of select="concat('_THIS_',$decFormname)"/></xsl:otherwise>
  55. </xsl:choose>
  56. <xsl:value-of select="$decName"/>
  57. </xsl:variable>
  58. <out:variable name="useDecId">
  59. <xsl:value-of select="$decId"/>
  60. </out:variable>
  61. <out:variable name="useDecFormname">
  62. <xsl:value-of select="$decShortName"/>
  63. </out:variable>
  64. <out:variable name="useDecState">
  65. <xsl:choose>
  66. <xsl:when test="./layout:controlparameters/state">
  67. <xsl:copy-of select="./layout:controlparameters/state/*"/></xsl:when>
  68. <xsl:otherwise>
  69. <out:copy-of select="/root/state/*"/>
  70. </xsl:otherwise>
  71. </xsl:choose>
  72. </out:variable>
  73. <out:variable name="useDecCustoms">
  74. <xsl:choose>
  75. <xsl:when test="./layout:controlparameters/customs">
  76. <xsl:copy-of select="./layout:controlparameters/customs/*"/>
  77. </xsl:when>
  78. <xsl:otherwise>
  79. <out:copy-of select="/root/customs/*"/>
  80. </xsl:otherwise>
  81. </xsl:choose>
  82. </out:variable>
  83. <out:variable name="useDecDisplaySetting">
  84. <out:choose>
  85. <out:when test="string($useDecState/param[@name={$decName}]) != ''">
  86. <out:value-of select="$useDecState/param[@name={$decName}]"/>
  87. </out:when>
  88. <out:when test="string($useDecCustoms/param[@name={$decName}]) != ''">
  89. <out:value-of select="$useDecCustoms/param[@name={$decName}]"/>
  90. </out:when>
  91. </out:choose>
  92. </out:variable>
  93. <out:variable name="useDecSkin">
  94. <xsl:choose>
  95. <xsl:when test="./layout:controlparameters/preferences"><xsl:copy-of select="./layout:controlparameters/preferences/param[@name='skin']"/></xsl:when>
  96. <xsl:otherwise><out:copy-of select="/root/preferences/param[@name='skin']"/></xsl:otherwise>
  97. </xsl:choose>
  98. </out:variable>
  99. <layout:section format="dynamicexpand">
  100. <out:attribute name="id"><xsl:value-of select="$decId"/></out:attribute>
  101. <out:attribute name="name"><xsl:value-of select="$decShortName"/></out:attribute>
  102. <out:attribute name="defaultview">
  103. <out:choose>
  104. <out:when test="$useDecDisplaySetting !=''"><out:value-of select="$useDecDisplaySetting"/></out:when>
  105. <out:otherwise>none</out:otherwise>
  106. </out:choose>
  107. </out:attribute>
  108. <layout:script>
  109. var _THIS_imgUp_<out:value-of select="$useDecFormname"/> = new Image();
  110. var _THIS_imgDown_<out:value-of select="$useDecFormname"/> = new Image();
  111. _THIS_imgUp_<out:value-of select="$useDecFormname"/>.src = "_THIS?frag-resource=/skins/<out:value-of select="xtsext:javascriptencode($useDecSkin)"/>/fragments/images/action_collapse.gif/THIS_";
  112. _THIS_imgDown_<out:value-of select="$useDecFormname"/>.src = "_THIS?frag-resource=/skins/<out:value-of select="xtsext:javascriptencode($useDecSkin)"/>/fragments/images/action_expand.gif/THIS_";
  113. function _THIS_displayArea_<out:value-of select="$useDecFormname"/>()
  114. {
  115. var eDiv = document.getElementById("<out:value-of select="$useDecId"/>");
  116. <xsl:if test="layout:dynamicareacollapsed">
  117. var eDivCollapsed = document.getElementById("<out:value-of select="concat($useDecId,'_collapsed')"/>")
  118. </xsl:if>
  119. var cImg = document.getElementById("_THIS_expandimg_<out:value-of select="$useDecFormname"/>");
  120. if (eDiv.style.display == "block")
  121. {
  122. eDiv.style.display="none";
  123. <xsl:if test="layout:dynamicareacollapsed">
  124. eDivCollapsed.style.display="block";
  125. </xsl:if>
  126. cImg.src = _THIS_imgDown_<out:value-of select="$useDecFormname"/>.src;
  127. cImg.setAttribute('alt','<xts:string id="IDS_PROP_EXPAND_IMG_TITLE" encode="javascript"/>');
  128. cImg.setAttribute('title','<xts:string id="IDS_PROP_EXPAND_IMG_TITLE" encode="javascript"/>');
  129. }
  130. else
  131. {
  132. eDiv.style.display="block";
  133. <xsl:if test="layout:dynamicareacollapsed">
  134. eDivCollapsed.style.display="none";
  135. </xsl:if>
  136. cImg.src = _THIS_imgUp_<out:value-of select="$useDecFormname"/>.src;
  137. cImg.setAttribute('alt','<xts:string id="IDS_PROP_COLLAPSE_IMG_TITLE" encode="javascript"/>');
  138. cImg.setAttribute('title','<xts:string id="IDS_PROP_COLLAPSE_IMG_TITLE" encode="javascript"/>');
  139. }
  140. }
  141. </layout:script>
  142. <layout:link>
  143. <out:attribute name="href">javascript:_THIS_displayArea_<out:value-of select="$useDecFormname"/>()</out:attribute>
  144. <xsl:copy-of select="layout:text"/>
  145. </layout:link>
  146. <layout:img class="cogstyle-layout-static-expand-img">
  147. <out:attribute name="id">_THIS_expandimg_<out:value-of select="$useDecFormname"/></out:attribute>
  148. <out:attribute name="onclick">javascript:_THIS_displayArea_<out:value-of select="$useDecFormname"/>()</out:attribute>
  149. <out:choose>
  150. <out:when test="$useDecDisplaySetting!='' and $useDecDisplaySetting='block'">
  151. <out:attribute name="alt"><xts:string id="IDS_PROP_COLLAPSE_IMG_TITLE"/></out:attribute>
  152. <out:attribute name="title"><xts:string id="IDS_PROP_COLLAPSE_IMG_TITLE"/></out:attribute>
  153. </out:when>
  154. <out:otherwise>
  155. <out:attribute name="alt"><xts:string id="IDS_PROP_EXPAND_IMG_TITLE"/></out:attribute>
  156. <out:attribute name="title"><xts:string id="IDS_PROP_EXPAND_IMG_TITLE"/></out:attribute>
  157. </out:otherwise>
  158. </out:choose>
  159. <out:attribute name="src">
  160. <out:choose>
  161. <out:when test="$useDecDisplaySetting='block'">_THIS?frag-resource=/skins/<out:value-of select="$useDecSkin"/>/fragments/images/action_collapse.gif/THIS_</out:when>
  162. <out:otherwise>_THIS?frag-resource=/skins/<out:value-of select="$useDecSkin"/>/fragments/images/action_expand.gif/THIS_</out:otherwise>
  163. </out:choose>
  164. </out:attribute>
  165. </layout:img>
  166. <xsl:copy-of select="layout:hint"/>
  167. <xsl:copy-of select="layout:dynamicarea"/>
  168. <xsl:copy-of select="layout:dynamicareacollapsed"/>
  169. </layout:section>
  170. </xsl:template>
  171. <xsl:template match="*">
  172. <xsl:copy>
  173. <xsl:copy-of select="@*"/>
  174. <xsl:apply-templates/>
  175. </xsl:copy>
  176. </xsl:template>
  177. </xsl:stylesheet>