{% extends "categories/base.html" %}
{% load styled_forms %}
{% load i18n %}

{% block title %}{{ block.super }}{% trans "Add" %}{% endblock %}

{% block extra_head %}
{{ block.super }}
<link rel="stylesheet" href="{{ STATIC_URL }}css/forms.css">
{% endblock %}

{% block body %}
<div class="t">
    <h1>{{ MODULE_CATEGORIES_LABEL }} {% trans "Update" %}</h1>
    <p>{{ model|capfirst }} - <a href="{{ object.get_absolute_url }}">{{ object }}</a></p>
    <div class="article-wrap">
    	<form action="." method="post">{% csrf_token %}
    	<div class="forms">
            {{ form|styled_form }}
        	<input type="submit" value="Apply Changes" />
		</div>
        </form>
    </div>
</div>
{% endblock %}

{% block extra_body %}
    {{ block.super }}
    <script type="text/javascript">
		$(document).ready(function(){
			// delete confirmation
			$('.add-category').click(function(){
				select_box = $(this).parent().prev().find('select');
				var category = prompt('Category Name?','').toLowerCase();
				category = category.replace('"','')
				var option_html = '<option selected="selected" value="' + category + '">' + category + '</option>';
				if (category) select_box.append(option_html) 
				return false;
			});
			$('.add-sub-category').click(function(){
				select_box = $(this).parent().prev().find('select');
				var sub_category = prompt('Category Name?','').toLowerCase();
				sub_category = sub_category.replace('"','')
				var option_html = '<option selected="selected" value="' + sub_category + '">' + sub_category + '</option>';
				if (sub_category) select_box.append(option_html) 
				return false;
			});
		});
    </script>
{% endblock %}
