// Licensed Materials - Property of IBM // // IBM Cognos Products: pps // // (C) Copyright IBM Corp. 2005, 2017 // // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. var jtree = false; var toolbarPopup = false; var bannerPopDown = false; var forContextMenu = false; var ownerFrame = null; var theDoc = null; var theWindow = null; var PP_ContextPopUpcss = null; var PP_ContextPopUpDoc = null; var BODY_BORDER_AND_SHADING = 4; var BANNER_BODY_BORDER_AND_SHADING = 6; var BANNER_MENU_MIN_WIDTH = 80; var NETSCAPE_SCROLL_WIDTH = 15; ContextMenu.initialize = function(skipXtabFrame, skipCreate) { var id = "PP_ContextPopUp"; if (skipXtabFrame) { theDoc = document; theWindow = window; } else { ownerFrame = topparent.frames[window.name]; if (!ownerFrame) { if (window.name == "Crosstab") ownerFrame = topparent.getXtabFrame(); else if (window.name == "Chart") ownerFrame = topparent.getChartFrame(); } if (toolbarPopup == true) { var actPaneHeight = topparent.document.getElementById("rightFrameset").rows; actPaneHeight = actPaneHeight.substring(actPaneHeight.indexOf(",") + 1,actPaneHeight.lastIndexOf(",")); ownerFrame = topparent.getXtabFrame(); if(parseInt(actPaneHeight) > 0) ownerFrame = topparent.getActionFrame(); } else if (bannerPopDown == true) { ownerFrame = topparent.getXtabFrame(); if (ownerFrame.isSplitDisplay()) ownerFrame = topparent.getChartFrame(); } if(ownerFrame.window.frames[id] == null) skipCreate = false; theDoc = ownerFrame.document; theWindow = ownerFrame.window; } if ( theDoc.getElementById(id).contentWindow ) PP_ContextPopUpDoc = theDoc.getElementById(id).contentWindow.document; // IE, NS else PP_ContextPopUpDoc = theDoc.getElementById(id).contentDocument; // W3C, i.e., Safari, NS PP_ContextPopUpcss = theDoc.getElementById(id); if (!skipCreate) { if (!theDoc.body.onmousedown) { theDoc.body.onmousedown = function(){PP_ContextPopUpcss.style.visibility = "hidden"}; } if (!theWindow.onmousedown) theWindow.onmousedown = function(){PP_ContextPopUpcss.style.visibility = "hidden"}; } ContextMenu.initializeDoc(); } function ContextMenu(){} ContextMenu.display=function(event, popupoptions, contextMenu) { var eventM = new eventManager(event); if (!jtree) ContextMenu.initialize(false,true); var x,y; if (eventM.theEvent == null) return; if (toolbarPopup) { var button = eventM.getSrc(); if (button.id.indexOf("menu_") == 0) x = button.previousSibling.offsetLeft; else x = button.offsetLeft; } else if (bannerPopDown) { var button = eventM.getSrc(); while (button.tagName != "TD") button = button.parentNode; if (button.getAttribute("menubutton") == "true") { button = button.previousSibling; } x = getPageOffsetLeft(button) - topparent.getXtabFrameOffsetLeft(); } else x = eventM.theEvent.clientX; if (bannerPopDown) y = 0; else if (contextMenu) { y = eventM.theEvent.clientY; forContextMenu = true; }else y = 1000; ContextMenu.populatePopup(popupoptions,theWindow); //Create a wide short context menu first, so we can render and size properly PP_ContextPopUpcss.style.overflow = "auto"; PP_ContextPopUpcss.style.width = "100%"; PP_ContextPopUpcss.style.height = "0px"; var menuDiv = PP_ContextPopUpDoc.body.firstChild; menuDiv.style.width = "0px"; menuDiv.style.height = "0px"; menuDiv.style.overflow = "hidden"; //Wait 100 milliseconds to allow the browser to update its presentational information. setTimeout("ContextMenu.fixSizeAndPosition(" + x + "," + y + ");", 100); topparent.executeCrossFrameFunction( "hidePopupMenu", theWindow.name, true); eventM.cancelBubble(); } ContextMenu.fixSizeAndPosition=function(x,y) { if (!isLoadingImages()) { ContextMenu.fixSize(); //If the action pane is not large enough to hold the flyout, temporarily resize it if (toolbarPopup) ContextMenu.resizeActionPane(); ContextMenu.fixPos(x,y); PP_ContextPopUpcss.style.visibility = 'visible'; } else { setTimeout("ContextMenu.fixSizeAndPosition(" + x + "," + y + ");", 100); } } ContextMenu.setActionPaneSize=function(x) { var actPaneHeight = topparent.document.getElementById("rightFrameset").rows; var rows = actPaneHeight.substring(0,actPaneHeight.indexOf(",") + 1); rows += x; rows += actPaneHeight.substring(actPaneHeight.lastIndexOf(",")); topparent.document.getElementById("rightFrameset").rows = rows; } ContextMenu.setSplitViewXtabFrameSize=function(x) { //We can't use a * for the chart size because the browser will sometimes simply //Set the chart frame to size 0 and hide ths chart alltoghether. So we will attempt to //Extrapolate a reasonable percentage value. var splitViewFrameset = topparent.Data.document.getElementById("dataArea"); if (splitViewFrameset && splitViewFrameset.childNodes.length > 1) { var xtabFrameSize = splitViewFrameset.lastChild.offsetHeight; var chartFrameSize = splitViewFrameset.firstChild.offsetHeight; var newChartFrameSize = chartFrameSize - (x - xtabFrameSize); //Adjust the chart framesize. var newXtabFrameSize = x; if (newChartFrameSize <= 0) { newXtabFrameSize -= ((0 - newChartFrameSize) + 10) newChartFrameSize = 10; } topparent.Data.document.getElementById("dataArea").rows = newChartFrameSize + "," + newXtabFrameSize; } } ContextMenu.resizeActionPane=function() { var actPaneHeight = topparent.document.getElementById("rightFrameset").rows; var actionPaneSize = actPaneHeight.substring(actPaneHeight.indexOf(",") + 1,actPaneHeight.lastIndexOf(",")); if (actionPaneSize > 0 && actionPaneSize < PP_ContextPopUpcss.offsetHeight) { var height = PP_ContextPopUpcss.offsetHeight + 20; //Add 20px for scrollbars ContextMenu.setActionPaneSize(height); if (!PP_ContextPopUpDoc.body.getAttribute("APprefferedSize") || !parseInt(PP_ContextPopUpDoc.body.getAttribute("APprefferedSize"))) PP_ContextPopUpDoc.body.setAttribute("APprefferedSize",actionPaneSize); } //We may also have to resize the crosstab portion of the split view var splitViewFrameset = topparent.Data.document.getElementById("dataArea"); if (splitViewFrameset && splitViewFrameset.childNodes.length > 1) { var xtabFrameSize = splitViewFrameset.lastChild.offsetHeight; if (xtabFrameSize > 0 && xtabFrameSize < PP_ContextPopUpcss.offsetHeight) { var height = PP_ContextPopUpcss.offsetHeight + 20; //Add 20px for scrollbars ContextMenu.setSplitViewXtabFrameSize(height); } } } //TODO ContextMenu.getScrollTop=function() { return theDoc.body.scrollTop; //window.pageXOffset and window.pageYOffset for moz } ContextMenu.getScrollLeft=function() { return theDoc.body.scrollLeft; } ContextMenu.fixPos=function(x,y) { var docheight,docwidth,dh,dw; if (theWindow.innerHeight) { docheight = theWindow.innerHeight; docwidth = theWindow.innerWidth; } else { docheight = theDoc.body.offsetHeight; docwidth = theDoc.body.offsetWidth; } dh = (PP_ContextPopUpcss.offsetHeight+y) - docheight; dw = (PP_ContextPopUpcss.offsetWidth+x) - docwidth; if(dw>0) { PP_ContextPopUpcss.style.left = (x - dw) + ContextMenu.getScrollLeft() + "px"; } else { PP_ContextPopUpcss.style.left = x + ContextMenu.getScrollLeft(); } if(dh>0) { if (!topparent.getGlobal("nn7")) { if (forContextMenu) { PP_ContextPopUpcss.style.top = y + ContextMenu.getScrollTop() - PP_ContextPopUpcss.offsetHeight;; PP_ContextPopUpcss.style.bottom = ""; forContextMenu = false; } else { //Set the bottom instead of the top. PP_ContextPopUpcss.style.top = ""; PP_ContextPopUpcss.style.bottom = "0px"; } } else { PP_ContextPopUpcss.style.top = theWindow.scrollY + docheight - PP_ContextPopUpcss.offsetHeight; } } else { PP_ContextPopUpcss.style.bottom = ""; PP_ContextPopUpcss.style.top = y + ContextMenu.getScrollTop(); } } ContextMenu.fixSize=function() { var menuDiv = PP_ContextPopUpDoc.body.firstChild; if (bannerPopDown) { if (menuDiv.scrollWidth < BANNER_MENU_MIN_WIDTH) menuDiv.style.width = BANNER_MENU_MIN_WIDTH; else menuDiv.style.width = menuDiv.scrollWidth; menuDiv.style.height = menuDiv.scrollHeight; PP_ContextPopUpcss.style.height = menuDiv.scrollHeight + BANNER_BODY_BORDER_AND_SHADING; PP_ContextPopUpcss.style.width = menuDiv.scrollWidth + BANNER_BODY_BORDER_AND_SHADING; } else { if (topparent.getGlobal("nn7") && menuDiv.getAttribute("horizontal") != "true") menuDiv.style.width = menuDiv.scrollWidth + NETSCAPE_SCROLL_WIDTH; else menuDiv.style.width = menuDiv.scrollWidth; menuDiv.style.height = menuDiv.scrollHeight; PP_ContextPopUpcss.style.height = menuDiv.scrollHeight + BODY_BORDER_AND_SHADING; PP_ContextPopUpcss.style.width = menuDiv.scrollWidth + BODY_BORDER_AND_SHADING; } } ContextMenu.initializeDoc=function() { if ( typeof PP_ContextPopUpDoc == "undefined" ) { doc.clear(); doc.open(); doc.write(''); doc.close(); } else doc = PP_ContextPopUpDoc; var headtag = doc.getElementsByTagName('head')[0]; if (!headtag) headtag = doc.firstChild; var link = doc.createElement('link'); link.rel = "StyleSheet"; link.type = "text/css"; link.href = topparent.getGlobal("virtualDirRoot") + '/../skins/' + topparent.getGlobal("ppSkin") + '/ppwb/styles.css'; headtag.appendChild(link); //Remove any extra tags that were automatically inserted into the body tag. while(doc.body.childNodes.length) doc.body.removeChild(doc.body.childNodes[0]); } ContextMenu.clearPopup=function() { if (PP_ContextPopUpDoc) { var menuDiv = PP_ContextPopUpDoc.body.firstChild; if (menuDiv) { //Clean up dangling functions while (menuDiv.childNodes.length ) { menuDiv.childNodes[0].onmouseover = null; menuDiv.childNodes[0].onmouseout = null; menuDiv.childNodes[0].onclick = null; menuDiv.removeChild(menuDiv.childNodes[0]); } } } ContextMenu.restoreActionPaneSize(); } ContextMenu.restoreActionPaneSize = function() { if (PP_ContextPopUpDoc && PP_ContextPopUpDoc.body) { var actionPaneSize = PP_ContextPopUpDoc.body.getAttribute("APprefferedSize"); if (actionPaneSize) { ContextMenu.setActionPaneSize(parseInt(actionPaneSize)); PP_ContextPopUpDoc.body.setAttribute("APprefferedSize",0); } } } ContextMenu.populatePopup=function(arr,win) { var alen,tmpobj,doc,height,htmstr,span_outer,imgobj; alen = arr.length; this.alen = alen; if (arr[0].toolbarPopup) this.toolbarPopup = true; else this.toolbarPopup = false; if (arr[0].bannerPopDown) this.bannerPopDown = true; else this.bannerPopDown = false; doc = PP_ContextPopUpDoc; var menuDiv = doc.body.firstChild; var horizontal = false; if (!menuDiv) { menuDiv = doc.createElement("DIV"); doc.body.appendChild(menuDiv); } for( var i=0;i