/**
 * Created by jaskokoyn on 2/20/2015.
 */
jQuery(function($){
    $(document).on( "submit", "#updateUserForm", function(e){
        e.preventDefault();

        $(this).slideUp('fast', function(){
            $("#updateUserStatus").html(
                '<div class="alert alert-info"><strong>Please wait!</strong> This user is being updated.</div>'
            ).hide().slideDown('fast');

            var formData    =   {
                uid:          $("#inputUid").val(),
                username:     $("#inputUsername").val(),
                email:        $("#inputEmail").val(),
                location:     $("#inputLoc").val(),
                age:          $("#inputAge").val(),
                gender:       $("#inputGender").val(),
                about:        $("#inputAbout").val(),
                level:        $("#inputLevel").val()
            };

            $.post( "actions/update-user.php", formData, function(res){
                if(res == "SUCCESS"){
                    $("#updateUserStatus").html(
                        '<div class="alert alert-success"><strong>Success!</strong> This user has been updated.</div>'
                    );
                }else{
                    $("#updateUserStatus").html(
                        '<div class="alert alert-danger"><strong>Error!</strong> Try again later..</div>'
                    );
                }
                $("#updateUserForm").slideDown('fast');
            });
        });
    });
});