Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add required bindings to the like count container. closes #562 #568

Merged
merged 2 commits into from
Feb 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -9,16 +9,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