Fav and comments are shown only if there are any

This commit is contained in:
Marcin Kurczewski 2013-11-22 11:51:33 +01:00
parent 95b2eec461
commit c1e763316a
2 changed files with 16 additions and 20 deletions

View file

@ -34,7 +34,7 @@ function onDomUpdate()
{ {
$.get(window.location.href, function(data) $.get(window.location.href, function(data)
{ {
$('.comments.unit').replaceWith($(data).find('.comments.unit')); $('.comments-wrapper').replaceWith($(data).find('.comments-wrapper'));
$('body').trigger('dom-update'); $('body').trigger('dom-update');
}); });
}); });
@ -133,7 +133,7 @@ $(function()
{ {
$.get(window.location.href, function(data) $.get(window.location.href, function(data)
{ {
$('.comments.unit').replaceWith($(data).find('.comments.unit')); $('.comments-wrapper').replaceWith($(data).find('.comments-wrapper'));
$('body').trigger('dom-update'); $('body').trigger('dom-update');
}); });
formDom.find('textarea').val(''); formDom.find('textarea').val('');

View file

@ -146,11 +146,8 @@
<?php endif ?> <?php endif ?>
</div> </div>
<?php if (count($this->context->transport->post->ownFavoritee) > 0): ?>
<div class="unit favorites"> <div class="unit favorites">
<?php if (count($this->context->transport->post->ownFavoritee) == 0): ?>
<h1>favorites</h1>
<p>None yet.</p>
<?php else: ?>
<h1>favorites (<?php echo count($this->context->transport->post->ownFavoritee) ?>)</h1> <h1>favorites (<?php echo count($this->context->transport->post->ownFavoritee) ?>)</h1>
<ul> <ul>
<?php foreach ($this->context->transport->post->via('favoritee')->sharedUser as $user): ?> <?php foreach ($this->context->transport->post->via('favoritee')->sharedUser as $user): ?>
@ -161,8 +158,8 @@
</li> </li>
<?php endforeach ?> <?php endforeach ?>
</ul> </ul>
<?php endif ?>
</div> </div>
<?php endif ?>
<?php if (count($this->context->transport->post->via('crossref')->sharedPost)): ?> <?php if (count($this->context->transport->post->via('crossref')->sharedPost)): ?>
<div class="relations unit"> <div class="relations unit">
@ -296,11 +293,9 @@
<?php $this->renderFile('post-edit') ?> <?php $this->renderFile('post-edit') ?>
<?php endif ?> <?php endif ?>
<div class="comments-wrapper">
<?php if (!empty($this->context->transport->post->ownComment)): ?>
<div class="comments unit"> <div class="comments unit">
<?php if (empty($this->context->transport->post->ownComment)): ?>
<h1>comments</h1>
None yet.
<?php else: ?>
<h1>comments (<?php echo $this->context->transport->post->countOwn('comment') ?>)</h1> <h1>comments (<?php echo $this->context->transport->post->countOwn('comment') ?>)</h1>
<div class="comments"> <div class="comments">
<?php foreach ($this->context->transport->post->ownComment as $comment): ?> <?php foreach ($this->context->transport->post->ownComment as $comment): ?>
@ -308,6 +303,7 @@
<?php echo $this->renderFile('comment-small') ?> <?php echo $this->renderFile('comment-small') ?>
<?php endforeach ?> <?php endforeach ?>
</div> </div>
</div>
<?php endif ?> <?php endif ?>
</div> </div>