Sha256: 33107656730c11f61ff7bdea678b29265d95f1b9d98b620b13cb961bfd952847

Contents?: true

Size: 1.44 KB

Versions: 7

Compression:

Stored size: 1.44 KB

Contents

#= require raphael
#= require raphael.morris

#= require_self
#= require ./layout

@Character.Dashboard ||= {}

#
# Marionette.js Router Documentation
# https://github.com/marionettejs/backbone.marionette/blob/master/docs/marionette.router.md
#
@Character.Dashboard.Router = Backbone.Marionette.AppRouter.extend
  initialize: (options) ->
    @appRoutes ||= {}
    @appRoutes["#{ options.path }(/:scope)"] = "index"

#
# Marionette.js Controller Documentation
# https://github.com/marionettejs/backbone.marionette/blob/master/docs/marionette.controller.md
#
@Character.Dashboard.Controller = Backbone.Marionette.Controller.extend
  initialize: ->
    @module = @options.module

  index: (scope, callback) ->
    chr.execute('showModule', @module)

    path = @options.moduleName + ( if scope then "/#{ scope }" else '' )
    if chr.currentPath != path
      chr.currentPath = path
      @module.layout.setDateRange()
      @module.layout.updateScope(scope, callback)
    else
      callback?()

chr.dashboardModule = ->
  moduleName = 'dashboard'

  chr.module moduleName, (module) ->
    module = _(module).extend(Character.Dashboard)

    options =
      module:     module
      moduleName: moduleName

    module.on 'start', ->
      @controller = new @Controller(options)
      @layout     = new @Layout(options)
      @router     = new @Router({ path: moduleName, controller: @controller })
      chr.execute('addMenuItem', moduleName, 'bar-chart-o', 'Dashboard')

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
character-1.0.6 app/assets/javascripts/character/dashboard/module.coffee
character-1.0.5 app/assets/javascripts/character/dashboard/module.coffee
character-1.0.4 app/assets/javascripts/character/dashboard/module.coffee
character-1.0.3 app/assets/javascripts/character/dashboard/module.coffee
character-1.0.2 app/assets/javascripts/character/dashboard/module.coffee
character-1.0.1 app/assets/javascripts/character/dashboard/module.coffee
character-1.0.0 app/assets/javascripts/character/dashboard/module.coffee