Pony.fm/public/scripts/app/services/taxonomies.coffee
2013-07-25 16:33:12 -05:00

23 lines
No EOL
527 B
CoffeeScript

angular.module('ponyfm').factory('taxonomies', [
'$rootScope'
($rootScope) ->
def = null
self =
trackTypes: [],
licenses: []
genres: []
refresh: () ->
return def if def != null
def = new $.Deferred()
$.getJSON('/api/web/taxonomies/all')
.done (taxonomies) -> $rootScope.$apply ->
self.trackTypes.push t for t in taxonomies.track_types
self.licenses.push t for t in taxonomies.licenses
self.genres.push t for t in taxonomies.genres
def.resolve self
def
self
])