Enhance pane split methods. Spec them in pane-spec.

When a pane is split, it attempts to make a copy of its current item
if no items are passed to the split method. When splitting, multiple
items can also be passed to the constructor of the new pane.
This commit is contained in:
Nathan Sobo
2013-02-20 20:53:34 -07:00
committed by probablycorey
parent 45eec6a8ff
commit 0c2a5f273c
2 changed files with 72 additions and 11 deletions

View File

@@ -104,30 +104,34 @@ class Pane extends View
verticalGridUnits: -> 1
splitUp: (view) ->
@split(view, 'column', 'before')
splitUp: (items...) ->
@split(items, 'column', 'before')
splitDown: (view) ->
@split(view, 'column', 'after')
splitDown: (items...) ->
@split(items, 'column', 'after')
splitLeft: (view) ->
@split(view, 'row', 'before')
splitLeft: (items...) ->
@split(items, 'row', 'before')
splitRight: (view) ->
@split(view, 'row', 'after')
splitRight: (items...) ->
@split(items, 'row', 'after')
split: (view, axis, side) ->
split: (items, axis, side) ->
unless @parent().hasClass(axis)
@buildPaneAxis(axis)
.insertBefore(this)
.append(@detach())
pane = new Pane(view)
items = [@copyCurrentItem()] unless items.length
pane = new Pane(items...)
this[side](pane)
rootView?.adjustPaneDimensions()
pane.focus()
pane
copyCurrentItem: ->
deserialize(@currentItem.serialize())
remove: (selector, keepData) ->
return super if keepData
# find parent elements before removing from dom