WebMsgDialog.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*
  2. var TYPE_NOTICE = 0;
  3. var TYPE_WARN = 1;
  4. var TYPE_ASK = 2;
  5. var TYPE_ASK = 3;
  6. var TYPE_ERROR = 4;
  7. */
  8. function WebMsgDialog(ctxPath) {
  9. /* public properties */
  10. this.TYPE_NOTICE = 0;
  11. this.TYPE_WARN = 1;
  12. this.TYPE_ASK = 2;
  13. this.TYPE_ERROR = 3;
  14. this.TYPE_CONFIRM = 4;
  15. /* private properties */
  16. this._ctxPath = ctxPath;
  17. }
  18. WebMsgDialog.prototype.showMessageBox = function(msgType,msgContents,detailContents,delayTime) {
  19. var msgURL = "/common/msgBox.do";
  20. var pObj = new Object();
  21. pObj.msgType = msgType;
  22. //pObj.msgTitle = msgTitle;
  23. pObj.msgContents = msgContents;
  24. pObj.detailContents = detailContents;
  25. pObj.delayTime = delayTime;
  26. if(this._ctxPath!= null && this._ctxPath != "")
  27. {
  28. msgURL = this._ctxPath + msgURL;
  29. }
  30. msgURL = msgURL +"?msgType="+msgType;
  31. //alert("msgURL="+msgURL);
  32. //alert("msgType="+pObj.msgType+",msgContents="+msgContents);
  33. var Obj = window.showModalDialog(msgURL,pObj,'dialogWidth:429px;DialogHeight=208px;help:no;status:no');
  34. return Obj;
  35. }
  36. WebMsgDialog.prototype.showMessageLessBox = function(msgType,msgContents,detailContents,delayTime) {
  37. var msgURL = "/common/msgBox.do";
  38. var pObj = new Object();
  39. pObj.msgType = msgType;
  40. //pObj.msgTitle = msgTitle;
  41. pObj.msgContents = msgContents;
  42. pObj.detailContents = detailContents;
  43. pObj.delayTime = delayTime;
  44. if(this._ctxPath!= null && this._ctxPath != "")
  45. {
  46. msgURL = this._ctxPath + msgURL;
  47. }
  48. msgURL = msgURL +"?msgType="+msgType;
  49. //alert("msgURL="+msgURL);
  50. //alert("msgType="+pObj.msgType+",msgContents="+msgContents);
  51. var Obj = window.showModelessDialog(msgURL,pObj,'dialogWidth:429px;DialogHeight=208px;help:no;status:no');
  52. return Obj;
  53. }
  54. WebMsgDialog.prototype.showIndexMessageBox = function(msgType,msgContents,detailContents,delayTime) {
  55. var msgURL = "/msgbox.jsp";
  56. var pObj = new Object();
  57. pObj.msgType = msgType;
  58. //pObj.msgTitle = msgTitle;
  59. pObj.msgContents = msgContents;
  60. pObj.detailContents = detailContents;
  61. pObj.delayTime = delayTime;
  62. if(this._ctxPath!= null && this._ctxPath != "")
  63. {
  64. msgURL = this._ctxPath + msgURL;
  65. }
  66. msgURL = msgURL +"?msgType="+msgType;
  67. //alert("msgURL="+msgURL);
  68. //alert("msgType="+pObj.msgType+",msgContents="+msgContents);
  69. var Obj = window.showModalDialog(msgURL,pObj,'dialogWidth:429px;DialogHeight=208px;help:no;status:no');
  70. return Obj;
  71. }
  72. WebMsgDialog.prototype.showIndexAskMessageBox = function(msgType,msgContents,detailContents,delayTime) {
  73. var msgURL = "/askMsgbox.jsp";
  74. var pObj = new Object();
  75. pObj.msgType = msgType;
  76. //pObj.msgTitle = msgTitle;
  77. pObj.msgContents = msgContents;
  78. pObj.detailContents = detailContents;
  79. pObj.delayTime = delayTime;
  80. if(this._ctxPath!= null && this._ctxPath != "")
  81. {
  82. msgURL = this._ctxPath + msgURL;
  83. }
  84. msgURL = msgURL +"?msgType="+msgType;
  85. //alert("msgURL="+msgURL);
  86. //alert("msgType="+pObj.msgType+",msgContents="+msgContents);
  87. var Obj = window.showModalDialog(msgURL,pObj,'dialogWidth:429px;DialogHeight=208px;help:no;status:no');
  88. return Obj;
  89. }
  90. function cmd_OK()
  91. {
  92. var obj = new Object();
  93. obj.id=1;
  94. window.returnValue = obj;
  95. window.close();
  96. }
  97. function cmd_NO()
  98. {
  99. var obj = new Object();
  100. obj.id=0;
  101. window.returnValue = obj;
  102. window.close();
  103. }
  104. function cmd_detail()
  105. {
  106. var display = document.all("detailID").style.display;
  107. var preHeight = document.all("detailTdID").clientHeight;
  108. if(display == "none"){
  109. document.all("detailID").style.display = "";
  110. }else{
  111. document.all("detailID").style.display = "none";
  112. }
  113. var curHeight = document.all("detailTdID").clientHeight;
  114. //alert("curHeight - preHeight="+curHeight - preHeight);
  115. //alert("preHeight="+preHeight+",curHeight="+curHeight);
  116. resetDialog(curHeight - preHeight);
  117. }
  118. function resetDialog(vl){
  119. var indexOfp = dialogHeight.indexOf("p");
  120. var dialogHeightInt = parseInt(dialogHeight.substring(0,indexOfp));
  121. //alert("vl="+vl);
  122. window.dialogHeight = dialogHeightInt + vl + "px";
  123. }
  124. function setMsgBoxData()
  125. {
  126. var argArray = new Array(window.dialogArguments);
  127. //alert(argArray.length);
  128. var valueObj = new Object();
  129. valueObj = argArray[0];
  130. //alert("msgType="+valueObj.msgType+",msgTitle="+valueObj.msgTitle+",msgContents="+valueObj.msgContents);
  131. var preCtHeight = document.all("windowHeight").clientHeight;
  132. var preDialogHeight = window.dialogHeight;
  133. var addHeight = document.body.scrollHeight - document.body.clientHeight
  134. //alert("preCtHeight="+preCtHeight+",preDialogHeight="+preDialogHeight);
  135. document.all("msgContentID").innerHTML = valueObj.msgContents;
  136. if(valueObj.detailContents != null && valueObj.detailContents != "")
  137. {
  138. document.all("detailCtID").value = valueObj.detailContents;
  139. }else{
  140. document.all("detailBtID").innerHTML="";
  141. }
  142. //alert( document.all("trID").clientHeight);
  143. var ctHeight = document.all("windowHeight").clientHeight;
  144. var increasedHeight = parseInt(ctHeight) - parseInt(preCtHeight);
  145. // alert("increasedHeight="+increasedHeight);
  146. var dialogHeight = window.dialogHeight;
  147. var indexOfp = dialogHeight.indexOf("p");
  148. var dialogHeightInt = parseInt(dialogHeight.substring(0,indexOfp));
  149. //alert("dialogHeightInt="+dialogHeightInt);
  150. window.dialogHeight = dialogHeightInt + increasedHeight + addHeight + "px";
  151. //alert("dialogHeight="+window.dialogHeight);
  152. if(valueObj.delayTime != null && valueObj.delayTime != "")
  153. {
  154. setTimeout("window.close()",valueObj.delayTime);
  155. }
  156. }