57 lines
1.4 KiB
CoffeeScript
57 lines
1.4 KiB
CoffeeScript
$ = jQuery
|
|
context = window
|
|
logger = context.JK.logger
|
|
rest = context.JK.Rest()
|
|
EVENTS = context.JK.EVENTS
|
|
|
|
|
|
JamTrackActions = @JamTrackActions
|
|
|
|
@JamTrackStore = Reflux.createStore(
|
|
{
|
|
listenables: JamTrackActions
|
|
jamTrack: null
|
|
requestedSearch: null
|
|
requestedFilter: null
|
|
|
|
init: ->
|
|
# Register with the app store to get @app
|
|
this.listenTo(context.AppStore, this.onAppInit)
|
|
|
|
onAppInit: (app) ->
|
|
@app = app
|
|
|
|
onOpen: (jamTrack) ->
|
|
if @jamTrack?
|
|
@app.notify({text: 'Unable to open JamTrack because another one is already open.'})
|
|
return
|
|
|
|
@jamTrack = jamTrack
|
|
this.trigger(@jamTrack)
|
|
|
|
onClose: () ->
|
|
@jamTrack = null
|
|
this.trigger(@jamTrack)
|
|
|
|
onRequestSearch:(searchType, searchData) ->
|
|
@requestedSearch = {searchType: searchType, searchData: searchData}
|
|
window.location.href = '/client#/jamtrack/search'
|
|
|
|
# needed by the JamTrackSearchScreen
|
|
checkRequestedSearch:() ->
|
|
requested = @requestedSearch
|
|
@requestedSearch = null
|
|
requested
|
|
|
|
onRequestFilter:(genre, instrument) ->
|
|
@requestedFilter = {genre: genre, instrument:instrument}
|
|
window.location.href = '/client#/jamtrack/filter'
|
|
|
|
# needed by the JamTrackSearchScreen
|
|
checkRequestedFilter:() ->
|
|
requested = @requestedFilter
|
|
@requestedFilter = null
|
|
requested
|
|
|
|
}
|
|
) |