Sha256: ff0925781336cc7ebb4174aa8e55f81db065be1f08f035e3d64f6adfb4e69f16

Contents?: true

Size: 1.65 KB

Versions: 16

Compression:

Stored size: 1.65 KB

Contents

#= require joosy/joosy
#= require joosy/widget
#= require joosy/helpers/view

#
# Base class for all Joosy Layouts.
#
# @example Sample application layout
#   class @ApplicationLayout extends Joosy.Layout
#     @view 'application'
#
class Joosy.Layout extends Joosy.Widget
  @helper 'page'

  #
  # @param [Hash] params              Route params
  # @param [Joosy.Layout] previous    Layout to replace on load
  #
  constructor: (@params, @previous) ->
    @uid = Joosy.uid()

  #
  # Helper that outputs container tag for the page
  #
  # @param [String]  name             Tag name
  # @param [Object]  options          Tag attributes
  #
  page: (tag, options={}) ->
    options.id = @uid
    Joosy.Helpers.Application.tag tag, options

  #
  # Gets DOM element that should be used as container for nested Page
  #
  # @return [jQuery]
  #
  content: ->
    $("##{@uid}")

  ######
  ###### Widget extensions
  ######

  #
  # This is required by {Joosy.Modules.Renderer}
  # Sets the base template dir to app_name/templates/layouts
  #
  __renderSection: ->
    'layouts'

  #
  # Extends list of registered nested widgets with page
  #
  __nestingMap: (page) ->
    map = super()
    map["##{@uid}"] =
      instance: page
      nested: page.__nestingMap()

    map

  #
  # Adds page as first argument to default bootstrap
  #
  # @param [Joosy.Page] page                  Page to inject
  # @param [jQuery] applicationContainer      The base container for the application to paint at
  #
  __bootstrapDefault: (page, applicationContainer) ->
    @__bootstrap null, @__nestingMap(page), applicationContainer

# AMD wrapper
if define?.amd?
  define 'joosy/layout', -> Joosy.Layout

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
joosy-1.2.0.beta.4 source/joosy/layout.coffee
joosy-1.2.0.beta.3 source/joosy/layout.coffee
joosy-1.2.0.beta.2 source/joosy/layout.coffee
joosy-1.2.0.beta.1 source/joosy/layout.coffee
joosy-1.2.0.alpha.73 source/joosy/layout.coffee
joosy-1.2.0.alpha.71 source/joosy/layout.coffee
joosy-1.2.0.alpha.70 source/joosy/layout.coffee
joosy-1.2.0.alpha.68 source/joosy/layout.coffee
joosy-1.2.0.alpha.67 source/joosy/layout.coffee
joosy-1.2.0.alpha.66 source/joosy/layout.coffee
joosy-1.2.0.alpha.65 source/joosy/layout.coffee
joosy-1.2.0.alpha.64 source/joosy/layout.coffee
joosy-1.2.0.alpha.63 source/joosy/layout.coffee
joosy-1.2.0.alpha.62 source/joosy/layout.coffee
joosy-1.2.0.alpha.59 source/joosy/layout.coffee
joosy-1.2.0.alpha.58 source/joosy/layout.coffee