sorting works on a single editor

Needs updating to support dragging between panels
This commit is contained in:
Justin Palmer
2013-02-09 15:34:35 -08:00
parent 8a50581430
commit e92d9ea998
2 changed files with 28 additions and 7 deletions

View File

@@ -1,9 +1,9 @@
$ = require 'jquery'
SortableView = require 'sortable-view'
SortableList = require 'sortable-list'
Tab = require 'tabs/src/tab'
module.exports =
class Tabs extends SortableView
class Tabs extends SortableList
@activate: (rootView) ->
rootView.eachEditor (editor) =>
@prependToEditorPane(rootView, editor) if editor.attached
@@ -13,7 +13,7 @@ class Tabs extends SortableView
pane.prepend(new Tabs(editor))
@content: ->
@ul class: 'tabs'
@ul class: "tabs #{@viewClass()}"
initialize: (@editor) ->
super
@@ -44,3 +44,16 @@ class Tabs extends SortableView
removeTabAtIndex: (index) ->
@find(".tab:eq(#{index})").remove()
onDrop: (event) =>
super
sessions = @editor.editSessions
el = @sortableElement(event)
previousIndex = event.originalEvent.dataTransfer.getData('index')
currentIndex = el.index() - 1
sessions.splice(currentIndex, 0, sessions.splice(previousIndex, 1)[0])
@setActiveTab(currentIndex)
@editor.setActiveEditSessionIndex(currentIndex)
@editor.focus()