dialog.xsl 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: cogadmin
  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:uic="http://developer.cognos.com/schemas/uic/presentation/markup/"
  15. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  16. exclude-result-prefixes="xsl uic xtsext">
  17. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
  18. <!--
  19. header
  20. uic:title - title to be shown in the header
  21. uic:help - should the help link be shown
  22. uic:close - Should we show the 'X' in the header
  23. @onclick - javascript for the 'X'
  24. uic:description - text to be shown for the description
  25. -->
  26. <xsl:template match="uic:header">
  27. <div>
  28. <table cellpadding="1" cellspacing="0" border="0" width="100%" role="presentation">
  29. <xsl:choose>
  30. <xsl:when test="@modal">
  31. <script>
  32. <xsl:variable name="height">
  33. <xsl:choose>
  34. <xsl:when test="uic:height">
  35. <xsl:value-of select="uic:height"/>
  36. </xsl:when>
  37. <xsl:otherwise>
  38. null
  39. </xsl:otherwise>
  40. </xsl:choose>
  41. </xsl:variable>
  42. <xsl:variable name="width">
  43. <xsl:choose>
  44. <xsl:when test="uic:width">
  45. <xsl:value-of select="uic:width"/>
  46. </xsl:when>
  47. <xsl:otherwise>
  48. null
  49. </xsl:otherwise>
  50. </xsl:choose>
  51. </xsl:variable>
  52. _THIS_.afterRetrieve = function(evt) {
  53. _THIS_.uiDialog = showModalDialog(ui_dialog.style.BTN_OKCANCEL,_THIS_.div, '<xsl:value-of select="uic:title"/>',<xsl:value-of select="$height"/>,<xsl:value-of select="$width"/>,_THIS_);
  54. _THIS_.addEventListener("cognos.ui.dialog.cancel", "_THIS_.onDialogClose");
  55. }
  56. _THIS_.addEventListener("fragment.retrieve.after", "_THIS_.afterRetrieve");
  57. _THIS_.onDialogClose = function(evt) {
  58. _THIS_.removeEventListener("cognos.ui.dialog.cancel", "_THIS_.onDialogClose");
  59. if (evt.name == "cognos.ui.dialog.cancel") {
  60. raiseReloadEvent(_THIS_);
  61. _THIS_.uiDialog.destroy();
  62. return true;
  63. }
  64. _THIS_.uiDialog.destroy();
  65. return true;
  66. }
  67. </script>
  68. </xsl:when>
  69. <xsl:otherwise>
  70. <tr class="dialogHeader">
  71. <td width="100%" class="dialogHeaderTitle"><xsl:apply-templates select="uic:title"/></td>
  72. <xsl:if test="uic:help">
  73. <xsl:apply-templates select="uic:help"/>
  74. <td valign="middle" nowrap="" class="dialogHeaderLink">
  75. <a onmouseout="window.status='';return true;" onmouseover="window.status='';return true;" class="dialogHeaderLinkColor" href="javascript:help()"><xsl:value-of select="$helpLabel"/></a>
  76. </td>
  77. </xsl:if>
  78. <xsl:if test="uic:close">
  79. <td valign="middle" align="right" style="padding-right: 3px;">
  80. <a onmouseout="window.status='';return true;" onmouseover="window.status='';return true;" id="IDS_CLOSE" role="button">
  81. <xsl:if test="uic:close/@onclick != ''">
  82. <xsl:attribute name="onclick"><xsl:value-of select="uic:close/@onclick"/></xsl:attribute>
  83. </xsl:if>
  84. <img width="16" vspace="2" height="16" border="0" onmouseout="this.className = 'dialogClose'" onmouseover="this.className = 'dialogCloseOver'" class="dialogClose">
  85. <xsl:attribute name="src"><xsl:value-of select="concat($skinWebcontentPath, 'close.gif')"/></xsl:attribute>
  86. <xsl:attribute name="title"><xsl:value-of select="$dialogClose"/></xsl:attribute>
  87. <xsl:attribute name="alt"><xsl:value-of select="$dialogClose"/></xsl:attribute>
  88. </img>
  89. </a>
  90. </td>
  91. </xsl:if>
  92. </tr>
  93. </xsl:otherwise>
  94. </xsl:choose>
  95. <xsl:if test="uic:description">
  96. <tr>
  97. <td width="100%" style="padding-left: 5px;" class="dialogHeaderText" colspan="{1 + number(uic:help) + number(uic:close)}" wrap="wrap">
  98. <xsl:apply-templates select="uic:description"/>
  99. </td>
  100. </tr>
  101. </xsl:if>
  102. </table>
  103. </div>
  104. </xsl:template>
  105. <!-- dialog body -->
  106. <xsl:template match="uic:dialogbody">
  107. <div class="cogstyle-dialog-body">
  108. <div class="cogstyle-dialog-content">
  109. <div><xsl:apply-templates select="uic:description"/></div>
  110. <xsl:apply-templates select="uic:bodycontent"/>
  111. </div>
  112. <xsl:if test="uic:commandbar">
  113. <div class="cogstyle-dialog-commandbar">
  114. <table cellpadding="0" cellspacing="0" border="0" width="100%" role="presentation">
  115. <tr>
  116. <td>
  117. <xsl:for-each select="uic:commandbar/uic:button">
  118. <input type="button" class="cogstyle-dialog-button" value="{uic:text}" onclick="{uic:onclick}"/>
  119. </xsl:for-each>
  120. </td>
  121. </tr>
  122. </table>
  123. </div>
  124. </xsl:if>
  125. </div>
  126. </xsl:template>
  127. <!-- body: deperacated, use uic:dialogbody instead-->
  128. <xsl:template match="uic:body">
  129. <div style="padding:5px;">
  130. <xsl:apply-templates/>
  131. </div>
  132. </xsl:template>
  133. <!-- footer: deperacated, you don't need this if you use uic:dialogbody-->
  134. <xsl:template match="uic:footer">
  135. <div class="cogstyle-dialog-commandbar">
  136. <table cellpadding="0" cellspacing="0" border="0" width="100%" role="presentation">
  137. <xsl:choose>
  138. <xsl:when test="@align">
  139. <xsl:attribute name="align"><xsl:value-of select="@align"/></xsl:attribute>
  140. </xsl:when>
  141. <xsl:otherwise>
  142. <xsl:attribute name="style">padding-left:10px;</xsl:attribute>
  143. </xsl:otherwise>
  144. </xsl:choose>
  145. <tr>
  146. <xsl:for-each select="child::*">
  147. <td>
  148. <xsl:if test="position() = last()">
  149. <xsl:attribute name="width">100%</xsl:attribute>
  150. </xsl:if>
  151. <xsl:if test="position() &gt; 1">
  152. <xsl:attribute name="style">padding-left: 10px;</xsl:attribute>
  153. </xsl:if>
  154. <xsl:if test="../@align">
  155. <xsl:attribute name="align"><xsl:value-of select="../@align"/></xsl:attribute>
  156. </xsl:if>
  157. <xsl:apply-templates select="."/>
  158. </td>
  159. </xsl:for-each>
  160. </tr>
  161. </table>
  162. </div>
  163. </xsl:template>
  164. <!--
  165. uic:sideBySide - used if you want to put multiple controls on the same line
  166. -->
  167. <xsl:template match="uic:sideBySide">
  168. <table cellpadding="0" cellspacing="0" width="100%" role="presentation">
  169. <tr>
  170. <xsl:for-each select="child::*">
  171. <td>
  172. <xsl:if test="@width">
  173. <xsl:attribute name="width"><xsl:value-of select="@width"/></xsl:attribute>
  174. </xsl:if>
  175. <xsl:apply-templates select="."/>
  176. </td>
  177. </xsl:for-each>
  178. </tr>
  179. </table>
  180. </xsl:template>
  181. <!--
  182. uic:button
  183. generates the standard dialog button
  184. uic:text - text to be shown on the button
  185. uic:onclick - action to take when button is clicked
  186. -->
  187. <xsl:template match="uic:button">
  188. <!-- this comes from the HTML generated by dp:button. -->
  189. <table cellspacing="0" cellpadding="0" style="width: 55px; padding: 2px 10px 3px;" class="commandButton" onmousedown="this.className = 'commandButtonDown'" onmouseout="this.className = 'commandButton'" onmouseover="this.className = 'commandButtonOver'">
  190. <tbody>
  191. <tr>
  192. <td valign="middle" nowrap="nowrap" align="center" class="formText" onclick="{uic:onclick}" width="55">
  193. <!-- TODO: temp workaround since CPS puts a font-size of 80% on all tables. Need to up the font-size for the buttons -->
  194. <span style="font-size:120%;white-space: nowrap;"><xsl:value-of select="uic:text"/></span>
  195. </td>
  196. </tr>
  197. </tbody>
  198. </table>
  199. </xsl:template>
  200. <!--
  201. uic:input
  202. will display a label and an input under it
  203. @addSpace - if false, no spacing will be added
  204. -->
  205. <!-- todo: make this alot more generic and use table or divs for the spacing -->
  206. <xsl:template match="uic:input">
  207. <table cellspacing="0" cellpadding="1" border="0" role="presentation">
  208. <xsl:if test="uic:label">
  209. <tr>
  210. <td>
  211. <xsl:apply-templates select="uic:label"/>
  212. </td>
  213. </tr>
  214. </xsl:if>
  215. <xsl:if test="uic:control">
  216. <tr>
  217. <td>
  218. <xsl:apply-templates select="uic:control"/>
  219. </td>
  220. </tr>
  221. </xsl:if>
  222. <xsl:if test="not(@addSpace = 'false')">
  223. <tr>
  224. <td height="10px"/>
  225. </tr>
  226. </xsl:if>
  227. </table>
  228. </xsl:template>
  229. <!--
  230. uic:choice
  231. will display a label and an input & text under it
  232. uic:label - label to be shown
  233. uic:control - the html field (usually a radiobutton)
  234. uic:controlContext - text of another control that will be beside the radiobutton
  235. @addSpace - if false, no spacing will be added
  236. -->
  237. <xsl:template match="uic:choice">
  238. <table cellspacing="0" cellpadding="1" border="0">
  239. <xsl:copy-of select="@*"/>
  240. <xsl:if test="not(@role) or @role = ''">
  241. <xsl:attribute name="role">presentation</xsl:attribute>
  242. </xsl:if>
  243. <xsl:if test="uic:label">
  244. <tr>
  245. <td colspan="2">
  246. <xsl:apply-templates select="uic:label"/>
  247. </td>
  248. </tr>
  249. </xsl:if>
  250. <!-- can have one label for multiple controls (i.e. radio buttons) -->
  251. <xsl:for-each select="uic:control">
  252. <tr>
  253. <td>
  254. <xsl:apply-templates/>
  255. </td>
  256. <td>
  257. <xsl:choose>
  258. <xsl:when test="following-sibling::*[1]/@for != ''">
  259. <label for="{following-sibling::*[1]/@for}">
  260. <xsl:apply-templates select="following-sibling::*[1]"/>
  261. </label>
  262. </xsl:when>
  263. <xsl:otherwise>
  264. <xsl:apply-templates select="following-sibling::*[1]"/>
  265. </xsl:otherwise>
  266. </xsl:choose>
  267. </td>
  268. </tr>
  269. </xsl:for-each>
  270. <xsl:if test="not(@addSpace = 'false')">
  271. <tr>
  272. <td height="10px"/>
  273. </tr>
  274. </xsl:if>
  275. </table>
  276. </xsl:template>
  277. <!--
  278. uic:popupDiv - temp template to create a popup div. CPS should provide a 'real' modal dialog
  279. uic:content - contents of the div
  280. note: call showModalDialog(id, height, width) to show and center the div
  281. -->
  282. <xsl:template match="uic:popupDiv">
  283. <div id="{@id}" style="z-index:100; display: none;" class="cogstyle-dialog">
  284. <xsl:apply-templates select="uic:content"/>
  285. </div>
  286. </xsl:template>
  287. <!--
  288. uic:dynamicSection
  289. dynamic div that will collapse/expand when the user hits a link
  290. @name - name of the div
  291. child elemens:
  292. uic:title - Text to be show as the link
  293. uic:content - what will be placed in the div
  294. -->
  295. <xsl:template match="uic:dynamicSection">
  296. <!-- used to expand/collapse the uic:dynamicSection -->
  297. <xsl:variable name="dynamicSectionExpandGif" select="concat($skinWebcontentPath, 'prompt_option_expand.gif')"/>
  298. <xsl:variable name="dynamicSectionCollapseGif" select="concat($skinWebcontentPath, 'prompt_option_collapse.gif')"/>
  299. <script language="javascript">
  300. <!-- TODO: Move this javascript into a js file -->
  301. function toggleDynamicSection(name)
  302. {
  303. if(document.getElementById(name).style.display == 'none')
  304. {
  305. showDynamicSection(name);
  306. }
  307. else
  308. {
  309. hideDynamicSection(name);
  310. }
  311. <xsl:if test="string(@callback-func) != ''">
  312. <xsl:value-of select="@callback-func"/>
  313. </xsl:if>
  314. }
  315. function showDynamicSection(name)
  316. {
  317. document.getElementById(name).style.display='';
  318. var imgName = document.getElementById('img' + name);
  319. document.getElementById(name).setAttribute('aria-expanded', 'true');
  320. imgName.src = '<xsl:value-of select="xtsext:javascriptencode(string($dynamicSectionCollapseGif))"/>';
  321. imgName.setAttribute('alt','<xsl:value-of select="xtsext:javascriptencode(string($collapseTooltip))"/>');
  322. imgName.setAttribute('title','<xsl:value-of select="xtsext:javascriptencode(string($collapseTooltip))"/>');
  323. }
  324. function hideDynamicSection(name)
  325. {
  326. document.getElementById(name).style.display='none';
  327. document.getElementById(name).setAttribute('aria-expanded', 'false');
  328. var imgName = document.getElementById('img' + name);
  329. imgName.src = '<xsl:value-of select="xtsext:javascriptencode(string($dynamicSectionExpandGif))"/>';
  330. imgName.setAttribute('alt','<xsl:value-of select="xtsext:javascriptencode(string($expandTooltip))"/>');
  331. imgName.setAttribute('title','<xsl:value-of select="xtsext:javascriptencode(string($expandTooltip))"/>');
  332. }
  333. </script>
  334. <!-- the link to expand/collapse the section -->
  335. <a href="#" id="anchor{@name}" onclick="toggleDynamicSection('{@name}');{@onclick}" role="button" aria-controls="{@name}" class="cogstyle-form-link" nowrap="nowrap" style="padding-bottom:5px; padding-top:5px; padding-left:0px;white-space:nowrap;">
  336. <xsl:if test="uic:title">
  337. <xsl:if test="not(@indent) or (@indent='yes')">
  338. <xsl:attribute name="style">padding-left:12px;</xsl:attribute>
  339. </xsl:if>
  340. <xsl:value-of select="uic:title"/>
  341. </xsl:if>
  342. <img name="img{@name}" id="img{@name}" border="0" style="vertical-align: middle">
  343. <xsl:choose>
  344. <xsl:when test="@visible = 'true'">
  345. <xsl:attribute name="src"><xsl:value-of select="$dynamicSectionCollapseGif"/></xsl:attribute>
  346. <xsl:attribute name="title"><xsl:value-of select="$collapseTooltip"/></xsl:attribute>
  347. <xsl:attribute name="alt"><xsl:value-of select="$collapseTooltip"/></xsl:attribute>
  348. </xsl:when>
  349. <xsl:otherwise>
  350. <xsl:attribute name="src"><xsl:value-of select="$dynamicSectionExpandGif"/></xsl:attribute>
  351. <xsl:attribute name="title"><xsl:value-of select="$expandTooltip"/></xsl:attribute>
  352. <xsl:attribute name="alt"><xsl:value-of select="$expandTooltip"/></xsl:attribute>
  353. </xsl:otherwise>
  354. </xsl:choose>
  355. </img>
  356. </a>
  357. <div id="{@name}" role="group">
  358. <xsl:if test="uic:title"><xsl:attribute name="aria-label"><xsl:value-of select="uic:title"/></xsl:attribute></xsl:if>
  359. <xsl:attribute name="style">
  360. <xsl:choose>
  361. <xsl:when test="@visible='true'">display:</xsl:when>
  362. <xsl:otherwise>display:none</xsl:otherwise>
  363. </xsl:choose>
  364. </xsl:attribute>
  365. <xsl:attribute name="aria-expanded"><xsl:value-of select="@visible='true'"/></xsl:attribute>
  366. <xsl:apply-templates select="uic:content"/>
  367. </div>
  368. </xsl:template>
  369. </xsl:stylesheet>