
<!DOCTYPE html>
<html class="devise-layout-html">
<head  >

    {% include 'twig/common/header/include.twig' %}

</head>

<body class="ui_charcoal login-page application navless" data-page="passwords:edit">
<div class="page-wrap">

    {% include 'twig/common/body/script.twig' %}
    {% include 'twig/common/body/header.twig' %}

    <div class="container navless-container">
        <div class="content">
            <div class="flash-container flash-container-page">
            </div>

            <div class="row">
                <div class="col-sm-5 pull-right new-session-forms-container">
                    <ul class="nav-links nav-tabs new-session-tabs single-tab">
                        <li class="active">
                            <a>加入Masterlab</a>
                        </li>
                    </ul>

                    <div class="login-box">
                        <div class="login-body">
                            <form class="gl-show-field-errors" id="form-invite_join" action="/invite/join" accept-charset="UTF-8" method="post">
                                <input type="hidden" name="token" value="<?=token?>" />
                                <div class="devise-errors">

                                </div>
                                <div class="form-group">
                                    <label for="password">显示名称</label>
                                    <input class="form-control top" required="required" title="This field is required" type="text" name="display_name" id="display_name" />
                                    <p id="tip_error_display_name" class="gl-field-error hide"></p>
                                </div>
                                <div class="form-group">
                                    <label for="password">新密码</label>
                                    <input class="form-control top" required="required" title="This field is required" type="password" name="password" id="user_password" />
                                    <p id="tip_error_password" class="gl-field-error hide"></p>
                                </div>
                                <div class="form-group">
                                    <label for="password_confirmation">确认密码</label>
                                    <input class="form-control bottom" title="This field is required" required="required" type="password"
                                           name="password_confirmation" id="password_confirmation" />
                                    <p id="tip_error_password_confirmation" class="gl-field-error hide"></p>
                                </div>
                                <div class="clearfix">
                                    <input id="btn-submit" type="button" name="commit" value="提 交" class="btn btn-primary" />
                                </div>
                            </form></div>
                    </div>
                    <div class="clearfix prepend-top-20">

                    </div>
                    <p>
                    <span class="light">

                    <a href="/passport/login">返回登录</a>
                    </span>
                    </p>

                </div>
                {% include 'twig/common/body/brand-holder.twig' %}
            </div>
        </div>
    </div>
    <hr class="footer-fixed">
    {% include 'twig/common/body/footer.twig' %}
</div>

<script type="text/javascript">
    $(document).ready(function () {
        $('.gl-field-error').each(function(){
            $(this).addClass('hide');
        })
        $("#btn-submit").on("click", function () {
            $.ajax({
                type: "POST",
                dataType: 'json',
                url: '/invite/join',
                data: $('#form-invite_join').serialize(),
                success: function (resp) {
                    if (resp.ret == 200) {
                        notify_success('加入成功')
                        //setTimeout(function(){ window.location.href = root_url+'passport/login'; }, 1500);
                    } else {
                        if(resp.ret=='104'){
                            for (var skey in resp.data) {
                                $('#tip_error_'+skey).html(resp.data[skey]);
                                $('#tip_error_'+skey).removeClass('hide');
                            }
                            notify_error(resp.msg,resp.data);

                        }else{
                            notify_error(resp.msg+":"+resp.data);
                        }
                    }
                },
                error: function (resp) {
                    notify_error(resp.msg, resp.data);
                }
            });
        });

        Mousetrap.bind('enter', function () {
            $("#btn-submit").click();
        });

        $(document).on("keydown", function(event) {
            if (event.keyCode == 13 && $("#btn-submit").length) {
                $("#btn-submit").click();
            }
        });
    });
</script>
</body>
</html>
