Skip to content
This repository was archived by the owner on Jul 26, 2019. It is now read-only.

Commit

Permalink
Activate Article Hart Btn
Browse files Browse the repository at this point in the history
  • Loading branch information
Thabet-Do committed Apr 16, 2019
1 parent 8373cfb commit 3794a8b
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 67 deletions.
129 changes: 67 additions & 62 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions public/js/article_show.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
$(document).ready(function () {
$('.js-like-article').click(function (e) {
e.preventDefault();
var $link = $(e.currentTarget);
var $count = $('.js-like-counter').text();
$link.toggleClass('fa-heart-o').toggleClass('fa-heart');
$('.js-like-counter').html(parseInt($count) + 1);
})
});
13 changes: 9 additions & 4 deletions templates/article/show.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
{% block title %}Read {{ title }} {% endblock title %}

{% block body %}

<div class="container">
<div class="row">
<div class="col-sm-12">
Expand All @@ -16,7 +15,10 @@
<br>
<span class="align-left article-details"><img class="article-author-img rounded-circle" src="{{ asset('images/alien-profile.png') }}"> Mike Ferengi </span>
<span class="pl-2 article-details"> 3 hours ago</span>
<span class="pl-2 article-details"> 5 <a href="#" class="fa fa-heart-o like-article"></a> </span>
<span class="pl-2 article-details">
<span class="js-like-counter">5</span>
<a href="#" class="fa fa-heart-o like-article js-like-article"></a>
</span>
</div>
</div>
</div>
Expand Down Expand Up @@ -96,7 +98,10 @@
</div>
</div>
</div>


{#{{ dump() }}#}
{% endblock body %}

{% block javascripts %}
{{ parent() }}
<script src="{{ asset('js/article_show.js') }}"></script>
{% endblock %}
5 changes: 4 additions & 1 deletion tutorial/templates/article.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
<br>
<span class="align-left article-details"><img class="article-author-img rounded-circle" src="{{ asset('images/alien-profile.png') }}"> Mike Ferengi </span>
<span class="pl-2 article-details"> 3 hours ago</span>
<span class="pl-2 article-details"> 5 <a href="#" class="fa fa-heart-o like-article"></a> </span>
<span class="pl-2 article-details">
<span class="js-like-counter">5</span>
<a href="#" class="fa fa-heart-o like-article js-like-article"></a>
</span>
</div>
</div>
</div>
Expand Down

0 comments on commit 3794a8b

Please sign in to comment.