Sha256: f439ac54e63ebb33c8765473aac6641c83db43646fb0566a7bf580825293492c

Contents?: true

Size: 821 Bytes

Versions: 4

Compression:

Stored size: 821 Bytes

Contents

class Layout
  constructor: (@fn) ->
    this.resize()
    this.listen()
    setTimeout (=> this.resize()), 250

  resize: ->
    this.fill '.x-fill', 'outerWidth', 'width'
    this.fill '.y-fill', 'outerHeight', 'height'
    this.fn()

  fill: (selector, get, set) ->
    $(selector).each (ix, node) =>
      node = $(node)
      getter = node[get]
      parent = getter.call node.parent(), true
      fixed = this.fixed node, selector, (n) -> getter.call(n, true)
      node[set].call node, parent - fixed

  fixed: (node, selector, fn) ->
    node.siblings().not(selector).not('.float').filter(':visible')
      .map(-> fn $ this).get()
      .reduce ((sum, num) -> sum + num), 0

  listen: ->
    id = null
    $(window).resize =>
      clearTimeout id
      id = setTimeout (=> this.resize()), 10
      this.resize()

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vines-0.4.0 web/lib/coffeescripts/layout.coffee
vines-0.3.2 web/lib/coffeescripts/layout.coffee
vines-0.3.1 web/lib/coffeescripts/layout.coffee
vines-0.3.0 web/lib/coffeescripts/layout.coffee