2013-08-01 04:47:21 +02:00
|
|
|
angular.module('ponyfm').directive 'pfmTracksList', () ->
|
|
|
|
restrict: 'E'
|
|
|
|
templateUrl: '/templates/directives/tracks-list.html'
|
|
|
|
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) ->
|
|
|
|
track.is_favourited = res.is_favourited
|
|
|
|
|
|
|
|
$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
|
|
|
]
|