Pony.fm/public/scripts/embed/favourite.coffee

12 lines
340 B
CoffeeScript
Raw Normal View History

2013-09-01 04:20:48 +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'