ngAWDSApp.directive("formMailBasicV2Directive",["$rootScope","$window","FormMailFactory","vcRecaptchaService","FormMailServices",function(n,t,i,r,u){return{restrict:"A",scope:!0,link:function(){},controller:["$scope","$element","$attrs",function(f,e){f.options={};f.mail={};f.Recaptcha={};f.isUbsCaptcha=!1;f.hasNewModelMedia=!1;f.initMailBasic=function(t){f.options=angular.merge({isUMFW:!0,MailTypeOptions:"",MailFrom:"",MailSubject:"",TxtMessage:"",MailType:""},t);n.webApp.util.hasVal(f.options.MailFrom)&&(f.mail.MailFrom=f.options.MailFrom);n.webApp.util.hasVal(f.options.MailSubject)&&(f.mail.MailSubject=f.options.MailSubject);n.webApp.util.hasVal(f.options.TxtMessage)&&(f.mail.TxtMessage=f.options.TxtMessage);n.webApp.util.hasVal(f.options.MailType)&&(f.mail.MailType=f.options.MailType);n.webApp.util.hasVal(f.options.MailTypeOptions)&&(f.mail.MailTypeOptions=f.options.MailTypeOptions);f.loadCaptcha()};f.OnClickSend=function(n){f.sendEmail(n)};f.OnClickSendWithData=function(n,t,i){f.mail.MailBody=n;f.mail.MailSubject=t;f.sendEmail(i)};f.OnClickSendWithDataV2=function(n,t,i,r){f.mail.MailBody=n;f.mail.MailSubject=t;f.sendEmailV2(r,i)};f.sendMailWithoutCap=function(t,i,r,e){if(r=r||f.myForm,f.mail.MailBody=t,f.mail.MailSubject=i,r.submitted=!0,r.$valid){var o=n.webApp.util.generateUID().substring(1,10);f.mail.CapId=o;f.mail.CapCode=u.Base64.generateCode(o);s(e,"sendMailWithoutCap")}};f.sendEmailV2=function(t,i){i.submitted=!0;f.isUbsCaptcha==!1&&n.webApp.util.trimString(n.webApp.ga.recaptchaSize)=="invisible"&&angular.forEach(i.$error,function(n,t){t=="recaptcha"&&i.$setValidity(t,null)});i.$valid&&(f.isUbsCaptcha==!1?n.webApp.util.trimString(n.webApp.ga.recaptchaSize)=="invisible"?(f.Recaptcha.cbSendSuccess=t,r.execute(f.Recaptcha.widgetId)):f.verifyGoogleRecaptchaAndSend({sRecaptchaResponse:f.Recaptcha.response,cbSendSuccess:t}):s(t,null))};f.sendEmail=function(n){f.sendEmailV2(n,f.myForm)};f.sendEmailByObj=function(n,t){i.SendMailBasicV2(t).then(function(t){t.data!=""?alert(t.data):angular.isFunction(n)?n(t):console.error("fnSendEmailByObj - status: Sent email - cb function NOT found");AWDSApp.util.showLoadingIcon(e,!1)},function(n){o();AWDSApp.util.showLoadingIcon(e,!1);console.error("Send Mail",n)})};f.loadCaptcha=function(){n.webApp.util.isNullOrEmpty(n.webApp.ga.recaptchaSiteKey)?(f.isUbsCaptcha=!0,o()):(f.isUbsCaptcha=!1,f.Recaptcha={response:null,widgetId:null,cbSendSuccess:function(){},SetResponse:f.cbCreateRecaptcha,SetWidgetId:f.cbSuccessRecaptcha,Reset:function(){r.reload(f.Recaptcha.widgetId);f.Recaptcha.response=null}})};var o=function(){n.webApp.util.isNullOrEmpty(n.webApp.ga.recaptchaSiteKey)?i.getUbsCaptcha({}).then(function(n){f.Recaptcha=n.data},function(){}):f.Recaptcha.Reset()},s=function(r,s){var h,c;n.webApp.util.showLoadingIcon(e,!0);angular.isDefined(t.IsTesting_formMailBasicDirective)&&t.IsTesting_formMailBasicDirective&&(f.mail.IsTesting=!0);h="";h=s!=null?s:f.options.isUMFW?f.hasNewModelMedia?"SendMailWithNewModelMedia":"SendMailBasic":f.hasNewModelMedia?"SendMailWithNewModelMediaV2":"SendMailBasicV2";n.webApp.util.isNullOrEmpty(n.webApp.ga.recaptchaSiteKey)&&(f.mail.CapCode=f.Recaptcha.CaptCode,f.mail.CapId=f.Recaptcha.CaptID);f.mail.IsSubscribeSpecials&&(c=angular.copy(f.mail),c.MailType="Subscribe",f.mail.SecondMail=c);i[h](f.mail).then(function(n){n.data!=""?alert(n.data):angular.isFunction(r)?r(n):u.redirectToThankYou("formMailBasicDirective",e,null);AWDSApp.util.showLoadingIcon(e,!1)},function(n){o();AWDSApp.util.showLoadingIcon(e,!1);console.error("Send Mail",n)})};f.updateMediaAfterSave=function(n){var t=[];return n.forEach(function(n){n.UID!=null&&(n.Base64=null,t.push(n))}),t};f.cbSuccessRecaptcha=function(t){f.Recaptcha.response=t;n.webApp.util.trimString(n.webApp.ga.recaptchaSize)=="invisible"&&f.verifyGoogleRecaptchaAndSend({sRecaptchaResponse:t,cbSendSuccess:f.Recaptcha.cbSendSuccess})};f.cbCreateRecaptcha=function(n){f.Recaptcha.widgetId=n};f.verifyGoogleRecaptchaAndSend=function(n){f.mail.CapCode=n.sRecaptchaResponse;s(n.cbSendSuccess,null)}}]}}]);ngAWDSApp.directive("formMailSubscribeDirective",["$rootScope","$window","FormMailFactory","vcRecaptchaService","FormMailServices",function(n,t,i,r,u){return{restrict:"A",scope:!0,link:function(){},controller:["$scope","$element","$attrs",function(f,e){f.mail={};f.IsShowContent=!1;f.Recaptcha={response:null,widgetId:null,cbSendSuccess:function(){},SetResponse:f.cbCreateRecaptcha,SetWidgetId:f.cbSuccessRecaptcha,Reset:function(){r.reload(f.Recaptcha.widgetId);f.Recaptcha.response=null}};f.OnClickSend=function(){f.myForm.submitted=!0;angular.isDefined(f.myForm.ContactEmail)?f.myForm.ContactEmail.$valid&&(f.IsShowContent=!0):f.myForm.MailFrom.$valid&&(f.IsShowContent=!0);var t=f.myForm;f.isUbsCaptcha==!1&&n.webApp.util.trimString(n.webApp.ga.recaptchaSize)=="invisible"&&angular.forEach(t.$error,function(n,i){i=="recaptcha"&&t.$setValidity(i,null)});t.$valid&&(f.isUbsCaptcha==!1?n.webApp.util.trimString(n.webApp.ga.recaptchaSize)=="invisible"?r.execute(f.Recaptcha.widgetId):f.verifyGoogleRecaptchaAndSend({sRecaptchaResponse:f.Recaptcha.response}):o())};var o=function(){angular.isDefined(t.IsTesting_formMailSubscribeDirective)&&t.IsTesting_formMailSubscribeDirective&&(f.mail.IsTesting=!0);n.webApp.util.isNullOrEmpty(n.webApp.ga.recaptchaSiteKey)&&(f.mail.CapCode=f.Recaptcha.CaptCode,f.mail.CapId=f.Recaptcha.CaptID);i.SendMailSubscribe(f.mail).then(function(){n.webApp.util.hasVal(jsonData.ResponseMessage)?alert(jsonData.ResponseMessage+". Please contact administrator!"):u.redirectToThankYou("formMailSubscribeDirective",e,null)},function(){})};f.cbSuccessRecaptcha=function(t){f.Recaptcha.response=t;n.webApp.util.trimString(n.webApp.ga.recaptchaSize)=="invisible"&&f.verifyGoogleRecaptchaAndSend({sRecaptchaResponse:t})};f.cbCreateRecaptcha=function(n){f.Recaptcha.widgetId=n};f.verifyGoogleRecaptchaAndSend=function(n){f.mail.CapCode=n.sRecaptchaResponse;o()}}]}}]);ngAWDSApp.directive("formMailSubscribe2Directive",["$rootScope","$window","FormMailFactory","vcRecaptchaService","FormMailServices",function(n,t,i,r,u){return{restrict:"A",scope:!0,link:function(){},controller:["$scope","$element","$attrs",function(f,e){f.mail={};f.Recaptcha={};f.options={};f.isUbsCaptcha=!1;f.IsShowContent=!1;f.init=function(t){f.options=angular.merge({HasRide:!1,HasImportMailChimp:!1,IsAllCaps:!1},t);f.mail.sResponseMessage=null;f.mail.HasRide=f.options.HasRide;f.mail.HasImportMailChimp=n.webApp.util.toBool(f.options.HasImportMailChimp);f.mail.IsAllCaps=n.webApp.util.toBool(f.options.IsAllCaps);n.webApp.util.isNullOrEmpty(n.webApp.ga.recaptchaSiteKey)?(f.isUbsCaptcha=!0,f.reloadUbsCaptcha()):(f.isUbsCaptcha=!1,f.Recaptcha={response:null,widgetId:null,cbSendSuccess:function(){},SetResponse:f.cbCreateRecaptcha,SetWidgetId:f.cbSuccessRecaptcha,Reset:function(){r.reload(f.Recaptcha.widgetId);f.Recaptcha.response=null}})};f.reloadUbsCaptcha=function(){n.webApp.util.isNullOrEmpty(n.webApp.ga.recaptchaSiteKey)?i.getUbsCaptcha({}).then(function(n){f.Recaptcha=n.data},function(){}):f.Recaptcha.Reset()};f.OnClickSend=function(){f.myForm.submitted=!0;angular.isDefined(f.myForm.ContactEmail)?f.myForm.ContactEmail.$valid&&(f.IsShowContent=!0):f.myForm.MailFrom.$valid&&(f.IsShowContent=!0);var t=f.myForm;f.isUbsCaptcha==!1&&n.webApp.util.trimString(n.webApp.ga.recaptchaSize)=="invisible"&&angular.forEach(t.$error,function(n,i){i=="recaptcha"&&t.$setValidity(i,null)});t.$valid&&(f.isUbsCaptcha==!1?n.webApp.util.trimString(n.webApp.ga.recaptchaSize)=="invisible"?r.execute(f.Recaptcha.widgetId):f.verifyGoogleRecaptchaAndSend({sRecaptchaResponse:f.Recaptcha.response}):o())};var o=function(){angular.isDefined(t.IsTesting_formMailSubscribeDirective)&&t.IsTesting_formMailSubscribeDirective&&(f.mail.IsTesting=!0);n.webApp.util.isNullOrEmpty(n.webApp.ga.recaptchaSiteKey)&&(f.mail.CapCode=f.Recaptcha.CaptCode,f.mail.CapId=f.Recaptcha.CaptID);i.SendMailSubscribe(f.mail).then(function(t){var i=angular.fromJson(t.data);n.webApp.util.hasVal(i.ResponseMessage)?(f.mail.sResponseMessage=i.ResponseMessage,f.reloadUbsCaptcha()):u.redirectToThankYou("formMailSubscribeDirective",e,null)},function(){f.mail.sResponseMessage="Unknow error. Please contact administrator!"})};f.cbSuccessRecaptcha=function(t){f.Recaptcha.response=t;n.webApp.util.trimString(n.webApp.ga.recaptchaSize)=="invisible"&&f.verifyGoogleRecaptchaAndSend({sRecaptchaResponse:t})};f.cbCreateRecaptcha=function(n){f.Recaptcha.widgetId=n};f.verifyGoogleRecaptchaAndSend=function(n){f.mail.CapCode=n.sRecaptchaResponse;o()}}]}}])