mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-24 14:08:00 +01:00
20 lines
No EOL
576 B
CoffeeScript
20 lines
No EOL
576 B
CoffeeScript
angular.module('ponyfm').directive 'pfmTracksList', () ->
|
|
restrict: 'E'
|
|
templateUrl: '/templates/directives/tracks-list.html'
|
|
scope:
|
|
tracks: '=tracks',
|
|
class: '@class'
|
|
|
|
controller: [
|
|
'$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
|
|
] |