{if $context eq 'standalone' and $outBound_option != 2 }
<script type="text/javascript">
{literal}
-CRM.$(function($) {
- cj("#contact_1").blur( function( ) {
- checkEmail( );
- } );
- checkEmail( );
-});
-function checkEmail( ) {
- var contactID = cj("input[name='contact_select_id[1]']").val();
- if ( contactID ) {
- var postUrl = "{/literal}{crmURL p='civicrm/ajax/checkemail' h=0}{literal}";
- cj.post( postUrl, {contact_id: contactID},
- function ( response ) {
- if ( response ) {
- cj("#email-receipt").show( );
- if ( cj("#send_receipt").is(':checked') ) {
- cj("#notice").show( );
- }
+ CRM.$(function($) {
+ var $form = $("form.{/literal}{$form.formClass}{literal}");
+ $("#contact_id", $form).change(checkEmail);
+ checkEmail();
- cj("#email-address").html( response );
- } else {
- cj("#email-receipt").hide( );
- cj("#notice").hide( );
- }
- }
- );
+ function checkEmail( ) {
+ var data = $("#contact_id", $form).select2('data');
+ if (data && data.extra && data.extra.email && data.extra.email.length) {
+ $("#email-receipt", $form).show();
+ if ($("#send_receipt", $form).is(':checked')) {
+ $("#notice", $form).show();
+ }
+ $("#email-address", $form).html(data.extra.email);
+ }
+ else {
+ $("#email-receipt, #notice", $form).hide();
+ }
}
-}
+ });
{/literal}
</script>
{/if}