/* *+------------------------------------------------------------------------+ *| Licensed Materials - Property of IBM *| *| BI and PM: BUX *| *| (C) Copyright IBM Corp. 2009 *| *| US Government Users Restricted Rights - Use, duplication or *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp. *| *+------------------------------------------------------------------------+ */ // create script variables used to store TM1 callbacks var COGNOS_TM1_cubeWgtToolbarFuncs; var COGNOS_TM1_cubeWgtFilterFuncs; dojo.require("dojo.string"); dojo.require("dojo._base.array"); dojo.require("bux.i18n"); dojo.require("bux.Helper"); dojo.require("bux.data.UserPreferencesStore"); dojo.provide("tm1ContentCubeViewerWidget"); dojo.declare("tm1ContentCubeViewerWidget", null, { iframeCtrl: null, _paramgizmo_id: null, returnURL: null, initialHeight: 286, xmlhttp: null, commonDomain: null, bTurnOffCallbacks: false, tm1Toolbar: null, _currentRole: null, // ====== DefaultSize Support - Start ======== _defaultWidth:700, _defaultHeight:400, _firstRender:true, // ====== DefaultSize Support - End ======== // ====== Multilingual Support - Start ======== _productLocale:null, _tm1messages:null, // ====== Multilingual Support - End ======== _firstVisible:false, onSetVisible: function(evt) { if(!this._firstVisible && evt.payload.isVisible) { this._firstVisible = true; } }, onLoad: function(evt) { if(!this._firstVisible && this.iContext._mm.widget.widgetInstance.itemSets.buxdelayedload.widgetVisible.value == "false") { setTimeout(dojo.hitch(this, this.onLoad), 50); return; } this._firstVisible = true; // ====== Multilingual Support - Start ======== // Remember where we were loaded from: this is our path for future AJAX calls and .js loads dojo.registerModulePath("tm1ContentCubeViewerWidget",this.iContext.io.rewriteURI("js")); this.setLanguage().then(dojo.hitch(this, "continueOnLoad")); // ====== Multilingual Support - End ======== }, continueOnLoad: function() { this.getRole(); this.createBasicWidgetToolbar(); this.getWidgetAttributes(); if (this.areTM1ParametersValid ()) { this.refreshView(); } else { this.onGetProperties(null, true); } // ====== DefaultSize Support - Start ======== //Delay the creation of some dynamic content to allow the widget to render first, //otherwise the dojo controlscannot properly render within its allowed real-estate. setTimeout(dojo.hitch(this,this.postLoadInit),1); // ====== DefaultSize Support - End ======== }, // ====== DefaultSize Support - Start ======== postLoadInit: function() { // In this function, create the dynamic contents of the iWidget that are dojo objects based on dynamic HTML // call auto resize if it's the first time and is this widget was never saved. if (this._firstRender == true) { this._firstRender = false; var setDefaultSize = this.iContext.getiWidgetAttributes().getItemValue("setDefaultSize"); if (setDefaultSize == "1") { // Next time the container dashboard loads, the default size must be ignored - as desired this.iContext.getiWidgetAttributes().setItemValue("setDefaultSize", "0"); this.setPreferredSize(); } } }, getChrome: function() { var chromeObjectId = bux.Helper.widgetIdToChromeId(this.iContext.widgetId); var chromeObject = bux.Helper.getChromeById(chromeObjectId); return chromeObject; }, setPreferredSize: function() { var chromeObject = this.getChrome(); var newSize = {h: this._defaultHeight, w : this._defaultWidth}; chromeObject.setPreferredSize(newSize); chromeObject.doChromeAutoResize(); }, // ====== DefaultSize Support - End ======== // ====== Multilingual Support - Start ======== updateView: function() { this.setLanguage(); }, setLanguage: function() { // Setup Localization tables - Use the BUX preferences for locale. Use Product locale for loading strings var curProductLocale=bux.Helper.getUserPreference("productLocale"); if (this._productLocale != curProductLocale) { this._productLocale = curProductLocale; var deferred = new dojo.Deferred(); var self = this; dojo.requireLocalization("tm1ContentCubeViewerWidget", "tm1ContentCubeViewerWidget_msg", curProductLocale); dojo.ready(function() { self._tm1messages = dojo.i18n.getLocalization("tm1ContentCubeViewerWidget", "tm1ContentCubeViewerWidget_msg", curProductLocale); deferred.resolve(); }); return deferred; } }, // ====== Multilingual Support - End ======== getRole: function () { if( this.iContext ) { var userProfileItemSet = this.iContext.getItemSet("buxuserprofile", false); if( userProfileItemSet ){ var role = userProfileItemSet.getItemValue("currentUserRole"); if( role && bux.UserRole.isValidRole(role) ) { this._currentRole = role; } } } }, createBasicWidgetToolbar: function () { if (this.bTurnOffCallbacks) { var toolbarItems = [ { _root: [ {separator: true }, {name: "Restart", action: "IDM_RESTART", label: this._tm1messages.MEN.TMX_MEN_BLUEDOT_RESTART, showLabel: false, "iconClass": "tutorial-toolbar-icon-canada"} ] } ]; this.iContext.iEvents.fireEvent("com.ibm.bux.widgetchrome.toolbar.init", null, toolbarItems); } else { var toolbarItems = [ { _root: [ {separator: true }, {name: "Refresh", action: "IDM_RECALCULATE", label: this._tm1messages.MEN.TMX_MEN_BLUEDOT_REFRESH, showLabel: false, "iconClass": "bux-refresh-image"}, {name: "Reset", action: "IDM_RESET", label: this._tm1messages.MEN.TMX_MEN_BLUEDOT_RESET, showLabel: false, "iconClass": "tutorial-toolbar-icon-canada"}, {name: "Restart", action: "IDM_RESTART", label: this._tm1messages.MEN.TMX_MEN_BLUEDOT_RESTART, showLabel: false, "iconClass": "tutorial-toolbar-icon-canada"} ] } ]; this.iContext.iEvents.fireEvent("com.ibm.bux.widgetchrome.toolbar.init", null, toolbarItems); } }, fireFilterChanged: function (dimName, subsetName, elemName) { var extraParams = "title_"; extraParams += dimName; extraParams += "="; extraParams += encodeURIComponent(elemName); this.iContext.iEvents.fireEvent("Context filter change", null, extraParams); }, createWidgetToolbar: function (inToolbar) { var temptoolbarItems; this.tm1Toolbar = inToolbar; var toolbarItems = [ { _root: [ {separator: true }, {name: "Refresh", action: "IDM_RECALCULATE", label: this._tm1messages.MEN.TMX_MEN_BLUEDOT_REFRESH, showLabel: false, "iconClass": "bux-refresh-image"}, {name: "Reset", action: "IDM_RESET", label: this._tm1messages.MEN.TMX_MEN_BLUEDOT_RESET, showLabel: false, "iconClass": "tutorial-toolbar-icon-canada"}, {name: "Restart", action: "IDM_RESTART", label: this._tm1messages.MEN.TMX_MEN_BLUEDOT_RESTART, showLabel: false, "iconClass": "tutorial-toolbar-icon-canada"} ] } ]; toolbarItems = this.addToolbutton(toolbarItems, "IDM_COMMIT"); toolbarItems = this.addToolbutton(toolbarItems, "IDM_SAVEVIEW"); toolbarItems = this.addToolbutton(toolbarItems, "IDM_SAVEAS"); toolbarItems = this.addToolbuttonWithSubmenu (toolbarItems, "IDM_EXPORT"); toolbarItems = this.addSeparator(toolbarItems); toolbarItems = this.addToolbutton(toolbarItems, "IDM_SAVEDATACHANGES"); toolbarItems = this.addToolbutton(toolbarItems, "IDM_REVIEWDATACHANGES"); toolbarItems = this.addSeparator(toolbarItems); toolbarItems = this.addToolbutton(toolbarItems, "IDM_RECALCULATE"); toolbarItems = this.addToolbutton(toolbarItems, "IDM_TOGGLE_AUTOMATICRECALCULATE"); toolbarItems = this.addToolbuttonWithSubmenu (toolbarItems, "IDM_SUPPRESS_ZEROS"); toolbarItems = this.addSeparator(toolbarItems); toolbarItems = this.addToolbutton(toolbarItems, "IDM_CHART"); toolbarItems = this.addToolbutton(toolbarItems, "IDM_CHARTANDGRID"); toolbarItems = this.addToolbutton(toolbarItems, "IDM_GRID"); toolbarItems = this.addToolbuttonWithSubmenu (toolbarItems, "IDM_CHART-SELECT"); toolbarItems = this.addSeparator(toolbarItems); toolbarItems = this.addToolbutton(toolbarItems, "IDM_RESET_DATA"); toolbarItems = this.addToolbutton(toolbarItems, "IDM_SANDBOX_UNDO"); toolbarItems = this.addToolbutton(toolbarItems, "IDM_SANDBOX_REDO"); toolbarItems = this.addSeparator(toolbarItems); toolbarItems = this.addToolbuttonWithSubmenu (toolbarItems, "IDM_SANDBOX"); toolbarItems = this.addToolbuttonWithSubmenu (toolbarItems, "IDM_SANDBOXITEMS"); this.iContext.iEvents.fireEvent("com.ibm.bux.widgetchrome.toolbar.init", null, toolbarItems); }, addSeparator: function (toolbarItems) { var separator = { "separator": true }; return toolbarItems.concat(separator); }, addToolbutton: function (toolbarItems, toolbarAction) { if (this.isToolbuttonVisible(toolbarAction)) { return toolbarItems.concat(this.createSimpleToolbutton(toolbarAction)); } else { return toolbarItems; } }, addToolbuttonWithSubmenu: function (toolbarItems, toolbarAction) { if (this.isToolbuttonVisible(toolbarAction)) { return toolbarItems.concat(this.createToolbuttonWithSubmenu(toolbarAction)); } else { return toolbarItems; } }, createSimpleToolbutton: function (toolbarAction) { var toolbutton = { "name" : toolbarAction, "action" : toolbarAction, "label": this.getToolbuttonTooltip(toolbarAction), "iconClass": this.getToolbuttonImage(toolbarAction), "disabled": this.isToolbuttonDisabled(toolbarAction) } return toolbutton; }, appendSandboxMenuChoice: function (menuItems, sandboxIndex, sandboxName, activeSandbox) { var toolbarAction = "SANDBOXCHOICE" + sandboxIndex; var toolbutton = { "name" : toolbarAction, "action" : toolbarAction, "label": sandboxName, "iconClass": (activeSandbox == sandboxName ? "tm1-menu-radioselection" : "tm1-menu-empty") } return menuItems.concat(toolbutton); }, createToolbuttonWithSubmenu: function (toolbarAction) { var menuitems = null; if (toolbarAction == "IDM_EXPORT") { var menuItems = []; menuItems = this.addToolbutton(menuItems, "IDM_SLICE_TO_EXCEL"); menuItems = this.addToolbutton(menuItems, "IDM_SNAPSHOT_TO_EXCEL"); menuItems = this.addToolbutton(menuItems, "IDM_EXPORT_TO_PDF"); var toolbutton = { "name" : toolbarAction, "action" : toolbarAction, "label": this.getToolbuttonTooltip(toolbarAction), "iconClass": this.getToolbuttonImage(toolbarAction), "disabled": this.isToolbuttonDisabled(toolbarAction), "items" : menuItems } return toolbutton; } else if (toolbarAction == "IDM_SUPPRESS_ZEROS") { var menuItems = []; menuItems = this.addToolbutton(menuItems, "IDM_SUPPRESS_ZEROS_ROWS_COLUMNS"); menuItems = this.addToolbutton(menuItems, "IDM_SUPPRESS_ZEROS_ROWS"); menuItems = this.addToolbutton(menuItems, "IDM_SUPPRESS_ZEROS_COLUMNS"); var toolbutton = { "name" : toolbarAction, "action" : toolbarAction, "label": this.getToolbuttonTooltip(toolbarAction), "iconClass": this.getToolbuttonImage(toolbarAction), "disabled": this.isToolbuttonDisabled(toolbarAction), "items" : menuItems } return toolbutton; } else if (toolbarAction == "IDM_CHART-SELECT") { var menuItems = []; menuItems = this.addToolbuttonWithSubmenu (menuItems, "IDM_CHARTTYPE"); menuItems = this.addToolbuttonWithSubmenu (menuItems, "IDM_CHARTPALETTE"); menuItems = this.addToolbutton(menuItems, "IDM_SHOWLEGEND"); menuItems = this.addToolbutton(menuItems, "IDM_3DVIEW"); menuItems = this.addToolbutton(menuItems, "IDM_CHART_PROPERTIES"); var toolbutton = { "name" : toolbarAction, "action" : toolbarAction, "label": this.getToolbuttonTooltip(toolbarAction), "iconClass": this.getToolbuttonImage(toolbarAction), "disabled": this.isToolbuttonDisabled(toolbarAction), "items" : menuItems } return toolbutton; } else if (toolbarAction == "IDM_CHARTTYPE") { var menuItems = []; menuItems = this.addToolbutton(menuItems, "IDM_CHART_POINT"); menuItems = this.addToolbutton(menuItems, "IDM_CHART_BUBBLE"); menuItems = this.addToolbutton(menuItems, "IDM_CHART_LINE"); menuItems = this.addToolbutton(menuItems, "IDM_CHART_SPLINE"); menuItems = this.addToolbutton(menuItems, "IDM_CHART_STEPLINE"); menuItems = this.addToolbutton(menuItems, "IDM_CHART_FASTLINE"); menuItems = this.addToolbutton(menuItems, "IDM_CHART_BAR"); menuItems = this.addToolbutton(menuItems, "IDM_CHART_STACKEDBAR"); menuItems = this.addToolbutton(menuItems, "IDM_CHART_STACKEDBAR100"); menuItems = this.addToolbutton(menuItems, "IDM_CHART_COLUMN"); menuItems = this.addToolbutton(menuItems, "IDM_CHART_STACKEDCOLUMN"); menuItems = this.addToolbutton(menuItems, "IDM_CHART_STACKEDCOLUMN100"); menuItems = this.addToolbutton(menuItems, "IDM_CHART_AREA"); menuItems = this.addToolbutton(menuItems, "IDM_CHART_STACKEDAREA"); menuItems = this.addToolbutton(menuItems, "IDM_CHART_STACKEDAREA100"); menuItems = this.addToolbutton(menuItems, "IDM_CHART_PIE"); menuItems = this.addToolbutton(menuItems, "IDM_CHART_DOUGHNUT"); menuItems = this.addToolbutton(menuItems, "IDM_CHART_STOCK"); menuItems = this.addToolbutton(menuItems, "IDM_CHART_CANDLESTICK"); menuItems = this.addToolbutton(menuItems, "IDM_CHART_RANGE"); menuItems = this.addToolbutton(menuItems, "IDM_CHART_SPLINERANGE"); menuItems = this.addToolbutton(menuItems, "IDM_CHART_GANTT"); menuItems = this.addToolbutton(menuItems, "IDM_CHART_RANGECOLUMN"); menuItems = this.addToolbutton(menuItems, "IDM_CHART_RADAR"); menuItems = this.addToolbutton(menuItems, "IDM_CHART_POLAR"); menuItems = this.addToolbutton(menuItems, "IDM_CHART_BOXPLOT"); menuItems = this.addToolbutton(menuItems, "IDM_CHART_FUNNEL"); menuItems = this.addToolbutton(menuItems, "IDM_CHART_PYRAMID"); var toolbutton = { "name" : toolbarAction, "action" : toolbarAction, "label": this.getToolbuttonTooltip(toolbarAction), "iconClass": this.getToolbuttonImage(toolbarAction), "disabled": this.isToolbuttonDisabled(toolbarAction), "items" : menuItems } return toolbutton; } else if (toolbarAction == "IDM_CHARTPALETTE") { var menuItems = []; menuItems = this.addToolbutton(menuItems, "IDM_PALETTE_DEFAULT"); menuItems = this.addToolbutton(menuItems, "IDM_PALETTE_STEEL"); menuItems = this.addToolbutton(menuItems, "IDM_PALETTE_EARTH"); menuItems = this.addToolbutton(menuItems, "IDM_PALETTE_GRAYS"); menuItems = this.addToolbutton(menuItems, "IIDM_PALETTE_TRANSPARENT"); menuItems = this.addToolbutton(menuItems, "IDM_PALETTE_EXCEL"); menuItems = this.addToolbutton(menuItems, "IDM_PALETTE_BEIGE"); menuItems = this.addToolbutton(menuItems, "IDM_PALETTE_BERRY"); menuItems = this.addToolbutton(menuItems, "IDM_PALETTE_FIRE"); menuItems = this.addToolbutton(menuItems, "IDM_PALETTE_GREEN"); var toolbutton = { "name" : toolbarAction, "action" : toolbarAction, "label": this.getToolbuttonTooltip(toolbarAction), "iconClass": this.getToolbuttonImage(toolbarAction), "disabled": this.isToolbuttonDisabled(toolbarAction), "items" : menuItems } return toolbutton; } else if (toolbarAction == "IDM_SANDBOX") { var menuItems = []; menuItems = this.addToolbutton(menuItems, "IDM_CREATE_SANDBOX"); menuItems = this.addToolbutton(menuItems, "IDM_DELETE_SANDBOX"); var toolbutton = { "name" : toolbarAction, "action" : toolbarAction, "label": this.getToolbuttonTooltip(toolbarAction), "iconClass": this.getToolbuttonImage(toolbarAction), "disabled": this.isToolbuttonDisabled(toolbarAction), "items" : menuItems } return toolbutton; } else if (toolbarAction == "IDM_SANDBOXITEMS") { var menuItems = []; menuItems = this.appendSandboxMenuChoice(menuItems, 0, "[Base]", this.tm1Toolbar.ToolbarInfo.Sandbox.ActiveSandbox); if (this.tm1Toolbar.ToolbarInfo.Sandbox.SandboxList.length > 0) { for (i=0; i= 0) { buxDomain = buxDomain.substring(0, buxColonIndex); } var tm1WebColonIndex = tm1WebDomain.indexOf(":"); if (tm1WebColonIndex >= 0) { tm1WebDomain = tm1WebDomain.substring(0, tm1WebColonIndex); } var buxDotIndex = buxDomain.indexOf("."); var tm1WebDotIndex = tm1WebDomain.indexOf("."); if (buxDotIndex >= 0 && tm1WebDotIndex >= 0) { var buxDomainSuffix = buxDomain.substring(buxDotIndex + 1); var tm1DomainSuffix = tm1WebDomain.substring(tm1WebDotIndex + 1); if (buxDomainSuffix.toLowerCase() == tm1DomainSuffix.toLowerCase()) { this.commonDomain = buxDomainSuffix; return; } } */ } } return; }, refreshView : function () { // initialize javascript callback functions // callback functions are stored in an array where the array index // is the context widgetId if (COGNOS_TM1_cubeWgtToolbarFuncs == null) COGNOS_TM1_cubeWgtToolbarFuncs = new Array(); if (COGNOS_TM1_cubeWgtFilterFuncs == null) COGNOS_TM1_cubeWgtFilterFuncs = new Array(); if (COGNOS_TM1_cubeWgtToolbarFuncs["_"+this.iContext.widgetId+"_"] == null) { COGNOS_TM1_cubeWgtToolbarFuncs["_"+this.iContext.widgetId+"_"] = dojo.hitch(this, "createWidgetToolbar"); } if (COGNOS_TM1_cubeWgtFilterFuncs["_"+this.iContext.widgetId+"_"] == null) { COGNOS_TM1_cubeWgtFilterFuncs["_"+this.iContext.widgetId+"_"] = dojo.hitch(this, "fireFilterChanged"); } var url = this.tm1WebURL; url += "/TM1WebMain.aspx?action=OpenObject&type=Cubeviewer"; url += "&HideTabs=1&AdminHost=" + encodeURIComponent(this.tm1Host) + "&TM1server=" + encodeURIComponent(this.tm1Server) + "&value=" + encodeURIComponent(this.tm1Cube) + "$$" + encodeURIComponent(this.tm1CubeView); this.determineCommonDomain(); if (this.bTurnOffCallbacks /*this.commonDomain != null && this.commonDomain.length > 0*/) { this.tm1InternalToolbar = 1; this.createBasicWidgetToolbar(); // document.domain = this.commonDomain; // url += "&CommonDomain="; // url += encodeURIComponent(this.commonDomain); } else { if (this.tm1InternalToolbar != 1) { url += "&HideToolbar=1"; } url += "&toolbarCallbackFunc=COGNOS_TM1_cubeWgtToolbarFuncs._"+encodeURIComponent(this.iContext.widgetId)+"_&TitleChangeCallback=COGNOS_TM1_cubeWgtFilterFuncs._"+encodeURIComponent(this.iContext.widgetId)+"_($dimName$, $subsetName$, $elemName$)"; } if ((this.tm1UserName != null) && (this.tm1UserName != "")) { url += "&username="; url += encodeURIComponent(this.tm1UserName); url += "&password="; if ((this.tm1Password != null) && (this.tm1Password != "")) { url += encodeURIComponent(this.tm1Password); } } if (this.iframeCtrl == null) { this.initializeiframe (url); } else { this.iframeCtrl.setUrl(url); } } }); dojo.provide("cubeViewerIFrame"); dojo.declare("cubeViewerIFrame", dijit._Widget, { url: null, iWidget: null, resizeZone: null, iframe: null, recalcURL: null, constructor: function(params) { // }, getObjectIDURL: function () { this.recalcURL = null; if (this.iframe.contentDocument) { if (this.iframe.contentDocument.URL == "about:blank") { } else { this.recalcURL = this.iframe.contentDocument.URL; } } else if (this.iframe.contentWindow) { this.recalcURL = this.iframe.contentWindow.location.href; } return this.recalcURL; }, setUrl: function(url) { this.url = url; if (this.iframe) { this.iframe.src = url; } }, assignReturnURL: function () { }, startup: function(inHght) { var ref = this; this.inherited(arguments); this.resizeZone = this.domNode.ownerDocument.createElement("div"); this.domNode.appendChild(this.resizeZone); var dn = (this.iframe = dojo.doc.createElement('iframe')); var url = this.url; var widgetParent = this.iWidget; dn.id = this.id + "_iframe"; dn.style.border = "none"; dn.style.width = "100%"; dn.style.height = inHght + "px"; dn.frameBorder = 0; dn.tabIndex = 0; dn.setAttribute('src', url); dn.setAttribute('scrolling', "no"); this.resizeZone.appendChild(dn); if (dojo.isWebKit) { // Safari seems to always append iframe with src=about:blank setTimeout(function() { dn.setAttribute('src', url) }, 0); } }, resize: function(size) { dijit.layout._LayoutWidget.prototype.resize.apply(this, arguments); }, layout: function() { if (this.iframe.parentNode != null) { if (this.iframe.clientHeight > 0) { this.iframe.style.height = this.iframe.parentNode.parentNode.clientHeight + "px"; } } } });