pulsar/src/app/pane-row.coffee

37 lines
749 B
CoffeeScript
Raw Normal View History

$ = require 'jquery'
_ = require 'underscore'
PaneAxis = require 'pane-axis'
2013-04-19 05:50:22 +04:00
###
# Internal #
###
module.exports =
class PaneRow extends PaneAxis
@content: ->
@div class: 'row'
className: ->
"PaneRow"
adjustDimensions: ->
totalUnits = @horizontalGridUnits()
unitsSoFar = 0
for child in @children()
child = $(child).view()
childUnits = child.horizontalGridUnits()
child.css
width: "#{childUnits / totalUnits * 100}%"
height: '100%'
top: 0
left: "#{unitsSoFar / totalUnits * 100}%"
child.adjustDimensions()
unitsSoFar += childUnits
horizontalGridUnits: ->
_.sum(@horizontalChildUnits())
verticalGridUnits: ->
Math.max(@verticalChildUnits()...)