WorkingDialog.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. *+------------------------------------------------------------------------+
  3. *| Licensed Materials - Property of IBM
  4. *| IBM Cognos Products: Viewer
  5. *| (C) Copyright IBM Corp. 2001, 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. dojo.provide("WorkingDialog");
  13. dojo.declare("WorkingDialog", IRequestIndicator, {
  14. constructor: function(oCV) {
  15. this.m_oCV = oCV;
  16. this.m_sNamespace = oCV.getId();
  17. this.m_sGateway = oCV.getGateway();
  18. try {
  19. var buttons = [];
  20. if (oCV.getAdvancedServerProperty("VIEWER_JS_HIDE_CANCEL_BUTTON") != "true") {
  21. buttons.push({"class":"icdDialogButton", label: RV_RES.CANCEL, onClick: dojo.hitch(this, this.doCancel)});
  22. }
  23. this.m_waitPageDialog = new ViewerIWidgetInlineDialog(this.getCognosViewer(), this.getWaitPageHTML(), buttons, "waitButtonContainer_" + this.getCognosViewer().getId());
  24. // uncomment to help debug the wait dialog
  25. // this.m_waitPageDialog.setDebugHelper(getCognosViewerObjectRefAsString(this.getCognosViewer().getId()) + ".m_waitPage");
  26. }
  27. catch (e) {
  28. if (console && console.log) {
  29. console.log(e);
  30. }
  31. }
  32. },
  33. setSimpleWorkingDialogFlag: function( flag ){},
  34. getCognosViewer: function() {
  35. return this.m_oCV;
  36. },
  37. show: function() {
  38. this.m_waitPageDialog.show();
  39. },
  40. getWaitPageHTML: function() {
  41. var id = this.getCognosViewer().getId();
  42. return '<table cellspacing="4" cellpadding="0" border="0" wairole="presentation" role="presentation" style="width:100%;height:100%">' +
  43. '<tbody><tr><td align="center">' +
  44. '<div class="dijitInline widget_load_background" role="presentation" tabindex="0">' +
  45. '<div id="working' + id +'" class="widget_load" aria-labelledby="working' + id + '">' +
  46. RV_RES.IDS_JS_WAIT_PAGE_LOADING +
  47. '</div>' +
  48. '<div id="waitButtonContainer_' + id + '" class="icdDialogButtonBar" style="text-align:center;padding-left:12px;padding-right:12px;"></div>' +
  49. '</div>' +
  50. '</td></tr></tbody>' +
  51. '</table>';
  52. },
  53. hide: function() {
  54. this.m_waitPageDialog.hide();
  55. this.m_cancelCallback = null;
  56. },
  57. setCancelCallback: function(callback) {
  58. this.m_cancelCallback = callback;
  59. },
  60. doCancel: function() {
  61. var oCV = this.getCognosViewer();
  62. if(this.m_cancelCallback) {
  63. this.m_cancelCallback();
  64. this.m_cancelCallback = null;
  65. }
  66. else {
  67. var bCancelCalled = oCV.cancel();
  68. // is we actually sent a cancel request, fix up the undo/redo stack
  69. if (bCancelCalled) {
  70. var undoRedoQueue = oCV.getViewerWidget().getUndoRedoQueue();
  71. if (undoRedoQueue) {
  72. undoRedoQueue.handleCancel();
  73. }
  74. }
  75. }
  76. if (oCV.isReportRenderingDone()) {
  77. this.hide();
  78. }
  79. else {
  80. var payload = { action: 'deleteWidget' };
  81. oCV.getViewerWidget().iContext.iEvents.fireEvent("com.ibm.bux.widget.action", null, payload);
  82. }
  83. }
  84. });