/**************************************************************** ** Licensed Materials - Property of IBM ** ** IBM Cognos Products: drill ** ** (C) Copyright IBM Corp. 2001, 2010 ** ** US Government Users Restricted Rights - Use, duplication or ** disclosure restricted by GSA ADP Schedule Contract with ** IBM Corp. *****************************************************************/ /** * D_RenameReplace.F_Dialog_OnBeforeVisible Called before dialog becomes visible. * Used to set the warning icon, and strings. */ D_RenameReplace.F_Dialog_OnBeforeVisible = function() { var v_imgWarnning = this.F_GetDlgItem( "iWarning" ); v_imgWarnning.src = webRoot+'/ps/portal/images/msg_warning.gif'; var v_divNameExist = this.F_GetDlgItem( "dNameExist" ); 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"); v_divNameExist.innerText = v_sTheNameMessage; var v_inputTextBox = this.F_GetDlgItem( "iTextBox" ); v_inputTextBox.value = this.m_sObjectName; }; /** *D_RenameReplace.F_Dialog_OnAfterVisible Called after dialog becomes visible * used to set some of the behaviors of the dialog * Including, Disable OK button and set the focus on text box */ D_RenameReplace.F_Dialog_OnAfterVisible = function() { this.F_DisableOkSelectText(); v_oCurrentActionRename = this.F_GetDlgItem( "iCurrentActionRename" ); // Rename is the default action v_oCurrentActionRename.checked = true; } /** *F_DisableOkSelectText Disables the OK button, sets the focus on text box and highlights the text */ D_RenameReplace.F_DisableOkSelectText = function() { var v_oOKButton = this.F_GetDlgItem( "IDS_HAL_BTN_OK" ); var v_inputTextBox = this.F_GetDlgItem( "iTextBox" ); v_inputTextBox.disabled = false; v_inputTextBox.focus(); v_inputTextBox.select(); v_oOKButton.disabled = true; v_oOKButton.style.color = 'LightGrey'; } /** *F_DisableOkSelectText Disables the OK button, */ D_RenameReplace.F_DisableOk = function() { var v_oOKButton = this.F_GetDlgItem( "IDS_HAL_BTN_OK" ); var v_inputTextBox = this.F_GetDlgItem( "iTextBox" ); v_inputTextBox.disabled = false; v_oOKButton.disabled = true; v_oOKButton.style.color = 'LightGrey'; } D_RenameReplace.F_EnableOK = function() { var v_oOKButton = this.F_GetDlgItem( "IDS_HAL_BTN_OK" ); v_oOKButton.disabled = false; v_oOKButton.style.color = 'black'; } /** * F_Dialog_EnableOK Enables the OK button if user selects replace or change the name of the object * This is called onClick event of replace option control and onKeyUp event of the * text box. */ D_RenameReplace.F_Dialog_CheckEnableOK = function() { v_oCurrentActionReplace = this.F_GetDlgItem( "iCurrentActionReplace" ); var v_inputTextBox = this.F_GetDlgItem( "iTextBox" ); if (v_oCurrentActionReplace.checked) { this.F_EnableOK(); var v_oOKButton = this.F_GetDlgItem( "IDS_HAL_BTN_OK" ); v_oOKButton.focus(); v_inputTextBox.value = this.m_sObjectName; v_inputTextBox.disabled = true; } else if (this.m_sObjectName != v_inputTextBox.value.F_Trim() && v_inputTextBox.value.F_Trim() != '') { this.F_EnableOK(); } else { this.F_DisableOk(); } }; /* * F_Dialog_CheckDisableOK Disables the OK button if the name of the object is still the same or blank * This method is called when user clicks on rename option */ D_RenameReplace.F_Dialog_CheckDisableOK = function() { var v_inputTextBox = this.F_GetDlgItem( "iTextBox" ); if (this.m_sObjectName == v_inputTextBox.value || v_inputTextBox.value.F_Trim() == '') { this.F_DisableOkSelectText(); } }; /* * F_Dialog_OnAfterHide This is called after hide is called on the dialog. */ D_RenameReplace.F_Dialog_OnAfterHide = function() { delete this.m_oListener; delete this.m_nInfo; delete this.m_iHeight; delete this.m_iWidth; }; /** * F_OnOK This method is called when user clicks on OK It passes the name and the update action to the listener object * The listener object should implements a method called F_D_RenameReplace_OnOK (this,v_sCurrentAction,v_inputTextBox.value) and performs the proper action based on the passed parameters to it */ D_RenameReplace.F_OnOK = function() { var v_inputTextBox = this.F_GetDlgItem( "iTextBox" ); if ( this.m_oListener) { v_oCurrentActionReplace = this.F_GetDlgItem( "iCurrentActionReplace" ); var v_inputTextBox = this.F_GetDlgItem( "iTextBox" ); var v_sCurrentAction = ""; if (v_oCurrentActionReplace.checked) { v_sCurrentAction = "replace"; } else { v_sCurrentAction = "rename"; } // if action is not replace once more we validate that the name has changed // 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) if (v_sCurrentAction == "replace" || (this.m_sObjectName != v_inputTextBox.value.F_Trim() && v_inputTextBox.value.F_Trim() != '')) { this.m_oListener.F_D_RenameReplace_OnOK(this,v_sCurrentAction,v_inputTextBox.value); } else { this.F_DisableOkSelectText(); } } else { this.M_fnSuper_OnOK(); } }; /** * F_OnCancel This method is called when user clicks on Cancel * It calls a method called F_D_RenameReplace_OnCancel(this) passing the dialog object * This is used to hide the dialog object and perform any other action required onCancel * In Drill Case it is used to enable the page controls that are disabled before calling * this modal dialog. */ D_RenameReplace.F_OnCancel = function() { if ( this.m_oListener) { if (this.m_oListener) { this.m_oListener.F_D_RenameReplace_OnCancel(this); } } else { this.M_fnSuper_OnOK(); } };