Sha256: c592a27c0f933e06ee6bd5605a3b1c6281d33fbb1b7eb69c91fdd402f719dc0c

Contents?: true

Size: 1.31 KB

Versions: 19

Compression:

Stored size: 1.31 KB

Contents

ELA.Models ?= {}
class ELA.Models.App extends Backbone.Model
  helpText: 'about'

  defaults:
    path: null
    params: null
    showAbout: false

  initialize: ->
    @on('change:path', @handlePath)
    @on('change:params', @handleParams)

  # @returns BaseApp or BaseSubappContainer
  currentAppModel: ->
    @get('currentAppModel')

  # @returns BaseApp
  currentApp: ->
    @currentAppModel()?.currentApp()

  currentNamespace: ->
    path = @get('path')
    if path?
      klass = path[0].toCapitalCamel()
      ELA[klass]

  handlePath: (model, path) ->
    if path?
      if path[0] is 'about'
        @set(showAbout: true)
      else if path[0] isnt @currentAppModel()?.name
        AppClass = @currentNamespace().Models.App
        @set
          showAbout: false
          currentAppModel: new AppClass(path: path.slice(1))
      else
        @currentAppModel()?.set(path: path.slice(1))
        @set(showAbout: false)
    else
      @set
        currentAppModel: null
        showAbout: false

  handleParams: (model, params) ->
    @currentApp().deserialize(params) if params?

  url: ->
    url = location.origin
    if json = @toJSON()
      url += '/#app/' +
        @get('path').join('/') +
        '?' +
        encodeURI(json)
    url

  toJSON: ->
    JSON.stringify(currentApp.serialize()) if currentApp = @currentApp()

Version data entries

19 entries across 19 versions & 1 rubygems

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