{% load sekizai_tags %}
{% load i18n %}

{% addtoblock "js" %}<script type="text/javascript" src="{{ STATIC_URL }}js/libs/underscore-1.3.1.min.js"></script>{% endaddtoblock %}
{% addtoblock "js" %}<script type="text/javascript" src="{{ STATIC_URL }}js/libs/json2.js"></script>{% endaddtoblock %}
{% addtoblock "js" %}<script type="text/javascript" src="{{ STATIC_URL }}js/libs/backbone-0.9.1.min.js"></script>{% endaddtoblock %}
{% addtoblock "js" %}<script type="text/javascript" src="{{ STATIC_URL }}js/saq.js"></script>{% endaddtoblock %}
{% addtoblock "js" %}
<script type="text/javascript">
    $(function () {
        var model = new SAQ.Question({
            slug: '{{ question.slug }}',
            optional: {{ question.optional|yesno:"true,false" }}
        });
        var view = new SAQ.FreeTextQuestionView({
            el: $('#saq-question-free-{{ question.slug }}')[0],
            model: model
        });
        SAQ.questions.add(model);
        $('input.numeric').bind('keypress', function (e) {
            if($(this).val().length == 0 && e.which == 45)
                return true;
            return (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57) && e.which != 46) ? false : true;
        });
    });
</script>
{% endaddtoblock %}

<div class="saq-question-container {{ question.slug }}-container saq-question-free-container"
{% if not triggered %} style="display:none;" {% endif %}
{% if depends_on %} data-dependency="{{ depends_on }}" {% endif %}
>
{% if question.label %}
<div>
    <label class="saq-question-label" for="saq-question-free-{{ question.slug }}">{% trans question.label %}</label>
    <span class="saq-question-help-text">{% if question.help_text %}{% trans question.help_text %}{% endif %}</span>
</div>
{% endif %}
<div id="saq-question-free-{{ question.slug }}">
<div class="saq-question-error"></div>
<input class="saq-question saq-question-free {% if numeric %} numeric {% endif %}" type="text" value="{{ submission.answer }}">
</div>
</div>
{# vim: set filetype=htmldjango: #}
