Pony.fm/public/scripts/app/directives/tracks-list.coffee

21 lines
601 B
CoffeeScript
Raw Normal View History

2013-08-01 04:47:21 +02:00
angular.module('ponyfm').directive 'pfmTracksList', () ->
restrict: 'E'
templateUrl: '/templates/directives/tracks-list.html'
replace: true
2013-08-01 04:47:21 +02:00
scope:
tracks: '=tracks',
class: '@class'
controller: [
2013-08-01 10:57:08 +02:00
'$scope', 'favourites', 'player', 'auth'
($scope, favourites, player, auth) ->
$scope.auth = auth.data
$scope.toggleFavourite = (track) ->
favourites.toggle('track', track.id).done (res) ->
2013-08-19 05:39:29 +02:00
track.user_data.is_favourited = res.is_favourited
2013-08-01 10:57:08 +02:00
$scope.play = (track) ->
index = _.indexOf $scope.tracks, (t) -> t.id == track.id
player.playTracks $scope.tracks, index
2013-08-01 04:47:21 +02:00
]