123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: Viewer
- *| (C) Copyright IBM Corp. 2001, 2012
- *|
- *| US Government Users Restricted Rights - Use, duplication or
- *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- *|
- *+------------------------------------------------------------------------+
- */
- /**
- * Override the page click event so that mobile can show their
- * own context menu
- */
- CMainWnd.prototype.pageClicked = function(evt) {
- var oCV = this.getCV();
- var selectionController = oCV.getSelectionController();
- if (selectionController && oCV.bCanUseCognosViewerSelection == true) {
- selectionController.resetSelections();
-
- var nodeSelected = selectionController.pageClickedForMobile(evt);
- // Only show the menu in Mobile if there's something selected
- if (nodeSelected) {
-
- // If we have a bookmark drill through with no target then execute the drill through instead of showing a menu
- if (this._bookmarkDrillThrough(evt, oCV)) {
- return;
- }
-
- var contextMenu = CCognosViewerToolbarHelper.updateContextMenuForCurrentSelection(oCV, oCV.getContextMenu());
-
- this._fixGotoMenu(contextMenu);
- var containerType = selectionController.getContainerType();
-
- // if we're dealing with a chart then get the tooltip
- var chartTooltip = containerType === "chart" ? selectionController.getChartTooltip() : null;
-
- var payload = {
- "action" : "showMenu",
- "event" : evt,
- "payload" : contextMenu.length > 0 ? contextMenu : null,
- "displayValues" : selectionController.getDisplayValues(selectionController),
- "chartTooltip" : chartTooltip,
- "containerType" : containerType
- };
-
- // window.onAction is the entry point into Mobile, call them so they can show their own menu
- if (window.onAction) {
- window.onAction(payload);
- }
- else if(typeof console != "undefined") {
- // must not be in Mobile, log it to the console
- console.log(payload);
- }
- }
- }
- };
- /**
- * If the user clicked on a cell with a bookmark drill with no target report
- * then execute the drill through
- * @returns true if a drill through was executed
- */
- CMainWnd.prototype._bookmarkDrillThrough = function(evt, oCV) {
- var oDrillMgr = oCV.getDrillMgr();
- var drillThroughs = oDrillMgr.getAuthoredDrillsForCurrentSelection();
- if (drillThroughs) {
- // If we have a bookmark drill through with no target then execute the drill through instead of showing a menu
- var drillTargets = XMLHelper_FindChildrenByTagName(drillThroughs, "drillTarget", false);
- if (drillTargets && drillTargets.length == 1) {
- var drillTarget = drillTargets[0];
- var bookmarkRef = drillTarget.getAttribute("bookmarkRef");
- var path = drillTarget.getAttribute("path");
- if (bookmarkRef && bookmarkRef.length > 0 && (!path || path.length == 0)) {
- oDrillMgr.singleClickDrillEvent(evt, 'RV');
- return true;
- }
- }
- }
-
- return false;
- };
- /**
- * Override the displayContextMenu so that we call Mobile instead
- */
- CMainWnd.prototype.displayContextMenu = function(evt, selectNode) {
- if(!this.getCV().bEnableContextMenu) {
- return false;
- }
-
- this.pageClicked(evt);
- };
- /**
- * Mobile doesn't want all the drill through items in a sub-menu
- */
- CMainWnd.prototype._fixGotoMenu = function(contextMenu) {
- if (contextMenu && contextMenu.length) {
- var gotoMenuItem = null;
- var menuSize = contextMenu.length;
- var menuPosition = 0;
-
- // find the 'Goto' menu
- for (var i=0; i < menuSize; i++) {
- if (contextMenu[i].name === 'Goto') {
- menuPosition = i;
- gotoMenuItem = contextMenu.splice(i, 1);
- break;
- }
- }
-
- // Loop through all the sub-menu items and move them into the main menu
- if (gotoMenuItem && gotoMenuItem[0] && gotoMenuItem[0].items) {
- var gotoItems = gotoMenuItem[0].items;
- var gotoSize = gotoItems.length;
- for (var i=0; i < gotoSize; i++) {
- // Mobile doesn't want separators or the 'Goto' menu item
- if (!gotoItems[i].separator) {
- contextMenu.splice(menuPosition, 0, gotoItems[i]);
- menuPosition++;
- }
- }
- }
- }
- };
|