diff --git a/web/app/assets/javascripts/bandProfile.js b/web/app/assets/javascripts/bandProfile.js index 20ff38afc..7027661ea 100644 --- a/web/app/assets/javascripts/bandProfile.js +++ b/web/app/assets/javascripts/bandProfile.js @@ -47,55 +47,53 @@ /****************** MAIN PORTION OF SCREEN *****************/ function addFollowing(isBand, id) { - var newFollowing = {}; + var newFollowing = {}; - if (!isBand) { - newFollowing.user_id = id; - } - else { - newFollowing.band_id = id; - } + if (!isBand) { + newFollowing.user_id = id; + } + else { + newFollowing.band_id = id; + } - rest.addFollowing(newFollowing) - .done(function() { - if (isBand) { - var newCount = parseInt($("#band-profile-follower-stats").text()) + 1; - var text = newCount > 1 || newCount == 0 ? " Followers" : " Follower"; - $('#band-profile-follower-stats').html(newCount + text); - configureBandFollowingButton(true); - } - else { - configureMemberFollowingButton(true, id); - } - }) - .fail(app.ajaxError); + rest.addFollowing(newFollowing) + .done(function() { + if (isBand) { + var newCount = parseInt($("#band-profile-follower-stats").text()) + 1; + var text = newCount > 1 || newCount == 0 ? " Followers" : " Follower"; + $('#band-profile-follower-stats').html(newCount + text); + configureBandFollowingButton(true); + } + else { + configureMemberFollowingButton(true, id); + } + renderActive(); + }) + .fail(app.ajaxError); } function removeFollowing(isBand, id) { - var following = {}; - following.target_entity_id = id; - - rest.removeFollowing(following) - .done(function() { - renderActive(); // refresh stats - if (isBand) { - var newCount = parseInt($("#band-profile-follower-stats").text()) - 1; - var text = newCount > 1 || newCount == 0 ? " Followers" : " Follower"; - $('#band-profile-follower-stats').html(newCount + text); - configureBandFollowingButton(false); - } - else { - configureMemberFollowingButton(false, id); - } - }) - .fail(app.ajaxError); + rest.removeFollowing(id) + .done(function() { + if (isBand) { + var newCount = parseInt($("#band-profile-follower-stats").text()) - 1; + var text = newCount > 1 || newCount == 0 ? " Followers" : " Follower"; + $('#band-profile-follower-stats').html(newCount + text); + configureBandFollowingButton(false); + } + else { + configureMemberFollowingButton(false, id); + } + renderActive(); + }) + .fail(app.ajaxError); } function configureBandFollowingButton(following) { $('#btn-follow-band').unbind("click"); if (following) { - $('#btn-follow-band').text('STOP FOLLOWING'); + $('#btn-follow-band').text('UNFOLLOW'); $('#btn-follow-band').click(function() { removeFollowing(true, bandId); return false; @@ -121,7 +119,7 @@ $btnFollowMember.unbind("click"); if (following) { - $btnFollowMember.text('UN-FOLLOW'); + $btnFollowMember.text('UNFOLLOW'); $btnFollowMember.click(function() { removeFollowing(false, userId); return false; diff --git a/web/app/assets/javascripts/hoverBand.js b/web/app/assets/javascripts/hoverBand.js index f1324b217..2b98e8e62 100644 --- a/web/app/assets/javascripts/hoverBand.js +++ b/web/app/assets/javascripts/hoverBand.js @@ -49,21 +49,23 @@ }); var bandHtml = context.JK.fillTemplate(template, { - avatar_url: context.JK.resolveBandAvatarUrl(response.photo_url), - name: response.name, - location: response.location, - genres: genres.join(', '), - musicians: musicianHtml, - like_count: response.liker_count, - follower_count: response.follower_count, - recording_count: response.recording_count, - session_count: response.session_count, - biography: response.biography, - profile_url: "/client#/bandProfile/" + response.id + bandId: response.id, + avatar_url: context.JK.resolveBandAvatarUrl(response.photo_url), + name: response.name, + location: response.location, + genres: genres.join(', '), + musicians: musicianHtml, + like_count: response.liker_count, + follower_count: response.follower_count, + recording_count: response.recording_count, + session_count: response.session_count, + biography: response.biography, + followAction: response.is_following ? "removeBandFollowing" : "addBandFollowing", + profile_url: "/client#/bandProfile/" + response.id }); $(hoverSelector).append('