{% load i18n %}
{% load staticfiles %}
{% load comments %}
{% if user.is_authenticated and comment_object %}
    <div class="comments-container">
        <p>{% trans 'Add new comment' %}</p>
        <div>
            {% get_comment_form for comment_object as form %}
            <form id="frm_comment" action="{% comment_form_target %}" method="POST">
                {% csrf_token %}
                {{ form.comment }}
                {{ form.content_type }}
                {{ form.object_pk }}
                {{ form.timestamp }}
                {{ form.security_hash }}
                <input type="hidden" name="next" value="{{ comment_object.post_back_url }}"/>
                <div>
                    <input type="button" value="Add comment" id="id_submit" class="btn-brand btn-base" />
                </div>
            </form>
        </div>
    </div>
{% endif %}

{% block extra_js %}
    <script type="text/javascript">
        $(document).ready(function() {
            var box = $('#id_comment');
           $("#id_submit").click(function(event){
               if( !box.val() ) {
                    box.addClass('has-error');
                    box.focus();
                }
               else{
                   $("#frm_comment").submit();
               }

           });
        });
    </script>
{% endblock %}
