';
}
} else {
this.setLoadingMenuItem(false);
//add the items
var i=0;
html='
';
html += this.genMenuAltText();
var anyVisibleItems = false;
for (i=0; i < this.m_menuItems.length; i++) {
if(this.m_menuItems[i].isVisible()) {
anyVisibleItems = true;
html += '
';
html += this.m_menuItems[i].draw();
html += '
';
}
}
if (!anyVisibleItems) {
this.remove();
return;
}
html += '
';
}
try
{
this.m_htmlDivElement.innerHTML = html;
// attach the event handlers
this.attachEvents();
}
catch (e)
{
}
this.updateCoords();
// update hidden iframe
var iFrameId = "uiFrameworkHiddenIframe" + this.m_id;
var isNS7 = ((!isIE()) && (document.getElementById)) ? true : false;
setTimeout('updateIframeCoords("' + iFrameId + '", "' + this.m_htmlDivElement.id + '", ' + isNS7 + ')',50);
//Only gets applied when rv is in fragment mode
if ((typeof gCognosViewer != "undefined") && (gCognosViewer.envParams["cv.responseFormat"]) && (gCognosViewer.envParams["cv.responseFormat"] == 'fragment'))
{
AdjustPortalFont(this.m_htmlDivElement);
}
}
function CMenu_setLoadingMenuItem(bLoadingMenuItem)
{
this.m_loadingMenuItem = bLoadingMenuItem;
}
function CMenu_getLoadingMenuItem()
{
return this.m_loadingMenuItem;
}
/**
* CMenu_getScrollingPosition
* Cross Browser method to get the scroll position of a mouse click.
* QuirksMode supports document.body.scrollTop, document.body.scrollLeft
* Strict Mode
* Firefox, Opera, Safari, Konqueror support window.pageYOffset, window.pageXOffset
* IE 6.0 supports document.documentElement.scrollTop, document.documentElement.scrollLeft
* @return Object - contain x,y information of the position of the mouse click.
*/
function CMenu_getScrollingPosition()
{
var position = {"x":0,"y": 0};
if (typeof window.pageYOffset != "undefined")
{
position = {"x":window.pageXOffset,"y":window.pageYOffset};
}
else if ((typeof document.documentElement.scrollTop != "undefined") &&
(document.documentElement.scrollTop > 0 || typeof document.body.scrollTop == "undefined" || document.body.scrollTop == document.documentElement.scrollTop))
{
position = {"x":document.documentElement.scrollLeft,"y":document.documentElement.scrollTop};
}
else if (typeof document.body.scrollTop != "undefined")
{
position = {"x":document.body.scrollLeft,"y":document.body.scrollTop};
}
return position;
}
/**
* AdjustPortalFont
* @author whelanp
* This function fixes a problem with font sizes in the portal environment,
* we are using the computed style of the fragment div to set the font on the menu item
* this keeps it consistent with the font being used by the rest of the page.
* Problems this solves, menus get appended to the body of the document, if the body does
* not set the font size correctly the font can either be too small or too big. If we are
* in fragment mode there is always a div created with the appropriate css rules applied to it
* thus getting the font size from the fragment div fixes the problem.
* To fix a browser bug that causes tables to not properly inherit there parents font size, we've appended
* a class to the menu as well. This class sets all table descendents of any element with PortalFontFix as a
* class to use font-size:100% this forces the tables to use 100% of there parents font-size.
* class is located in CRNFragment.css
* .PortalFontFix table {font-size:100%;}
*
*/
function AdjustPortalFont(div)
{
var fragArray = fragments;
if (fragArray)
{
div.className += " PortalFontFix";
var fragDiv = null;
for (var frag in fragArray)
{
if (frag.indexOf("rvCanvas") > -1)
{
fragDiv = $(fragArray[frag].div);
if (fragDiv != null)
{
break;
}
}
}
if (fragDiv != null)
{
div.style.fontSize = xGetComputedStyle(fragDiv, "font-size");
}
}
}
function CMenu_updateCoords() {
var myParent = this.getParent();
var mnu = this.m_htmlDivElement;
if(mnu != null)
{
var myDocument = this.m_htmlContainer.document ? this.m_htmlContainer.document : this.m_htmlContainer.ownerDocument;
//Backup the visibilty and display properties of this menu
var originalVisibility = mnu.style.visibility;
var originalDisplay = mnu.style.display;
mnu.style.visibility = "hidden";
mnu.style.display = "block";
//This line is used to make sure the width of the DIV element is correct in Mozilla
if(mnu.firstChild != null) {
mnu.style.width = mnu.firstChild.offsetWidth;
}
var x=0, y=0;
var db = mnu.parentNode; //db = Document body
// calculate the page width
var pageWidth = db.clientWidth;
var pageHeight = db.clientHeight;
var pagePosition = CMenu_getScrollingPosition();
var scrollLeft = pagePosition.x;
var scrollTop = pagePosition.y;
if(myParent == null)
{
//If this is the main context menu...
x = mnu.style.left;
y = mnu.style.top;
//Remove "px" on x and y coordinates if it exists
if (x.substr(x.length - 2, 2) == "px")
{
x = parseInt(x.substring(0, x.length-2),10);
y = parseInt(y.substring(0, y.length-2),10);
}
//Change the y coordinate if the menu goes below the visible page
if (y + mnu.offsetHeight >= (pageHeight))
{
if (y - mnu.offsetHeight > 0) {
y = y + scrollTop - mnu.offsetHeight;
}
else {
y = Math.max(pageHeight - mnu.offsetHeight, 0);
}
}
else {
y = y + scrollTop;
}
//Change the x coordinate if the menu goes below the visible page
if (x + mnu.offsetWidth >= (pageWidth))
{
if (x - mnu.offsetWidth > 0) {
x = x + scrollLeft - mnu.offsetWidth;
}
else {
x = Math.max(pageWidth - mnu.offsetWidth, 0);
}
}
else {
x = x + scrollLeft;
}
}
else
{
//This is one of the menu items...
if(!(myParent instanceof CToolbarButton) && !(myParent instanceof CMenuItem)) {
return;
}
// make sure the parent has implemented the method "getMenuType"
if(typeof myParent.getMenuType != "function") {
return;
}
var myParentHTMLElement = myDocument.getElementById(this.getParent().getId());
var myParentDropdownButton = myDocument.getElementById('menu' + this.getParent().getId());
if(myParentHTMLElement == null) {
return;
}
var current = myParentHTMLElement;
// handle drop down menus
if(myParent.getMenuType() == 'dropDown') {
x = 0; y = myParentHTMLElement.offsetHeight;
while(current != null) {
x += current.offsetLeft; y += current.offsetTop;
current = current.offsetParent;
}
if(getViewerDirection()=="rtl"){
var xMirrored = x - (mnu.offsetWidth - myParentHTMLElement.offsetWidth);
if(xMirrored > scrollLeft){
x = xMirrored;
}
}
// For defect COGCQ00646908.
// If we are in a portlet we must also take into account its scrollable position.
// The caveat here is that the portlet div is scrollable and a parent element that is scrollable is not necessarily an
// offsetParent (and in this case it is not). Therefore, we must travel up the parentNode DOM tree and calculate the scroll
// position values of the portlet div (and any subsequent scrollable element) and subtract them accordingly.
if ((typeof gCognosViewer != "undefined") && (gCognosViewer.envParams["cv.responseFormat"]) && (gCognosViewer.envParams["cv.responseFormat"] == 'fragment')) {
var scrollPos = myParentHTMLElement;
while((scrollPos != document.body) && (scrollPos = scrollPos.parentNode)) {
// if the scroll values return a null, we must OR a 0-value to force return a number instead of null or NaN
x -= scrollPos.scrollLeft || 0;
y -= scrollPos.scrolltop || 0;
}
}
// if the right side of the drop down menu extends beyond browser window viewing area, adjust accordingly
if((x + mnu.offsetWidth) > (pageWidth + scrollLeft)) {
x = x + myParentHTMLElement.offsetWidth - mnu.offsetWidth;
if(myParentDropdownButton != null) {
x = x + myParentDropdownButton.offsetWidth;
}
}
// if the bottom of the drop down menu extends below the browser viewing area and there is enough room to draw at the top, then draw to the top
if(((y + mnu.offsetHeight) > (pageHeight + scrollTop)) && (y - (mnu.offsetHeight + myParentHTMLElement.clientHeight) >= 0)) {
y -= (mnu.offsetHeight + myParentHTMLElement.clientHeight);
}
} else if(myParent.getMenuType() == 'cascaded') {
x = myParentHTMLElement.offsetWidth;
while(current != null) {
x += current.offsetLeft; y += current.offsetTop;
current = current.offsetParent;
}
if(getViewerDirection()=="rtl"){
var xMirrored = x - (mnu.offsetWidth + myParentHTMLElement.offsetWidth);
if(xMirrored > scrollLeft){
x = xMirrored;
}
}
// if the right side of the cascaded menu extends beyond the viewing area of the browser window right side, render to the left insted of the right
if((x + mnu.offsetWidth) > (pageWidth + scrollLeft)) {
x -= (myParentHTMLElement.offsetWidth + mnu.offsetWidth);
}
// if the bottom of the cascaded menu extends beyond the bottom of the browser viewing area, draw to the top
if((y + mnu.offsetHeight) > (pageHeight + scrollTop)) {
y -= (mnu.offsetHeight-myParentHTMLElement.clientHeight);
}
}
}
//Restore the visibilty and display properties of this menu
mnu.style.visibility = originalVisibility;
mnu.style.display = originalDisplay;
this.setXCoord(x);
this.setYCoord(y);
this.setZIndex(500);
}
}
function CMenu_add(menuItem) {
if(typeof menuItem.getObservers == "function" && typeof menuItem.getObservers() == "object") {
menuItem.getObservers().attach(this, this.closeSubMenus, menuItem.onmouseover);
menuItem.getObservers().attach(this, this.closeAllMenus, menuItem.onmouseup);
menuItem.getObservers().attach(this, this.closeSubMenus, menuItem.onfocus);
menuItem.getObservers().attach(this, this.closeAllMenus, menuItem.onkeypress);
}
this.m_menuItems[this.m_menuItems.length] = menuItem;
}
function CMenu_get(index) {
if(index >= 0 && index < this.getNumItems()) {
return this.m_menuItems[index];
}
return null;
}
CMenu.prototype.getItem = function(sItemId)
{
var sId = sItemId;
if (this.m_oCV) {
sId = this.m_oCV.getId() + sItemId;
}
for (var iIndex=0; iIndex < this.getNumItems(); iIndex++)
{
var uiItem = this.get(iIndex);
if(typeof uiItem.getId == "function" && uiItem.getId() == sId)
{
return uiItem;
}
}
};
function CMenu_getNumItems() {
return this.m_menuItems.length;
}
function CMenu_hide() {
this.hideHiddenIframe();
if(this.m_htmlDivElement != null) {
this.m_htmlDivElement.style.visibility = "hidden";
}
this.m_bVisible = false;
// get the actual element that spawned the menu
var theControl = this.getParent();
if (theControl != null && typeof theControl.setFocus == "function") {
theControl.setFocus();
} else if (theControl != null && typeof theControl.focus == "function") {
theControl.focus();
} else if (typeof this.m_focusCell == "object" && typeof this.m_focusCell.focus == "function" ) {
this.m_focusCell.focus();
}
}
function CMenu_setFocus() {
try {
var menuItem = null;
for (var menuItemIndex = 0; menuItemIndex < this.getNumItems() && !menuItem; menuItemIndex++) {
var _menuItem = this.get(menuItemIndex);
if (_menuItem.isVisible && _menuItem.isVisible() ) {
menuItem = _menuItem;
}
}
if (!menuItem || !menuItem.setFocus()) {
this.m_htmlDivElement.childNodes[0].focus();
}
} catch (e) {}
}
function CMenu_show() {
if(this.m_htmlDivElement != null) {
this.m_bVisible = true;
// update the x and y coords
this.updateCoords();
var isNS7 = ((!isIE()) && (document.getElementById)) ? true : false;
var iFrameId = "uiFrameworkHiddenIframe" + this.m_id;
var hiddenIframeElement = this.m_htmlContainer.document ? this.m_htmlContainer.document.getElementById(iFrameId) : this.m_htmlContainer.ownerDocument.getElementById(iFrameId);
if (hiddenIframeElement == null) {
hiddenIframeElement = this.createHiddenIFrame(iFrameId);
}
if(hiddenIframeElement) {
hiddenIframeElement.style.display = "block";
hiddenIframeElement.style.left = "0px";
hiddenIframeElement.style.top = "0px";
updateIframeCoords(iFrameId, this.m_htmlDivElement.id, isNS7);
setTimeout('updateIframeCoords("'+iFrameId+'", "'+this.m_htmlDivElement.id+'", '+isNS7+')',50);
}
//Show the context menu
this.m_htmlDivElement.style.display = "block";
this.m_htmlDivElement.style.visibility = "visible";
this.setFocus();
// Only attach the onresize & onscroll events when we're not on an iOS. This is to fix an issue
// where we'd get a scroll event right away when displaying our menu, so the menu would
// show up and then get removed right away.
if (!window.isIOS()) {
var cmenuObj = this;
if (window.attachEvent) {
window.attachEvent("onresize", function() { cmenuObj.remove()});
window.attachEvent("onscroll", function() { cmenuObj.remove()});
}
else {
window.addEventListener("resize", function() { cmenuObj.remove()}, false);
window.addEventListener("scroll", function() { cmenuObj.remove()}, false);
}
var contentDiv = null;
if (this.m_oCV != null) {
contentDiv = document.getElementById(this.m_oCV.getId() + "content");
}
if (contentDiv) {
if (contentDiv.parentNode.parentNode.attachEvent) {
contentDiv.parentNode.parentNode.attachEvent("onscroll", function() { cmenuObj.remove()});
}
else {
contentDiv.parentNode.parentNode.addEventListener("scroll", function() { cmenuObj.remove()}, false);
}
}
}
}
}
function CMenu_createHiddenIFrame(iFrameId)
{
var container = this.getHTMLContainer();
var iframeElem = container.document ? container.document.createElement("iframe") : container.ownerDocument.createElement("iframe");
iframeElem.setAttribute("id",iFrameId);
iframeElem.setAttribute("src",this.m_webContentRoot + '/common/images/spacer.gif');
iframeElem.setAttribute("scrolling",'no');
iframeElem.setAttribute("frameborder",'0');
iframeElem.style.position="absolute";
iframeElem.style.minWidth="0px";
iframeElem.style.minHeight="0px";
iframeElem.style.left="0px";
iframeElem.style.top="0px";
iframeElem.style.zIndex=499;
iframeElem.style.display="none";
iframeElem.setAttribute("title", "Empty frame");
iframeElem.setAttribute("role", "presentation");
container.appendChild(iframeElem);
return iframeElem;
}
function CMenu_isVisible() {
return this.m_bVisible;
}
function CMenu_remove() {
this.removeHiddenIframe();
for(var i = 0; i < this.getNumItems(); ++i) {
var currentItem = this.get(i);
if(typeof currentItem.getMenu == "function" && currentItem.getMenu() != null) {
currentItem.getMenu().remove();
}
}
if(this.m_htmlContainer != null && this.m_htmlDivElement != null) {
this.m_htmlContainer.removeChild(this.m_htmlDivElement);
}
this.m_htmlDivElement = null;
this.m_bVisible = false;
}
function CMenu_removeHiddenIframe()
{
try
{
if (g_ownerDocument)
{
var hiddenIframeElement = g_ownerDocument.getElementById("uiFrameworkHiddenIframe" + this.m_id);
if (hiddenIframeElement != null) {
hiddenIframeElement.style.display = "none";
if (hiddenIframeElement.parentNode && hiddenIframeElement.parentNode.removeChild) {
hiddenIframeElement.parentNode.removeChild(hiddenIframeElement);
}
}
}
}
catch(e)
{
}
}
function CMenu_hideHiddenIframe() {
try
{
if (g_ownerDocument)
{
var hiddenIframeElement = g_ownerDocument.getElementById("uiFrameworkHiddenIframe" + this.m_id);
if(hiddenIframeElement) {
hiddenIframeElement.style.display = "none";
}
}
}
catch(e)
{
}
}
function CMenu_enable() {
}
function CMenu_disable() {
}
function CMenu_getState() {
}
function CMenu_clear() {
if(this.m_htmlDivElement != null) {
this.m_htmlDivElement.innerHTML="";
}
this.m_menuItems.splice(0, this.m_menuItems.length);
}
function CMenu_attachEvents() {
for(var i = 0; i < this.m_menuItems.length; i++) {
if(typeof this.m_menuItems[i].attachEvents == "function") {
this.m_menuItems[i].attachEvents();
}
}
this.m_htmlDivElement.onkeypress = this.onkeypress;
this.m_htmlDivElement.tbMenu = eval(this);
}
function CMenu_closeSubMenus(state) {
// Called during a notification...
// make sure we hide any submenus which have been opened.
for(var i = 0; i < this.m_menuItems.length; i++) {
var menuItem = this.m_menuItems[i];
var subject = state.getSubject();
if(menuItem != subject && typeof menuItem.getMenu == "function" && menuItem.getMenu() != null && menuItem.getMenu().isVisible()) {
menuItem.getMenu().remove();
}
}
}
function CMenu_closeAllMenus(state) {
// Called during a notification...
var current = this;
var highestMenu = null;
while(current) {
if(current instanceof CMenu) {
highestMenu = current;
}
current = current.getParent();
}
if(highestMenu != null) {
highestMenu.remove();
}
}
function CMenu_setStyle(style) {
this.m_style = style;
}
function CMenu_getStyle() {
return this.m_style;
}
function CMenu_setXCoord(x) {
var htmlDiv = this.getHTMLDiv();
if(htmlDiv != null) {
htmlDiv.style.left = x + "px";
}
}
function CMenu_setYCoord(y) {
var htmlDiv = this.getHTMLDiv();
if(htmlDiv != null) {
htmlDiv.style.top = y + "px";
}
}
function CMenu_setZIndex(zIndex) {
var htmlDiv = this.getHTMLDiv();
if(htmlDiv != null) {
htmlDiv.style.zIndex = zIndex;
}
}
// set a callback routine to populate the menu
function CMenu_registerCallback(callback) {
this.m_callback = callback;
}
function CMenu_executeCallback() {
if(typeof this.m_callback == "function")
{
this.m_callback();
}
else if(typeof this.m_callback == "string")
{
eval(this.m_callback);
}
}
function CMenu_getObservers() {
return this.m_observers;
}
function CMenu_onmouseover(evt) {
//get the event in a cross-browser fashion
evt = (evt) ? evt : ((event) ? event : null);
// notify our parent (if one exists) of this event
if(this.getParent() != null && typeof this.getParent().onmouseover == "function") {
this.getParent().onmouseover(evt);
}
// notify observers of this event
this.getObservers().notify(CMenu_onmouseover);
}
function CMenu_onmouseout(evt) {
//get the event in a cross-browser fashion
evt = (evt) ? evt : ((event) ? event : null);
// notify our parent (if one exists) of this event
if(this.getParent() != null && typeof this.getParent().onmouseout == "function") {
this.getParent().onmouseout(evt);
}
// notify observers of this event
this.getObservers().notify(CMenu_onmouseout);
}
function CMenu_onmouseup(evt) {
//get the event in a cross-browser fashion
evt = (evt) ? evt : ((event) ? event : null);
// notify our parent (if one exists) of this event
if(this.getParent() != null && typeof this.getParent().onmouseup == "function") {
this.getParent().onmouseup(evt);
}
// notify observers of this event
this.getObservers().notify(CMenu_onmouseup);
}
function CMenu_onkeypress(evt) {
//get the event in a cross-browser fashion
evt = (evt) ? evt : ((event) ? event : null);
var menu = this.tbMenu;
if (typeof menu == "object") {
// down arrow, select the first enabled item or close the menu if there aren't any enabled menu items
if (evt.keyCode == 40) {
var bMenuItemEnabled = false;
for(var i = 0; i < menu.m_menuItems.length; i++) {
var menuItem = menu.m_menuItems[i];
if ( typeof menuItem.isVisible == "function" && menuItem.isVisible() &&
typeof menuItem.setFocus == "function") {
menuItem.setFocus();
bMenuItemEnabled = true;
break;
}
}
if (!bMenuItemEnabled) {
menu.hide();
}
}
// up arrow, simply hide the menu
if (evt.keyCode == 38) {
menu.hide();
}
}
// notify our parent (if one exists) of this event
if(typeof this.getParent == "function" && this.getParent() != null && typeof this.getParent().onkeypress == 'function') {
this.getParent().onkeypress(evt);
}
// notify observers of this event
if (typeof this.getObservers == "function") {
this.getObservers().notify(CMenu_onkeypress);
}
}
function CMenu_getForceCallback()
{
return this.m_bForceCallback;
}
function CMenu_setForceCallback(forceCallback)
{
this.m_bForceCallback = forceCallback;
}
CMenu.prototype.draw = CMenu_draw;
CMenu.prototype.updateCoords = CMenu_updateCoords;
CMenu.prototype.add = CMenu_add;
CMenu.prototype.get = CMenu_get;
CMenu.prototype.getNumItems = CMenu_getNumItems;
CMenu.prototype.hide = CMenu_hide;
CMenu.prototype.hideHiddenIframe = CMenu_hideHiddenIframe;
CMenu.prototype.removeHiddenIframe = CMenu_removeHiddenIframe;
CMenu.prototype.show = CMenu_show;
CMenu.prototype.enable = CMenu_enable;
CMenu.prototype.disable = CMenu_disable;
CMenu.prototype.getState = CMenu_getState;
CMenu.prototype.clear = CMenu_clear;
CMenu.prototype.attachEvents = CMenu_attachEvents;
CMenu.prototype.setParent = CMenu_setParent;
CMenu.prototype.getParent = CMenu_getParent;
CMenu.prototype.getHTMLContainer = CMenu_getHTMLContainer;
CMenu.prototype.setHTMLContainer = CMenu_setHTMLContainer;
CMenu.prototype.getHTMLDiv = CMenu_getHTMLDiv;
CMenu.prototype.create = CMenu_create;
CMenu.prototype.remove = CMenu_remove;
CMenu.prototype.getId = CMenu_getId;
CMenu.prototype.isVisible = CMenu_isVisible;
CMenu.prototype.setStyle = CMenu_setStyle;
CMenu.prototype.getStyle = CMenu_getStyle;
CMenu.prototype.closeSubMenus = CMenu_closeSubMenus;
CMenu.prototype.closeAllMenus = CMenu_closeAllMenus;
CMenu.prototype.setXCoord = CMenu_setXCoord;
CMenu.prototype.setYCoord = CMenu_setYCoord;
CMenu.prototype.setZIndex = CMenu_setZIndex;
CMenu.prototype.update = new Function("return true");
CMenu.prototype.registerCallback = CMenu_registerCallback;
CMenu.prototype.executeCallback = CMenu_executeCallback;
CMenu.prototype.getObservers = CMenu_getObservers;
CMenu.prototype.onmouseover = CMenu_onmouseover;
CMenu.prototype.onmouseout = CMenu_onmouseout;
CMenu.prototype.onmouseup = CMenu_onmouseup;
CMenu.prototype.onkeypress = CMenu_onkeypress;
CMenu.prototype.createHiddenIFrame = CMenu_createHiddenIFrame;
CMenu.prototype.setForceCallback = CMenu_setForceCallback;
CMenu.prototype.getForceCallback = CMenu_getForceCallback;
CMenu.prototype.setFocus = CMenu_setFocus;
CMenu.prototype.genARIATags = CMenu_genARIATags;
CMenu.prototype.setAltText = CMenu_setAltText;
CMenu.prototype.getAltText = CMenu_getAltText;
CMenu.prototype.genMenuAltText = CMenu_genMenuAltText;
CMenu.prototype.setLoadingMenuItem = CMenu_setLoadingMenuItem;
CMenu.prototype.getLoadingMenuItem = CMenu_getLoadingMenuItem;
function updateIframeCoords(id, containerId, isNS7)
{
if (g_ownerDocument == null) {
return;
}
var container = g_ownerDocument.getElementById(containerId);
var hiddenIframeElement = g_ownerDocument.getElementById(id);
if (hiddenIframeElement && container) {
if(isNS7 == true) {
hiddenIframeElement.style.left = container.offsetLeft + "px";
hiddenIframeElement.style.top = container.offsetTop + "px";
hiddenIframeElement.style.width = container.offsetWidth + "px";
hiddenIframeElement.style.height = container.offsetHeight + "px";
} else {
hiddenIframeElement.style.pixelLeft = container.offsetLeft;
hiddenIframeElement.style.pixelTop = container.offsetTop;
hiddenIframeElement.style.pixelWidth = container.offsetWidth;
hiddenIframeElement.style.pixelHeight = container.offsetHeight;
}
}
}
// Copyright (C) 2008 Cognos Incorporated. All rights reserved.
// Cognos (R) is a trademark of Cognos Incorporated.
/*
Class CIcon
todo : Add commments describing class....
*/
function CIcon(iconPath, toolTip, webContentRoot) {
this.m_iconPath = iconPath;
this.m_toolTip = toolTip;
this.m_enabled = true;
// The UI framework defaults the icon width/height to 16. If you need to change this, call setHeight and/or setWidth
this.m_height = 16;
this.m_width = 16;
if (typeof webContentRoot != "undefined" && webContentRoot != "")
{
this.m_webContentRoot = webContentRoot;
}
else
{
this.m_webContentRoot = "..";
}
}
function CIcon_draw() {
var html="";
html += ' 0) {
html += this.m_toolTip;
}
html += '" alt="';
if(typeof this.m_toolTip == "string" && this.m_toolTip.length > 0) {
html += this.m_toolTip;
}
html += '" width="';
html += this.m_width;
html += '" height="';
html += this.m_height;
html += '"/>';
} else {
html += this.m_webContentRoot + '/common/images/spacer.gif';
html += '" alt=""';
if (this.m_iconPath == "blankIcon")
{
html += ' width="';
html += this.m_width;
html += '" height="';
html += this.m_height;
html += '"/>';
}
else
{
html += ' width="1" height="1"/>';
}
}
return html;
}
function CIcon_getDisabledImagePath() {
var imagePathArray = this.m_iconPath.split('/');
var iconPath="";
for(var i = 0; i < (imagePathArray.length -1); ++i) {
iconPath += imagePathArray[i] + '/';
}
iconPath += 'dis_' + imagePathArray[imagePathArray.length-1];
return iconPath;
}
function CIcon_getPath() {
return this.m_iconPath;
}
function CIcon_setPath(path) {
this.m_iconPath = path;
}
function CIcon_getToolTip() {
return this.m_toolTip;
}
function CIcon_setToolTip(toolTip) {
this.m_toolTip = toolTip;
}
function CIcon_enable() {
this.m_enabled = true;
}
function CIcon_disable() {
this.m_enabled = false;
}
function CIcon_isEnabled() {
return this.m_enabled;
}
function CIcon_setHeight(height) {
this.m_height = height;
}
function CIcon_getHeight() {
return this.m_height;
}
function CIcon_setWidth(width) {
this.m_width = width;
}
function CIcon_getWidth() {
return this.m_width;
}
CIcon.prototype.draw = CIcon_draw;
CIcon.prototype.enable = CIcon_enable;
CIcon.prototype.disable = CIcon_disable;
CIcon.prototype.isEnabled = CIcon_isEnabled;
CIcon.prototype.getDisabledImagePath = CIcon_getDisabledImagePath;
CIcon.prototype.getPath = CIcon_getPath;
CIcon.prototype.setPath = CIcon_setPath;
CIcon.prototype.setHeight = CIcon_setHeight;
CIcon.prototype.getHeight = CIcon_getHeight;
CIcon.prototype.setWidth = CIcon_setWidth;
CIcon.prototype.getWidth = CIcon_getWidth;
CIcon.prototype.getToolTip = CIcon_getToolTip;
CIcon.prototype.setToolTip = CIcon_setToolTip;
// Copyright (C) 2008 Cognos Incorporated. All rights reserved.
// Cognos (R) is a trademark of Cognos Incorporated.
/*-----------------------------------------------------------------------------------------------------
Class : CBar
Description :
-----------------------------------------------------------------------------------------------------*/
var cHorizonalBar = 0;
var cVerticalBar = 1;
function CBar(containerId, style, sId, imagePath, showTooltip, hideTooltip, cookieVar, cookieName) {
this.m_align = 'left';
this.m_items = [];
this.m_htmlContainerId = containerId;
this.m_htmlContainer = null;
this.m_id = 'cbar'+containerId;
this.m_menuType = cVerticalBar;
this.m_style = style;
this.m_parent = null;
this.m_observers = new CObserver(this);
this.m_cookieVar = cookieVar;
this.m_cookieName = cookieName;
//reference to the object name
this.m_sId = (sId) ? sId : null;
this.m_display = DISPLAY_INLINE;
this.m_imagePath = (imagePath) ? imagePath : '../common/images/toolbar/';
this.m_imgCollapseSrc = this.m_imagePath + 'toolbar_collapse.gif';
this.m_imgExpandSrc = this.m_imagePath + 'toolbar_expand.gif';
this.m_showTooltip = showTooltip ? showTooltip : null;
this.m_hideTooltip = hideTooltip ? hideTooltip : null;
}
function CBar_hideBar() {
var bar = document.getElementById('bar'+ this.m_id);
var barToggleIcon = document.getElementById('barIcon'+ this.m_id);
if(barToggleIcon)
{
barToggleIcon.src= this.m_imgExpandSrc;
if (this.m_showTooltip != null) {
barToggleIcon.alt = this.m_showTooltip;
barToggleIcon.title = this.m_showTooltip;
}
}
if(bar)
{
bar.style.display = DISPLAY_NONE;
if (typeof setQSCookie == "function") {
setQSCookie(this.m_cookieVar, this.m_cookieName, 0);
}
}
}
function CBar_showBar() {
var bar = document.getElementById('bar'+ this.m_id);
var barToggleIcon = document.getElementById('barIcon'+ this.m_id);
if(barToggleIcon)
{
barToggleIcon.src= this.m_imgCollapseSrc;
if (this.m_hideTooltip != null) {
barToggleIcon.alt = this.m_hideTooltip;
barToggleIcon.title = this.m_hideTooltip;
}
}
if(bar)
{
bar.style.display = this.m_display;
if (typeof setQSCookie == "function") {
setQSCookie(this.m_cookieVar, this.m_cookieName, 1);
}
}
}
function CBar_toggleBar(){
var bar = document.getElementById('bar'+ this.m_id);
var barDisplay = bar.style.display;
if ( (barDisplay == this.m_display) || (barDisplay==""))
{
this.hideBar();
}
else
{
this.showBar();
}
}
function CBar_getParent() {
return this.m_parent;
}
function CBar_setParent(parent) {
this.m_parent = parent;
}
function CBar_draw() {
if(this.m_htmlContainer == null) {
this.m_htmlContainer = document.getElementById(this.m_htmlContainerId);
if(this.m_htmlContainer == null) { // if we can't find the container, return
return;
}
}
var html = "";
html += '
';
/*The height of 26 is chosen so that the collapse/expand icons will always line up in Firefox. Bug #483255*/
html += '
';
}
else
{
var marginStyle = "";
if (this.m_htmlContainer.style.textAlign == "right") {
marginStyle = 'margin-left:auto; margin-right: 0;';
}
else if (this.m_htmlContainer.style.textAlign == 'left') {
marginStyle = 'margin-left:0; margin-right: auto;';
}
else if (this.m_htmlContainer.style.textAlign == 'center') {
marginStyle = 'margin-left:auto; margin-right: auto;';
}
if (marginStyle != "") {
html += ' style="'+marginStyle+'"';
}
html += '>
';
}
html += '
';
html += '
';
html += this.drawItems();
html += '
';
html += '
';
this.m_htmlContainer.innerHTML = html;
this.m_htmlContainer.style.textAlign = this.m_align;
//initialize any items
for(var i = 0; i < this.m_items.length; ++i) {
if(typeof this.m_items[i].init == "function")
{
this.m_items[i].init();
}
}
this.attachEvents();
}
function CBar_drawItems() {
var html = "";
for(var i = 0; i < this.m_items.length; ++i) {
if(typeof this.m_items[i].draw == "function") {
if(this.m_menuType == cHorizonalBar && !(this.m_items[i] instanceof CSeperator) ) {
html += '
';
}
if(this.m_items[i].isVisible()) {
html += this.m_items[i].draw();
}
if(this.m_menuType == cHorizonalBar && !(this.m_items[i] instanceof CSeperator) ) {
html += '
';
}
}
}
return html;
}
function CBar_attachEvents() {
for(var i = 0; i < this.m_items.length; ++i) {
if(typeof this.m_items[i].attachEvents == "function" && this.m_items[i].isVisible()) {
this.m_items[i].attachEvents();
}
}
}
function CBar_add(item) {
if(typeof item.getObservers == "function" && typeof item.getObservers() == "object" && typeof item.onmouseover == "function" && item instanceof CMenuItem) {
item.getObservers().attach(this, this.closeMenus, item.onmouseover);
}
this.m_items[this.m_items.length] = item;
}
function CBar_getNumItems() {
return this.m_items.length;
}
function CBar_getId() {
return this.m_id;
}
function CBar_get(index) {
if(index >= 0 && index < this.getNumItems()) {
return this.m_items[index];
}
return null;
}
function CBar_hide(index) {
if(index > 0 && index < this.getNumItems()) {
if(typeof this.m_items[i].hide == "function") {
this.m_items[i].hide();
}
}
}
function CBar_show(index) {
if(index > 0 && index < this.getNumItems()) {
if(typeof this.m_items[i].show == "function") {
this.m_items[i].show();
}
}
}
function CBar_enable(index) {
if(index > 0 && index < this.getNumItems()) {
if(typeof this.m_items[i].enable == "function") {
this.m_items[i].enable();
}
}
}
function CBar_disable(index) {
if(index > 0 && index < this.getNumItems()) {
if(typeof this.m_items[i].disable == "function") {
this.m_items[i].disable();
}
}
}
function CBar_getState(index) {
if(index > 0 && index < this.getNumItems()) {
if(typeof this.m_items[i].getState == "function") {
this.m_items[i].getState();
}
}
}
function CBar_setMenuType(menuType) {
this.m_menuType = menuType;
}
function CBar_getMenuType() {
return this.m_menuType;
}
function CBar_setStyle(style) {
this.m_style = style;
}
function CBar_setAlign(align) {
this.m_align = align;
}
function CBar_getStyle() {
return this.m_style;
}
function CBar_closeMenus(state) {
// make sure we hide any submenus which have been opened.
for(var i = 0; i < this.getNumItems(); i++) {
var currentItem = this.get(i);
if(typeof state == "object") {
if(state.getSubject() == currentItem) {
continue;
}
}
if(typeof currentItem.getMenu == "function" && currentItem.getMenu() != null && currentItem.getMenu().isVisible()) {
currentItem.getMenu().remove();
}
}
}
function CBar_getHTMLContainer() {
return this.m_htmlContainer;
}
function CBar_getObservers() {
return this.m_observers;
}
function CBar_onmouseover(evt) {
//get the event in a cross-browser fashion
evt = (evt) ? evt : ((event) ? event : null);
// notify our parent (if one exists) of this event
if(this.getParent() != null && typeof this.getParent().onmouseover == "function") {
this.getParent().onmouseover(evt);
}
// notify observers of this event
this.getObservers().notify(CBar_onmouseover);
}
function CBar_onmouseout(evt) {
//get the event in a cross-browser fashion
evt = (evt) ? evt : ((event) ? event : null);
// notify our parent (if one exists) of this event
if(this.getParent() != null && typeof this.getParent().onmouseout == "function") {
this.getParent().onmouseout(evt);
}
// notify observers of this event
this.getObservers().notify(CBar_onmouseout);
}
function CBar_onmouseup(evt) {
//get the event in a cross-browser fashion
evt = (evt) ? evt : ((event) ? event : null);
// notify our parent (if one exists) of this event
if(this.getParent() != null && typeof this.getParent().onmouseup == "function") {
this.getParent().onmouseup(evt);
}
// notify observers of this event
this.getObservers().notify(CBar_onmouseup);
}
function CBar_onkeypress(evt) {
//get the event in a cross-browser fashion
evt = (evt) ? evt : ((event) ? event : null);
// notify our parent (if one exists) of this event
if(this.getParent() != null && typeof this.getParent().onkeypress == "function") {
this.getParent().onkeypress(evt);
}
// notify observers of this event
this.getObservers().notify(CBar_onkeypress);
}
CBar.prototype.draw = CBar_draw;
CBar.prototype.add = CBar_add;
CBar.prototype.get = CBar_get;
CBar.prototype.hide = CBar_hide;
CBar.prototype.show = CBar_show;
CBar.prototype.enable = CBar_enable;
CBar.prototype.disable = CBar_disable;
CBar.prototype.getState = CBar_getState;
CBar.prototype.attachEvents = CBar_attachEvents;
CBar.prototype.drawItems = CBar_drawItems;
CBar.prototype.getId = CBar_getId;
CBar.prototype.setMenuType = CBar_setMenuType;
CBar.prototype.getMenuType = CBar_getMenuType;
CBar.prototype.getNumItems = CBar_getNumItems;
CBar.prototype.setStyle = CBar_setStyle;
CBar.prototype.getStyle = CBar_getStyle;
CBar.prototype.setAlign = CBar_setAlign;
CBar.prototype.closeMenus = CBar_closeMenus;
CBar.prototype.setParent = CBar_setParent;
CBar.prototype.getParent = CBar_getParent;
CBar.prototype.getHTMLContainer = CBar_getHTMLContainer;
CBar.prototype.getObservers = CBar_getObservers;
CBar.prototype.update = new Function("return true");
CBar.prototype.getObservers = CBar_getObservers;
CBar.prototype.onmouseover = CBar_onmouseover;
CBar.prototype.onmouseout = CBar_onmouseout;
CBar.prototype.onmouseup = CBar_onmouseup;
CBar.prototype.onkeypress = CBar_onkeypress;
CBar.prototype.hideBar = CBar_hideBar;
CBar.prototype.showBar = CBar_showBar;
CBar.prototype.toggleBar = CBar_toggleBar;
/*
Class CStaticText
Static text to be shown in the banner or header
*/
function CStaticText(text, style)
{
this.m_text = text;
this.m_style = style;
this.m_bVisible = true;
this.m_sId = "";
}
CStaticText.prototype.setId = function(sId)
{
this.m_sId = sId;
};
CStaticText.prototype.getId = function()
{
return this.m_sId;
};
CStaticText.prototype.setText = function(text)
{
this.m_text = text;
};
CStaticText.prototype.setLabelledBy = function(text)
{
this.m_labelledBy = text;
};
CStaticText.prototype.draw = function()
{
var html="";
html += '
';
var labelledByAttribute = this.m_labelledBy ? 'aria-labelledby="' + this.getId() + 'label"' : "";
html += '