toolbar.xslt 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: AGS
  5. (C) Copyright IBM Corp. 2005, 2008
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:pf="http://developer.cognos.com/schemas/xts/pf" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" xmlns:cp="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/controls/presentation/" xmlns:xts="http://developer.cognos.com/schemas/xts/" xmlns:cf="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/controls/framework/" exclude-result-prefixes="xsl pf xtsext cp xts cf">
  9. <xsl:output method="html" version="1.0" encoding="UTF-8" indent="no"/>
  10. <pf:variables/>
  11. <xsl:template match="/">
  12. <div id="toolbarContainer" role="menubar" style="width:100%; height: 100%"/>
  13. <xsl:text>
  14. </xsl:text>
  15. <script language="javascript"><![CDATA[
  16. //Contains the menus and toolbar buttons that have capablities only.
  17. var toolbarMenuMap = new Object();
  18. var toolbarButtonStyle = new CUIStyle('toolbarImageNormal_studio', 'toolbarImageOver_studio', 'toolbarImagePressed_studio', 'toolbarImageOverPressed_studio', 'toolbarImageNormal_studio');
  19. var toolbarDropdownButtonStyle = new CUIStyle('toolbarDropdownImageNormal_studio', 'toolbarDropdownImageOver_studio', 'toolbarDropdownImagePressed_studio', 'toolbarDropdownImageOverPressed_studio', 'toolbarDropdownImageNormal_studio');
  20. var toolbarStyle = new CUIStyle('', '', '', '', '');
  21. var menuItemStyle = new CUIStyle('menuItem_normal', 'menuItem_hover', '', '', '');
  22. var menuStyle = new CUIStyle('menuContainer', '', '', '', '');
  23. //var blankSeperator = new CSeperator("vertical_line", "12");
  24. var blankSeperator = new CSeperator("vertical_line_img", 20);
  25. var toolbar = new CBar('toolbarContainer');
  26. toolbar.setStyle(toolbarStyle);
  27. //<!-- change the images for the toolbar during a mouseover -->
  28. function mouseoverImage(item) {
  29. if (item.className == 'toolbarImageNormal_studio')
  30. item.className = 'toolbarImageOver';
  31. if (item.className == 'toolbarImagePressed')
  32. item.className = 'toolbarImageOverPressed';
  33. }
  34. //<!-- change the images for the toolbar during a mouseout -->
  35. function mouseoutImage(item) {
  36. if (item.className == 'toolbarImageOver')
  37. item.className = 'toolbarImageNormal_studio';
  38. if (item.className == 'toolbarImageOverPressed')
  39. item.className = 'toolbarImagePressed';
  40. }
  41. ]]>
  42. <xsl:apply-templates select="//*[local-name()='button' or local-name()='dropbutton']"/>
  43. //toolbar.m_observers.attach(toolbar, toolbar.closeMenus, document.body.onmousedown);
  44. toolbar.setMenuType(cHorizonalBar);
  45. toolbar.setAlign('left');
  46. toolbar.draw();
  47. </script>
  48. <xsl:text>
  49. </xsl:text>
  50. <xsl:call-template name="buttonScripts"/>
  51. </xsl:template>
  52. <!-- create a group button spacer of 10 pixels-->
  53. <xsl:template match="button[@type='separator']">
  54. toolbar.add(blankSeperator);
  55. </xsl:template>
  56. <!-- create a menu item-->
  57. <xsl:template match="menuItem">
  58. <xsl:param name="parentMenu"/>
  59. <xsl:variable name="menuName" select="concat('toolbarButtonMenu_',generate-id())"/>
  60. var <xsl:value-of select="$menuName"/> = new CMenuItem(<xsl:value-of select="$parentMenu"/>, '<xsl:value-of select="xtsext:javascriptencode(string(./name))"/>', '<xsl:value-of select="xtsext:javascriptencode(string(./id))"/>', '<xsl:value-of select="xtsext:javascriptencode(string(./action))"/>', '<xsl:value-of select="./icon"/>', menuItemStyle, '<xsl:value-of select="xtsext:javascriptencode(string(./tooltip))"/>',"", "<xsl:value-of select="xtsext:javascriptencode(string(userCapability))"/>");
  61. <xsl:if test="./userCapability">
  62. toolbarMenuMap[&quot;<xsl:value-of select="xtsext:javascriptencode(string(normalize-space(id)))"/>&quot;] = <xsl:value-of select="$menuName"/>;
  63. </xsl:if>
  64. </xsl:template>
  65. <!-- create a cascaded menu item -->
  66. <xsl:template match="cascadedMenuItem">
  67. <xsl:param name="parentMenu"/>
  68. <xsl:variable name="menuName" select="concat('toolbarButton_',generate-id())"/>
  69. var <xsl:value-of select="$menuName"/> = new CMenuItem(<xsl:value-of select="$parentMenu"/>, '<xsl:value-of select="xtsext:javascriptencode(string(./name))"/>', '<xsl:value-of select="xtsext:javascriptencode(string(./id))"/>', '<xsl:value-of select="xtsext:javascriptencode(string(./action))"/>', '<xsl:value-of select="./icon"/>', menuItemStyle, '');
  70. var <xsl:value-of select="$menuName"/>_cascaded = <xsl:value-of select="$menuName"/>.createCascadedMenu(menuStyle,5);
  71. <xsl:apply-templates select="menuItem">
  72. <xsl:with-param name="parentMenu" select="concat($menuName,'_cascaded')"/>
  73. </xsl:apply-templates>
  74. </xsl:template>
  75. <!-- create a toolbar button. The dimensions should be 24px by 24px and the class 'toolbarImageNormal_studio' which is defined in CRN.css. For more information
  76. see the visual style guide here -
  77. http://sottmyprodapp/liz/index.htm
  78. -->
  79. <xsl:template match="button">
  80. <xsl:variable name="buttonName" select="concat('toolbarButton_',generate-id())"/>
  81. <!-- parent, action, iconPath, toolTip, style, bHideDropDown, label, dropDownToolTip, capbility-->
  82. var <xsl:value-of select="$buttonName"/> = new CToolbarButton(toolbar, '<xsl:value-of select="xtsext:javascriptencode(string(./link))"/>', &quot;<xsl:value-of select="./icon[@state='active']"/>&quot;, '<xsl:value-of select="xtsext:javascriptencode(string(./tooltip))"/>',toolbarButtonStyle,undefined,undefined,undefined,undefined, "<xsl:value-of select="xtsext:javascriptencode(string(userCapability))"/>");
  83. <xsl:if test="./userCapability">
  84. toolbarMenuMap[&quot;<xsl:value-of select="$buttonName"/>&quot;] = <xsl:value-of select="$buttonName"/>;
  85. </xsl:if>
  86. </xsl:template>
  87. <!-- render a drop down button-->
  88. <xsl:template match="dropbutton">
  89. <xsl:variable select="string(/root/http/param[@name=&apos;SCRIPT_NAME&apos;])" name="gateway"/>
  90. <!--xsl:variable select="key(&apos;system-param&apos;, &apos;app&apos;)" name="app"/-->
  91. <!--xsl:variable name="back-url">
  92. <xsl:value-of select="$gateway"/>?b_action=xts.run&amp;m=<xsl:value-of select="key(&apos;env-param&apos;,&apos;m&apos;)"/>
  93. </xsl:variable-->
  94. <!--xsl:variable name="encoded-back-url">
  95. <xsl:value-of select="xtsext:protect(xtsext:urlencode(string($back-url)),'url','url','getdata')"/>
  96. </xsl:variable-->
  97. <xsl:variable name="hideDrop" select="./hideDropArrow"/>
  98. <xsl:variable name="iconWidth">
  99. <xsl:choose>
  100. <xsl:when test="./icon/@width"><xsl:value-of select="./icon/@width"/></xsl:when>
  101. <xsl:otherwise>16</xsl:otherwise>
  102. </xsl:choose>
  103. </xsl:variable>
  104. <xsl:variable name="class">
  105. <xsl:choose>
  106. <xsl:when test="$hideDrop='true'">toolbarDropdownButtonStyle</xsl:when>
  107. <xsl:otherwise>toolbarButtonStyle</xsl:otherwise>
  108. </xsl:choose>
  109. </xsl:variable>
  110. <xsl:variable name="menuName" select="concat('toolbarButton_',generate-id())"/>
  111. <!--
  112. //If we have a two action type drop down then the action will be passed.
  113. //however if the menu is a single action i.e only drop down then the action will be ignored.
  114. -->
  115. var <xsl:value-of select="$menuName"/> = new CToolbarButton(toolbar, '<xsl:value-of select="xtsext:javascriptencode(string(./action))"/>', '<xsl:value-of select="./icon"/>', '<xsl:value-of select="xtsext:javascriptencode(string(./tooltip))"/>',<xsl:value-of select="$class"/>,<xsl:value-of select="$hideDrop"/>, null,null, <xsl:value-of select="$iconWidth"/>);
  116. var <xsl:value-of select="$menuName"/>_menu = <xsl:value-of select="$menuName"/>.createDropDownMenu(menuStyle);
  117. <xsl:apply-templates select="menuItem">
  118. <xsl:with-param name="parentMenu" select="concat($menuName,'_menu')"/>
  119. </xsl:apply-templates>
  120. <xsl:apply-templates select="cascadedMenuItem">
  121. <xsl:with-param name="parentMenu" select="concat($menuName,'_menu')"/>
  122. </xsl:apply-templates>
  123. </xsl:template>
  124. <xsl:template name="buttonScripts">
  125. <script language="JavaScript">
  126. function openTool(s)
  127. {
  128. var cf = window.parent.getConfigFrame();
  129. if (s == "" || s == null) return;
  130. if(!self.messageIFrame.doAction) return;
  131. self.messageIFrame.doAction(s);
  132. }
  133. function goToPage(location, type){
  134. var cf = window.parent.getConfigFrame();
  135. makeSelection(type);
  136. cf.loadPage(location);
  137. }
  138. function reselectTab(tabId, type)
  139. {
  140. if(!self.messageIFrame.selectTab) return;
  141. self.messageIFrame.selectTab(tabId, type);
  142. }
  143. </script>
  144. </xsl:template>
  145. </xsl:stylesheet>