43 lines
946 B
CoffeeScript
43 lines
946 B
CoffeeScript
window.App = App || {}
|
|
App.Features = {}
|
|
App.Routers = {}
|
|
App.Views = {}
|
|
App.Collections = {}
|
|
App.Models = {}
|
|
App.Data = {}
|
|
App.Dispatcher = _.clone(Backbone.Events)
|
|
|
|
App.initFeatures = ->
|
|
$('[data-features]').each ->
|
|
el = `$(this)`
|
|
features = (el.attr 'data-features').split ' '
|
|
for key in features
|
|
if App.Features[key]
|
|
new App.Features[key](el)
|
|
|
|
App.initBackbone = ->
|
|
App.Data.verses = new App.Collections.Verses()
|
|
|
|
mainRouter = new App.Routers.MainRouter()
|
|
Backbone.history.start()
|
|
mainRouter.navigate 'read', trigger: true
|
|
|
|
App.setupEvents = ->
|
|
App.Dispatcher.on 'show-loader', () ->
|
|
$('#loader').show()
|
|
App.Dispatcher.on 'hide-loader', () ->
|
|
$('#loader').hide()
|
|
|
|
$(window).on 'keydown', (e) ->
|
|
App.Dispatcher.trigger 'keydown', e
|
|
|
|
App.init = ->
|
|
@initFeatures()
|
|
@initBackbone()
|
|
@setupEvents()
|
|
|
|
|
|
$(->
|
|
App.init()
|
|
)
|