Sha256: a65a543b830fcea9e333c970c3c4127b4cd4d2b703e9aa51f9a600e7582d5875

Contents?: true

Size: 1.72 KB

Versions: 6

Compression:

Stored size: 1.72 KB

Contents

ELA.Models ?= {}
class ELA.Models.BaseApp extends ELA.Models.BaseAppModel
  hasHelpText: true

  initialize: (options = {}) ->
    @parentApp = options.parentApp

    @on 'change:path', @handlePath
    @set currentAside: @get('currentAside') or null
    @handlePath()

  handlePath: =>
    path = @get('path')?[0]
    if path is 'help'
      @set showHelp: true
    else
      @set showHelp: false

  helpTextName: =>
    @path.replace('/', '_')

  # Initialize the curves attribute with all necessary options.
  #
  # @param [Array] curves curves to add to the curves collection
  # @param [Object] options reached through to collection initialization
  initCurves: (curves, options = {}) ->
    @curves = new ELA.Collections.Curves(curves, options)

  currentApp: -> this

  serialize: ->
    v = parameters: _.pick(
        @attributes
        _.keys(@defaults())
      )
    if @curves?
      v.selectedCurves = for curve in @curves.getHistory()
        curve.get('function')
    if @displayParams?
      v.displayParams = @displayParams.serialize()
    if @get('axisLabelingForCurve')?
      v.axisLabelingForCurve = @get('axisLabelingForCurve').get('function')
    v

  deserialize: (params) ->
    @set(params.parameters)

    for curve in @curves.models
      curve.set(selected: false)

    for curve in @curves.models
      curveFunction = curve.get('function')
      if _.contains(params.selectedCurves, curveFunction)
        curve.set(selected: true)
        if curveFunction is params.axisLabelingForCurve
          @set(axisLabelingForCurve: curve)

    # Wait until graphView has been created, it's initializer resets
    # displayParams
    if params.displayParams?
      _.defer =>
        @displayParams.deserialize(params.displayParams)

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ela-3.2.0 app/js/lib/models/base_app.coffee
ela-3.1.1 app/js/lib/models/base_app.coffee
ela-3.1.0 app/js/lib/models/base_app.coffee
ela-3.0.0 app/js/lib/models/base_app.coffee
ela-2.0.0 app/js/lib/models/base_app.coffee
ela-1.1.0 app/js/lib/models/base_app.coffee