fix ajax display when posting first comment on a page

This commit is contained in:
codeshell 2017-10-30 12:53:13 +01:00
parent bd1799cc7e
commit ee89c2bdca
3 changed files with 11 additions and 16 deletions

View File

@ -154,7 +154,7 @@ jQuery(document).ready(function () {
if ($( "div[data-id='" + response.data.parent_id + "']" ).length > 0) {
$( "div[data-id='" + response.data.parent_id + "']" ).first().after(newMedia);
} else {
$( "div.comments" ).last().prepend(newMedia);
$( "#comments" ).prepend(newMedia);
}
}
setTimeout(function () {

View File

@ -2,14 +2,12 @@
{% set scope = scope ?: 'data.' %}
<section id="comments-section">
<h2>{{'PLUGIN_COMMENTS.COMMENTS'|t}}</h3>
<!-- <h2>{{ 'COMMENTS'|t }}</h2> -->
<a class="comment-add-new" href="#"><i class="fa fa-plus" title="{{'PLUGIN_COMMENTS.ADD_NEW'|t}}"></i> {{'PLUGIN_COMMENTS.ADD_NEW'|t}}</a>
{% include 'partials/comments.form.html.twig' %}
<div id="comments" class="row comments">
{% if grav.twig.comments|length %}
<a class="comment-add-new" href="#"><i class="fa fa-plus" title="{{'PLUGIN_COMMENTS.ADD_NEW'|t}}"></i> {{'PLUGIN_COMMENTS.ADD_NEW'|t}}</a>
<div class="row comments">
{% for comment in grav.twig.comments %}
<div class="comment comment-level-{{comment.level|e}}" data-level="{{comment.level}}" data-id="{{comment.id}}" >
<div class="comment-left">
@ -33,10 +31,7 @@
</div>
</div>
{% endfor %}
</div>
{% endif %}
</div>
</section>
{% endif %}

View File

@ -1,6 +1,6 @@
{# you may set options when using this partial. Example: include 'partials/recentcomments.html.twig' with {'limit': 5, 'pages_limit': 3} #}
{% if grav.twig.enable_comments_plugin %}
<h1>{'PLUGIN_COMMENTS.COMMENTS_STATS'|t}}</h1>
<h1>{{'PLUGIN_COMMENTS.COMMENTS_STATS'|t}}</h1>
{% set stats = recent_comments(limit|default(5), pages_limit|default(3)) %}
{% if stats.global_stats.active_entries %}
<i class="fa fa-comments" title="active_entries"></i> {{stats.global_stats.active_entries}}
@ -13,7 +13,7 @@
{% endif %}
{% for key, entry in stats.pages %}
{% if loop.first %}
<h2>{'PLUGIN_COMMENTS.RECENT_PAGES'|t}} (limit {{stats.options.pages_limit}})</h2>
<h2>{{'PLUGIN_COMMENTS.RECENT_PAGES'|t}} (limit {{stats.options.pages_limit}})</h2>
<ul class="fa-ul">
{% endif %}
<li><i class="fa-li fa fa-file" title="{{entry.route}}"></i>
@ -31,7 +31,7 @@
{% endfor %}
{% for key, entry in stats.comments %}
{% if loop.first %}
<h2>{'PLUGIN_COMMENTS.RECENT_COMMENTS'|t}} (limit {{stats.options.comments_limit}})</h2>
<h2>{{'PLUGIN_COMMENTS.RECENT_COMMENTS'|t}} (limit {{stats.options.comments_limit}})</h2>
<ul class="fa-ul">
{% endif %}
{% set entry_icon = 'fa-comment' %}