Sha256: 03a05cdc205e003b95d6ea1c41d577d3a1c3b26263a2da8b578894d75a3751dd
Contents?: true
Size: 977 Bytes
Versions: 25
Compression:
Stored size: 977 Bytes
Contents
{ log, warn }= require('utils') class Application extends Backbone.Router views: {} routes: '': 'home' home: -> @views.home = new (require('views/home')) unless @views.home? $('body').html @views.home.render().el constructor: -> @initializers= [] @isReady= no super addInitializer: (fn)-> if @isReady fn.call this, @options else @initializers.push fn this start: (options)-> if @isReady # You can only 'start' the app once! warn "You can only start the application once!" this else log "Init!" @trigger 'app:init:before', app:this, options:options for fn in @initializers fn.call this, options @trigger 'app:init:after', app:this, options:options delete @initializers @options= options @isReady= yes Backbone.history.start pushState:(@options.pushState) log "Ready." this module.exports= new Application
Version data entries
25 entries across 25 versions & 1 rubygems