waitdialog.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. // <script>
  2. /*
  3. =============================================================
  4. WebIntelligence(r) Report Panel
  5. Copyright(c) 2001-2003 Business Objects S.A.
  6. All rights reserved
  7. Use and support of this software is governed by the terms
  8. and conditions of the software license agreement and support
  9. policy of Business Objects S.A. and/or its subsidiaries.
  10. The Business Objects products and technology are protected
  11. by the US patent number 5,555,403 and 6,247,008
  12. File: waitdialog.js
  13. Waiting Dialog boxes
  14. dom.js dialog.js palette.js must be included before
  15. =============================================================
  16. */
  17. // ================================================================================
  18. // ================================================================================
  19. //
  20. // ================================================================================
  21. // ================================================================================
  22. //
  23. // OBJECT newWaitDialogBoxWidget (Constructor)
  24. //
  25. // Class for waiting dialog box
  26. //
  27. // ================================================================================
  28. // ================================================================================
  29. function newWaitDialogBoxWidget(id,w,h,title,bShowCancel,cancelCB,bShowLabel,text)
  30. // CONSTRUCTOR
  31. // id [String] the id for DHTML processing
  32. // title [String] the caption dialog text
  33. // width [int optional] dialog box width
  34. // height [int optional] dialog box height
  35. // showCancel [boolean optional] if true, a CANCEL button is displayed
  36. // cancelCB [Function optional] callback when esc key is hit or CANCEL button pushed
  37. // showLabel [boolean optional] if true, a label is displayed
  38. // text [String optional] label
  39. {
  40. // Min values for width and height of this dialog box
  41. var minW=250
  42. var minH=150
  43. if (w<minW)
  44. w=minW
  45. if (h<minH)
  46. h=minH
  47. // Justin: I've added the close button to the top right corner (last param=false) so that the user can hide
  48. // the progress dialog. The cancel button option of the waitdialog adds a full button to the dialog
  49. // and gives the user the expectation that the request has been cancelled vs. just hiding this dialog.
  50. var o=newDialogBoxWidget(id,title,w,h,null,WaitDialogBoxWidget_cancelCB,false)
  51. // Properties
  52. o.pad=5
  53. var zoneW=o.getContainerWidth()-10
  54. var zoneH=o.getContainerHeight()-(2*o.pad+21+10)
  55. o.frZone=newFrameZoneWidget(id+"_frZone",zoneW,zoneH)
  56. o.frZone.beginHTML=WaitDialog_FrameZoneWidget_beginHTML
  57. o.frZone.endHTML=WaitDialog_FrameZoneWidget_endHTML
  58. o.showLabel=(bShowLabel!=null)?bShowLabel:false
  59. o.showCancel=(bShowCancel!=null)?bShowCancel:false
  60. o.label=newWidget(id+"_label")
  61. o.label.text=text
  62. if (o.showCancel) {
  63. o.cancelButton=newButtonWidget(id+"_cancelButton",_cancelButtonLab,CancelButton_cancelCB)
  64. o.cancelButton.par=o
  65. }
  66. else {
  67. // otherwise getHTML asks for button.gif which costs an extra http request
  68. o.cancelButton={};
  69. o.cancelButton.init=function(){};
  70. o.cancelButton.setDisplay=function(x) {};
  71. o.cancelButton.setDisabled=function(x) {};
  72. o.cancelButton.getHTML=function(){ return '' };
  73. }
  74. o.cancelCB=cancelCB
  75. // Methods
  76. o.oldDialogBoxInit=o.init
  77. o.init=WaitDialogBoxWidget_init
  78. o.oldShow2=o.show
  79. o.show=WaitDialogBoxWidget_show
  80. o.getHTML=WaitDialogBoxWidget_getHTML
  81. o.setShowCancel=WaitDialogBoxWidget_setShowCancel
  82. o.setShowLabel=WaitDialogBoxWidget_setShowLabel
  83. return o
  84. }
  85. // ================================================================================
  86. function WaitDialogBoxWidget_init()
  87. // Init the widget layers
  88. // Return [void]
  89. {
  90. var o=this
  91. o.oldDialogBoxInit()
  92. o.frZone.init()
  93. o.label.init()
  94. o.label.setDisplay(o.showLabel)
  95. o.cancelButton.init()
  96. o.cancelButton.setDisplay(o.showCancel)
  97. }
  98. // ================================================================================
  99. function WaitDialogBoxWidget_getHTML()
  100. // getHTML
  101. // Returns the HTML generated for the WaitDialogBoxWidget
  102. {
  103. var o=this, s=''
  104. s+= o.beginHTML()
  105. s+= '<table border="0" cellspacing="0" cellpadding="0" width="100%"><tbody>'
  106. s+= '<tr>' +
  107. '<td align="center" valign="top">' +
  108. o.frZone.beginHTML()
  109. s+= '<table border="0" cellspacing="0" cellpadding="0" width="100%"><tbody>' +
  110. '<tr>' +
  111. '<td align="center" style="padding-top:5px;">' + img(_skin+'wait01.gif',200,40) + '</td>' +
  112. '</tr>' +
  113. '<tr>' +
  114. '<td align="left" style="padding-left:2px;padding-right:2px;padding-top:5px;">' +
  115. '<div id="'+o.label.id+'" class="icontext" style="wordWrap:break_word;">'+convStr(o.label.text,false,true)+'</div>'+
  116. '</td>' +
  117. '</tr>' +
  118. '</tbody></table>'
  119. s+= o.frZone.endHTML() +
  120. '</td>' +
  121. '</tr>'
  122. s+= '<tr>' +
  123. '<td align="center" valign="middle" style="padding-top:5px;">' +
  124. '<div id="cancelDiv' + o.id + '">' + o.cancelButton.getHTML() + '</div>' +
  125. '</td>' +
  126. '</tr>'
  127. s+= '</tbody></table>'
  128. s+= o.endHTML()
  129. return s
  130. }
  131. // ================================================================================
  132. function WaitDialog_FrameZoneWidget_beginHTML()
  133. {
  134. var o=this
  135. return '<table class="waitdialogzone" style="'+sty("width",o.w)+sty("height",o.h)+'" id="'+o.id+'" cellspacing="0" cellpadding="0" border="0"><tbody>'+
  136. '<tr><td valign="top" class="dialogzone" id="frame_cont_'+o.id+'">'
  137. }
  138. // ================================================================================
  139. function WaitDialog_FrameZoneWidget_endHTML()
  140. {
  141. var o=this
  142. return '</td></tr></tbody></table>'
  143. }
  144. // ================================================================================
  145. function WaitDialogBoxWidget_setShowCancel(show,cancelCB)
  146. // Show or hide the cancel button
  147. // show [boolean] if true, cancel button is displayed
  148. {
  149. var o=this
  150. o.showCancel=show
  151. o.cancelButton.setDisabled(false)
  152. o.cancelButton.setDisplay(show)
  153. o.cancelCB=cancelCB
  154. }
  155. // ================================================================================
  156. function WaitDialogBoxWidget_setShowLabel(show,text)
  157. // Show or hide the label
  158. // show [boolean] if true, label is displayed
  159. // text [string] text label
  160. {
  161. var o=this
  162. o.showLabel=show
  163. o.label.text=text
  164. o.label.setHTML(text)
  165. o.label.setDisplay(show)
  166. }
  167. // ================================================================================
  168. function WaitDialogBoxWidget_cancelCB()
  169. // Callback called when the cancel button is hit
  170. {
  171. var o=this
  172. if (o.cancelCB != null)
  173. {
  174. o.cancelCB()
  175. o.cancelButton.setDisabled(true);
  176. }
  177. }
  178. // ================================================================================
  179. function CancelButton_cancelCB()
  180. // Callback called when the cancel button is hit
  181. {
  182. var o=this
  183. if (o.par.cancelCB != null)
  184. {
  185. o.par.cancelCB()
  186. o.par.cancelButton.setDisabled(true);
  187. }
  188. }
  189. // ================================================================================
  190. function WaitDialogBoxWidget_show(bShow)
  191. // Show the WaitDialog and start the progress bar animation if necessary
  192. // bShow [boolean] if true, waitDialog is displayed
  193. {
  194. var o=this
  195. if (bShow)
  196. {
  197. if (o.showCancel)
  198. o.frZone.resize(null,o.getContainerHeight()-(2*o.pad+21+10))
  199. else
  200. o.frZone.resize(null,o.getContainerHeight()-10)
  201. }
  202. o.oldShow2(bShow)
  203. }