Sha256: 944f6ff46c277f45f7b79b593ac53dd691cc7a2b0be9c1730c62265adb0977fa

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

#= require joosy/core/joosy

#
# Joosy Application container
#
# @mixin
#
Joosy.Application =
  Pages: {}
  Layouts: {}
  Controls: {}

  loading: true
  identity: true
  debounceForms: false

  config:
    debug: false
    router:
      html5: false
      base:  '/'

  #
  # Starts Joosy application by binding to element and bootstraping routes
  #
  # @param [String] name        Name of app (the dir its located in)
  # @param [String] selector    jQuery-compatible selector of root application element
  # @param [Object] options
  #
  initialize: (@name, @selector, options={}) ->
    @mergeConfig(window.JoosyEnvironment) if window.JoosyEnvironment?
    @mergeConfig(options)

    @templater = new Joosy.Templaters.RailsJST @name

    Joosy.Router.__setupRoutes()

  #
  # Gets current application root node
  #
  content: ->
    $(@selector)

  #
  # Gets current application sandbox node
  #
  sandbox: ->
    $(@sandboxSelector)

  #
  # Switches to given page
  #
  # @param [Joosy.Page] page      The class (not object) of page to load
  # @param [Object] params        Hash of page params
  #
  setCurrentPage: (page, params) ->
    attempt = new page(params, @page)
    @page = attempt unless attempt.halted

  mergeConfig: (options) ->
    for key, value of options
      if Object.isObject @config[key]
        Object.merge @config[key], value
      else
        @config[key] = value

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
joosy-1.2.0.alpha.38 src/joosy/core/application.coffee