{% load i18n static sekizai_tags cms_tags sass_tags %}{% spaceless %}

{% addtoblock "css" %}<link href="{% sass_src 'shop/css/navbar.scss' %}" rel="stylesheet" type="text/css" />{% endaddtoblock %}
{% addtoblock "js" %}<script src="{% static 'shop/js/auth.js' %}" type="text/javascript"></script>{% endaddtoblock %}
{% add_data "ng-requires" "django.shop.auth" %}

{% page_url 'shop-order' as shop_order_url %}
{% page_url 'shop-customer-details' as customer_details_url %}
{% page_url 'shop-password-change' as password_change_url %}
{% page_url 'shop-password-reset' as password_reset_url %}
{% page_url 'shop-register-customer' as register_customer_url %}

<li class="dropdown {{ dropdown_extra_class }}" uib-dropdown{% if customer.is_anonymous %} auto-close="disabled{# retest with outsideClick #}"{% endif %}>
	<a class="dropdown-toggle" uib-dropdown-toggle>
	{% if customer.is_authenticated %}
		<i class="fa fa-user"></i>&nbsp;{{ customer.first_name|default:customer }}
	{% else %}
		<i class="fa fa-sign-in"></i>&nbsp;{% trans "Sign in" %}
	{% endif %}<b class="caret"></b></a>
	<ul class="dropdown-menu shop-dropdown-forms">
	{% if customer.is_authenticated %}
		<shop-auth-form name="logout_form" ng-form action="RELOAD_PAGE" role="form">
			<button class="btn btn-primary btn-block" type="button" ng-click="submitForm('{% url "shop:logout" %}')">{% trans "Logout" %}</button>
		</shop-auth-form>
		{% if shop_order_url %}
		<li><a href="{{ shop_order_url }}">{% page_attribute "menu_title" "shop-order" %}</a></li>
		{% endif %}
		{% if customer_details_url %}
		<li><a href="{{ customer_details_url }}">{% page_attribute "menu_title" "shop-customer-details" %}</a></li>
		{% endif %}
		{% if password_change_url %}
		<li><a href="{{ password_change_url }}">{% page_attribute "menu_title" "shop-password-change" %}</a></li>
		{% endif %}
	{% else %}
		<shop-auth-form ng-form name="auth_form" action="RELOAD_PAGE" accept-charset="UTF-8" role="form" form-submit-url="{% url "shop:login" %}">
			<div class="alert alert-danger" ng-show="error_message" ng-cloak>
				<a class="close" ng-click="dismiss()">×</a>{% verbatim %}{{ error_message }}{% endverbatim %}
			</div>
			<div class="form-group form-group-sm">
				<label class="control-label" for="username">{% trans 'E-Mail' %}</label>
				<div class="input-group">
					<div class="input-group-addon"><i class="fa fa-user"></i></div>
					<input class="form-control input-sm" type="text" placeholder="{% trans 'E-Mail' %}" name="username" ng-model="form_data.username">
				</div>
			</div>
			<div class="form-group form-group-sm">
				<label class="control-label" for="password">{% trans 'Password' %}</label>
				<div class="input-group">
					<div class="input-group-addon"><i class="fa fa-unlock-alt"></i></div>
					<input class="form-control input-sm" type="password" placeholder="{% trans 'Password' %}" name="password" ng-model="form_data.password">
				</div>
			</div>
			<button class="btn btn-primary btn-block" type="button" ng-click="submitForm()">{% trans "Login" %}</button>
		</shop-auth-form>
		{% if password_reset_url or register_customer_url %}
		<li role="separator" class="divider"></li>
			{% if password_reset_url %}
		<li><a href="{{ password_reset_url }}">{% trans "Password Forgotten?" %}</a></li>
			{% endif %}
			{% if register_customer_url %}
		<li><a href="{{ register_customer_url }}">{% trans "Register Yourself" %}</a></li>
			{% endif %}
		{% endif %}
	{% endif %}
	</ul>
</li>
{% endspaceless %}
