D_RenameReplace_async.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /****************************************************************
  2. ** Licensed Materials - Property of IBM
  3. **
  4. ** IBM Cognos Products: drill
  5. **
  6. ** (C) Copyright IBM Corp. 2001, 2010
  7. **
  8. ** US Government Users Restricted Rights - Use, duplication or
  9. ** disclosure restricted by GSA ADP Schedule Contract with
  10. ** IBM Corp.
  11. *****************************************************************/
  12. /**
  13. * D_RenameReplace.F_Dialog_OnBeforeVisible Called before dialog becomes visible.
  14. * Used to set the warning icon, and strings.
  15. */
  16. D_RenameReplace.F_Dialog_OnBeforeVisible = function()
  17. {
  18. var v_imgWarnning = this.F_GetDlgItem( "iWarning" );
  19. v_imgWarnning.src = webRoot+'/ps/portal/images/msg_warning.gif';
  20. var v_divNameExist = this.F_GetDlgItem( "dNameExist" );
  21. v_sTheNameMessage = G_ResManager.F_GetString("IDS_WIZARD_THE_NAME")+ " '" + this.m_sObjectName +"' " + G_ResManager.F_GetString("IDS_WIZARD_ALREADY_EXISTS") + G_ResManager.F_GetString("IDS_WIZARD_YOU_CAN_REPLACE");
  22. v_divNameExist.innerText = v_sTheNameMessage;
  23. var v_inputTextBox = this.F_GetDlgItem( "iTextBox" );
  24. v_inputTextBox.value = this.m_sObjectName;
  25. };
  26. /**
  27. *D_RenameReplace.F_Dialog_OnAfterVisible Called after dialog becomes visible
  28. * used to set some of the behaviors of the dialog
  29. * Including, Disable OK button and set the focus on text box
  30. */
  31. D_RenameReplace.F_Dialog_OnAfterVisible = function()
  32. {
  33. this.F_DisableOkSelectText();
  34. v_oCurrentActionRename = this.F_GetDlgItem( "iCurrentActionRename" );
  35. // Rename is the default action
  36. v_oCurrentActionRename.checked = true;
  37. }
  38. /**
  39. *F_DisableOkSelectText Disables the OK button, sets the focus on text box and highlights the text
  40. */
  41. D_RenameReplace.F_DisableOkSelectText = function()
  42. {
  43. var v_oOKButton = this.F_GetDlgItem( "IDS_HAL_BTN_OK" );
  44. var v_inputTextBox = this.F_GetDlgItem( "iTextBox" );
  45. v_inputTextBox.disabled = false;
  46. v_inputTextBox.focus();
  47. v_inputTextBox.select();
  48. v_oOKButton.disabled = true;
  49. v_oOKButton.style.color = 'LightGrey';
  50. }
  51. /**
  52. *F_DisableOkSelectText Disables the OK button,
  53. */
  54. D_RenameReplace.F_DisableOk = function()
  55. {
  56. var v_oOKButton = this.F_GetDlgItem( "IDS_HAL_BTN_OK" );
  57. var v_inputTextBox = this.F_GetDlgItem( "iTextBox" );
  58. v_inputTextBox.disabled = false;
  59. v_oOKButton.disabled = true;
  60. v_oOKButton.style.color = 'LightGrey';
  61. }
  62. D_RenameReplace.F_EnableOK = function()
  63. {
  64. var v_oOKButton = this.F_GetDlgItem( "IDS_HAL_BTN_OK" );
  65. v_oOKButton.disabled = false;
  66. v_oOKButton.style.color = 'black';
  67. }
  68. /**
  69. * F_Dialog_EnableOK Enables the OK button if user selects replace or change the name of the object
  70. * This is called onClick event of replace option control and onKeyUp event of the
  71. * text box.
  72. */
  73. D_RenameReplace.F_Dialog_CheckEnableOK = function()
  74. {
  75. v_oCurrentActionReplace = this.F_GetDlgItem( "iCurrentActionReplace" );
  76. var v_inputTextBox = this.F_GetDlgItem( "iTextBox" );
  77. if (v_oCurrentActionReplace.checked)
  78. {
  79. this.F_EnableOK();
  80. var v_oOKButton = this.F_GetDlgItem( "IDS_HAL_BTN_OK" );
  81. v_oOKButton.focus();
  82. v_inputTextBox.value = this.m_sObjectName;
  83. v_inputTextBox.disabled = true;
  84. }
  85. else if (this.m_sObjectName != v_inputTextBox.value.F_Trim() && v_inputTextBox.value.F_Trim() != '')
  86. {
  87. this.F_EnableOK();
  88. }
  89. else
  90. {
  91. this.F_DisableOk();
  92. }
  93. };
  94. /*
  95. * F_Dialog_CheckDisableOK Disables the OK button if the name of the object is still the same or blank
  96. * This method is called when user clicks on rename option
  97. */
  98. D_RenameReplace.F_Dialog_CheckDisableOK = function()
  99. {
  100. var v_inputTextBox = this.F_GetDlgItem( "iTextBox" );
  101. if (this.m_sObjectName == v_inputTextBox.value || v_inputTextBox.value.F_Trim() == '')
  102. {
  103. this.F_DisableOkSelectText();
  104. }
  105. };
  106. /*
  107. * F_Dialog_OnAfterHide This is called after hide is called on the dialog.
  108. */
  109. D_RenameReplace.F_Dialog_OnAfterHide = function()
  110. {
  111. delete this.m_oListener;
  112. delete this.m_nInfo;
  113. delete this.m_iHeight;
  114. delete this.m_iWidth;
  115. };
  116. /**
  117. * F_OnOK This method is called when user clicks on OK
  118. It passes the name and the update action to the listener object
  119. * The listener object should implements a method called F_D_RenameReplace_OnOK (this,v_sCurrentAction,v_inputTextBox.value)
  120. and performs the proper action based on the passed parameters to it
  121. */
  122. D_RenameReplace.F_OnOK = function()
  123. {
  124. var v_inputTextBox = this.F_GetDlgItem( "iTextBox" );
  125. if ( this.m_oListener)
  126. {
  127. v_oCurrentActionReplace = this.F_GetDlgItem( "iCurrentActionReplace" );
  128. var v_inputTextBox = this.F_GetDlgItem( "iTextBox" );
  129. var v_sCurrentAction = "";
  130. if (v_oCurrentActionReplace.checked)
  131. {
  132. v_sCurrentAction = "replace";
  133. }
  134. else
  135. {
  136. v_sCurrentAction = "rename";
  137. }
  138. // if action is not replace once more we validate that the name has changed
  139. // this is done for the paste in IE (If user paste the same name in IE we enable the OK button because we can't check the content)
  140. if (v_sCurrentAction == "replace" || (this.m_sObjectName != v_inputTextBox.value.F_Trim() && v_inputTextBox.value.F_Trim() != ''))
  141. {
  142. this.m_oListener.F_D_RenameReplace_OnOK(this,v_sCurrentAction,v_inputTextBox.value);
  143. }
  144. else
  145. {
  146. this.F_DisableOkSelectText();
  147. }
  148. }
  149. else
  150. {
  151. this.M_fnSuper_OnOK();
  152. }
  153. };
  154. /**
  155. * F_OnCancel This method is called when user clicks on Cancel
  156. * It calls a method called F_D_RenameReplace_OnCancel(this) passing the dialog object
  157. * This is used to hide the dialog object and perform any other action required onCancel
  158. * In Drill Case it is used to enable the page controls that are disabled before calling
  159. * this modal dialog.
  160. */
  161. D_RenameReplace.F_OnCancel = function()
  162. {
  163. if ( this.m_oListener)
  164. {
  165. if (this.m_oListener)
  166. {
  167. this.m_oListener.F_D_RenameReplace_OnCancel(this);
  168. }
  169. }
  170. else
  171. {
  172. this.M_fnSuper_OnOK();
  173. }
  174. };