Skip to content

Commit

Permalink
Merge pull request #568 from vladjerca/feature/click_heart_to_like
Browse files Browse the repository at this point in the history
Add required bindings to the like count container. closes #562
  • Loading branch information
weblancaster committed Feb 19, 2016
2 parents cced398 + 1bed78d commit 93c1b0a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
5 changes: 4 additions & 1 deletion app/public/js/common/favoriteSongDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ app.directive('favoriteSong', function(
return {
restrict: 'A',
scope: {
favorite: "="
favorite: "=",
count: "="
},
link: function($scope, elem, attrs) {
var userId
Expand All @@ -25,6 +26,7 @@ app.directive('favoriteSong', function(
if ( typeof status == "object" ) {
notificationFactory.success("Song removed from likes!");
$scope.favorite = false;
$scope.count -= 1;
}
}, function() {
notificationFactory.error("Something went wrong!");
Expand All @@ -35,6 +37,7 @@ app.directive('favoriteSong', function(
if ( typeof status == "object" ) {
notificationFactory.success("Song added to likes!");
$scope.favorite = true;
$scope.count += 1;
}
}, function(status) {
notificationFactory.error("Something went wrong!");
Expand Down
7 changes: 7 additions & 0 deletions app/public/stylesheets/sass/_components/_track.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
.trackView {
& .likes_count {
&.liked {
& > i {
color: $scColor;
}
}
}
& .trackDetails {
display: flex;

Expand Down
2 changes: 1 addition & 1 deletion app/views/common/tracks.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ <h3 class="songList_item_song_info clearfix">

<div class="songList_item_song_details">
<div class="songList_item_actions">
<a favorite-song data-song-id="{{ data.id }}" favorite="data.user_favorite" ng-class="{liked: data.user_favorite}" title="{{data.user_favorite ? 'Unlike' : 'Like'}}">
<a favorite-song data-song-id="{{ data.id }}" favorite="data.user_favorite" count="data.favoritings_count" ng-class="{liked: data.user_favorite}" title="{{data.user_favorite ? 'Unlike' : 'Like'}}">
<i class="fa fa-heart"></i>
</a>
<a reposted-song data-song-id="{{ data.id }}" reposted="data.user_reposted" ng-class="{ reposted: data.user_reposted }" title="{{data.user_reposted ? 'Unpost' : 'Repost'}}" ng-if="data.user.id !== $root.userId">
Expand Down
8 changes: 5 additions & 3 deletions app/views/track/track.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,18 @@
<span class="playback_count">
<i class="fa fa-play"></i> {{track.playback_count | number}}
</span>
<span class="likes_count">
<span class="likes_count"
ng-class="{liked: track.user_favorite}"
favorite-song data-song-id="{{ track.id }}" favorite="track.user_favorite" count="track.favoritings_count">
<i class="fa fa-heart"></i> {{track.favoritings_count | round}}
</span>
</div>
</div>
</div>
<div class="content">
<div ng-click="changeLike()" ng-mouseenter="hover = true" ng-mouseleave="hover = false"
<div ng-mouseenter="hover = true" ng-mouseleave="hover = false"
ng-class="{liked: track.user_favorite}" class="button follow_button"
favorite-song data-song-id="{{ track.id }}" favorite="track.user_favorite">
favorite-song data-song-id="{{ track.id }}" favorite="track.user_favorite" count="track.favoritings_count">
<span ng-if="hover == false">{{track.user_favorite ? 'Liked' : 'Like'}}</span>
<span ng-if="hover == true">{{track.user_favorite ? 'Unlike' : 'Like'}}</span>
</div>
Expand Down

0 comments on commit 93c1b0a

Please sign in to comment.