| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!--
- Licensed Materials - Property of IBM
- IBM Cognos Products: AGS
- (C) Copyright IBM Corp. 2005, 2014
- US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- -->
- <xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:xts="http://developer.cognos.com/schemas/xts/"
- xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
- exclude-result-prefixes="xsl xts xtsext">
- <xsl:output method="html" version="1.0" encoding="UTF-8" indent="no"/>
-
- <!-- create the menu bar-->
- <xsl:template match="/">
- <xsl:apply-templates select="/root/menuBar"/>
- </xsl:template>
-
- <!-- create the JS to load the menu bar-->
- <xsl:template match="menuBar">
- <script type="text/javascript">
- //Contains the menus that have capablities only.
- var menuItemMap = new Object();
- function loadMenu() {
- var menuItemStyle = new CUIStyle('menuItem_normal', 'menuItem_hover', 'menuItem_hover', 'menuItem_hover', 'menuItem_disabled');
- var menuTitleStyle = new CUIStyle('menuTitle_normal', 'menuTitle_hover', 'menuTitle_hover', 'menuTitle_hover', '');
- var menuStyle = new CUIStyle('menuContainer', 'menuTitle_pressed', 'menuTitle_pressed', 'menuTitle_pressed', '');
- // define the separators
- var gMenuSeperatorStyle = new CUIStyle('menuHorizontalSeperator','','','','');
- var menuSeperator = new CSeperator('horizontal_line', '1',gMenuSeperatorStyle);
- var blankSeparator = new CSeperator("horizonal_blank", "16");
- m_menu = new CBar('menuBar');
-
- var accessibility_cookie = getCookie("AGS_ACCESSIBILITY_ENABLED");
-
- //define the menu items
- if (accessibility_cookie != 'true') {
- <xsl:apply-templates select="label">
- <xsl:with-param name="a11y_enabled">false</xsl:with-param>
- </xsl:apply-templates>
- }
- else {
- <xsl:apply-templates select="label">
- <xsl:with-param name="a11y_enabled">true</xsl:with-param>
- </xsl:apply-templates>
- }
- m_menu.setMenuType(cHorizonalBar);
- m_menu.draw();
- }
- </script>
- </xsl:template>
- <!-- create the top level menu label-->
- <xsl:template match="label">
- <xsl:param name="a11y_enabled"/>
- <!-- create a unique label menu id-->
- <xsl:variable name="menuName" select="concat('label',generate-id())"/>
- <!-- add the menu label-->
- var <xsl:value-of select="$menuName"/>=new CMenuItem(m_menu, "<xsl:value-of select='xtsext:javascriptencode(string(normalize-space(name)))'/>","<xsl:value-of select='xtsext:javascriptencode(string(normalize-space(id)))'/>", '','',menuTitleStyle);
- var <xsl:value-of select="$menuName"/>_menuItems = <xsl:value-of select="$menuName"/>.createDropDownMenu(menuStyle);
- <xsl:value-of select="$menuName"/>_menuItems.setOffsetXCoords(-1);
- <xsl:value-of select="$menuName"/>_menuItems.setOffsetYCoords(3);
- <!-- add the menu items for the current label-->
- <xsl:apply-templates select="./items/item">
- <xsl:with-param name="parentMenu" select="concat($menuName,'_menuItems')"/>
- <xsl:with-param name="a11y_flag" select="$a11y_enabled"/>
- </xsl:apply-templates>
- </xsl:template>
- <!-- this template will loop through the menu items and create the JS for each one-->
- <xsl:template match="items/item">
- <xsl:param name="parentMenu"/>
- <xsl:param name="a11y_flag"/>
- <xsl:variable name="subMenuName" select="concat('item',generate-id())"/>
- <!-- define the action, it may be null -->
- <xsl:variable name="action">
- <xsl:choose>
- <xsl:when test="action != ''">"javascript:<xsl:value-of select="xtsext:javascriptencode(string(action))"/>"</xsl:when>
- <xsl:when test="not(items/item)">"javascript:alert('This menu item is not implemented yet');"</xsl:when>
- <xsl:otherwise>null</xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:if test="not(./hide) or (./hide and /root/evts/configuration/property[@name='enableHiddenMenuItems']='true')">
- <!-- add the menu item-->
- var <xsl:value-of select="$subMenuName"/>= new CMenuItem(<xsl:value-of select="$parentMenu"/>, "<xsl:value-of select="xtsext:javascriptencode(string(normalize-space(name)))"/>", "<xsl:value-of select="xtsext:javascriptencode(string(normalize-space(id)))"/>", <xsl:value-of select="$action"/>, "<xsl:value-of select="xtsext:javascriptencode(string(icon))"/>", menuItemStyle, "<xsl:value-of select="xtsext:javascriptencode(string(tooltip))"/>","", "<xsl:value-of select="xtsext:javascriptencode(string(userCapability))"/>" );
-
- // add cascade true so that we can get space in the right after menuitem text
- <xsl:value-of select="$parentMenu"/>.setContainsCascadedChildren(true);
- <!--keyed menu items can be retrieved using the key, keys should be unique for all menu items in the application menu bar-->
- <xsl:if test="./key">
- menuItemMap["<xsl:value-of select="./key"/>"] = <xsl:value-of select="$subMenuName"/>;
- </xsl:if>
- <!-- Do not add the ones with key again. -->
- <xsl:if test="not(./key) and ./userCapability">
- menuItemMap["<xsl:value-of select="xtsext:javascriptencode(string(normalize-space(id)))"/>"] = <xsl:value-of select="$subMenuName"/>;
- </xsl:if>
-
- <!-- A11Y check for switch the enable or disable accessibility menu item-->
- <xsl:if test="./accessibility">
- <xsl:value-of select="$subMenuName"/>.hide();
- <xsl:choose>
- <xsl:when test="accessibility = 'enable' and $a11y_flag = 'false'">
- <xsl:value-of select="$subMenuName"/>.show();
- </xsl:when>
- <xsl:when test="accessibility = 'disable' and $a11y_flag = 'true'">
- <xsl:value-of select="$subMenuName"/>.show();
- </xsl:when>
- </xsl:choose>
- </xsl:if>
- <xsl:if test="./items/item">
- var <xsl:value-of select="$subMenuName"/>_cascaded = <xsl:value-of select="$subMenuName"/>.createCascadedMenu(menuStyle,5);
- <xsl:value-of select="$subMenuName"/>_cascaded.setOffsetYCoords(-1);
- <xsl:apply-templates select="./items/item">
- <xsl:with-param name="parentMenu" select="concat($subMenuName,'_cascaded')"/>
- </xsl:apply-templates>
- </xsl:if>
- </xsl:if>
- </xsl:template>
- <!-- create a menu separator (hr) -->
- <xsl:template match="items/item[@type='separator']">
- <xsl:param name="parentMenu"/>
- <xsl:value-of select="$parentMenu"/>.add(menuSeperator);
- </xsl:template>
- </xsl:stylesheet>
|