Sha256: acf69702788d6185a01c3829c5e399dbc5c182634542f408dfac937b20480b38

Contents?: true

Size: 1.49 KB

Versions: 19

Compression:

Stored size: 1.49 KB

Contents

ELA.Views ?= {}
class ELA.Views.App extends Backbone.View
  initialize: ->
    @subviews = {}
    @listenTo @model, 'change:currentAppModel', @render
    @listenTo @model, 'change:showAbout', @renderAbout

  # @returns BaseApp or BaseSubappContainer
  currentAppModel: -> @model.currentAppModel()

  activateSubviews: =>
    if @currentAppModel()
      @subviews.index?.deactivate()
      @subviews.app?.activate()
    else
      @subviews.index?.activate()
      @subviews.app?.deactivate()

  loadedViewName: ->
    @subviews.app?.model.name

  currentAppModelName: ->
    @model.currentAppModel()?.name

  renderAbout: =>
    showAbout = @model.get('showAbout')
    if showAbout and not @subviews.help?
      @subviews.help = view = new ELA.Views.Help
        model: @model
      @$el.append(view.render().el)

    delay =>
      @subviews.help?.setActive(showAbout)
      @subviews.index?.setActive(not showAbout)

  render: =>
    unless @subviews.index?
      @subviews.index = new ELA.Views.Overview()
      @$el.append(@subviews.index.render().el)

    if @subviews.app and @loadedViewName() isnt @currentAppModelName()
      @subviews.app.remove()
      delete @subviews.app

    if @model.currentAppModel() and not @subviews.app?
      AppView = @model.currentNamespace().Views.App
      @subviews.app = view = new AppView
        model: @model.currentAppModel()
        localePrefix: @model.currentAppModel().localePrefix()
      @$el.append(view.render().el)

    @renderAbout()

    delay @activateSubviews

    this

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
ela-4.1.6 app/js/lib/views/app.coffee
ela-4.1.5 app/js/lib/views/app.coffee
ela-4.1.4 app/js/lib/views/app.coffee
ela-4.1.3 app/js/lib/views/app.coffee
ela-4.1.2 app/js/lib/views/app.coffee
ela-4.1.1 app/js/lib/views/app.coffee
ela-4.1.0 app/js/lib/views/app.coffee
ela-4.0.0 app/js/lib/views/app.coffee
ela-3.4.3 app/js/lib/views/app.coffee
ela-3.4.2 app/js/lib/views/app.coffee
ela-3.4.0 app/js/lib/views/app.coffee
ela-3.3.1 app/js/lib/views/app.coffee
ela-3.3.0 app/js/lib/views/app.coffee
ela-3.2.0 app/js/lib/views/app.coffee
ela-3.1.1 app/js/lib/views/app.coffee
ela-3.1.0 app/js/lib/views/app.coffee
ela-3.0.0 app/js/lib/views/app.coffee
ela-2.0.0 app/js/lib/views/app.coffee
ela-1.1.0 app/js/lib/views/app.coffee