123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543 |
- // 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('<html><head></head><body></body></html>');
- 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<alen;i++)
- {
- if(arr[i].type == "ContextItem")
- {
- tmpobj=doc.createElement("DIV");
- tmpobj.style.whitespace = "nowrap";
- tmpobj.className = "PP-ContextMenu-Item";
- var el;
- span_outer = doc.createElement("SPAN");
- el = doc.createElement("NOBR");
- if (this.toolbarPopup) {
- if (arr[i].disabled)
- span_outer.className = "PP-ContextMenu-DisabledContainer";
- insertIMGNode(el, arr[i].image, "ContextMenu-Image", [], doc);
- }
- el.appendChild(doc.createTextNode(" " + arr[i].text));
- span_outer.appendChild(el);
- tmpobj.appendChild(span_outer);
- if (!arr[i].disabled) {
- tmpobj.onclick = (function (f)
- {
- return function () {
- theDoc.getElementById("PP_ContextPopUp").style.visibility = "hidden";
- ContextMenu.restoreActionPaneSize();
- if (typeof(f)=="function"){ f(); }
- };
- })(arr[i].action);
- tmpobj.onmouseover = function(){this.className="PP-ContextMenu-Over"}
- tmpobj.onmouseout = function(){this.className="PP-ContextMenu-Item"}
- } else {
- tmpobj.className = "PP-ContextMenu-Disabled-item";
- tmpobj.onmouseover = function(){this.className="PP-ContextMenu-Disabled-Over"}
- tmpobj.onmouseout = function(){this.className="PP-ContextMenu-Disabled-item"}
- }
- menuDiv.appendChild(tmpobj);
- }
- else if (arr[i].type == "BannerMenuItem")
- {
- tmpobj=doc.createElement("DIV");
- tmpobj.className = "BannermenuItemNormal";
- var el = doc.createElement("NOBR");
- if (arr[i].image != '') {
- insertIMGNode(el, arr[i].image, "BannermenuItemIcon", [], doc);
- } else {
- insertIMGNode(el, topparent.getGlobal("imgPath") + "blank.gif", "BannermenuItemSpacer", [], doc);
- }
- el.appendChild(doc.createTextNode(arr[i].text));
- insertIMGNode(el, topparent.getGlobal("imgPath") + "blank.gif", "BannermenuItemSpacer", [], doc);
- tmpobj.appendChild(el);
- tmpobj.onclick = (function (f)
- {
- return function () {
- theDoc.getElementById("PP_ContextPopUp").style.visibility = "hidden";
- if (typeof(f)=="function"){ f(); }
- };
- })(arr[i].action);
- tmpobj.onmouseover = function(){this.className="BannermenuItemOver"}
- tmpobj.onmouseout = function(){this.className="BannermenuItemNormal"}
- menuDiv.appendChild(tmpobj);
- }
- else if (arr[i].type == "ContextSeparator")
- {
- menuDiv.appendChild(doc.createElement("DIV")).className = "PP-ContextMenu-Separator";
- }
- else if (arr[i].type == "BannerMenuDivider")
- {
- menuDiv.appendChild(doc.createElement("DIV")).className = "BannerflyOutMenuSeparator";
- }
- else if (arr[i].type == "ContextImageItem")
- {
- if (!horizontal) {
- horizontal = true;
- menuDiv.appendChild(doc.createElement("NOBR"));
- }
-
- var img = insertIMGNode(menuDiv.firstChild, arr[i].image, "ContextMenu-ImageItem", [new attrib("title",arr[i].tooltip)], doc);
- if (!arr[i].disabled) {
- img.onmouseover = new Function("this.className = 'ContextMenu-ImageItemRollover';");
- img.onmouseout = new Function("this.className = 'ContextMenu-ImageItem';");
- img.onclick = (function (f)
- {
- return function () {
- theDoc.getElementById("PP_ContextPopUp").style.visibility = "hidden";
- if (typeof(f)=="function"){ f(); }
- };
- })(arr[i].action);
- }
- }
- }
-
- if (bannerPopDown)
- doc.body.className = "BannerflyOutMenu";
- else if (!horizontal)
- doc.body.className = "PP-ContextMenu-Body";
- else
- doc.body.className = "PP-ContextMenu-Body-horizontal";
-
- menuDiv.setAttribute("horizontal",(horizontal)?"true":"false");
-
- doc.body.onselectstart = function(){return false;}
- }
- function ContextItem(image,str,fnc,disabled)
- {
- if (image == '') {
- this.toolbarPopup = false;
- }
- else {
- this.toolbarPopup = true;
- if (!image) {
- image = "empty.gif";
- alert(image);
- }
- this.image = topparent.getGlobal("toolbarMenuIconPath") + image;
- }
- this.text = str;
- this.action = fnc;
- this.disabled = disabled || false;
- }
- ContextItem.prototype.type = "ContextItem";
- function ContextSeparator()
- {
- this.toolbarPopup = false;
- }
- ContextSeparator.prototype.type = "ContextSeparator";
- function ContextImageItem(image,fnc,tooltip,disabled)
- {
- this.image = image;
- this.action = fnc;
- this.disabled = disabled || false;
- this.tooltip = tooltip;
- }
- ContextImageItem.prototype.type = "ContextImageItem";
- function BannerMenuItem(image,str,func) {
- this.image = image;
- this.text = str;
- this.action = func;
-
- this.bannerPopDown = true;
- }
- BannerMenuItem.prototype.type = "BannerMenuItem";
- function BannerMenuDivider() {}
- BannerMenuDivider.prototype.type = "BannerMenuDivider";
- function hidePopupMenu(targetDoc) {
- var doc;
- if (!targetDoc)
- doc = theDoc;
- else
- doc = targetDoc;
-
- var popUp = doc.getElementById("PP_ContextPopUp");
- if (popUp) {
- ContextMenu.clearPopup();
- popUp.style.visibility = "hidden";
- }
- }
|