layout.xslt 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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, 2014
  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:xts="http://developer.cognos.com/schemas/xts/"
  15. xmlns:encode="java:com.cognos.portal.utils.EncodingUtils"
  16. exclude-result-prefixes="encode">
  17. <xsl:attribute-set name="hover">
  18. <xsl:attribute name="class">cogstyle-portlet-action</xsl:attribute>
  19. <xsl:attribute name="onmouseover">caption.prototype.mouseOver(this)</xsl:attribute>
  20. <xsl:attribute name="onmouseout">caption.prototype.mouseOut(this)</xsl:attribute>
  21. <xsl:attribute name="align">center</xsl:attribute>
  22. <xsl:attribute name="valign">middle</xsl:attribute>
  23. <xsl:attribute name="tabindex">0</xsl:attribute>
  24. <xsl:attribute name="role">button</xsl:attribute>
  25. </xsl:attribute-set>
  26. <xsl:variable name="layout-id" select="/root/id"/>
  27. <xsl:variable name="is-ie" select="contains(/root/settings/browserAgent , 'MSIE')"/>
  28. <xsl:template match="layout">
  29. <xsl:param name="pageType"/>
  30. <xsl:variable name="use-fixed-tables-value">
  31. <xsl:choose>
  32. <xsl:when test="layoutProperties/param[@name='fixed']">
  33. <xsl:value-of select="layoutProperties/param[@name='fixed']"/>
  34. </xsl:when>
  35. <xsl:otherwise>
  36. <xsl:value-of select="/root/settings/pageFixed"/>
  37. </xsl:otherwise>
  38. </xsl:choose>
  39. </xsl:variable>
  40. <xsl:variable name="use-fixed-tables" select="not(layoutProperties/param[@name='flexibleColumnLayout'] = 'true') and $use-fixed-tables-value = 'true'"/>
  41. <script>
  42. var <xsl:value-of select="/root/id"/>
  43. <xsl:text>distributionList = [</xsl:text>
  44. <xsl:for-each select="/root/fragment">
  45. <xsl:value-of select="concat('&quot;', id, '&quot;')"/>
  46. <xsl:if test="position() != last()">, </xsl:if>
  47. </xsl:for-each>
  48. <xsl:text>];&#10;</xsl:text>
  49. <xsl:text>function </xsl:text>
  50. <xsl:value-of select="/root/id"/>distributor(evt)
  51. {
  52. _F_Event.distribute(<xsl:value-of select="/root/id"/>distributionList, evt);
  53. }
  54. <xsl:value-of select="/root/id"/>.addEventListener("*", "<xsl:value-of select="/root/id"/>distributor", true);
  55. </script>
  56. <div id="{$layout-id}normal">
  57. <xsl:if test="$pageType = 'page'">
  58. <xsl:attribute name="role">main</xsl:attribute>
  59. </xsl:if>
  60. <xsl:apply-templates>
  61. <xsl:with-param name="use-fixed-tables" select="$use-fixed-tables"/>
  62. </xsl:apply-templates>
  63. </div>
  64. <div id="{$layout-id}maximized" style="display:none">
  65. </div>
  66. </xsl:template>
  67. <xsl:template match="layoutProperties">
  68. </xsl:template>
  69. <xsl:template match="row">
  70. <xsl:param name="use-fixed-tables" select="true()"/>
  71. <table border="0" cellpadding="0" cellspacing="0" width="100%" role="presentation">
  72. <xsl:if test="$use-fixed-tables">
  73. <xsl:attribute name="style">table-layout:fixed</xsl:attribute>
  74. </xsl:if>
  75. <tr>
  76. <xsl:apply-templates>
  77. <xsl:with-param name="use-fixed-tables" select="$use-fixed-tables"/>
  78. </xsl:apply-templates>
  79. </tr>
  80. </table>
  81. </xsl:template>
  82. <xsl:template match="column">
  83. <xsl:param name="use-fixed-tables" select="true()"/>
  84. <td valign="top">
  85. <xsl:if test="@width">
  86. <xsl:attribute name="width"><xsl:value-of select="@width"/></xsl:attribute>
  87. </xsl:if>
  88. <xsl:apply-templates>
  89. <xsl:with-param name="use-fixed-tables" select="$use-fixed-tables"/>
  90. </xsl:apply-templates>
  91. </td>
  92. </xsl:template>
  93. <xsl:template match="fragment">
  94. <xsl:param name="use-fixed-tables" select="true()"/>
  95. <xsl:variable name="frag" select="/root/fragment[id = current()/@refid]"/>
  96. <xsl:variable name="layout-properties" select="layoutProperties/param"/>
  97. <xsl:variable name="show-borders" select="not($layout-properties[@name='borders']='false')"/>
  98. <xsl:variable name="show-margins" select="not($layout-properties[@name='margins']='false')"/>
  99. <xsl:variable name="show-caption" select="not($layout-properties[@name='caption']='false')"/>
  100. <xsl:variable name="show-paddings" select="not($layout-properties[@name='paddings']='false')"/>
  101. <xsl:variable name="height" select="$layout-properties[@name='height']"/>
  102. <xsl:variable name="overflow" select="$layout-properties[@name='overflow']"/>
  103. <xsl:variable name="meta-modes">
  104. <xsl:text>|</xsl:text>
  105. <xsl:for-each select="$frag/meta/modes">
  106. <xsl:value-of select="."/>
  107. <xsl:text>|</xsl:text>
  108. </xsl:for-each>
  109. </xsl:variable>
  110. <div id="{$frag/id}frame">
  111. <xsl:attribute name="style">
  112. <xsl:text>overflow-x:hidden</xsl:text>
  113. <!-- This is to fix problems in IE where absolute content is rendered inside the content div (e.g. search portlet popup menu)-->
  114. <!-- temporary: only do this for now when we have a wsrp portlet, other wise cogadmin will break : COGCQ00266449-->
  115. <xsl:if test="$is-ie and $frag/meta/customProperties[@name='wsrp_portlet_context']">
  116. <xsl:text>;position:relative</xsl:text>
  117. </xsl:if>
  118. </xsl:attribute>
  119. <xsl:if test="$show-margins">
  120. <xsl:attribute name="class">cogstyle-portlet-frame</xsl:attribute>
  121. </xsl:if>
  122. <table border="0" cellpadding="0" cellspacing="0" width="100%" role="presentation">
  123. <xsl:if test="$use-fixed-tables">
  124. <xsl:attribute name="style">table-layout:fixed</xsl:attribute>
  125. </xsl:if>
  126. <xsl:variable name="css-paddings">
  127. <xsl:if test="$show-paddings">cogstyle-portlet-content</xsl:if>
  128. </xsl:variable>
  129. <xsl:variable name="css-borders">
  130. <xsl:if test="$show-borders">
  131. <xsl:choose>
  132. <xsl:when test="$show-caption"> cogstyle-portlet-borders</xsl:when>
  133. <xsl:otherwise> cogstyle-portlet-borders-nocaption</xsl:otherwise>
  134. </xsl:choose>
  135. </xsl:if>
  136. </xsl:variable>
  137. <xsl:choose>
  138. <xsl:when test="$show-caption">
  139. <tr role="heading" aria-label="{$frag/info/title}">
  140. <td>
  141. <xsl:apply-templates select="$frag/info/title">
  142. <xsl:with-param name="layout-properties" select="$layout-properties"/>
  143. <xsl:with-param name="preferred-title" select="$frag/preferredTitle"/>
  144. <xsl:with-param name="meta-modes" select="$meta-modes"/>
  145. </xsl:apply-templates>
  146. <xsl:apply-templates select="$frag/menu"/>
  147. </td>
  148. </tr>
  149. </xsl:when>
  150. <xsl:otherwise>
  151. <tr id="{$frag/id}caption_restore" style="display:none">
  152. <td align="right">
  153. <a class="cognos-anchor" href="javascript:noop()">
  154. <xsl:attribute name="alt"><xts:string id="IDS_GEN_ACTIONS_RETURN"><xts:param><xsl:value-of select="$title"/></xts:param></xts:string></xsl:attribute>
  155. <xsl:text/><xts:string id="IDS_GEN_ACTIONS_RETURN"/><xsl:text/>
  156. </a>
  157. </td>
  158. </tr>
  159. </xsl:otherwise>
  160. </xsl:choose>
  161. <tr>
  162. <td class="{$css-paddings}{$css-borders}">
  163. <xsl:if test="$height">
  164. <xsl:attribute name="style">height:<xsl:value-of select="$height"/></xsl:attribute>
  165. </xsl:if>
  166. <xsl:apply-templates select="$frag/markup">
  167. <xsl:with-param name="overflow" select="$overflow"/>
  168. <xsl:with-param name="use-fixed-tables" select="$use-fixed-tables"/>
  169. </xsl:apply-templates>
  170. </td>
  171. </tr>
  172. </table>
  173. </div>
  174. <script type="text/javascript">
  175. var <xsl:value-of select="$frag/id"/>caption = new caption('<xsl:value-of select="$frag/id"/>', '<xsl:value-of select="$layout-id"/>');
  176. </script>
  177. </xsl:template>
  178. <xsl:template match="fragment[@page='true']">
  179. <xsl:variable name="frag" select="/root/fragment[id = current()/@refid]"/>
  180. <xsl:variable name="nodes" select="$frag/markup"/>
  181. <xsl:apply-templates select="$nodes"/>
  182. </xsl:template>
  183. <xsl:template match="title">
  184. <xsl:param name="id" select="../../id"/>
  185. <xsl:param name="preferred-title"/>
  186. <xsl:param name="layout-properties"/>
  187. <xsl:param name="meta-modes"/>
  188. <xsl:variable name="web" select="/root/settings/contextPath"/>
  189. <table class="cogstyle-portlet-caption-bar" border="0" cellpadding="0" cellspacing="0" width="100%" role="presentation">
  190. <tr>
  191. <td class="cogstyle-portlet-caption">
  192. <xsl:variable name="title">
  193. <xsl:choose>
  194. <xsl:when test="$preferred-title != ''">
  195. <xsl:value-of select="normalize-space($preferred-title)"/>
  196. </xsl:when>
  197. <xsl:otherwise>
  198. <xsl:value-of select="normalize-space(.)"/>
  199. </xsl:otherwise>
  200. </xsl:choose>
  201. </xsl:variable>
  202. <div id="{$id}caption" style="float:left">
  203. <xsl:value-of select="$title"/>
  204. </div>
  205. <div style="float:right">
  206. <table class="cogstyle-portlet-actions" cellpadding="0" cellspacing="2" border="0" role="presentation">
  207. <tr>
  208. <xsl:if test="../../menu">
  209. <td id="{$id}caption_menu" xsl:use-attribute-sets="hover" onclick="ui_menuShow(event,menu_{../../menu/@id})" onkeypress="if(event.keyCode==9)return true;ui_menuShow(event,menu_{../../menu/@id})">
  210. <img src="{$web}/fragments/common/images/menudrop.gif">
  211. <xsl:attribute name="alt"><xts:string id="IDS_GEN_ACTIONS_MORE"><xts:param><xsl:value-of select="$title"/></xts:param></xts:string></xsl:attribute>
  212. <xsl:attribute name="title"><xts:string id="IDS_GEN_ACTIONS_MORE"><xts:param><xsl:value-of select="$title"/></xts:param></xts:string></xsl:attribute>
  213. </img>
  214. </td>
  215. </xsl:if>
  216. <xsl:if test="not ($layout-properties[@name='nohelp'] = 'true' ) and contains($meta-modes, '|help|')">
  217. <td id="{$id}caption_help" xsl:use-attribute-sets="hover">
  218. <img src="{$web}/fragments/portlet/images/portlet_action_help.gif">
  219. <xsl:attribute name="alt"><xts:string id="IDS_GEN_ACTIONS_HELP"><xts:param name="title"><xsl:value-of select="$title"/></xts:param></xts:string></xsl:attribute>
  220. <xsl:attribute name="title"><xts:string id="IDS_GEN_ACTIONS_HELP"><xts:param name="title"><xsl:value-of select="$title"/></xts:param></xts:string></xsl:attribute>
  221. </img>
  222. </td>
  223. </xsl:if>
  224. <td id="{$id}caption_refresh" xsl:use-attribute-sets="hover">
  225. <img src="{$web}/fragments/portlet/images/portlet_action_refresh.gif">
  226. <xsl:attribute name="alt"><xts:string id="IDS_GEN_ACTIONS_REFRESH"><xts:param name="title"><xsl:value-of select="$title"/></xts:param></xts:string></xsl:attribute>
  227. <xsl:attribute name="title"><xts:string id="IDS_GEN_ACTIONS_REFRESH"><xts:param name="title"><xsl:value-of select="$title"/></xts:param></xts:string></xsl:attribute>
  228. </img>
  229. </td>
  230. <xsl:if test="not ($layout-properties[@name='noreset'] = 'true' )">
  231. <td id="{$id}caption_reset" xsl:use-attribute-sets="hover" style="display:none">
  232. <img src="{$web}/fragments/portlet/images/portlet_action_reset.gif" border="0">
  233. <xsl:attribute name="alt"><xts:string id="IDS_GEN_ACTIONS_RESET"><xts:param name="title"><xsl:value-of select="$title"/></xts:param></xts:string></xsl:attribute>
  234. <xsl:attribute name="title"><xts:string id="IDS_GEN_ACTIONS_RESET"><xts:param name="title"><xsl:value-of select="$title"/></xts:param></xts:string></xsl:attribute>
  235. </img>
  236. </td>
  237. </xsl:if>
  238. <xsl:if test="not ($layout-properties[@name='noedit'] = 'true' )">
  239. <td id="{$id}caption_edit" xsl:use-attribute-sets="hover">
  240. <img src="{$web}/fragments/portlet/images/portlet_action_edit.gif">
  241. <xsl:attribute name="alt"><xts:string id="IDS_GEN_ACTIONS_EDIT"><xts:param name="title"><xsl:value-of select="$title"/></xts:param></xts:string></xsl:attribute>
  242. <xsl:attribute name="title"><xts:string id="IDS_GEN_ACTIONS_EDIT"><xts:param name="title"><xsl:value-of select="$title"/></xts:param></xts:string></xsl:attribute>
  243. </img>
  244. </td>
  245. </xsl:if>
  246. <td id="{$id}caption_view" xsl:use-attribute-sets="hover" style="display:none">
  247. <img src="{$web}/fragments/portlet/images/portlet_action_view.gif">
  248. <xsl:attribute name="alt"><xts:string id="IDS_GEN_ACTIONS_VIEW"><xts:param name="title"><xsl:value-of select="$title"/></xts:param></xts:string></xsl:attribute>
  249. <xsl:attribute name="title"><xts:string id="IDS_GEN_ACTIONS_VIEW"><xts:param name="title"><xsl:value-of select="$title"/></xts:param></xts:string></xsl:attribute>
  250. </img>
  251. </td>
  252. <xsl:if test="not ($layout-properties[@name='nominimize'] = 'true' )">
  253. <td id="{$id}caption_minimize" xsl:use-attribute-sets="hover">
  254. <img src="{$web}/fragments/portlet/images/portlet_action_minimize.gif">
  255. <xsl:attribute name="alt"><xts:string id="IDS_GEN_ACTIONS_MINIMIZE"><xts:param name="title"><xsl:value-of select="$title"/></xts:param></xts:string></xsl:attribute>
  256. <xsl:attribute name="title"><xts:string id="IDS_GEN_ACTIONS_MINIMIZE"><xts:param name="title"><xsl:value-of select="$title"/></xts:param></xts:string></xsl:attribute>
  257. </img>
  258. </td>
  259. </xsl:if>
  260. <td id="{$id}caption_restore" xsl:use-attribute-sets="hover" style="display:none">
  261. <img src="{$web}/fragments/portlet/images/portlet_action_restore.gif">
  262. <xsl:attribute name="alt"><xts:string id="IDS_GEN_ACTIONS_RESTORE"><xts:param name="title"><xsl:value-of select="$title"/></xts:param></xts:string></xsl:attribute>
  263. <xsl:attribute name="title"><xts:string id="IDS_GEN_ACTIONS_RESTORE"><xts:param name="title"><xsl:value-of select="$title"/></xts:param></xts:string></xsl:attribute>
  264. </img>
  265. </td>
  266. <xsl:if test="not ($layout-properties[@name='nomaximize'] = 'true' )">
  267. <td id="{$id}caption_maximize" xsl:use-attribute-sets="hover">
  268. <img src="{$web}/fragments/portlet/images/portlet_action_maximize.gif">
  269. <xsl:attribute name="alt"><xts:string id="IDS_GEN_ACTIONS_MAXIMIZE"><xts:param name="title"><xsl:value-of select="$title"/></xts:param></xts:string></xsl:attribute>
  270. <xsl:attribute name="title"><xts:string id="IDS_GEN_ACTIONS_MAXIMIZE"><xts:param name="title"><xsl:value-of select="$title"/></xts:param></xts:string></xsl:attribute>
  271. </img>
  272. </td>
  273. </xsl:if>
  274. </tr>
  275. </table>
  276. </div>
  277. </td>
  278. </tr>
  279. </table>
  280. </xsl:template>
  281. <xsl:template match="markup">
  282. <xsl:param name="use-fixed-tables" select="true()"/>
  283. <xsl:param name="overflow"/>
  284. <xsl:variable name="css-overflow">
  285. <xsl:choose>
  286. <xsl:when test="$overflow">
  287. <xsl:value-of select="$overflow"/>
  288. </xsl:when>
  289. <xsl:otherwise>auto</xsl:otherwise>
  290. </xsl:choose>
  291. </xsl:variable>
  292. <div id="{../id}content" aria-live="polite">
  293. <xsl:attribute name="style">
  294. <xsl:if test="$use-fixed-tables">
  295. <xsl:text>overflow-x:</xsl:text>
  296. <xsl:value-of select="$css-overflow"/>
  297. <!-- This to fix problems in IE where absolute content is rendered inside the content div (e.g. search portlet popup menu)-->
  298. <!-- temporary: only do this for now when we have a wsrp portlet, other wise cogadmin will break : COGCQ00266449-->
  299. <xsl:if test="$is-ie and ../meta/customProperties[@name='wsrp_portlet_context']">
  300. <xsl:text>;position:relative</xsl:text>
  301. </xsl:if>
  302. <xsl:text>;</xsl:text>
  303. </xsl:if>
  304. <xsl:text>width:100%;</xsl:text>
  305. </xsl:attribute>
  306. <xsl:value-of select="markupString" disable-output-escaping="yes"/>
  307. </div>
  308. </xsl:template>
  309. </xsl:stylesheet>