123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!--
- Licensed Materials - Property of IBM
- IBM Cognos Products: HTS
- (C) Copyright IBM Corp. 2005, 2010
- 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:xtsext="xalan://com.cognos.xts.ext.XTSExt">
- <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
- <xsl:template match="/">
- <xsl:call-template name="renderMenu"/>
- </xsl:template>
- <!-- the template that creates the menu -->
- <xsl:template name="renderMenu">
- <xsl:param name="customName"/>
- <xsl:param name="menu" select="/root/actions/menu"/>
- <xsl:param name="menuType" select="'dropdown'"/>
- <xsl:variable name="name" select="$menu/item[@selected='true']/name"/>
- <xsl:variable name="mtooltip" select="$menu/@tooltip"/>
- <xsl:variable name="tooltip" select="$menu/item[@selected='true']/name"/>
-
- <xsl:variable name="action" select="$menu/item[@selected='true']/action"/>
- <xsl:variable name="image" select="$menu/item[@selected='true']/image"/>
- <xsl:variable name="skin"><xsl:value-of select="xtsext:javascriptencode(string(/root/preferences/param[@name='skin']))"/></xsl:variable>
- <!-- the menu tooltip -->
- <xsl:variable name="menuTooltip">
- <xsl:choose>
- <xsl:when test="$mtooltip">
- <xsl:value-of select="$mtooltip"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$name"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <!-- the unique menu name -->
- <xsl:variable name="menuName">
- <xsl:choose>
- <xsl:when test="not($customName)">
- <xsl:text>_THIS_</xsl:text><xsl:value-of select="$menu/@id"/>
- </xsl:when>
- <xsl:otherwise><xsl:value-of select="$customName"/></xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:choose>
- <xsl:when test="starts-with($menuType,'combo')">
- <!-- the tooltip displayed when the mouse is hovered over the drop down arrow, it is empty for a menu with an image, the img tag sets the alt text instead-->
- <xsl:variable name="displayName">
- <xsl:choose>
- <xsl:when test="$menu/@displayName"><xsl:value-of select="$menu/@displayName"/></xsl:when>
- <xsl:when test="$menu/item/image"></xsl:when>
-
- <xsl:otherwise><xsl:value-of select="$menu/@id"/></xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="onClickAction">
- <xsl:choose>
- <xsl:when test="$menu/@rebuild">ui_menuUpdate(<xsl:value-of select="$menuName"/>);ui_menuShow(event,<xsl:value-of select="$menuName"/>);</xsl:when>
- <xsl:otherwise>ui_menuShow(event,<xsl:value-of select="$menuName"/>);</xsl:otherwise>
- </xsl:choose>
- replaceCheckBox();
- </xsl:variable>
- <div id="{$menuName}_div" align="right">
- <xsl:if test="$menu/@titleStyle">
- <xsl:attribute name="class"><xsl:value-of select="$menu/@titleStyle"/></xsl:attribute>
- </xsl:if>
- <!-- if we have an image under the menu and no menu name then we assume it's a toggle menu-->
- <xsl:if test="$menu/item/image and $displayName=''">
- <!-- when the toggle menu button is clicked then fire the correct action -->
- <script type="text/javascript">
- function _THIS_<xsl:value-of select="$menuName"/>() {
- var menu = <xsl:value-of select="xtsext:javascriptencode(string($menuName))"/>;
- var item = hts_getSelectedMenuItem(menu);
- setTimeout(item.action, 1);
- }
- </script>
- <div onKeyPress="if (_hts_getKeyCode(event) == 32) _THIS_{$menuName}()" onclick="_THIS_{$menuName}()">
-
- <xsl:variable name="res">
- <xsl:if test="$menu/item/image[@pre]"><xsl:value-of select="$menu/item/image/@pre"/></xsl:if>
- <xsl:value-of select="$menu/item/image"/>
- <xsl:if test="$menu/item/image[@post]"><xsl:value-of select="$menu/item/image/@post"/></xsl:if>
- </xsl:variable>
-
- <xsl:choose>
- <!-- render the image for the initial selected image next to the drop down arrow -->
- <xsl:when test="$image">
- <img id="{$menuName}_img" border="0" src="{$res}" alt="{$menuTooltip}" title="{$menuTooltip}"/>
- </xsl:when>
- <!-- no image so just show the text -->
- <xsl:otherwise><xsl:value-of select="$name"/></xsl:otherwise>
- </xsl:choose>
- </div>
- </xsl:if>
-
- <div id="{$menuName}_div_text" onclick="{$onClickAction}"><xsl:if test="$displayName!=''"><xsl:value-of select="$displayName"/></xsl:if></div>
- <img id="{$menuName}_downarrow_img_id" role="button" tabindex="0" alt="{$menuTooltip}" title="{$menuTooltip}" style="vertical-align:middle;" onfocus="hts_setFocusCookie(this.id)" onblur="hts_setFocusCookie('')" onKeyPress=" if ( _hts_getKeyCode(event) == 32) {$onClickAction}" onclick="{$onClickAction}">
- <xsl:attribute name="src">
- <xsl:text>_THIS?frag-resource=/skins/</xsl:text>
- <xsl:value-of select="$skin"/>
- <xsl:text>/shared/images/dropdown_arrow.gif/THIS_</xsl:text>
- </xsl:attribute>
- </img>
- <xsl:call-template name="buildMenu">
- <xsl:with-param name="menu" select="$menu"/>
- <xsl:with-param name="name" select="$menuName"/>
- </xsl:call-template>
- </div>
- </xsl:when>
- <xsl:when test="$menuType = 'contextMenu'">
- <xsl:call-template name="buildMenu">
- <xsl:with-param name="menu" select="$menu"/>
- <xsl:with-param name="name" select="$menuName"/>
- </xsl:call-template>
- </xsl:when>
- </xsl:choose>
- </xsl:template>
- <!-- display the menu -->
- <xsl:template name="buildMenu">
- <xsl:param name="menu"/>
- <xsl:param name="name"/>
- <script type="text/javascript">
- var _THIS_values = new Array();
- var <xsl:value-of select="$name"/>=new ui_menu({id: "<xsl:value-of select="xtsext:javascriptencode(string($name))"/>", fragment: "_THIS_", items:[
- <xsl:for-each select="$menu/item">
- {
- title: "<xsl:value-of select="xtsext:javascriptencode(string(./name))"/>",
- <xsl:if test="@selected='true'">
- selected: <xsl:value-of select="@selected"/>,
- </xsl:if>
- <xsl:if test="$menu/item/image[@pre]">
- pre: "<xsl:value-of select="xtsext:javascriptencode(string($menu/item/image/@pre))"/>",
- </xsl:if>
- <xsl:if test="$menu/item/image[@post]">
- post: "<xsl:value-of select="xtsext:javascriptencode(string($menu/item/image/@post))"/>",
- </xsl:if>
- <xsl:if test="./image">
- image: "<xsl:value-of select="xtsext:javascriptencode(string(./image))"/>",
- </xsl:if>
- <xsl:if test="@separatorBefore='true'">
- <xsl:text>separatorBefore: true,</xsl:text>
- </xsl:if>
- action: function(evt) {
- <xsl:value-of select="./action"/>
- } ,
- getItemState: function(menudef, i) {
- return _THIS_action_getItemState(menudef, i);
- }
- }
- <xsl:if test="position() != last()">,</xsl:if>
- </xsl:for-each>
- <xsl:text>]});</xsl:text>
-
- <!-- collect the combo values -->
- <xsl:for-each select="$menu/item/value">
- <xsl:choose>
- <xsl:when test="@type='script'">
- var result = function () {<xsl:value-of select="normalize-space(.)"/>}
- _THIS_values['<xsl:value-of select="xtsext:javascriptencode(string(../name))"/>']=result();
- </xsl:when>
- <xsl:otherwise>
- _THIS_values["<xsl:value-of select="xtsext:javascriptencode(string(../name))"/>"]="<xsl:value-of select="."/>";
- </xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
-
- <!-- now load the combo values into the menu definition -->
- var _THIS_def = <xsl:value-of select="xtsext:javascriptencode(string($name))"/>.menudef;
- for(key in _THIS_def.items) {
- var item = _THIS_def.items[key];
- if (_THIS_values[item.title] != undefined) {
- item.value = _THIS_values[item.title];
- }
- }
- if (typeof _THIS_menuLoaded != 'undefined') {
- _THIS_menuLoaded('<xsl:value-of select="xtsext:javascriptencode(string($name))"/>');
- }
- function replaceCheckBox() {
- dojo.query("TD[style*='checkmark.gif']").forEach(
- function(node, index, arr) {
- var srcImage = dojo.style(node,'backgroundImage');
- srcImage = srcImage.replace("fragments/common", "fragments/myinbox");
- srcImage = srcImage.replace("checkmark.gif", "radio_enabled.gif");
- dojo.style(node,'backgroundImage',srcImage);
- }
- );
- }
- </script>
- </xsl:template>
- </xsl:stylesheet>
|