WorkingDialog.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  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 WorkingDialog( cognosViewer )
  13. {
  14. if (cognosViewer) {
  15. this.m_bSimpleWorkingDialog = false;
  16. this.m_bShowCancelButton = (cognosViewer.getAdvancedServerProperty("VIEWER_JS_HIDE_CANCEL_BUTTON") == "true") ? false : true;
  17. WorkingDialog.baseConstructor.call( this, cognosViewer );
  18. this.m_secondaryRequests = cognosViewer.getSecondaryRequests();
  19. }
  20. }
  21. WorkingDialog.prototype = new ViewerBaseWorkingDialog();
  22. WorkingDialog.baseConstructor = ViewerBaseWorkingDialog;
  23. WorkingDialog.prototype.setSecondaryRequests = function( aSecRequests )
  24. {
  25. this.m_secondaryRequests = aSecRequests;
  26. }
  27. WorkingDialog.prototype._getSecondaryRequests = function(){
  28. return this.m_secondaryRequests;
  29. };
  30. WorkingDialog.prototype.getIsSavedReport = function()
  31. {
  32. return this.getCognosViewer().bIsSavedReport;
  33. };
  34. /**
  35. * Required only by lineage action.
  36. * TODO: ideally, the lineage action class need not set this flag but
  37. * can be figured out based on the cognos viewer object
  38. */
  39. WorkingDialog.prototype.setSimpleWorkingDialogFlag = function( flag )
  40. {
  41. this.m_bSimpleWorkingDialog = flag;
  42. };
  43. WorkingDialog.prototype.getSimpleWorkingDialogFlag = function()
  44. {
  45. return this.m_bSimpleWorkingDialog;
  46. };
  47. /**
  48. * Will hide/show the delivery options toolbar buttons within the wait page
  49. * @param bShow (boolean) Boolean which dictates whether to show the delivery option toolbar buttons
  50. */
  51. WorkingDialog.prototype.showDeliveryOptions = function(bShow)
  52. {
  53. var namespace = this.getNamespace();
  54. var htmlElement = document.getElementById("DeliveryOptionsVisible" + namespace);
  55. if (htmlElement)
  56. {
  57. htmlElement.style.display = (bShow === false ? "none" : "block");
  58. if (bShow)
  59. {
  60. var links = htmlElement.getElementsByTagName("a");
  61. for (var i=links.length; i > 0; i--)
  62. {
  63. if (links[i] && links[i].getAttribute("tabIndex") == "0") {
  64. links[i].focus();
  65. }
  66. }
  67. }
  68. }
  69. htmlElement = document.getElementById("OptionsLinkSelected" + namespace);
  70. if (htmlElement)
  71. {
  72. htmlElement.style.display = (bShow === false ? "none" : "block");
  73. }
  74. htmlElement = document.getElementById("OptionsLinkUnselected" + namespace);
  75. if (htmlElement)
  76. {
  77. htmlElement.style.display = (bShow === false ? "block" : "none");
  78. }
  79. };
  80. WorkingDialog.prototype.renderHTML = function()
  81. {
  82. var sNamespace = this.getNamespace();
  83. var ariaLabelledby = sNamespace + '_workingMsg ' + sNamespace + '_workingMsg2';
  84. var html = '<table class="viewerWorkingDialog" id="CVWaitTable' + sNamespace + '"' + ' role="presentation">';
  85. html += ('<tr>' + '<td align="center">' + '<div tabIndex="0" role="presentation" aria-labelledby="' + ariaLabelledby + '"' + ' class="body_dialog_modal workingDialogDiv">');
  86. html += this.renderFirstInnerTable();
  87. html += this.renderSecondInnerTable();
  88. html += ('</div>' + '</td>' + '</tr>' + '</table>');
  89. return html;
  90. };
  91. WorkingDialog.prototype.renderFirstInnerTable = function()
  92. {
  93. var bSimpleWaitPage = this.getSimpleWorkingDialogFlag();
  94. var workingMsg = bSimpleWaitPage ? RV_RES.GOTO_WORKING : RV_RES.RV_RUNNING;
  95. var sNamespace = this.m_sNamespace;
  96. var output =
  97. '<table class="workingDialogInnerTable" role="presentation">' +
  98. '<tr>' +
  99. '<td valign="middle">';
  100. var sBrandImageLocation = this.getCognosViewer().getSkin() + '/branding/';
  101. output += '<img src="' + sBrandImageLocation + 'progress.gif"';
  102. if( isIE() )
  103. {
  104. output += ' width="48" height="48" border="0"';
  105. }
  106. output += ' name="progress"';
  107. if( isIE() )
  108. {
  109. output += ' align="top"';
  110. }
  111. output += ' alt="';
  112. output += workingMsg;
  113. output += '"/></td>';
  114. output += '<td width="20">&nbsp;</td>';
  115. output += '<td style="padding-top: 5px;" class="tableText">';
  116. output += '<span id="' + sNamespace + '_workingMsg">';
  117. output += workingMsg;
  118. output += '</span>';
  119. output += '<br/><br/>';
  120. var sResponseFormat = this.getCognosViewer().envParams[ 'cv.responseFormat' ];
  121. if(bSimpleWaitPage || this.isUIBlacklisted('RV_TOOLBAR_BUTTONS') || !this.deliverySectionIsNeeded() || ( sResponseFormat && ( 'qs' === sResponseFormat || 'fragment' === sResponseFormat )) )
  122. {
  123. output += RV_RES.RV_PLEASE_WAIT;
  124. }
  125. else
  126. {
  127. var bCanShowDeliveryOptions = this.canShowDeliveryOptions();
  128. if(bCanShowDeliveryOptions)
  129. {
  130. output += this.optionLinkSelectedDiv();
  131. output += this.optionLinkUnselectedDiv();
  132. }
  133. else
  134. {
  135. output += RV_RES.RV_PLEASE_WAIT;
  136. }
  137. }
  138. output += '</td></tr><tr><td colspan="3">&nbsp;</td></tr></table>';
  139. return output;
  140. };
  141. WorkingDialog.prototype.optionLinkSelectedDiv = function()
  142. {
  143. var sbOutput = '';
  144. sbOutput += '<div id="OptionsLinkSelected' + this.getNamespace() + '" style="display: none">';
  145. sbOutput += RV_RES.RV_BUSY_OPTIONS_SELECTED;
  146. sbOutput += '</div>';
  147. return sbOutput;
  148. };
  149. WorkingDialog.prototype.optionLinkUnselectedDiv = function()
  150. {
  151. var sbOutput = '';
  152. var sNamespace = this.getNamespace();
  153. var sWaitPageObject = 'window.oCV' + sNamespace + '.getWorkingDialog()';
  154. sbOutput += '<div id="OptionsLinkUnselected' + sNamespace + '">';
  155. sbOutput += '<span id="' + sNamespace + '_workingMsg2">';
  156. sbOutput += RV_RES.RV_BUSY_OPTIONS_UNSELECTED;
  157. sbOutput += '</span><br/>';
  158. sbOutput += '<a href="#" class="deliveryOptionLink" onclick="javascript:' + sWaitPageObject + '.showDeliveryOptions(true)">';
  159. sbOutput += RV_RES.RV_BUSY_OPTIONS_LINK;
  160. sbOutput += '</a></div>';
  161. return sbOutput;
  162. };
  163. WorkingDialog.prototype.canShowDeliveryOptions = function()
  164. {
  165. var sAction = this.getCognosViewer().envParams['ui.primaryAction'];
  166. if( 'saveAs' !== sAction && 'email' !== sAction && this.getIsSavedReport() )
  167. {
  168. return true;
  169. }
  170. return false;
  171. };
  172. WorkingDialog.prototype.isUIBlacklisted = function( item )
  173. {
  174. var aUIBlacklist = this.getUIBlacklist();
  175. for( var index in aUIBlacklist )
  176. {
  177. if( aUIBlacklist[index] === item )
  178. {
  179. return true;
  180. }
  181. }
  182. return false;
  183. };
  184. WorkingDialog.prototype.getUIBlacklist = function()
  185. {
  186. if( !this.m_UIBlacklist && this.getCognosViewer().UIBlacklist )
  187. {
  188. this.m_UIBlacklist = this.getCognosViewer().UIBlacklist.split( ' ' );
  189. }
  190. return this.m_UIBlacklist;
  191. };
  192. WorkingDialog.prototype.deliverySectionIsNeeded = function() {
  193. return !this._isSaveBlackListed() || !this._isSaveAsBlackListed() || !this._isEmailBlackListed();
  194. };
  195. WorkingDialog.prototype._isSaveBlackListed = function() {
  196. return this.isUIBlacklisted("RV_TOOLBAR_BUTTONS_SAVE") || this.isUIBlacklisted("RV_WORKING_DIALOG_SAVE") || !this._hasSecondaryRequest("save");
  197. };
  198. WorkingDialog.prototype._isSaveAsBlackListed = function() {
  199. return this.isUIBlacklisted("RV_TOOLBAR_BUTTONS_SAVEAS") || this.isUIBlacklisted("RV_WORKING_DIALOG_SAVEAS") || !this._hasSecondaryRequest("saveAs");
  200. };
  201. WorkingDialog.prototype._isEmailBlackListed = function() {
  202. return this.isUIBlacklisted("RV_TOOLBAR_BUTTONS_SEND") || this.isUIBlacklisted("RV_WORKING_DIALOG_SEND") || !this._hasSecondaryRequest("email");
  203. };
  204. WorkingDialog.prototype.showCancelButton = function()
  205. {
  206. return this.m_bShowCancelButton;
  207. };
  208. WorkingDialog.prototype._hasSecondaryRequest = function(request) {
  209. var secondaryRequests = this._getSecondaryRequests();
  210. if (secondaryRequests) {
  211. var arrayLength = secondaryRequests.length;
  212. for (var i = 0; i < arrayLength; i++) {
  213. if (secondaryRequests[i] == request) {
  214. return true;
  215. }
  216. }
  217. }
  218. return false;
  219. };
  220. WorkingDialog.prototype.renderSecondInnerTable = function()
  221. {
  222. var sbOutput = '';
  223. var sWebRoot = this.getCognosViewer().getWebContentRoot();
  224. sbOutput += '<table width="300" border="0" cellpadding="0" cellspacing="0" role="presentation">';
  225. sbOutput += '<tr id="DeliveryOptionsVisible' + this.getNamespace() + '" class="workingDialogOptions">';
  226. sbOutput += '<td align="left">';
  227. sbOutput += '<table class="workingDialogInnerTable workingDialogLinks" role="presentation">';
  228. var bCanShowDeliveryOptions = this.canShowDeliveryOptions();
  229. if( bCanShowDeliveryOptions && this.deliverySectionIsNeeded() )
  230. {
  231. if (!this._isSaveBlackListed()) {
  232. sbOutput += this.addDeliverOption('/rv/images/action_save_report_output.gif', RV_RES.RV_SAVE_REPORT, 'SaveReport(true);');
  233. }
  234. if( 'reportView' !== this.getCognosViewer().envParams['ui.objectClass'] && !this._isSaveAsBlackListed() )
  235. {
  236. sbOutput += this.addDeliverOption('/rv/images/action_save_report_view.gif', RV_RES.RV_SAVE_AS_REPORT_VIEW, 'SaveAsReportView(true);');
  237. }
  238. if( !this.isUIBlacklisted('CC_RUN_OPTIONS_EMAIL_ATTACHMENT') && !this._isEmailBlackListed())
  239. {
  240. sbOutput += this.addDeliverOption('/rv/images/action_send_report.gif', RV_RES.RV_EMAIL_REPORT, 'SendReport(true);');
  241. }
  242. }
  243. sbOutput += '</table></td></tr> ';
  244. sbOutput += '<tr style="padding-top: 5px"> ';
  245. sbOutput += '<td align="left" colspan="3" id="cancelButtonContainer' + this.getNamespace() + '"> ';
  246. if(this.showCancelButton()){
  247. sbOutput += this.addCancelButton();
  248. }
  249. sbOutput += '</td></tr> ';
  250. sbOutput += '</table> ';
  251. return sbOutput;
  252. };
  253. WorkingDialog.prototype.addDeliverOption = function( sImage, sText, sOptionHandler )
  254. {
  255. var sbOutput = '';
  256. var sWebRoot = this.getCognosViewer().getWebContentRoot();
  257. var sRvObject = 'javascript: window.oCV' + this.getNamespace() + '.getRV().';
  258. var s_onClick = sRvObject + sOptionHandler;
  259. sbOutput += '<tr><td> ';
  260. sbOutput += '<a tabIndex="-1" href="' + sOptionHandler + '"> ';
  261. sbOutput += '<img border="0" src="'+ sWebRoot + sImage + '" alt=" ' + html_encode(sText) + '"/></a> ';
  262. sbOutput += '</td><td width="100%" valign="middle" class="tableText"> ';
  263. sbOutput += '<a tabIndex="0" role="link" href="#" onclick="' + s_onClick + '" style="padding-left: 5px" class="deliveryOptionLink"> ';
  264. sbOutput += ( sText + '</a></td></tr>');
  265. return sbOutput;
  266. };
  267. WorkingDialog.prototype.addCancelButton = function()
  268. {
  269. var sbOutput = '';
  270. var sWebContent = this.getCognosViewer().getWebContentRoot();
  271. sbOutput += '<table role="presentation"><tr><td> ';
  272. sbOutput += '<table id="cvWorkingDialog' + this.getNamespace() + '" role="presentation" cellpadding="0" cellspacing="0" onmouseover="this.className = \'commandButtonOver\'" onmouseout="this.className = \'commandButton\'" onmousedown="this.className = \'commandButtonDown\'" class="commandButton"> ';
  273. sbOutput += '<tr> ';
  274. sbOutput += '<td valign="middle" align="center" nowrap="nowrap" class="workingDialogCancelButton" ';
  275. if( isIE() )
  276. {
  277. sbOutput += 'id="btnAnchorIE" ';
  278. }
  279. else
  280. {
  281. sbOutput += 'id="btnAnchor" ';
  282. }
  283. sbOutput += '> ';
  284. var cancelButtonHandler = 'window.oCV' + this.m_sNamespace + ".cancel(this)";
  285. sbOutput += '<a href="#" onclick="' + cancelButtonHandler + '"> ';
  286. sbOutput += RV_RES.CANCEL;
  287. sbOutput += '</a> ';
  288. sbOutput += '</td></tr></table></td> ';
  289. sbOutput += '<td><img alt="" height="1" ';
  290. if ( isIE() )
  291. {
  292. sbOutput += 'width="10" ';
  293. }
  294. sbOutput += 'src="' + sWebContent + '/ps/images/space.gif"/></td> ';
  295. sbOutput += '</tr></table> ';
  296. return sbOutput;
  297. };
  298. WorkingDialog.prototype.disableCancelButton = function(cancelLink) {
  299. this.cancelButtonDisabled = true;
  300. var workingDialogTable = document.getElementById('cvWorkingDialog' + this.getNamespace());
  301. if (workingDialogTable) {
  302. workingDialogTable.style.cursor="default";
  303. workingDialogTable.className = "commandButtonOver";
  304. workingDialogTable.removeAttribute("onmouseover");
  305. workingDialogTable.removeAttribute("onmouseout");
  306. }
  307. if (cancelLink) {
  308. cancelLink.removeAttribute("href");
  309. cancelLink.removeAttribute("onclick");
  310. cancelLink.style.cursor="default";
  311. }
  312. };
  313. WorkingDialog.prototype.enableCancelButton = function() {
  314. if (this.cancelButtonDisabled) {
  315. var cancelButtonContainer = document.getElementById("cancelButtonContainer" + this.getNamespace());
  316. if (cancelButtonContainer) {
  317. cancelButtonContainer.innerHTML = this.addCancelButton();
  318. }
  319. this.cancelButtonDisabled = false;
  320. }
  321. };
  322. WorkingDialog.prototype.getContainerId = function() {
  323. return "CVWait" + this.getNamespace();
  324. };