Pony.fm/resources/assets/scripts/embed/favourite.coffee
2015-08-31 16:42:23 +01:00

12 lines
No EOL
340 B
CoffeeScript

$player = $ '.player'
$favourite = $player.find '.favourite'
trackId = $player.data 'track-id'
$favourite.click (e) ->
e.preventDefault()
$.post('/api/web/favourites/toggle', {type: 'track', id: trackId, _token: pfm.token}).done (res) ->
if res.is_favourited
$player.addClass 'favourited'
else
$player.removeClass 'favourited'