function RecoveryUserView(options){var self=this; self.userServiceFacade=options.userServiceFacade; self.inet=options.inet; self.i18n=options.i18n; self.messageHandler=options.messageHandler; self.idRecaptcha=null; self._init(); }RecoveryUserView.prototype._init=function(){var self=this; self._loadStep("recoveryUserStep",{i18n:self.i18n}); $(document).off("submit","#recoveryUserForm").on("submit","#recoveryUserForm",function(event){event.preventDefault(); self._submitForm(); }); $(document).off("submit","#formRestoreUserFourthStep").on("submit","#formRestoreUserFourthStep",function(event){event.preventDefault(); self._submitFormFinalStep(); }); self.inet.getCountries(); $("#recoveryUserCountrySelect").selectpicker({width:"300px",height:"35px",dropupAuto:false,size:7}); $("body").loader("show"); self.loadCaptcha(); }; RecoveryUserView.prototype._loadStep=function(action,params,module){var self=this; captcha.hide(); if(!module&&module!=""){module="recoveryUser"; }self.inet.loadStep(action,params,module); }; RecoveryUserView.prototype.loadCaptcha=function(reset){var self=this; var countryCode={countryCode:inet.countryCode}; self.userServiceFacade.checkCaptcha(countryCode,self._onSuccessCheckCaptcha,self._onErrorCheckCaptcha,self); }; RecoveryUserView.prototype._onSuccessCheckCaptcha=function(data){var self=this; captcha.render(data); }; RecoveryUserView.prototype._onErrorCheckCaptcha=function(response,textStatus,errorThrown){var self=this; $("body").loader("hide"); self.messageHandler.showMessage(self.messageHandler.MESSAGE_TYPE_ERROR,self.i18n.msg("error.internal"),"messageArea"); }; RecoveryUserView.prototype._submitForm=function(){var self=this; var empId=$.trim($("#inputUserIdRecoveryUser").val()); var country=$("#recoveryUserCountrySelect").val(); var countryRequired=true; var captchaToken=""; var hasEmptyFields=false; var empIdComplete=""; if(empId!=""){self._removeValidationWarning("inputUserIdRecoveryUser",hasEmptyFields); }else{self._addValidationWarning("inputUserIdRecoveryUser"); hasEmptyFields=true; }if(empId!=""){countryRequired=true; mailRequired=false; empIdComplete="E"+country+empId; }else{mailRequired=true; }if(countryRequired&&(null==country||country=="-1")){hasEmptyFields=true; self._addValidationWarning("recoveryUserCountryDiv"); }else{self._removeValidationWarning("recoveryUserCountryDiv",hasEmptyFields); }var data=captcha.val(); if(captcha.isRequired()&&$.isEmptyObject(data)){hasEmptyFields=true; self._addValidationCaptchaWarning(); }else{self._removeValidationCaptchaWarning(hasEmptyFields); }if(hasEmptyFields==false){$("body").loader("show"); if($.isNumeric(empId)){while(empId.length<7){empId="0"+empId; }}self.userServiceFacade.getDeliveryType(empIdComplete,data,self._onSuccessRecoveryUser,self._onErrorRecoveryUser,self); }}; RecoveryUserView.prototype._onSuccessRecoveryUser=function(data){if(data.userValid==true){var login=data.login; this._loadStep("recoveryUserFinalStep",{login:login}); $("body").loader("hide"); }else{if(data.code=="98"){this.messageHandler.showMessage(this.messageHandler.MESSAGE_TYPE_ERROR,data.message,"messageArea"); }else{this.messageHandler.showMessage(this.messageHandler.MESSAGE_TYPE_ERROR,this.i18n.msg("error.user.not.valid"),"messageArea"); }this.loadCaptcha(); }}; RecoveryUserView.prototype._onErrorRecoveryUser=function(response,textStatus,errorThrown){this.messageHandler.handleErrors(response,"messageArea"); this.loadCaptcha(); }; RecoveryUserView.prototype._submitFormFinalStep=function(){var login=$("#recoverUserFormStepFinal").val(); $("#userLogin").val(login); $("#recoveryView").modal("hide"); $("#real_pass").focus(); }; RecoveryUserView.prototype._addValidationWarning=function(idDiv,msg){var self=this; $("#"+idDiv).addClass("rojo"); if(null==msg||msg==""){msg=this.i18n.msg("error.required.field"); }this.messageHandler.showMessage(this.messageHandler.MESSAGE_TYPE_REQUIRED_FIELD,msg,"messageArea"); }; RecoveryUserView.prototype._addValidationCaptchaWarning=function(idDiv){var self=this; captcha.addBorderValidation(); this.messageHandler.showMessage(this.messageHandler.MESSAGE_TYPE_REQUIRED_FIELD,this.i18n.msg("error.required.field"),"messageArea"); }; RecoveryUserView.prototype._removeValidationWarning=function(idDiv,hasEmptyFields){$("#"+idDiv).removeClass("rojo"); if(!hasEmptyFields){$("#texto_alerta").removeClass("texto_alerta_rojo"); }}; RecoveryUserView.prototype._removeValidationCaptchaWarning=function(hasEmptyFields){captcha.removeBorderValidation(); if(!hasEmptyFields){$("#texto_alerta").removeClass("texto_alerta_rojo"); }};