<!DOCTYPE html>
<html lang="en"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorator="default">
<head>
</head>
<body>
<nav layout:fragment="navbar">
    <div class="navbar-header">
        <a class="navbar-brand" href="/"><span class="ui-menuitem-text"><i
                class="fa fa-plane fa-4" aria-hidden="true"></i> Balance</span></a>
    </div>
</nav>
<div class="container" layout:fragment="content">
    <form id="reset-form" method="post" class="margined-top-10">
        <fieldset>
            <div class="form-group">
                <input type="email" name="email" id="email" class="form-control"
                       placeholder="E-Mail" required="true" autofocus="autofocus"/>
            </div>
            <button type="submit" class="btn btn-success btn-block">Сбросить пароль</button>
            <div class="form-group">
                <small class="form-text text-muted">
                    <a href="/login">Вернуться к странице входа</a>
                </small>
            </div>
        </fieldset>
    </form>
</div>
<th:block layout:fragment="data-scripts">
    <script type="text/javascript">
        /*<![CDATA[*/
        $(document).ready(function () {
            $("#reset-form").submit(function () {
                var email = $("#email").val();
                if (isEmpty(email)) {
                    showFeedbackMessage("Адрес электронной почты не задан", MessageTypesEnum.DANGER);
                    return false;
                }
                postToRest(urlUsersPasswordResetRequest + "?email=" + email, null,
                    function () {
                        showFeedbackMessage("Запрос на смену пароля отправлен");
                    },
                    function () {
                        $("#email").val("");
                    }
                );
                return false;
            });
        });
        /*]]>*/

    </script>
</th:block>
</body>
</html>