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

Version Path
gumdrop-0.8.0 templates/backbone/app/app.js.coffee
gumdrop-0.7.5 templates/backbone/app/app.js.coffee
gumdrop-0.7.4 templates/backbone/app/app.js.coffee
gumdrop-0.7.3.1 templates/backbone/app/app.js.coffee
gumdrop-0.7.3 templates/backbone/app/app.js.coffee
gumdrop-0.7.2 templates/backbone/app/app.js.coffee
gumdrop-0.7.1 templates/backbone/app/app.js.coffee
gumdrop-0.7.0 templates/backbone/app/app.js.coffee
gumdrop-0.6.4 templates/backbone/app/app.js.coffee
gumdrop-0.6.3 templates/backbone/app/app.js.coffee
gumdrop-0.6.2 templates/backbone/app/app.js.coffee
gumdrop-0.6.1 templates/backbone/app/app.js.coffee
gumdrop-0.6.0 templates/backbone/app/app.js.coffee
gumdrop-0.5.2 templates/backbone/app/app.js.coffee
gumdrop-0.5.1 templates/backbone/app/app.js.coffee
gumdrop-0.5 templates/backbone/app/app.js.coffee
gumdrop-0.4.0 lib/gumdrop/template/backbone/app/app.js.coffee
gumdrop-0.3.10 lib/gumdrop/template/backbone/app/app.js.coffee
gumdrop-0.3.9 lib/gumdrop/template/backbone/app/app.js.coffee
gumdrop-0.3.8 lib/gumdrop/template/backbone/app/app.js.coffee