Blocker.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. *+------------------------------------------------------------------------+
  3. *| Licensed Materials - Property of IBM
  4. *| IBM Cognos Products: Viewer
  5. *| (C) Copyright IBM Corp. 2013
  6. *|
  7. *| US Government Users Restricted Rights - Use, duplication or
  8. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9. *|
  10. *+------------------------------------------------------------------------+
  11. */
  12. function Blocker( oCVId )
  13. {
  14. this.oCV_Id = oCVId;
  15. this.m_viewerDiv = dojo.byId("RVContent" + this.oCV_Id);
  16. this.m_containerDiv = this._findContainerDiv()
  17. this.initialize();
  18. };
  19. Blocker.prototype._findContainerDiv = function()
  20. {
  21. var containerDiv = null;
  22. // we need to find the correct container div. It'll be the one with a height set in pixels
  23. if (!this.m_containerDiv) {
  24. containerDiv = this.m_viewerDiv;
  25. while (containerDiv) {
  26. if (containerDiv.style && containerDiv.style.height && containerDiv.style.height.indexOf("px") != -1) {
  27. return containerDiv;
  28. }
  29. containerDiv = containerDiv.parentNode;
  30. }
  31. }
  32. if (typeof console != "undefined" && console && console.log) {
  33. console.log("ViewerIWidgetInlineDialog: Could not find the container div for showing the dialog.");
  34. }
  35. return this.m_viewerDiv;
  36. };
  37. Blocker.prototype.setClassNameOverride = function(className)
  38. {
  39. if( !className){ return; }
  40. this.m_classNameOverride = className;
  41. this.applyClassNameOverride();
  42. };
  43. Blocker.prototype.applyClassNameOverride = function()
  44. {
  45. if(!this.m_classNameOverride || !this.m_background){ return; }
  46. dojo.removeClass( this.m_background );
  47. dojo.addClass( this.m_background, this.m_classNameOverride );
  48. };
  49. Blocker.prototype.getNode = function(){
  50. return this.m_background;
  51. };
  52. Blocker.prototype.initialize = function()
  53. {
  54. // we only ever have to create one background div for all our dialogs, so lets
  55. // see if it's already created
  56. if (!this.m_background) {
  57. this.m_background = dojo.byId("BACKGROUND" + this.oCV_Id);
  58. if (!this.m_background) {
  59. this.m_background = document.createElement("div");
  60. this.m_background.id = "BACKGROUND" + this.oCV_Id;
  61. this.m_background.className = "report-blocker";
  62. this.m_background.tabIndex = "0";
  63. dojo.place(this.m_background, this.m_containerDiv, 'before');
  64. }
  65. }
  66. };
  67. Blocker.prototype.show = function()
  68. {
  69. if( this.m_background ){
  70. this.m_background.style.display = 'block';
  71. }
  72. };
  73. Blocker.prototype.hide = function()
  74. {
  75. if( this.m_background ){
  76. this.m_background.style.display = 'none';
  77. }
  78. };
  79. Blocker.prototype.destroy = function()
  80. {
  81. if (this.m_background != null) {
  82. this.m_background.parentNode.removeChild(this.m_background);
  83. this.m_background = null;
  84. }
  85. }