Sha256: d382ed8e83efbf3433bba1d885da3975e69fa0b7594b9fd905a31a97daa27ab7

Contents?: true

Size: 973 Bytes

Versions: 3

Compression:

Stored size: 973 Bytes

Contents

_.def('Luca.containers.ColumnView').extends('Luca.core.Container').with
  componentType: 'column_view'

  className: 'luca-ui-column-view'

  components: []

  initialize: (@options={})->
    Luca.core.Container::initialize.apply @, arguments
    @setColumnWidths()

  componentClass: 'luca-ui-column'

  containerTemplate: "containers/basic"

  appendContainers: true

  autoColumnWidths: ()->
    widths = []

    _( @components.length ).times ()=>
      widths.push( parseInt( 100 / @components.length ) )

    widths

  setColumnWidths: ()->
    @columnWidths = if @layout?
      _( @layout.split('/') ).map((v)-> parseInt(v) )
    else
      @autoColumnWidths()

    @columnWidths = _( @columnWidths ).map (val)-> "#{ val }%"

  beforeLayout: ()->
    @debug "column_view before layout"

    _(@columnWidths).each (width,index) =>
      @components[index].float = "left"
      @components[index].width = width

    Luca.core.Container::beforeLayout?.apply @, arguments

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
luca-0.9.2 src/containers/column_view.coffee
luca-0.9.1 src/containers/column_view.coffee
luca-0.9.0 src/containers/column_view.coffee