{% extends "skeleton.html" %}
{% comment %}{% extends "base_fixed.html" %}{% endcomment %}
{% comment %}{% load i18n djangocodemirror_inputs autobreadcrumb djangocodemirror_assets %}{% endcomment %}
{% load i18n djangocodemirror_inputs djangocodemirror_assets %}

{% comment %}Translators: Demonstration page title{% endcomment %}
{% block head_title %}{% trans "DjangoCodeMirror sample" %}{% endblock %}
{% comment %}{% block html_more_js %}{{ block.super }} {% endcomment %}
{% block foot_more_js %}{{ block.super }} 
    {% get_current_language as LANGUAGE_CODE %}
    {% block djangocodemirror_assets_loading %}
        {% djangocodemirror_get_assets form.content %}
        {% comment %}You could also use the bundle mode if you have installed django-assets (but only 
        if you don't directly use the 'CodeMirrorAttrsWidget' widget, just remove the previous 
        djangocodemirror_get_assets' line and uncomment the following :
        {% djangocodemirror_get_bundles form.content %}{% endcomment %}
    {% endblock %}
    <script type="text/javascript">
    //<![CDATA[
    DCM_lang = "{{ LANGUAGE_CODE }}";
    $(document).ready(function() {
        {% comment %}Translators: Link name to load demonstration content{% endcomment %}
        $("#djangocodemirror-sample h2:first").after('<p id="menu"><a class="demo_content_loadlink" href="">{% filter addslashes %}{% trans "Load demo content" %}{% endfilter %}</a></p>');
        
        var content_codemirror_instance = $('#{{ form.content.auto_id }}').djangocodemirror({{ form.content|djangocodemirror_init_input }});
        
        $("#djangocodemirror-sample a.demo_content_loadlink").click(function () {
            var cm_instance = $('#{{ form.content.auto_id }}').data('djangocodemirror').codemirror;
            cm_instance.setValue( $("#sample_demo_content").val() );
            cm_instance.clearHistory();
            cm_instance.focus();
            return false;
        });
    });
    //]]>
    </script>
{% endblock %}

{% comment %}{% block content %}{% endcomment %}
{% block base_content %}
    <div id="djangocodemirror-sample">
        <h2>{% trans "DjangoCodeMirror sample" %}</h2>
        <form method="post" action="">{% csrf_token %}
            <div>{{ form.content }}</div>
        </form>
        <div style="display:none;">
            {% comment %}Translators: Demonstration form title{% endcomment %}
            <h2>{% trans "Sample content" %}</h2>
            <div><textarea name="sample_demo_content" id="sample_demo_content" cols="10" rows="8">{{ demo_content }}</textarea></div>
        </div>
    </div>
{% endblock %}