bux_top.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. // Licensed Materials - Property of IBM
  2. //
  3. // IBM Cognos Products: pps
  4. //
  5. // (C) Copyright IBM Corp. 2009, 2017
  6. //
  7. // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  8. /*****************************************************/
  9. /************* Dashboard (BUX) Support *************/
  10. /*****************************************************/
  11. // Determines if we are running inside a Dashboard "iWidget".
  12. function isDashboard() {
  13. var isdsh = getGlobal("is_dashboard");
  14. if ( isdsh != null && typeof isdsh != "undefined") {
  15. return isdsh;
  16. } else {
  17. if (window.frameElement != null && window.frameElement.id != null && window.frameElement.id.indexOf("_pps_iframe") != -1) {
  18. setGlobal("is_dashboard", true);
  19. return true;
  20. }
  21. else {
  22. setGlobal("is_dashboard", false);
  23. return false;
  24. }
  25. }
  26. }
  27. function getIContext() {
  28. if(typeof window.name != "undefined" && /^[a-zA-Z][a-zA-Z0-9]*$/.test(window.name) ) {
  29. var str = "window.parent." + window.name + "iContext";
  30. var icontext = eval(str);
  31. if (icontext != null && typeof icontext != "undefined" && icontext.iEvents != null && icontext.iEvents.fireEvent != null) {
  32. return icontext;
  33. }
  34. }
  35. return null;
  36. }
  37. function updateToolbar() {
  38. var icontext = getIContext();
  39. if (icontext != null && icontext.scope && icontext.scope.initOnDemandToolbar) {
  40. icontext.scope.initOnDemandToolbar();
  41. }
  42. }
  43. function enableDrill() {
  44. var icontext = getIContext();
  45. if (icontext != null && icontext.scope && icontext.scope.enableDrill) {
  46. icontext.scope.enableDrill();
  47. }
  48. }
  49. function disableDrill() {
  50. var icontext = getIContext();
  51. if (icontext != null && icontext.scope && icontext.scope.disableDrill) {
  52. icontext.scope.disableDrill();
  53. }
  54. }
  55. function fireEvent(evt, params, payload) {
  56. var icontext = getIContext();
  57. if (icontext != null) {
  58. icontext.iEvents.fireEvent(evt, params, payload);
  59. }
  60. }
  61. function handleSaveDone() {
  62. setGlobal('is_save', false);
  63. getIContext().getiWidgetAttributes().setItemValue('savedReport', getGlobal('bux_report'));
  64. setGlobal("treeVisible", false); // in BUX, tree is not visible by default.
  65. getMainFrameset().cols = '0,*'; // make sure the dimtree is closed...
  66. fireEvent('com.ibm.bux.widget.save.done', null, {'status':true});
  67. fireEvent('com.ibm.bux.widget.modified', null, { 'modified': false });
  68. }
  69. function handleInitialOpen() {
  70. setGlobal("initial_open", false);
  71. setGlobal("is_save", false);
  72. setGlobal("treeVisible", false); // in BUX, tree is not visible by default.
  73. getMainFrameset().cols = '0,*'; // make sure the dimtree is closed...
  74. fireEvent('com.ibm.bux.widget.render.done', { noAutoResize: getGlobal('no_auto_resize') });
  75. }
  76. // On an initial open of a report in BUX, we want to fire
  77. // an autoResize event when all content has been loaded.
  78. function doneLoadingFrameset( framesetName ) {
  79. if (isDashboard()) {
  80. // If this is a split-view report, we want to perform the action when the inner frameset loads.
  81. if ( getGlobal("isSplitView") && framesetName == 'Data' ) {
  82. return;
  83. }
  84. if (getGlobal("initial_open")) {
  85. if (getGlobal('is_save')) {
  86. handleSaveDone();
  87. } else {
  88. handleInitialOpen(); // only do AutoResize on the initial open.
  89. }
  90. } else {
  91. fireEvent('com.ibm.bux.widget.modified', null, { 'modified': true });
  92. }
  93. updateToolbar();
  94. }
  95. }