Change Editor.proto.split method to use new RootView.proto.addPane method.

RootView.proto.addPane takes a view to add, a sibling to add it next to, an axis along which to add (row or column), and a side (before or after)
This commit is contained in:
Nathan Sobo 2012-04-10 19:27:50 -06:00
parent 5d8affb3e4
commit ae5d64f06d
2 changed files with 12 additions and 8 deletions

View File

@ -468,15 +468,10 @@ class Editor extends View
splitDown: ->
@split('column', 'after')
split: (axis, insertMethod) ->
unless @parent().hasClass axis
container = $$ -> @div class: axis
container.insertBefore(this).append(this.detach())
split: (axis, side) ->
return unless rootView = @rootView()
editor = new Editor(@getEditorState())
this[insertMethod](editor)
@rootView().adjustSplitPanes()
editor
rootView.addPane(editor, this, axis, side)
remove: (selector, keepData) ->
return super if keepData

View File

@ -78,6 +78,15 @@ class RootView extends View
editor.appendTo(@panes)
editor.focus()
addPane: (view, sibling, axis, side) ->
unless sibling.parent().hasClass(axis)
container = $$ -> @div class: axis
container.insertBefore(sibling).append(sibling.detach())
sibling[side](view)
@adjustSplitPanes()
view
adjustSplitPanes: (element = @panes.children(':first'))->
if element.hasClass('row')
totalUnits = @horizontalGridUnits(element)