Pony.fm/resources/assets/scripts/embed/favourite.coffee

12 lines
340 B
CoffeeScript
Raw Normal View History

2015-08-31 17:42:21 +02:00
$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'