{"size": 2068, "ext": "js", "max_stars_repo_path": "wordpress/wp-content/themes/basic/themify/themify-builder/js/modules/signup-form.js", "max_stars_repo_name": "2511921-110/wp_dev", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "wordpress/wp-content/themes/basic/themify/themify-builder/js/modules/signup-form.js", "max_issues_repo_name": "2511921-110/wp_dev", "max_issues_repo_issues_event_min_datetime": "2020-07-02T06:11:46.000Z", "max_issues_repo_issues_event_max_datetime": "2021-02-08T03:11:28.000Z", "max_forks_repo_path": "wordpress/wp-content/themes/basic/themify/themify-builder/js/modules/signup-form.js", "max_forks_repo_name": "2511921-110/wp_dev", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 4, "max_forks_count": null, "avg_line_length": 36.2807017544, "max_line_length": 96, "alphanum_fraction": 0.4115087041}
/**
 * signup module
 */
;
(function ($,Themify) {
    'use strict';
    
    Themify.body.on( 'submit.tb_signup', '.tb_signup_form', function ( e ) {
        e.preventDefault();
        const $this = $( this ),
            $btn = $this.find('button');
        $btn.prop('disabled', true);
        $.ajax( {
            type: 'POST',
            url: themify_vars.ajax_url,
            data: {
                dataType : 'json',
                action : 'tb_signup_process',
                nonce : $this.find('input[name="nonce"]').val(),
                data: $this.serialize()
            },
            beforeSend:function(){
                $this.find('.tb_signup_errors').removeClass('tb_signup_errors').empty();
                $this.find('.tb_signup_success').hide();
            },
            success: function ( resp ) {
                if (resp.err ) {
                    const errWrapper = $this[0].getElementsByClassName('tb_signup_messages')[0];
                        errWrapper.classList.add('tb_signup_errors');
                    for(let i = resp.err.length-1;i>-1;--i){
                        let err = document.createElement('div');
                        err.innerText = resp.err[i];
                        errWrapper.appendChild(err);
                    }
                } else {
                    $this.find('.tb_signup_success').fadeIn();
                    const redirect = $this.find('input[name="redirect"]');
                    if(redirect[0]){
                        const url = redirect.val();
                        if(''!== url){
                            window.location.href = url;
                        }else{
                            window.location.reload(true);
                        }
                    }else{
                        $this[0].reset();
                    }
                }
                Themify.scrollTo($this.offset().top-100);
            },
            complete: function () {
                $btn.prop('disabled', false);
            }
        } );
    } );

})(jQuery,Themify);