mirror of
https://github.com/atom/atom.git
synced 2026-02-14 16:45:14 -05:00
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:
committed by
probablycorey
parent
45eec6a8ff
commit
0c2a5f273c
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user