2012-08-27 01:29:46 +04:00
|
|
|
$ = require 'jquery'
|
|
|
|
_ = require 'underscore'
|
2013-02-21 07:59:25 +04:00
|
|
|
PaneAxis = require 'pane-axis'
|
2012-08-27 01:29:46 +04:00
|
|
|
|
2013-04-19 05:50:22 +04:00
|
|
|
###
|
|
|
|
# Internal #
|
|
|
|
###
|
|
|
|
|
2012-08-27 01:29:46 +04:00
|
|
|
module.exports =
|
2013-02-21 07:59:25 +04:00
|
|
|
class PaneRow extends PaneAxis
|
2012-08-27 01:29:46 +04:00
|
|
|
@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()...)
|