{% load i18n %}
{% load static %}

{% load avatar_tags %}

{% load common_tags %}{% load nestedcomments_tags %}


<div id="nested-comments-path" data-value="{{ request.path }}"></div>
<div id="nested-comments-language-code" data-value="{{ LANGUAGE_CODE }}"></div>
<div id="nested-comments-user-id" data-value="{{ request.user.id }}"></div>
<div id="nested-comments-user-name" data-value="{{ request.user.username }}"></div>
<div id="nested-comments-user-real-name" data-value="{{ request.user.userprofile.real_name|default:'' }}"></div>
<div id="nested-comments-user-is-authenticated" data-value="{{ request.user.is_authenticated }}"></div>
<div id="nested-comments-user-is-superuser" data-value="{{ request.user.is_superuser }}"></div>
<div id="nested-comments-comments-content-type-id" data-value="{% nestedcomments_content_type_id %}"></div>

{% if image %}
    <div id="nested-comments-shadow-bans" data-value="{{ image.user.userprofile.shadow_bans.all|get_pks }}"></div>
{% endif %}

<div id="nested-comments-page-url" data-value="{{ request.get_full_path }}"></div>
<div id="nested-comments-loaderGif-url" data-value="{% static 'astrobin/images/ajax-loader.gif' %}"></div>
<div id="nested-comments-editor-placeholder" data-value="{% trans 'Type your comment here...' %}"></div>

<div style="display: none">
    <textarea id="hidden-textarea"></textarea>
</div>

<script type="application/javascript">
    {% trans "Error" as i18nError %}
    {% trans "Cancel" as i18nCancel %}
    {% trans "Add a comment" as i18nAddAComment %}
    {% trans "There are no comments yet." as i18nThereAreNoCommentsYet %}
    {% trans "The comment cannot be empty." as i18nTheCommentCannotBeEmpty %}
    {% trans "(deleted)" as i18nDeleted %}
    {% trans "Delete" as i18nDelete %}
    {% trans "Undelete" as i18nUndelete %}
    {% trans "Edit" as i18nEdit %}
    {% trans "Link" as i18nLink %}
    {% trans "likes" context "Noun, e.g. 'This element has 10 likes'" as i18nLikesNoun %}
    {% trans "Like" context 'Verb (imperative)' as i18nLike %}
    {% trans "Unlike" context 'Verb (imperative)' as i18nUnlike %}
    {% trans "Reply" context 'Verb (imperative)' as i18nReply %}
    {% trans "Approve" context 'Verb (imperative)' as i18nApprove %}
    {% trans "Report abuse" as i18nReportAbuse %}

    window.astrobin_nestedcomments_i18n = {
        error: '{{ i18nError | escapejs }}',
        cancel: '{{ i18nCancel | escapejs }}',
        addAComment: '{{ i18nAddAComment | escapejs }}',
        noCommentsYet: '{{ i18nThereAreNoCommentsYet | escapejs }}',
        theCommentCannotBeEmpty: '{{ i18nTheCommentCannotBeEmpty | escapejs }}',
        deleted: '{{ i18nDeleted | escapejs }}',
        delete: '{{ i18nDelete | escapejs }}',
        undelete: '{{ i18nUndelete | escapejs }}',
        edit: '{{ i18nEdit | escapejs }}',
        link: '{{ i18nLink | escapejs }}',
        likes: '{{ i18nLikesNoun | escapejs }}',
        like: '{{ i18nLike | escapejs }}',
        likeVerb: '{{ i18nLike | escapejs }}',
        unlikeVerb: '{{ i18nUnlike | escapejs }}',
        replyVerb: '{{ i18nReply | escapejs }}',
        approveVerb: '{{ i18nApprove | escapejs }}',
        reportAbuse: '{{ i18nReportAbuse | escapejs }}'
    };
</script>


<script type="text/x-handlebars" data-template-name="i18n">
{% verbatim %}
    {{view.translated}}
{% endverbatim %}
</script>


<script type="text/x-handlebars" data-template-name="login-or-sign-up">
    <p class="please-login">
        {% url 'auth_login' as login_url %}
        {% setvar "https://welcome.astrobin.com/pricing" as signup_url %}
        {% blocktrans trimmed with login_url as login_url and signup_url as signup_url %}
            Please <a href="{{ login_url }}">log in</a> or <a href="{{ signup_url }}">sign up</a> to leave a comment.
        {% endblocktrans %}
    </p>
</script>


<script type="text/x-handlebars" data-template-name="contribution-index-alert">
    {% include '_contribution_index_alert.html' %}
</script>


<script type="text/x-handlebars" data-template-name="rich-content-editor-help">
    {% include '_rich_content_editor_help.html' %}
</script>


<script type="text/x-handlebars" data-template-name="nested-comments">
{% verbatim %}
    {{outlet top-level}}
    {{outlet comments}}
{% endverbatim %}
</script>


<script type="text/x-handlebars" data-template-name="top-level">
{% verbatim %}
    {{#if view.userIsAuthenticated}}
        {{#unless view.collapsed}}
            {{view NestedCommentsApp.ContributionIndexAlertView}}
            <form>
                {{view Ember.TextArea rows=6 valueBinding="view.comment.text"}}
                {{view NestedCommentsApp.RichContentEditorHelpView}}
                {{view view.SaveCommentButtonView}}
                <a class="btn btn-mini" href="#" {{action "collapse" target="view"}}>
                  {{view NestedCommentsApp.I18nView value="cancel"}}
                </a>

                {{#if view.submitting}}
                    {{view NestedCommentsApp.LoaderView}}
                {{/if}}
            </form>
        {{else}}
            <a href="#"
               class="uncollapse add-top-level btn btn-primary"
               {{action "uncollapse" target="view"}}>
               {{view NestedCommentsApp.I18nView value="addAComment"}}
            </a>
        {{/unless}}
    {{else}}
        {{view NestedCommentsApp.LoginOrSignUpView}}
    {{/if}}
{% endverbatim %}
</script>


<script type="text/x-handlebars" data-template-name="comments">
{% verbatim %}
    {{#if controller.ready}}
        {{#unless controller.content.length}}
           <p class="comment">
             {{view NestedCommentsApp.I18nView value="noCommentsYet"}}
           </p>
        {{/unless}}

        {{#each controller.content}}
            {{view NestedCommentsApp.SingleCommentView nodeBinding="this"}}
        {{/each}}
    {{else}}
        {{view NestedCommentsApp.LoaderView}}
    {{/if}}
{% endverbatim %}
</script>


<script type="text/x-handlebars" data-template-name="singleComment">
{% verbatim %}
    {{#if view.node.displayAvatar}}
        <div class="avatar visible-desktop">
            <a class="author" {{bindAttr href="view.node.author_url"}}>
                <img
                    {{bindAttr src="view.node.author_avatar"}}
                    {{bindAttr alt="view.node.author_username"}}
                    width="40" height="40" />
            </a>
        </div>
    {{else}}
        <div class="avatar visible-desktop">
            <img src="https://cdn.astrobin.com/static/astrobin/images/default-avatar.jpeg?v=1"
                 alt=""
                 width="40"
                 height="40" />
        </div>
    {{/if}}

    <div class="comment-container" {{ bindAttr id="view.node.cid"}}>
        {{#if view.node.isPendingModeration}}
            <div class="content pending-moderation">
                <em>
                    {{#if view.node.userIsContentObjectOwner}}
                        {{view NestedCommentsApp.PendingModerationInfoForContentObjectOwnerView}}
                        {{view NestedCommentsApp.SingleCommentRenderView nodeBinding="this"}}
                    {{else}}
                        {{#if view.node.authorIsRequestingUser}}
                            {{view NestedCommentsApp.PendingModerationInfoForCommentOwnerView}}
                            {{view NestedCommentsApp.SingleCommentRenderView nodeBinding="this"}}
                        {{else}}
                            {{view NestedCommentsApp.PendingModerationInfoForEveryoneElseView}}
                        {{/if}}
                    {{/if}}
                </em>
            </div>
        {{else}}
            {{#if view.node.moderationRequested }}
                {{#if view.node.userIsContentObjectOwner}}
                    {{view NestedCommentsApp.ModerationRequestedButUnneeded}}
                {{/if}}
            {{/if}}

            {{view NestedCommentsApp.SingleCommentRenderView nodeBinding="this"}}
        {{/if}}
    </div>
{% endverbatim %}
</script>


<script type="text/x-handlebars" data-template-name="singleCommentRender">
{% verbatim %}
    <div class="meta">
        {{#if view.node.deleted}}
            {{view NestedCommentsApp.I18nView value="deleted"}}
        {{else}}
            <a class="author" {{bindAttr href="view.node.author_url"}}>
                {{view.node.author_username}}
            </a>
        {{/if}}

        {{view NestedCommentsApp.TimeagoView valueBinding="view.node.created"}}

        &middot;

        {{#if view.node.hasNoLikes}}
            {{view.node.likesCount }}
            {{view NestedCommentsApp.I18nView value="likes"}}
        {{/if}}

        {{#if view.node.hasOneLike}}
            {{view.node.likesCount }}
            {{view NestedCommentsApp.I18nView value="like"}}
        {{/if}}

        {{#if view.node.hasManyLikes}}
            {{view.node.likesCount }}
            {{view NestedCommentsApp.I18nView value="likes"}}
        {{/if}}

        {{#unless view.collapsed}}
            <a href="#" class="collapse" {{action "collapse" target="view"}}>[-]</a>
        {{else}}
            <a href="#" class="collapse" {{action "uncollapse" target="view"}}>[+]</a>
        {{/unless}}
    </div>

    {{#unless view.collapsed}}
        <div class="converter" style="display: none">
            {{view Ember.TextArea rows=6 valueBinding="view.node.text"}}
        </div>

        <div class="content">
            {{#if view.node.deleted}}
                <p>
                    {{view NestedCommentsApp.I18nView value="deleted"}}
                </p>
            {{else}}
                {{#if view.editing}}
                    {{view view.EditView commentBinding="view.node"}}
                {{else}}
                    {{# if view.node.ready}}
                        {{{view.node.getHTML}}}
                    {{else}}
                        {{view NestedCommentsApp.LoaderView}}
                    {{/if}}
                {{/if}}
            {{/if}}
        </div>

        {{#if view.node.isPendingModeration}}
            {{#if view.node.userIsContentObjectOwner}}
                <div class="links">
                    <a href="#"{{action "approve" target="view"}} class="btn btn-success btn-mini"
                       {{bindAttr class="view.node.loading:loading"}}>
                        <i class="icon-ok"></i>
                        {{view NestedCommentsApp.I18nView value="approveVerb"}}
                    </a>

                    <a href="#" {{action "reportAbuse" target="view"}} class="btn btn-danger btn-mini"
                       {{bindAttr class="view.node.loading:loading"}}>
                        <i class="icon-remove"></i>
                        {{view NestedCommentsApp.I18nView value="reportAbuse"}}
                    </a>
                </div>
            {{/if}}
        {{else}}
            <div class="links">
                {{#unless view.node.deleted}}
                    <a {{bindAttr href="view.node.url"}} {{action "link" target="view"}} class="no-page-loader">
                        <i class="icon-link"></i>
                        {{view NestedCommentsApp.I18nView value="link"}}
                    </a>

                    {{#unless view.node.authorIsRequestingUser}}
                        {{#if view.userIsAuthenticated}}
                            <a href="#" {{action "reportAbuse" target="view"}}>
                                <i class="icon-flag"></i>
                                {{view NestedCommentsApp.I18nView value="reportAbuse"}}
                            </a>
                        {{else}}
                            <a href="#" {{action "loginAndGoToComment" target="view"}}>
                                <i class="icon-flag"></i>
                                {{view NestedCommentsApp.I18nView value="reportAbuse"}}
                            </a>
                        {{/if}}
                    {{/unless}}
                {{/unless}}

                {{#if view.node.authorIsRequestingUser}}
                    {{#if view.node.deleted}}
                        <a href="#" {{action "undelete" target="view"}}>
                            {{view NestedCommentsApp.I18nView value="undelete"}}
                        </a>
                    {{else}}
                        <a href="#" {{action "delete_" target="view"}}>
                            <i class="icon-trash"></i>
                            {{view NestedCommentsApp.I18nView value="delete"}}
                        </a>
                    {{/if}}

                    {{#if view.node.allowEditing}}
                        {{#unless view.editing}}
                            <i class="icon-pencil"></i>
                            <a href="#" {{action "edit" target="view"}}>
                                {{view NestedCommentsApp.I18nView value="edit"}}
                            </a>
                        {{/unless}}
                    {{/if}}
                {{else}}
                    {{#unless view.node.deleted}}
                        <a href="#" class="btn btn-mini btn-primary" {{action "reply" target="view"}}>
                            <i class="icon-reply"></i>
                            {{view NestedCommentsApp.I18nView value="replyVerb"}}
                        </a>

                        {{#unless view.node.liked}}
                            <a href="#"
                               class="btn btn-mini btn-primary comment-like"
                               {{bindAttr class="view.node.liking:liking"}}
                               {{action "like" target="view"}}>
                                <i class="icon-thumbs-up"></i>
                                {{view NestedCommentsApp.I18nView value="likeVerb"}}
                            </a>
                        {{else}}
                            <a href="#"
                               class="btn btn-mini comment-unlike"
                               {{bindAttr class="view.node.unliking:unliking"}}
                               {{action "unlike" target="view"}}>
                                {{view NestedCommentsApp.I18nView value="unlikeVerb"}}
                            </a>
                        {{/unless}}
                    {{/unless}}
                {{/if}}
            </div>

            {{#if view.replying}}
                <div class="reply">
                    {{view view.ReplyView parentBinding="view.node.comment"}}
                </div>
            {{/if}}

            {{#if view.node.shouldNotIndent}}
                <div class="children no-indentation">
            {{else}}
                <div class="children">
            {{/if}}

                {{#each view.node.children}}
                    {{view NestedCommentsApp.SingleCommentView nodeBinding="this"}}
                {{/each}}
            </div>
        {{/if}}
    {{/unless}}
{% endverbatim %}
</script>


<script type="text/x-handlebars" data-template-name="pending-moderation-info-for-content-object-owner">
     <div class="alert alert-warning">
        <p>
            {% blocktrans trimmed %}
                This comment is pending moderation. Please approve it or report an abuse using the buttons below.
            {% endblocktrans %}
        </p>

        <p>
            {% blocktrans trimmed %}
                Thank you for your cooperation!
            {% endblocktrans %}
        </p>
    </div>
</script>


<script type="text/x-handlebars" data-template-name="moderation-requested-but-unneeded">
     <div class="alert alert-info">
        <p>
            {% blocktrans trimmed %}
                This comment was already moderated by you or an AstroBin moderator.
            {% endblocktrans %}
        </p>
    </div>
</script>


<script type="text/x-handlebars" data-template-name="pending-moderation-info-for-comment-owner">
    <div class="alert alert-info">
        <p>
            {% blocktrans trimmed %}
                Your comment is pending moderation and should be reviewed shortly by the author or owner of
                the content object that you commented on. If they do not take action within 24 hours, an
                AstroBin moderator will take over and review your comment on their behalf.
            {% endblocktrans %}
        </p>

        <p>
            {% blocktrans trimmed %}
                This process is necessary to prevent spam on AstroBin.
            {% endblocktrans %}
        </p>

        <p>
            {% blocktrans trimmed %}
                Thank you for understanding!
            {% endblocktrans %}
        </p>
    </div>
</script>


<script type="text/x-handlebars" data-template-name="pending-moderation-info-for-everyone-else">
    {% trans "This comment is pending moderation and will be reviewed shortly." %}
</script>


<script type="text/x-handlebars" data-template-name="edit">
{% verbatim %}
    {{view NestedCommentsApp.ContributionIndexAlertView}}
    {{view Ember.TextArea rows=6 valueBinding="view.comment.text"}}
    {{view NestedCommentsApp.RichContentEditorHelpView}}

    {{view view.SaveEditButtonView commentBinding="view.comment"}}
    <a class="btn btn-mini" href="#" {{action "cancel" target="view"}}>
      {{view NestedCommentsApp.I18nView value="cancel"}}
    </a>

    {{#unless view.comment.getHTML}}
        <small>
            {{view NestedCommentsApp.I18nView value="theCommentCannotBeEmpty"}}
        </small>
    {{/unless}}

    {{#if view.parentView.submitting}}
        {{view NestedCommentsApp.LoaderView}}
    {{/if}}
{% endverbatim %}
</script>


<script type="text/x-handlebars" data-template-name="reply">
{% verbatim %}
    {{#if view.userIsAuthenticated}}
        {{view NestedCommentsApp.ContributionIndexAlertView}}
        {{view Ember.TextArea rows=6 valueBinding="view.comment.text"}}
        {{view NestedCommentsApp.RichContentEditorHelpView}}

        {{view view.SaveReplyButtonView}}
        <a class="btn btn-mini" href="#" {{action "cancel" target="view"}}>
            {{view NestedCommentsApp.I18nView value="cancel"}}
        </a>

        {{#if view.parentView.submitting}}
            {{view NestedCommentsApp.LoaderView}}
        {{/if}}
    {{else}}
        {{view NestedCommentsApp.LoginOrSignUpView}}
    {{/if}}
{% endverbatim %}
</script>


<script type="text/x-handlebars" data-template-name="timeago">
{% verbatim %}
    {{view.value}}
{% endverbatim %}
</script>


<script type="text/x-handlebars" data-template-name="saveButton">
    {% trans "Submit" %}
</script>


<script type="text/x-handlebars" data-template-name="loader">
{% verbatim %}
    <img alt="" {{bindAttr src="view.loaderUrl"}}/>
{% endverbatim %}
</script>


<script type="text/javascript" src="{% static "common/js/handlebars-1.0.rc.1.js" %}"></script>
<script type="text/javascript" src="{% static "common/js/ember-1.0.0-pre.2.js" %}"></script>
<script type="text/javascript" src="{% static "nested_comments/js/nested_comments_app.js" %}"></script>
