ViewerBaseWorkingDialog.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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 ViewerBaseWorkingDialog( cognosViewer )
  13. {
  14. if( !cognosViewer )
  15. {
  16. return;
  17. }
  18. this.setCognosViewer( cognosViewer );
  19. this.m_oCV = cognosViewer;
  20. this.m_sNamespace = cognosViewer.getId();
  21. this.m_sGateway = cognosViewer.getGateway();
  22. this.m_UIBlacklist = null;
  23. this.m_bUse = true;
  24. this.m_bCancelSubmitted = false;
  25. }
  26. ViewerBaseWorkingDialog.prototype = new IRequestIndicator();
  27. ViewerBaseWorkingDialog.prototype.setCognosViewer = function(oCV)
  28. {
  29. this.m_oCV = oCV;
  30. };
  31. ViewerBaseWorkingDialog.prototype.getCognosViewer = function()
  32. {
  33. return this.m_oCV;
  34. };
  35. ViewerBaseWorkingDialog.prototype.getGateway = function()
  36. {
  37. return this.m_sGateway;
  38. };
  39. /**
  40. * Returns the unique namespace
  41. * @return (string)
  42. */
  43. ViewerBaseWorkingDialog.prototype.getNamespace = function()
  44. {
  45. return this.m_sNamespace;
  46. };
  47. /**
  48. * Used by lineage action.
  49. * TODO: should be deprecated when moving to new framework. This is specific to lineage action and is
  50. * used to suppress fault response if the request is cancelled. This should be handled
  51. * outside of this class.
  52. * the wait page when getting lineage
  53. * @deprecated
  54. */
  55. ViewerBaseWorkingDialog.prototype.cancelSubmitted = function()
  56. {
  57. return this.m_bCancelSubmitted;
  58. };
  59. /**
  60. * @deprecated - see comments for cancelSubmitted().
  61. */
  62. ViewerBaseWorkingDialog.prototype.setCancelSubmitted = function(bSubmitted)
  63. {
  64. this.m_bCancelSubmitted = bSubmitted;
  65. };
  66. /**
  67. * Will initialize and draw the wait page. This method should be used to render the page
  68. */
  69. ViewerBaseWorkingDialog.prototype.show = function()
  70. {
  71. var waitPageContainer = document.getElementById(this.getContainerId());
  72. if(waitPageContainer) {
  73. waitPageContainer.style.display = "block";
  74. this.enableCancelButton();
  75. } else {
  76. this.create();
  77. }
  78. var blocker = document.getElementById("reportBlocker" + this.m_oCV.getId());
  79. if (blocker) {
  80. blocker.style.display = "block";
  81. }
  82. };
  83. /**
  84. * Initializes the wait page div
  85. * @private
  86. */
  87. ViewerBaseWorkingDialog.prototype.create = function()
  88. {
  89. if (typeof document.body != "undefined") {
  90. if(this.isModal()) {
  91. this.createModalWaitDialog();
  92. } else {
  93. this.createInlineWaitDialog();
  94. }
  95. }
  96. };
  97. ViewerBaseWorkingDialog.prototype.createContainer = function(isModal) {
  98. var waitPageContainer = document.createElement("div");
  99. waitPageContainer.setAttribute("id", this.getContainerId());
  100. waitPageContainer.className = isModal ? "modalWaitPage" : "inlineWaitPage";
  101. return waitPageContainer;
  102. };
  103. ViewerBaseWorkingDialog.prototype.createModalWaitDialog = function(){
  104. this._createBlocker();
  105. var waitPageContainer = this.createContainer(true);
  106. waitPageContainer.innerHTML = this.renderHTML();
  107. waitPageContainer.style.zIndex = "7002";
  108. waitPageContainer.setAttribute("role", "region");
  109. waitPageContainer.setAttribute("aria-label", RV_RES.GOTO_WORKING);
  110. document.body.appendChild(waitPageContainer);
  111. var iframeBackground = this.createModalIframeBackground();
  112. document.body.appendChild(iframeBackground);
  113. var iBottom = 0;
  114. var iLeft = 0;
  115. if (typeof window.innerHeight != "undefined") {
  116. iBottom = Math.round((window.innerHeight/2) - (waitPageContainer.offsetHeight/2));
  117. iLeft = Math.round((window.innerWidth/2) - (waitPageContainer.offsetWidth/2));
  118. }
  119. else {
  120. iBottom = Math.round((document.body.clientHeight/2) - (waitPageContainer.offsetHeight/2));
  121. iLeft = Math.round((document.body.clientWidth/2) - (waitPageContainer.offsetWidth/2));
  122. }
  123. waitPageContainer.style.bottom = iBottom + "px";
  124. waitPageContainer.style.left = iLeft + "px";
  125. iframeBackground.style.left = iLeft - 1 + "px";
  126. iframeBackground.style.bottom = iBottom - 1 + "px";
  127. iframeBackground.style.width = waitPageContainer.offsetWidth + 2 + "px";
  128. iframeBackground.style.height = waitPageContainer.offsetHeight + 2 + "px";
  129. };
  130. ViewerBaseWorkingDialog.prototype._createBlocker = function() {
  131. var blocker = document.getElementById("reportBlocker" + this.m_oCV.getId());
  132. if (blocker) {
  133. return;
  134. }
  135. var mainTd = document.getElementById("mainViewerTable" + this.m_oCV.getId());
  136. if (mainTd) {
  137. blocker = document.createElement("div");
  138. mainTd.parentNode.appendChild(blocker);
  139. blocker.id = "reportBlocker" + this.m_oCV.getId();
  140. blocker.style.zIndex = "6001";
  141. blocker.style.position = "absolute";
  142. blocker.style.top = "0px";
  143. blocker.style.left = "0px";
  144. blocker.style.width = "100%";
  145. blocker.style.height = "100%";
  146. blocker.style.display = "none";
  147. blocker.style.opacity = "0";
  148. blocker.style.backgroundColor = "#FFFFFF";
  149. blocker.style.filter = "alpha(opacity:0)";
  150. }
  151. };
  152. ViewerBaseWorkingDialog.prototype.createInlineWaitDialog = function(){
  153. var sNamespace = this.m_oCV.getId();
  154. var cvReportDiv = document.getElementById("CVReport" + sNamespace);
  155. if(cvReportDiv) {
  156. var waitPageContainer = this.createContainer(false);
  157. waitPageContainer.innerHTML = "<table width=\"100%\" height=\"100%\"><tr><td valign=\"middle\" align=\"center\" role=\"presentation\">" + this.renderHTML() + "</td></tr></table>";
  158. cvReportDiv.appendChild(waitPageContainer);
  159. }
  160. };
  161. /**
  162. * Builds the wait page hidden iframe (used so the wait page draws over iframes)
  163. * @param bSavedReport (boolean) Indicates whether or not the wait page should render the delivery options
  164. * @private
  165. */
  166. ViewerBaseWorkingDialog.prototype.createModalIframeBackground = function()
  167. {
  168. var hiddenIframe = document.createElement("iframe");
  169. var sWebContentRoot = "..";
  170. var oCV = this.getCognosViewer();
  171. if (oCV !== null)
  172. {
  173. sWebContentRoot = oCV.getWebContentRoot();
  174. }
  175. hiddenIframe.setAttribute("id", this.getContainerId() + "Iframe");
  176. hiddenIframe.setAttribute("title", "Empty iframe");
  177. hiddenIframe.setAttribute("src",sWebContentRoot + '/common/images/spacer.gif');
  178. hiddenIframe.setAttribute("scrolling",'no');
  179. hiddenIframe.setAttribute("frameborder",'0');
  180. hiddenIframe.style.position="absolute";
  181. hiddenIframe.style.zIndex="6002";
  182. hiddenIframe.style.display="block";
  183. return hiddenIframe;
  184. };
  185. ViewerBaseWorkingDialog.prototype.updateCoords = function(waitPageDiv, waitPageIFrame)
  186. {
  187. if(this.m_container !== null && m_iframeBackground !== null) {
  188. // position the wait page in the middle of the report
  189. var iBottom = 0;
  190. var iLeft = 0;
  191. if (typeof window.innerHeight != "undefined") {
  192. iBottom = Math.round((window.innerHeight/2) - (waitPageDiv.offsetHeight/2));
  193. iLeft = Math.round((window.innerWidth/2) - (waitPageDiv.offsetWidth/2));
  194. }
  195. else {
  196. iBottom = Math.round((document.body.clientHeight/2) - (waitPageDiv.offsetHeight/2));
  197. iLeft = Math.round((document.body.clientWidth/2) - (waitPageDiv.offsetWidth/2));
  198. }
  199. waitPageDiv.style.bottom = iBottom + "px";
  200. waitPageDiv.style.left = iLeft + "px";
  201. waitPageIFrame.style.left = waitPageDiv.style.left;
  202. waitPageIFrame.style.bottom = waitPageDiv.style.bottom;
  203. waitPageIFrame.style.width = waitPageDiv.offsetWidth + "px";
  204. waitPageIFrame.style.height = waitPageDiv.offsetHeight + "px";
  205. }
  206. };
  207. /**
  208. * Will hide the wait page
  209. */
  210. ViewerBaseWorkingDialog.prototype.hide = function()
  211. {
  212. var waitPageContainer = document.getElementById(this.getContainerId());
  213. if(waitPageContainer) {
  214. waitPageContainer.parentNode.removeChild(waitPageContainer);
  215. }
  216. var waitIframe = document.getElementById(this.getContainerId() + "Iframe");
  217. if(waitIframe) {
  218. waitIframe.parentNode.removeChild(waitIframe);
  219. }
  220. var blocker = document.getElementById("reportBlocker" + this.m_oCV.getId());
  221. if (blocker) {
  222. blocker.parentNode.removeChild(blocker);
  223. }
  224. };
  225. ViewerBaseWorkingDialog.prototype.isModal = function() {
  226. var sNamespace = this.m_oCV.getId();
  227. var cvReportDiv = document.getElementById("CVReport" + sNamespace);
  228. var isModal = true;
  229. if(cvReportDiv && cvReportDiv.innerHTML === "") {
  230. isModal = false;
  231. }
  232. return isModal;
  233. };
  234. ViewerBaseWorkingDialog.prototype.disableCancelButton = function(cancelLink) {};
  235. ViewerBaseWorkingDialog.prototype.enableCancelButton = function() {};