{% extends "base.html" %}

{% block head_title %}Messages{% endblock %}
{% block site_title %}Messages{% endblock %}

{% block content %}
	<form id="messages_form" action="{{ request.path }}" method="post">
		{% csrf_token %}
		{% include "includes/form_loop.html" %}
		<div class="submit-row">
			<div class="positive">
				<button type="submit">Show</button>
			</div>
		</div>
	</form>
{% endblock %}

{% block extrajs %}
<script type="text/javascript">
//<![CDATA[
(function(_) {
	var LEVELS = {
		'10': 'debug',
		'20': 'info',
		'25': 'success',
		'30': 'warning',
		'40': 'error',
	};

	_.bindEvent(_.id('messages_form'), 'submit', function(event) {
		var message = _.id('id_message').value;
		var level = _.id('id_level').value;
		_.messageShow({
			messageText: message,
			cls: LEVELS[level],
		});
		event.preventDefault();
	});
}(_utils));
//]]>
</script>
{% endblock %}
