{% extends "login/layout/sidebar-layout.html.twig" %}

{% import "login/common/macros.html.twig" as auth_macro %}

{% block title %}
    {{ "Renew password" | trans }}
{% endblock %}

{% block sidebar %}
    <div class="well-large sidebar-block">
        <div class="row-fluid">
            <div class="span12 authentication-sidebar-title">
                <div class="text-title">
                    {{ "Choose a new password" | trans }}
                </div>
            </div>
        </div>
        <div class="row-fluid">
            <div class="span12">
                {{ auth_macro.flashes() }}
                <form
                    novalidate
                    name="passwordRenewForm"
                    method="POST"
                    action="{{ path('login_renew_password') }}"
                >
                    {% if form.vars.errors|length > 0 %}
                        <div class="row-fluid">
                            <div class="span12">
                                {{ form_errors(form) }}
                            </div>
                        </div>
                    {% endif %}

                    {{ auth_macro.repeatedInput(form.password, "passwordRenewForm", 'icon-lock') }}

                    {{ form_rest(form) }}
                    <div class="row-fluid">
                        <div class="span12">
                            <button type="submit" class="btn btn-success btn-trigger ">
                                {{ "Save" | trans }}
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
{% endblock %}

{% block scripts %}
    {{ parent() }}
    <script type="text/javascript" src="{{ path('minifier', {'f': '/scripts/apps/login/home/recoverPassword.js'}) }}"></script>
    <script>
        // cross-browser asynchronous script loading for zxcvbn.
        // adapted from http://friendlybit.com/js/lazy-loading-asyncronous-javascript/
        (function() {

            var ZXCVBN_SRC = 'assets/vendors/zxcvbn/zxcvbn{% if not app.debug %}.min{% endif %}.js';

            var async_load = function() {
                var first, s;
                s = document.createElement('script');
                s.src = ZXCVBN_SRC;
                s.type = 'text/javascript';
                s.async = true;
                first = document.getElementsByTagName('script')[0];
                return first.parentNode.insertBefore(s, first);
            };

            if (window.attachEvent != null) {
                window.attachEvent('onload', async_load);
            } else {
                window.addEventListener('load', async_load, false);
            }

        }).call(this);
    </script>
{% endblock %}
