From ae5d64f06ddf35d67364e956b9283f12918bf155 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 10 Apr 2012 19:27:50 -0600 Subject: [PATCH] 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) --- src/app/editor.coffee | 11 +++-------- src/app/root-view.coffee | 9 +++++++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/app/editor.coffee b/src/app/editor.coffee index b63f1d6cb..8e7e3ffa8 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -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 diff --git a/src/app/root-view.coffee b/src/app/root-view.coffee index 5c6da725c..63e2e9d1a 100644 --- a/src/app/root-view.coffee +++ b/src/app/root-view.coffee @@ -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)