mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-12-01 09:08:00 +01:00
20 lines
561 B
CoffeeScript
20 lines
561 B
CoffeeScript
|
angular.module('ponyfm').directive 'pfmFavouriteButton', () ->
|
||
|
restrict: 'E'
|
||
|
templateUrl: '/templates/directives/favourite-button.html'
|
||
|
scope:
|
||
|
resource: '=resource',
|
||
|
class: '@class',
|
||
|
type: '@type'
|
||
|
|
||
|
controller: [
|
||
|
'$scope', 'favourites', 'auth'
|
||
|
($scope, favourites, auth) ->
|
||
|
$scope.auth = auth.data
|
||
|
|
||
|
$scope.isWorking = false
|
||
|
$scope.toggleFavourite = () ->
|
||
|
$scope.isWorking = true
|
||
|
favourites.toggle($scope.type, $scope.resource.id).done (res) ->
|
||
|
$scope.isWorking = false
|
||
|
$scope.resource.is_favourited = res.is_favourited
|
||
|
]
|