{% extends "base.html" %}

{% load staticfiles %}

{% block title %}
	{% if page %}
		Update Page {{ page.title }}
	{% else %}
		Add Page
	{% endif %}
{% endblock %}

{% block extra_head %}
    <style type="text/css">
        form, .field_wrapper {margin: 0.2em; padding: 0.2em;}
        textarea {width: 100%;}
        .field_label {text-align: right; padding-right: 0.5em;}
        .error {color: white; background-color: maroon;}
        .field_help {font-size: small; margin: 0;}
        .field_required {font-weight: bold;}
        .non_field_error {text-align: center;}
    </style>
    <link rel="stylesheet" href="{% static 'chosen/chosen.css' %}" type="text/css" media="screen" />
    <script type="text/javascript" src="{% static 'chosen/chosen.jquery.js' %}"></script>
    <script type="text/javascript" src="{% static 'js/jquery.slugify.js' %}"></script>
    <script type="text/javascript">
        $(function() {
        	$('input:text').addClass('ui-corner-all');
        	$('textarea').addClass('ui-widget ui-corner-all');
            $('input:submit').button();
            $('#id_slug').slugify('#id_title');
            $('#id_published').datepicker({ dateFormat: "dd/mm/yy" });
            $('#id_parent').chosen();
        });
    </script>
{% endblock %}

{% block nav_path %}
	<a href="{% url 'dmcm:root' %}">{{ site.domain }}</a> &rsaquo; 
	<a href="{% url 'dmcm:edit:edit' %}">Edit</a> &rsaquo; 
	{% if page %}{{ page.title }}{% else %}Add Page{% endif %} 
{% endblock %}

{% block content %}
	<h1>{% if page %}Update Page {{ page.title }}{% else %}Add Page{% endif %}</h1>
    {% include "dmcm/edit/form_snippet.html" %}
{% endblock %}

{% block footer %}
    <p>
		{% if page.title %}
			<a href="{% url 'dmcm:page_detail'  page.slug %}" title="Return to Site">Site</a>;
		{% else %}
			<a href="{% url 'dmcm:root' %}" title="Return to Site">{{ site.domain }}</a>;
		{% endif %} 
        <a href="/markdown/" title="Markdown Markup">Markdown</a>;
        <a href="{% url 'admin:dmcm_page_change' page.id %}" title="Django Admin">Admin</a>;
        <a href="{% url 'logout' %}">Logout</a>.
    </p>
{% endblock %}
