From 2d968c11a1b015b64e5ae507ff55e9c331b6c803 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Fri, 8 Feb 2013 10:04:54 -0800 Subject: [PATCH 01/48] this should cause tabs to be draggable --- src/packages/tabs/src/tabs-view.coffee | 3 +++ static/tabs.css | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/packages/tabs/src/tabs-view.coffee b/src/packages/tabs/src/tabs-view.coffee index 96b1bc313..d5e48e4fd 100644 --- a/src/packages/tabs/src/tabs-view.coffee +++ b/src/packages/tabs/src/tabs-view.coffee @@ -33,6 +33,9 @@ class Tabs extends View @editor.destroyEditSessionIndex(index) false + @on 'dragstart', '.tab', (e) -> + console.log 'TAB DRAGGED', e + addTabForEditSession: (editSession) -> @append(new Tab(editSession, @editor)) diff --git a/static/tabs.css b/static/tabs.css index a6c9cb8b8..d4a52cb61 100644 --- a/static/tabs.css +++ b/static/tabs.css @@ -1,14 +1,14 @@ .tabs { font: caption; - -webkit-user-select: none; display: -webkit-box; -webkit-box-align: center; } .tab { + -webkit-user-select: none; + -webkit-user-drag: element; cursor: default; -webkit-box-flex: 2; - position: relative; width: 175px; max-width: 175px; min-width: 40px; @@ -16,6 +16,7 @@ text-shadow: -1px -1px 0 #000; font-size: 11px; padding: 5px 10px; + position: relative; } .tab.active { From 1cab51cefa3b54b09413d64b60d76a4e0bb6700b Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 8 Feb 2013 15:56:55 -0700 Subject: [PATCH 02/48] RootView can no longer be focused. Allowing root view to be focused was stealing focus away from the editor whenever a click event made it to the root view. This unnecessary switching of focus was interfering with the ability to drag tabs. But if RootView can't be focused, focus ends up being returned to the document body when there are no focusable elements. This would be fine, except for the fact that we frequently bind global events on root view, and so they aren't triggered when events are triggered on the body. We could just bind all global events on the body, but this would require us to always attach elements to the DOM during specs, which is a serious performance killer in specs. The workaround is in the keymap. When the keymap handles a key event that was triggered on the body, it triggers the corresponding semantic event on the root view anyway, so from the event perspective, it's as if the root view actually had focus. The only place this might fall down is if someone wants to capture raw key events. But that's the keymap's job anyway, and we maybe add a hook on the keymap if such a need ever arises. --- spec/app/keymap-spec.coffee | 18 ++++++++++++++++-- spec/app/root-view-spec.coffee | 4 ++-- spec/spec-helper.coffee | 5 ++--- src/app/keymap.coffee | 1 + src/app/root-view.coffee | 2 +- .../fuzzy-finder/spec/fuzzy-finder-spec.coffee | 4 ++-- src/packages/tree-view/keymaps/tree-view.cson | 2 +- 7 files changed, 25 insertions(+), 11 deletions(-) diff --git a/spec/app/keymap-spec.coffee b/spec/app/keymap-spec.coffee index 01ef31019..22c56c337 100644 --- a/spec/app/keymap-spec.coffee +++ b/spec/app/keymap-spec.coffee @@ -1,5 +1,6 @@ Keymap = require 'keymap' $ = require 'jquery' +RootView = require 'root-view' describe "Keymap", -> fragment = null @@ -23,8 +24,8 @@ describe "Keymap", -> keymap.bindKeys '.command-mode', 'x': 'deleteChar' keymap.bindKeys '.insert-mode', 'x': 'insertChar' - deleteCharHandler = jasmine.createSpy 'deleteCharHandler' - insertCharHandler = jasmine.createSpy 'insertCharHandler' + deleteCharHandler = jasmine.createSpy('deleteCharHandler') + insertCharHandler = jasmine.createSpy('insertCharHandler') fragment.on 'deleteChar', deleteCharHandler fragment.on 'insertChar', insertCharHandler @@ -149,6 +150,19 @@ describe "Keymap", -> keymap.handleKeyEvent(keydownEvent('y', target: target)) expect(bazHandler).toHaveBeenCalled() + describe "when the event's target is the document body", -> + it "triggers the mapped event on the rootView", -> + rootView = new RootView + keymap.bindKeys 'body', 'x': 'foo' + fooHandler = jasmine.createSpy("fooHandler") + rootView.on 'foo', fooHandler + + result = keymap.handleKeyEvent(keydownEvent('x', target: document.body)) + expect(result).toBe(false) + expect(fooHandler).toHaveBeenCalled() + expect(deleteCharHandler).not.toHaveBeenCalled() + expect(insertCharHandler).not.toHaveBeenCalled() + describe "when at least one binding partially matches the event's keystroke", -> [quitHandler, closeOtherWindowsHandler] = [] diff --git a/spec/app/root-view-spec.coffee b/spec/app/root-view-spec.coffee index b046bef30..1e2dc9786 100644 --- a/spec/app/root-view-spec.coffee +++ b/spec/app/root-view-spec.coffee @@ -201,11 +201,11 @@ describe "RootView", -> expect(rootView.find('#two')).not.toMatchSelector(':focus') describe "when there are no visible focusable elements", -> - it "retains focus itself", -> + it "surrenders focus to the body", -> rootView.remove() rootView = new RootView(require.resolve 'fixtures') rootView.attachToDom() - expect(rootView).toMatchSelector(':focus') + expect(document.activeElement).toBe $('body')[0] describe "panes", -> [pane1, newPaneContent] = [] diff --git a/spec/spec-helper.coffee b/spec/spec-helper.coffee index c46be84fe..d00160158 100644 --- a/spec/spec-helper.coffee +++ b/spec/spec-helper.coffee @@ -93,9 +93,8 @@ window.keyIdentifierForKey = (key) -> "U+00" + charCode.toString(16) window.keydownEvent = (key, properties={}) -> - event = $.Event "keydown", _.extend({originalEvent: { keyIdentifier: keyIdentifierForKey(key) }}, properties) - # event.keystroke = (new Keymap).keystrokeStringForEvent(event) - event + properties = $.extend({originalEvent: { keyIdentifier: keyIdentifierForKey(key) }}, properties) + $.Event("keydown", properties) window.mouseEvent = (type, properties) -> if properties.point diff --git a/src/app/keymap.coffee b/src/app/keymap.coffee index 97cf4303b..d7e2ae6e9 100644 --- a/src/app/keymap.coffee +++ b/src/app/keymap.coffee @@ -99,6 +99,7 @@ class Keymap b.specificity - a.specificity triggerCommandEvent: (keyEvent, commandName) -> + keyEvent.target = rootView[0] if keyEvent.target == document.body and window.rootView commandEvent = $.Event(commandName) commandEvent.keyEvent = keyEvent aborted = false diff --git a/src/app/root-view.coffee b/src/app/root-view.coffee index 4063ee863..2b86d95dc 100644 --- a/src/app/root-view.coffee +++ b/src/app/root-view.coffee @@ -18,7 +18,7 @@ class RootView extends View disabledPackages: [] @content: -> - @div id: 'root-view', tabindex: 0, => + @div id: 'root-view', => @div id: 'horizontal', outlet: 'horizontal', => @div id: 'vertical', outlet: 'vertical', => @div id: 'panes', outlet: 'panes' diff --git a/src/packages/fuzzy-finder/spec/fuzzy-finder-spec.coffee b/src/packages/fuzzy-finder/spec/fuzzy-finder-spec.coffee index 76f8bd476..9d90f26d3 100644 --- a/src/packages/fuzzy-finder/spec/fuzzy-finder-spec.coffee +++ b/src/packages/fuzzy-finder/spec/fuzzy-finder-spec.coffee @@ -205,7 +205,7 @@ describe 'FuzzyFinder', -> expect(finder.miniEditor.isFocused).toBeFalsy() describe "when no editors are open", -> - it "detaches the finder and focuses the previously focused element", -> + it "detaches the finder and surrenders focus to the body", -> rootView.attachToDom() rootView.getActiveEditor().destroyActiveEditSession() @@ -217,7 +217,7 @@ describe 'FuzzyFinder', -> finder.cancel() expect(finder.hasParent()).toBeFalsy() - expect($(document.activeElement).view()).toBe rootView + expect(document.activeElement).toBe $('body')[0] expect(finder.miniEditor.isFocused).toBeFalsy() describe "cached file paths", -> diff --git a/src/packages/tree-view/keymaps/tree-view.cson b/src/packages/tree-view/keymaps/tree-view.cson index 1e198d26d..0bdf1b863 100644 --- a/src/packages/tree-view/keymaps/tree-view.cson +++ b/src/packages/tree-view/keymaps/tree-view.cson @@ -1,4 +1,4 @@ -'#root-view': +'body': 'meta-\\': 'tree-view:toggle' 'meta-|': 'tree-view:reveal-active-file' From d8111797ba1a70f8567750d73d89f69fa68104d5 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 8 Feb 2013 15:56:55 -0700 Subject: [PATCH 03/48] RootView can no longer be focused. Allowing root view to be focused was stealing focus away from the editor whenever a click event made it to the root view. This unnecessary switching of focus was interfering with the ability to drag tabs. But if RootView can't be focused, focus ends up being returned to the document body when there are no focusable elements. This would be fine, except for the fact that we frequently bind global events on root view, and so they aren't triggered when events are triggered on the body. We could just bind all global events on the body, but this would require us to always attach elements to the DOM during specs, which is a serious performance killer in specs. The workaround is in the keymap. When the keymap handles a key event that was triggered on the body, it triggers the corresponding semantic event on the root view anyway, so from the event perspective, it's as if the root view actually had focus. The only place this might fall down is if someone wants to capture raw key events. But that's the keymap's job anyway, and we maybe add a hook on the keymap if such a need ever arises. --- src/app/keymap.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/keymap.coffee b/src/app/keymap.coffee index d7e2ae6e9..dd21eac85 100644 --- a/src/app/keymap.coffee +++ b/src/app/keymap.coffee @@ -73,6 +73,7 @@ class Keymap return true unless bindingSetsForFirstKeystroke? currentNode = $(event.target) + currentNode = rootView if currentNode is $('body')[0] while currentNode.length candidateBindingSets = @bindingSetsForNode(currentNode, bindingSetsForFirstKeystroke) for bindingSet in candidateBindingSets From ff4e374d44cf71be54aaaee8d0206654ba3f97b8 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Sat, 9 Feb 2013 09:08:46 -0800 Subject: [PATCH 04/48] basics of drag and drop support --- src/packages/tabs/src/tabs-view.coffee | 23 +++++++++++++++++++++-- static/tabs.css | 11 ++++++++++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/packages/tabs/src/tabs-view.coffee b/src/packages/tabs/src/tabs-view.coffee index d5e48e4fd..c2f3274c0 100644 --- a/src/packages/tabs/src/tabs-view.coffee +++ b/src/packages/tabs/src/tabs-view.coffee @@ -4,6 +4,8 @@ Tab = require 'tabs/src/tab' module.exports = class Tabs extends View + dndType: 'text/x-atom-tab' + @activate: (rootView) -> rootView.eachEditor (editor) => @prependToEditorPane(rootView, editor) if editor.attached @@ -33,8 +35,25 @@ class Tabs extends View @editor.destroyEditSessionIndex(index) false - @on 'dragstart', '.tab', (e) -> - console.log 'TAB DRAGGED', e + @on 'dragstart', '.tab', @onDragStart + @on 'dragend', '.tab', @onDragEnd + @on 'dragenter', '.tab', @onDragEnter + @on 'dragleave', '.tab', @onDragLeave + + onDragStart: (event) => + $(event.target).addClass 'is-dragging' + + onDragEnd: (event) => + $(event.target).removeClass 'is-dragging' + + onDragEnter: (event) => + el = $(event.target) + el = el.closest('.tab') if !el.hasClass('tab') + el.addClass 'is-drop-target' + + onDragLeave: (event) => + el = $(event.target) + el.removeClass 'is-drop-target' if el.hasClass 'tab' addTabForEditSession: (editSession) -> @append(new Tab(editSession, @editor)) diff --git a/static/tabs.css b/static/tabs.css index d4a52cb61..570e60720 100644 --- a/static/tabs.css +++ b/static/tabs.css @@ -76,4 +76,13 @@ .tab.file-modified:hover .close-icon:before { content: "\f081"; color: #66a6ff; -} \ No newline at end of file +} + +/* Drag and Drop */ +.tab.is-dragging { + -webkit-box-flex: 1; + color: red; +} + + +sdfsdf \ No newline at end of file From 9100367c122f2c7b792f5a59bd080b52d352d795 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Sat, 9 Feb 2013 11:47:12 -0800 Subject: [PATCH 05/48] very basic tab sorting --- src/app/sortable-view.coffee | 45 ++++++++++++++++++++++++++ src/packages/tabs/src/tab.coffee | 2 +- src/packages/tabs/src/tabs-view.coffee | 28 +++------------- static/tabs.css | 9 ++++-- 4 files changed, 57 insertions(+), 27 deletions(-) create mode 100644 src/app/sortable-view.coffee diff --git a/src/app/sortable-view.coffee b/src/app/sortable-view.coffee new file mode 100644 index 000000000..0375aef80 --- /dev/null +++ b/src/app/sortable-view.coffee @@ -0,0 +1,45 @@ +{View} = require 'space-pen' +$ = require 'jquery' + +module.exports = +class SortableView extends View + initialize: -> + @on 'dragstart', '.sortable', @onDragStart + @on 'dragend', '.sortable', @onDragEnd + @on 'dragover', '.sortable', @onDragOver + @on 'dragenter', '.sortable', @onDragEnter + @on 'dragleave', '.sortable', @onDragLeave + @on 'drop', '.sortable', @onDrop + + onDragStart: (event) => + el = @sortableElement(event) + el.addClass 'is-dragging' + + event.originalEvent.dataTransfer.setData 'index', el.index() + + onDragEnd: (event) => + el = @sortableElement(event) + el.removeClass 'is-dragging' + + onDragEnter: (event) => + event.preventDefault() + + onDragOver: (event) => + event.preventDefault() + + onDragLeave: (event) => + el = @sortableElement(event) + el.removeClass 'is-drop-target' + + onDrop: (event) => + event.stopPropagation() + el = @sortableElement(event) + idx = event.originalEvent.dataTransfer.getData('index') + dropped = el.parent().find(".sortable:eq(#{idx})") + dropped.remove() + dropped.insertBefore(el) + + sortableElement: (event) -> + el = $(event.target) + if !el.hasClass('sortable') then el.closest('.sortable') else el + diff --git a/src/packages/tabs/src/tab.coffee b/src/packages/tabs/src/tab.coffee index cdb225442..bcc055f1d 100644 --- a/src/packages/tabs/src/tab.coffee +++ b/src/packages/tabs/src/tab.coffee @@ -4,7 +4,7 @@ fs = require 'fs' module.exports = class Tab extends View @content: (editSession) -> - @li class: 'tab', => + @li class: 'tab sortable', => @span class: 'file-name', outlet: 'fileName' @span class: 'close-icon' diff --git a/src/packages/tabs/src/tabs-view.coffee b/src/packages/tabs/src/tabs-view.coffee index c2f3274c0..b59217570 100644 --- a/src/packages/tabs/src/tabs-view.coffee +++ b/src/packages/tabs/src/tabs-view.coffee @@ -1,11 +1,9 @@ $ = require 'jquery' -{View} = require 'space-pen' +SortableView = require 'sortable-view' Tab = require 'tabs/src/tab' module.exports = -class Tabs extends View - dndType: 'text/x-atom-tab' - +class Tabs extends SortableView @activate: (rootView) -> rootView.eachEditor (editor) => @prependToEditorPane(rootView, editor) if editor.attached @@ -18,6 +16,8 @@ class Tabs extends View @ul class: 'tabs' initialize: (@editor) -> + super + for editSession, index in @editor.editSessions @addTabForEditSession(editSession) @@ -35,26 +35,6 @@ class Tabs extends View @editor.destroyEditSessionIndex(index) false - @on 'dragstart', '.tab', @onDragStart - @on 'dragend', '.tab', @onDragEnd - @on 'dragenter', '.tab', @onDragEnter - @on 'dragleave', '.tab', @onDragLeave - - onDragStart: (event) => - $(event.target).addClass 'is-dragging' - - onDragEnd: (event) => - $(event.target).removeClass 'is-dragging' - - onDragEnter: (event) => - el = $(event.target) - el = el.closest('.tab') if !el.hasClass('tab') - el.addClass 'is-drop-target' - - onDragLeave: (event) => - el = $(event.target) - el.removeClass 'is-drop-target' if el.hasClass 'tab' - addTabForEditSession: (editSession) -> @append(new Tab(editSession, @editor)) diff --git a/static/tabs.css b/static/tabs.css index 570e60720..73ce62acf 100644 --- a/static/tabs.css +++ b/static/tabs.css @@ -80,9 +80,14 @@ /* Drag and Drop */ .tab.is-dragging { - -webkit-box-flex: 1; +/* -webkit-box-flex: 1;*/ color: red; } +.tab.is-drop-target { -sdfsdf \ No newline at end of file +} + +.placeholder { +/* background-color: #0098ff;*/ +} \ No newline at end of file From 8a505814305fe5e67df4f0353a1c1609ff6614e6 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Sat, 9 Feb 2013 15:33:48 -0800 Subject: [PATCH 06/48] rename sortable view to sortable list --- ...table-view.coffee => sortable-list.coffee} | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) rename src/app/{sortable-view.coffee => sortable-list.coffee} (71%) diff --git a/src/app/sortable-view.coffee b/src/app/sortable-list.coffee similarity index 71% rename from src/app/sortable-view.coffee rename to src/app/sortable-list.coffee index 0375aef80..7154a35a1 100644 --- a/src/app/sortable-view.coffee +++ b/src/app/sortable-list.coffee @@ -2,7 +2,9 @@ $ = require 'jquery' module.exports = -class SortableView extends View +class SortableList extends View + @viewClass: -> 'sortable-list' + initialize: -> @on 'dragstart', '.sortable', @onDragStart @on 'dragend', '.sortable', @onDragEnd @@ -14,32 +16,34 @@ class SortableView extends View onDragStart: (event) => el = @sortableElement(event) el.addClass 'is-dragging' - event.originalEvent.dataTransfer.setData 'index', el.index() onDragEnd: (event) => - el = @sortableElement(event) - el.removeClass 'is-dragging' + @sortableElement(event).removeClass 'is-dragging' onDragEnter: (event) => event.preventDefault() onDragOver: (event) => event.preventDefault() + @sortableElement(event).addClass 'is-drop-target' onDragLeave: (event) => - el = @sortableElement(event) - el.removeClass 'is-drop-target' + @sortableElement(event).removeClass 'is-drop-target' onDrop: (event) => event.stopPropagation() el = @sortableElement(event) - idx = event.originalEvent.dataTransfer.getData('index') - dropped = el.parent().find(".sortable:eq(#{idx})") + dropped = @getDroppedElement(event) dropped.remove() dropped.insertBefore(el) + @find('.is-drop-target').removeClass 'is-drop-target' + + getDroppedElement: (event) -> + idx = event.originalEvent.dataTransfer.getData('index') + @find ".sortable:eq(#{idx})" + sortableElement: (event) -> el = $(event.target) - if !el.hasClass('sortable') then el.closest('.sortable') else el - + if !el.hasClass('sortable') then el.closest('.sortable') else el \ No newline at end of file From e92d9ea9980fbfebe4d4a1579a2875d506223286 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Sat, 9 Feb 2013 15:34:35 -0800 Subject: [PATCH 07/48] sorting works on a single editor Needs updating to support dragging between panels --- src/packages/tabs/src/tabs-view.coffee | 19 ++++++++++++++++--- static/tabs.css | 16 ++++++++++++---- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/packages/tabs/src/tabs-view.coffee b/src/packages/tabs/src/tabs-view.coffee index b59217570..e8733d4da 100644 --- a/src/packages/tabs/src/tabs-view.coffee +++ b/src/packages/tabs/src/tabs-view.coffee @@ -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() diff --git a/static/tabs.css b/static/tabs.css index 73ce62acf..78bfa55db 100644 --- a/static/tabs.css +++ b/static/tabs.css @@ -80,12 +80,20 @@ /* Drag and Drop */ .tab.is-dragging { -/* -webkit-box-flex: 1;*/ - color: red; + } -.tab.is-drop-target { - +.tab.is-drop-target:before { + position: absolute; + top: 0; + left: -2px; + content: ""; + z-index: 999; + display: inline-block; + width: 1px; + height: 30px; + display: inline-block; + background: #0098ff; } .placeholder { From b00df1aae06675a6f1fadb625321f70bd958454d Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Sat, 9 Feb 2013 17:21:20 -0800 Subject: [PATCH 08/48] sortableElement -> getSortableElement --- src/app/sortable-list.coffee | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/app/sortable-list.coffee b/src/app/sortable-list.coffee index 7154a35a1..4c14226c1 100644 --- a/src/app/sortable-list.coffee +++ b/src/app/sortable-list.coffee @@ -14,22 +14,22 @@ class SortableList extends View @on 'drop', '.sortable', @onDrop onDragStart: (event) => - el = @sortableElement(event) + el = @getSortableElement(event) el.addClass 'is-dragging' event.originalEvent.dataTransfer.setData 'index', el.index() onDragEnd: (event) => - @sortableElement(event).removeClass 'is-dragging' + @getSortableElement(event).removeClass 'is-dragging' onDragEnter: (event) => event.preventDefault() onDragOver: (event) => event.preventDefault() - @sortableElement(event).addClass 'is-drop-target' + @getSortableElement(event).addClass 'is-drop-target' onDragLeave: (event) => - @sortableElement(event).removeClass 'is-drop-target' + @getSortableElement(event).removeClass 'is-drop-target' onDrop: (event) => event.stopPropagation() @@ -44,6 +44,6 @@ class SortableList extends View idx = event.originalEvent.dataTransfer.getData('index') @find ".sortable:eq(#{idx})" - sortableElement: (event) -> + getSortableElement: (event) -> el = $(event.target) if !el.hasClass('sortable') then el.closest('.sortable') else el \ No newline at end of file From be49f047e1cfa9b60f9d9c401c58bdc06705e7ef Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Sat, 9 Feb 2013 17:21:44 -0800 Subject: [PATCH 09/48] index -> sortable-index --- src/app/sortable-list.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/sortable-list.coffee b/src/app/sortable-list.coffee index 4c14226c1..946c3b3d1 100644 --- a/src/app/sortable-list.coffee +++ b/src/app/sortable-list.coffee @@ -16,7 +16,7 @@ class SortableList extends View onDragStart: (event) => el = @getSortableElement(event) el.addClass 'is-dragging' - event.originalEvent.dataTransfer.setData 'index', el.index() + event.originalEvent.dataTransfer.setData 'sortable-index', el.index() onDragEnd: (event) => @getSortableElement(event).removeClass 'is-dragging' @@ -41,7 +41,7 @@ class SortableList extends View @find('.is-drop-target').removeClass 'is-drop-target' getDroppedElement: (event) -> - idx = event.originalEvent.dataTransfer.getData('index') + idx = event.originalEvent.dataTransfer.getData 'sortable-index' @find ".sortable:eq(#{idx})" getSortableElement: (event) -> From c7c9656c463f713cf5799fb682aa88d331c1426d Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Sat, 9 Feb 2013 17:23:06 -0800 Subject: [PATCH 10/48] remove drop dom manipulation from sortable-list Not sure how we should handle generic drag and drop. Tabs are more complex because of multiple panels --- src/app/sortable-list.coffee | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/app/sortable-list.coffee b/src/app/sortable-list.coffee index 946c3b3d1..8e5e48a5d 100644 --- a/src/app/sortable-list.coffee +++ b/src/app/sortable-list.coffee @@ -33,11 +33,6 @@ class SortableList extends View onDrop: (event) => event.stopPropagation() - el = @sortableElement(event) - dropped = @getDroppedElement(event) - dropped.remove() - dropped.insertBefore(el) - @find('.is-drop-target').removeClass 'is-drop-target' getDroppedElement: (event) -> From 83631935ff2cf64648b013b4ebeb62f569960836 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Sat, 9 Feb 2013 17:24:13 -0800 Subject: [PATCH 11/48] working implementation of drag and drop across multiple panels --- src/packages/tabs/src/tabs-view.coffee | 40 ++++++++++++++++++++------ 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/src/packages/tabs/src/tabs-view.coffee b/src/packages/tabs/src/tabs-view.coffee index e8733d4da..8f03c48c5 100644 --- a/src/packages/tabs/src/tabs-view.coffee +++ b/src/packages/tabs/src/tabs-view.coffee @@ -45,15 +45,39 @@ class Tabs extends SortableList removeTabAtIndex: (index) -> @find(".tab:eq(#{index})").remove() + onDragStart: (event) => + super + pane = $(event.target).closest('.pane') + event.originalEvent.dataTransfer.setData 'from-pane-index', pane.index() + onDrop: (event) => super - sessions = @editor.editSessions - el = @sortableElement(event) - previousIndex = event.originalEvent.dataTransfer.getData('index') - currentIndex = el.index() - 1 + transfer = event.originalEvent.dataTransfer + previousDraggedTabIndex = transfer.getData 'sortable-index' - sessions.splice(currentIndex, 0, sessions.splice(previousIndex, 1)[0]) + fromPaneIndex = ~~transfer.getData 'from-pane-index' + toPaneIndex = ~~$(event.target).closest('.pane').index() + fromPane = rootView.find ".pane:nth-child(#{fromPaneIndex + 1})" + fromEditor = fromPane.find('.editor').view() - @setActiveTab(currentIndex) - @editor.setActiveEditSessionIndex(currentIndex) - @editor.focus() + if fromPaneIndex == toPaneIndex + toPane = fromPane + toEditor = fromEditor + else + toPane = rootView.find ".pane:nth-child(#{toPaneIndex + 1})" + toEditor = toPane.find('.editor').view() + + droppedNearTab = @getSortableElement(event) + draggedTab = fromPane.find(".#{Tabs.viewClass()} .sortable:eq(#{previousDraggedTabIndex})") + + draggedTab.remove() + draggedTab.insertBefore(droppedNearTab) + + currentDraggedTabIndex = draggedTab.index() + + toEditor.editSessions.splice(currentDraggedTabIndex, 0, fromEditor.editSessions.splice(previousDraggedTabIndex, 1)[0]) + + @setActiveTab(currentDraggedTabIndex) + fromEditor.setActiveEditSessionIndex(0) + toEditor.setActiveEditSessionIndex(currentDraggedTabIndex) + toEditor.focus() From a1a663cd30605f30942cf41eddf86834334c7d65 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Sat, 9 Feb 2013 19:37:07 -0800 Subject: [PATCH 12/48] implement indexOfPane in RootView to get array index We need something like this because jquery's el.index() doesn't work when multiple panes are spread out among different rows and columns. --- src/app/root-view.coffee | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/app/root-view.coffee b/src/app/root-view.coffee index 2b86d95dc..2e298ba91 100644 --- a/src/app/root-view.coffee +++ b/src/app/root-view.coffee @@ -277,3 +277,11 @@ class RootView extends View eachBuffer: (callback) -> callback(buffer) for buffer in @project.getBuffers() @project.on 'buffer-created', (buffer) -> callback(buffer) + + indexOfPane: (pane) -> + index = -1 + for p, idx in @panes.find('.pane') + if pane.is(p) + index = idx + break + index From a124f5aeeec5eedfc094f5d833b07e81e396aa2f Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Sat, 9 Feb 2013 19:38:26 -0800 Subject: [PATCH 13/48] update tabs to use new way to find pane index --- src/packages/tabs/src/tabs-view.coffee | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/packages/tabs/src/tabs-view.coffee b/src/packages/tabs/src/tabs-view.coffee index 8f03c48c5..35c3bee57 100644 --- a/src/packages/tabs/src/tabs-view.coffee +++ b/src/packages/tabs/src/tabs-view.coffee @@ -48,7 +48,8 @@ class Tabs extends SortableList onDragStart: (event) => super pane = $(event.target).closest('.pane') - event.originalEvent.dataTransfer.setData 'from-pane-index', pane.index() + paneIndex = rootView.indexOfPane(pane) + event.originalEvent.dataTransfer.setData 'from-pane-index', paneIndex onDrop: (event) => super @@ -56,22 +57,22 @@ class Tabs extends SortableList previousDraggedTabIndex = transfer.getData 'sortable-index' fromPaneIndex = ~~transfer.getData 'from-pane-index' - toPaneIndex = ~~$(event.target).closest('.pane').index() - fromPane = rootView.find ".pane:nth-child(#{fromPaneIndex + 1})" + toPaneIndex = rootView.indexOfPane($(event.target).closest('.pane')) + fromPane = $(rootView.find('.pane')[fromPaneIndex]) fromEditor = fromPane.find('.editor').view() if fromPaneIndex == toPaneIndex toPane = fromPane toEditor = fromEditor else - toPane = rootView.find ".pane:nth-child(#{toPaneIndex + 1})" + toPane = $(rootView.find('.pane')[toPaneIndex]) toEditor = toPane.find('.editor').view() droppedNearTab = @getSortableElement(event) draggedTab = fromPane.find(".#{Tabs.viewClass()} .sortable:eq(#{previousDraggedTabIndex})") draggedTab.remove() - draggedTab.insertBefore(droppedNearTab) + draggedTab.insertAfter(droppedNearTab) currentDraggedTabIndex = draggedTab.index() From d45aac57dd314f94a55b19956bf3f2955cb11931 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Sat, 9 Feb 2013 19:38:35 -0800 Subject: [PATCH 14/48] :after is better --- static/tabs.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/tabs.css b/static/tabs.css index 78bfa55db..f0c170d7e 100644 --- a/static/tabs.css +++ b/static/tabs.css @@ -83,10 +83,10 @@ } -.tab.is-drop-target:before { +.tab.is-drop-target:after { position: absolute; top: 0; - left: -2px; + right: -2px; content: ""; z-index: 999; display: inline-block; From ccb8688a43a8bee4c46fc056c45966beb7e94c8d Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Sun, 10 Feb 2013 09:50:44 -0800 Subject: [PATCH 15/48] update require paths --- src/packages/tabs/lib/tabs-view.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/packages/tabs/lib/tabs-view.coffee b/src/packages/tabs/lib/tabs-view.coffee index 8ce1f8243..4d7df7f55 100644 --- a/src/packages/tabs/lib/tabs-view.coffee +++ b/src/packages/tabs/lib/tabs-view.coffee @@ -1,9 +1,9 @@ $ = require 'jquery' SortableList = require 'sortable-list' -Tab = require 'tabs/src/tab' +Tab = require 'tabs/lib/tab' module.exports = -class Tabs extends View +class Tabs extends SortableList @activate: -> rootView.eachEditor (editor) => @prependToEditorPane(rootView, editor) if editor.attached From 9c99369c103a51bff5eaacab24f96dfd35d8b398 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Sun, 10 Feb 2013 10:46:02 -0800 Subject: [PATCH 16/48] add methods to determine if we should allow dragging and dropping --- src/app/sortable-list.coffee | 9 +++++++++ src/packages/tabs/lib/tabs-view.coffee | 9 +++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/app/sortable-list.coffee b/src/app/sortable-list.coffee index 8e5e48a5d..313178d22 100644 --- a/src/app/sortable-list.coffee +++ b/src/app/sortable-list.coffee @@ -14,6 +14,8 @@ class SortableList extends View @on 'drop', '.sortable', @onDrop onDragStart: (event) => + return false if !@shouldAllowDrag() + el = @getSortableElement(event) el.addClass 'is-dragging' event.originalEvent.dataTransfer.setData 'sortable-index', el.index() @@ -32,9 +34,16 @@ class SortableList extends View @getSortableElement(event).removeClass 'is-drop-target' onDrop: (event) => + return false if !@shouldAllowDrop() event.stopPropagation() @find('.is-drop-target').removeClass 'is-drop-target' + shouldAllowDrag: -> + true + + shouldAllowDrop: -> + true + getDroppedElement: (event) -> idx = event.originalEvent.dataTransfer.getData 'sortable-index' @find ".sortable:eq(#{idx})" diff --git a/src/packages/tabs/lib/tabs-view.coffee b/src/packages/tabs/lib/tabs-view.coffee index 4d7df7f55..27fbe83a7 100644 --- a/src/packages/tabs/lib/tabs-view.coffee +++ b/src/packages/tabs/lib/tabs-view.coffee @@ -45,6 +45,10 @@ class Tabs extends SortableList removeTabAtIndex: (index) -> @find(".tab:eq(#{index})").remove() + shouldAllowDrag: -> + panes = rootView.find('.pane') + panes.length == 1 && panes.find('.sortable').length > 0 + onDragStart: (event) => super pane = $(event.target).closest('.pane') @@ -75,10 +79,11 @@ class Tabs extends SortableList draggedTab.insertAfter(droppedNearTab) currentDraggedTabIndex = draggedTab.index() - + #console.log ".#{Tabs.viewClass()} .sortable:eq(#{previousDraggedTabIndex})" toEditor.editSessions.splice(currentDraggedTabIndex, 0, fromEditor.editSessions.splice(previousDraggedTabIndex, 1)[0]) @setActiveTab(currentDraggedTabIndex) - fromEditor.setActiveEditSessionIndex(0) + console.log fromPaneIndex, toPaneIndex, currentDraggedTabIndex + fromEditor.setActiveEditSessionIndex(0) if fromPaneIndex != toPaneIndex toEditor.setActiveEditSessionIndex(currentDraggedTabIndex) toEditor.focus() From b7d4689cfeb404e623f3bfd836155b2f04235e05 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Sun, 10 Feb 2013 10:53:19 -0800 Subject: [PATCH 17/48] fix logic error in shouldAllowDrag --- src/packages/tabs/lib/tabs-view.coffee | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/packages/tabs/lib/tabs-view.coffee b/src/packages/tabs/lib/tabs-view.coffee index 27fbe83a7..6441224f5 100644 --- a/src/packages/tabs/lib/tabs-view.coffee +++ b/src/packages/tabs/lib/tabs-view.coffee @@ -47,7 +47,7 @@ class Tabs extends SortableList shouldAllowDrag: -> panes = rootView.find('.pane') - panes.length == 1 && panes.find('.sortable').length > 0 + !(panes.length == 1 && panes.find('.sortable').length == 1) onDragStart: (event) => super @@ -79,11 +79,9 @@ class Tabs extends SortableList draggedTab.insertAfter(droppedNearTab) currentDraggedTabIndex = draggedTab.index() - #console.log ".#{Tabs.viewClass()} .sortable:eq(#{previousDraggedTabIndex})" toEditor.editSessions.splice(currentDraggedTabIndex, 0, fromEditor.editSessions.splice(previousDraggedTabIndex, 1)[0]) @setActiveTab(currentDraggedTabIndex) - console.log fromPaneIndex, toPaneIndex, currentDraggedTabIndex fromEditor.setActiveEditSessionIndex(0) if fromPaneIndex != toPaneIndex toEditor.setActiveEditSessionIndex(currentDraggedTabIndex) toEditor.focus() From 4474f2bc2d723142d8b4f1c1a09d9799db849eee Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Sun, 10 Feb 2013 11:12:14 -0800 Subject: [PATCH 18/48] rename Tabs -> TabView --- .../tabs/lib/{tabs-view.coffee => tab-view.coffee} | 11 ++++++----- src/packages/tabs/package.cson | 2 +- src/packages/tabs/spec/tabs-spec.coffee | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) rename src/packages/tabs/lib/{tabs-view.coffee => tab-view.coffee} (91%) diff --git a/src/packages/tabs/lib/tabs-view.coffee b/src/packages/tabs/lib/tab-view.coffee similarity index 91% rename from src/packages/tabs/lib/tabs-view.coffee rename to src/packages/tabs/lib/tab-view.coffee index 6441224f5..3d9b07f3e 100644 --- a/src/packages/tabs/lib/tabs-view.coffee +++ b/src/packages/tabs/lib/tab-view.coffee @@ -3,14 +3,14 @@ SortableList = require 'sortable-list' Tab = require 'tabs/lib/tab' module.exports = -class Tabs extends SortableList +class TabView extends SortableList @activate: -> rootView.eachEditor (editor) => @prependToEditorPane(rootView, editor) if editor.attached @prependToEditorPane: (rootView, editor) -> if pane = editor.pane() - pane.prepend(new Tabs(editor)) + pane.prepend(new TabView(editor)) @content: -> @ul class: "tabs #{@viewClass()}" @@ -73,15 +73,16 @@ class Tabs extends SortableList toEditor = toPane.find('.editor').view() droppedNearTab = @getSortableElement(event) - draggedTab = fromPane.find(".#{Tabs.viewClass()} .sortable:eq(#{previousDraggedTabIndex})") + draggedTab = fromPane.find(".#{TabView.viewClass()} .sortable:eq(#{previousDraggedTabIndex})") draggedTab.remove() draggedTab.insertAfter(droppedNearTab) - currentDraggedTabIndex = draggedTab.index() toEditor.editSessions.splice(currentDraggedTabIndex, 0, fromEditor.editSessions.splice(previousDraggedTabIndex, 1)[0]) @setActiveTab(currentDraggedTabIndex) - fromEditor.setActiveEditSessionIndex(0) if fromPaneIndex != toPaneIndex toEditor.setActiveEditSessionIndex(currentDraggedTabIndex) toEditor.focus() + + if fromPaneIndex != toPaneIndex + fromEditor.setActiveEditSessionIndex(0) diff --git a/src/packages/tabs/package.cson b/src/packages/tabs/package.cson index 6cc9d8565..0e40dfd74 100644 --- a/src/packages/tabs/package.cson +++ b/src/packages/tabs/package.cson @@ -1 +1 @@ -'main': 'lib/tabs-view' +'main': 'lib/tab-view' diff --git a/src/packages/tabs/spec/tabs-spec.coffee b/src/packages/tabs/spec/tabs-spec.coffee index a9bc5b358..d6c708ebe 100644 --- a/src/packages/tabs/spec/tabs-spec.coffee +++ b/src/packages/tabs/spec/tabs-spec.coffee @@ -3,7 +3,7 @@ _ = require 'underscore' RootView = require 'root-view' fs = require 'fs' -describe "Tabs", -> +describe "TabView", -> [editor, buffer, tabs] = [] beforeEach -> From ffbc0ab45c87ffcefb1fec0f16f54d9b2d76af0b Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Sun, 10 Feb 2013 11:20:47 -0800 Subject: [PATCH 19/48] only activate another tab if the pane's active tab wasn't dragged away --- src/packages/tabs/lib/tab-view.coffee | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/packages/tabs/lib/tab-view.coffee b/src/packages/tabs/lib/tab-view.coffee index 3d9b07f3e..dd867dc54 100644 --- a/src/packages/tabs/lib/tab-view.coffee +++ b/src/packages/tabs/lib/tab-view.coffee @@ -51,12 +51,14 @@ class TabView extends SortableList onDragStart: (event) => super + pane = $(event.target).closest('.pane') paneIndex = rootView.indexOfPane(pane) event.originalEvent.dataTransfer.setData 'from-pane-index', paneIndex onDrop: (event) => super + transfer = event.originalEvent.dataTransfer previousDraggedTabIndex = transfer.getData 'sortable-index' @@ -84,5 +86,5 @@ class TabView extends SortableList toEditor.setActiveEditSessionIndex(currentDraggedTabIndex) toEditor.focus() - if fromPaneIndex != toPaneIndex + if fromPaneIndex != toPaneIndex && !draggedTab.hasClass('active') fromEditor.setActiveEditSessionIndex(0) From ae841c2bf75d22a1304eb477dd24a5ffe118b123 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Mon, 11 Feb 2013 08:17:32 -0800 Subject: [PATCH 20/48] pass event to shouldAllow* methods --- src/app/sortable-list.coffee | 8 ++++---- src/packages/tabs/lib/tab-view.coffee | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/app/sortable-list.coffee b/src/app/sortable-list.coffee index 313178d22..a1c634d1e 100644 --- a/src/app/sortable-list.coffee +++ b/src/app/sortable-list.coffee @@ -14,7 +14,7 @@ class SortableList extends View @on 'drop', '.sortable', @onDrop onDragStart: (event) => - return false if !@shouldAllowDrag() + return false if !@shouldAllowDrag(event) el = @getSortableElement(event) el.addClass 'is-dragging' @@ -34,14 +34,14 @@ class SortableList extends View @getSortableElement(event).removeClass 'is-drop-target' onDrop: (event) => - return false if !@shouldAllowDrop() + return false if !@shouldAllowDrop(event) event.stopPropagation() @find('.is-drop-target').removeClass 'is-drop-target' - shouldAllowDrag: -> + shouldAllowDrag: (event) -> true - shouldAllowDrop: -> + shouldAllowDrop: (event) -> true getDroppedElement: (event) -> diff --git a/src/packages/tabs/lib/tab-view.coffee b/src/packages/tabs/lib/tab-view.coffee index dd867dc54..99715f815 100644 --- a/src/packages/tabs/lib/tab-view.coffee +++ b/src/packages/tabs/lib/tab-view.coffee @@ -45,7 +45,7 @@ class TabView extends SortableList removeTabAtIndex: (index) -> @find(".tab:eq(#{index})").remove() - shouldAllowDrag: -> + shouldAllowDrag: (event) -> panes = rootView.find('.pane') !(panes.length == 1 && panes.find('.sortable').length == 1) From 45d6a30a80cea5b7f117e070a25119e3dd44eca4 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Mon, 11 Feb 2013 08:26:18 -0800 Subject: [PATCH 21/48] determine if dragged tab was perviously active before reactivating in new pane --- src/packages/tabs/lib/tab-view.coffee | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/packages/tabs/lib/tab-view.coffee b/src/packages/tabs/lib/tab-view.coffee index 99715f815..02d315b41 100644 --- a/src/packages/tabs/lib/tab-view.coffee +++ b/src/packages/tabs/lib/tab-view.coffee @@ -82,9 +82,9 @@ class TabView extends SortableList currentDraggedTabIndex = draggedTab.index() toEditor.editSessions.splice(currentDraggedTabIndex, 0, fromEditor.editSessions.splice(previousDraggedTabIndex, 1)[0]) + if fromPaneIndex != toPaneIndex && draggedTab.hasClass('active') + fromEditor.setActiveEditSessionIndex(0) + @setActiveTab(currentDraggedTabIndex) toEditor.setActiveEditSessionIndex(currentDraggedTabIndex) toEditor.focus() - - if fromPaneIndex != toPaneIndex && !draggedTab.hasClass('active') - fromEditor.setActiveEditSessionIndex(0) From 52afa8983a9fb62a710dc960443f8d42d0c72b50 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Mon, 11 Feb 2013 09:12:06 -0800 Subject: [PATCH 22/48] remove pane if it has no tabs left --- src/packages/tabs/lib/tab-view.coffee | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/packages/tabs/lib/tab-view.coffee b/src/packages/tabs/lib/tab-view.coffee index 02d315b41..354cd1fd8 100644 --- a/src/packages/tabs/lib/tab-view.coffee +++ b/src/packages/tabs/lib/tab-view.coffee @@ -82,7 +82,9 @@ class TabView extends SortableList currentDraggedTabIndex = draggedTab.index() toEditor.editSessions.splice(currentDraggedTabIndex, 0, fromEditor.editSessions.splice(previousDraggedTabIndex, 1)[0]) - if fromPaneIndex != toPaneIndex && draggedTab.hasClass('active') + if fromPane.find('.tab').length == 0 + fromPane.view().remove() + else if fromPaneIndex != toPaneIndex && draggedTab.hasClass('active') fromEditor.setActiveEditSessionIndex(0) @setActiveTab(currentDraggedTabIndex) From 785d91e4f495474c6b9d66dc25a90fa0e403ce63 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 11 Feb 2013 10:48:23 -0800 Subject: [PATCH 23/48] Use relative require --- src/packages/tabs/lib/tab-view.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/packages/tabs/lib/tab-view.coffee b/src/packages/tabs/lib/tab-view.coffee index 354cd1fd8..cf1e293b7 100644 --- a/src/packages/tabs/lib/tab-view.coffee +++ b/src/packages/tabs/lib/tab-view.coffee @@ -1,6 +1,6 @@ $ = require 'jquery' SortableList = require 'sortable-list' -Tab = require 'tabs/lib/tab' +Tab = require './tab' module.exports = class TabView extends SortableList From b5451ce5b3c829cf73c219842a1d78e74a01fddd Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 11 Feb 2013 10:48:54 -0800 Subject: [PATCH 24/48] Remove unneeded rootView variable --- src/packages/tabs/spec/tabs-spec.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/packages/tabs/spec/tabs-spec.coffee b/src/packages/tabs/spec/tabs-spec.coffee index d6c708ebe..a103714eb 100644 --- a/src/packages/tabs/spec/tabs-spec.coffee +++ b/src/packages/tabs/spec/tabs-spec.coffee @@ -7,7 +7,7 @@ describe "TabView", -> [editor, buffer, tabs] = [] beforeEach -> - rootView = new RootView(require.resolve('fixtures/sample.js')) + new RootView(require.resolve('fixtures/sample.js')) rootView.open('sample.txt') rootView.simulateDomAttachment() atom.loadPackage("tabs") From 07ff931082e71593a2852e5f85cf3faa3d3a4f86 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 11 Feb 2013 10:51:12 -0800 Subject: [PATCH 25/48] Remove unneeded rootView parameter --- src/packages/tabs/lib/tab-view.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/packages/tabs/lib/tab-view.coffee b/src/packages/tabs/lib/tab-view.coffee index cf1e293b7..0c8864bda 100644 --- a/src/packages/tabs/lib/tab-view.coffee +++ b/src/packages/tabs/lib/tab-view.coffee @@ -6,9 +6,9 @@ module.exports = class TabView extends SortableList @activate: -> rootView.eachEditor (editor) => - @prependToEditorPane(rootView, editor) if editor.attached + @prependToEditorPane(editor) if editor.attached - @prependToEditorPane: (rootView, editor) -> + @prependToEditorPane: (editor) -> if pane = editor.pane() pane.prepend(new TabView(editor)) From 94ba8c119153510d29b4134384f3d183597773df Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 11 Feb 2013 11:16:14 -0800 Subject: [PATCH 26/48] Do nothing when dragged tab is dropped onto itself --- src/packages/tabs/lib/tab-view.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/src/packages/tabs/lib/tab-view.coffee b/src/packages/tabs/lib/tab-view.coffee index 0c8864bda..ce28c56dd 100644 --- a/src/packages/tabs/lib/tab-view.coffee +++ b/src/packages/tabs/lib/tab-view.coffee @@ -76,6 +76,7 @@ class TabView extends SortableList droppedNearTab = @getSortableElement(event) draggedTab = fromPane.find(".#{TabView.viewClass()} .sortable:eq(#{previousDraggedTabIndex})") + return if draggedTab[0] is droppedNearTab[0] draggedTab.remove() draggedTab.insertAfter(droppedNearTab) From 6a504fc29014d7c35f018a211cc064b61fa3a14d Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 11 Feb 2013 11:20:50 -0800 Subject: [PATCH 27/48] Remove unused index variable --- src/packages/tabs/lib/tab-view.coffee | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/packages/tabs/lib/tab-view.coffee b/src/packages/tabs/lib/tab-view.coffee index ce28c56dd..e25e9bf25 100644 --- a/src/packages/tabs/lib/tab-view.coffee +++ b/src/packages/tabs/lib/tab-view.coffee @@ -18,8 +18,7 @@ class TabView extends SortableList initialize: (@editor) -> super - for editSession, index in @editor.editSessions - @addTabForEditSession(editSession) + @addTabForEditSession(editSession) for editSession in @editor.editSessions @setActiveTab(@editor.getActiveEditSessionIndex()) @editor.on 'editor:active-edit-session-changed', (e, editSession, index) => @setActiveTab(index) From b9101b331035477c7a61dba1c272ff398c4c2d4f Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Mon, 11 Feb 2013 12:58:03 -0800 Subject: [PATCH 28/48] this is how we write this on .com --- src/packages/tabs/lib/tab-view.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/packages/tabs/lib/tab-view.coffee b/src/packages/tabs/lib/tab-view.coffee index e25e9bf25..175bdd3e5 100644 --- a/src/packages/tabs/lib/tab-view.coffee +++ b/src/packages/tabs/lib/tab-view.coffee @@ -82,7 +82,7 @@ class TabView extends SortableList currentDraggedTabIndex = draggedTab.index() toEditor.editSessions.splice(currentDraggedTabIndex, 0, fromEditor.editSessions.splice(previousDraggedTabIndex, 1)[0]) - if fromPane.find('.tab').length == 0 + if !fromPane.find('.tab').length fromPane.view().remove() else if fromPaneIndex != toPaneIndex && draggedTab.hasClass('active') fromEditor.setActiveEditSessionIndex(0) From ac39dd963fedb000e3f0e4309fd366e8b60ace2b Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Mon, 11 Feb 2013 13:01:03 -0800 Subject: [PATCH 29/48] :lipstick: --- static/tabs.css | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/static/tabs.css b/static/tabs.css index f0c170d7e..252c0253f 100644 --- a/static/tabs.css +++ b/static/tabs.css @@ -90,12 +90,8 @@ content: ""; z-index: 999; display: inline-block; - width: 1px; + width: 2px; height: 30px; display: inline-block; background: #0098ff; -} - -.placeholder { -/* background-color: #0098ff;*/ } \ No newline at end of file From 94cec69e313e71eb4b56937ba7ec5d6939f9b165 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Mon, 11 Feb 2013 13:10:59 -0800 Subject: [PATCH 30/48] little strong visual indication of drop location --- static/tabs.css | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/static/tabs.css b/static/tabs.css index 252c0253f..814af0ce3 100644 --- a/static/tabs.css +++ b/static/tabs.css @@ -94,4 +94,17 @@ height: 30px; display: inline-block; background: #0098ff; +} + +.tab.is-drop-target:before { + content: ""; + position: absolute; + width: 4px; + height: 4px; + background: #0098ff; + right: -4px; + top: 30px; + border-radius: 4px; + z-index: 9999; + border: 1px solid transparent; } \ No newline at end of file From d448db41d1d924d0a6aa3db6b9e48dba559a028c Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Mon, 11 Feb 2013 13:26:23 -0800 Subject: [PATCH 31/48] don't allow duplicate tabs in the same edit session --- src/packages/tabs/lib/tab-view.coffee | 11 ++++++++++- src/packages/tabs/lib/tab.coffee | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/packages/tabs/lib/tab-view.coffee b/src/packages/tabs/lib/tab-view.coffee index 175bdd3e5..a1137265f 100644 --- a/src/packages/tabs/lib/tab-view.coffee +++ b/src/packages/tabs/lib/tab-view.coffee @@ -44,6 +44,14 @@ class TabView extends SortableList removeTabAtIndex: (index) -> @find(".tab:eq(#{index})").remove() + containsTab: (tab) -> + unique = true + path = $(tab).view().buffer.file.path + paths = $.makeArray(@find('.tab')).map (e) -> + $(e).view().buffer.file.path + + return paths.some (tabpath) -> tabpath == path + shouldAllowDrag: (event) -> panes = rootView.find('.pane') !(panes.length == 1 && panes.find('.sortable').length == 1) @@ -75,7 +83,8 @@ class TabView extends SortableList droppedNearTab = @getSortableElement(event) draggedTab = fromPane.find(".#{TabView.viewClass()} .sortable:eq(#{previousDraggedTabIndex})") - return if draggedTab[0] is droppedNearTab[0] + + return if draggedTab[0] is droppedNearTab[0] or @containsTab(draggedTab) draggedTab.remove() draggedTab.insertAfter(droppedNearTab) diff --git a/src/packages/tabs/lib/tab.coffee b/src/packages/tabs/lib/tab.coffee index bcc055f1d..f538adb01 100644 --- a/src/packages/tabs/lib/tab.coffee +++ b/src/packages/tabs/lib/tab.coffee @@ -38,4 +38,4 @@ class Tab extends View fileNameText = 'untitled' @fileName.text(fileNameText) - @fileName.attr('title', @editSession.getPath()) + @fileName.attr('title', @editSession.getPath()) \ No newline at end of file From 96e2044e18bce548cdb0cbc18e8a9f20f9176905 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Mon, 11 Feb 2013 13:31:07 -0800 Subject: [PATCH 32/48] :lipstick: --- src/packages/tabs/lib/tab-view.coffee | 6 ++---- src/packages/tabs/lib/tab.coffee | 5 ++++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/packages/tabs/lib/tab-view.coffee b/src/packages/tabs/lib/tab-view.coffee index a1137265f..fcb3a9511 100644 --- a/src/packages/tabs/lib/tab-view.coffee +++ b/src/packages/tabs/lib/tab-view.coffee @@ -45,10 +45,8 @@ class TabView extends SortableList @find(".tab:eq(#{index})").remove() containsTab: (tab) -> - unique = true - path = $(tab).view().buffer.file.path - paths = $.makeArray(@find('.tab')).map (e) -> - $(e).view().buffer.file.path + path = $(tab).view().representedPath() + paths = $.makeArray(@find('.tab')).map (e) -> $(e).view().representedPath() return paths.some (tabpath) -> tabpath == path diff --git a/src/packages/tabs/lib/tab.coffee b/src/packages/tabs/lib/tab.coffee index f538adb01..50d80cba2 100644 --- a/src/packages/tabs/lib/tab.coffee +++ b/src/packages/tabs/lib/tab.coffee @@ -38,4 +38,7 @@ class Tab extends View fileNameText = 'untitled' @fileName.text(fileNameText) - @fileName.attr('title', @editSession.getPath()) \ No newline at end of file + @fileName.attr('title', @editSession.getPath()) + + representedPath: -> + @buffer.file.path \ No newline at end of file From fff049e8a6fae1e5590b5e19c612f761161ac1f8 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 11 Feb 2013 14:09:37 -0800 Subject: [PATCH 33/48] Use Buffer.getPath() --- src/packages/tabs/lib/tab.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/packages/tabs/lib/tab.coffee b/src/packages/tabs/lib/tab.coffee index 50d80cba2..0ef06d7d4 100644 --- a/src/packages/tabs/lib/tab.coffee +++ b/src/packages/tabs/lib/tab.coffee @@ -41,4 +41,4 @@ class Tab extends View @fileName.attr('title', @editSession.getPath()) representedPath: -> - @buffer.file.path \ No newline at end of file + @buffer.getPath() From 4502ec04d349cffdb5bdf4cf616d5cf9cb569b23 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Mon, 11 Feb 2013 16:49:28 -0800 Subject: [PATCH 34/48] only check for duplicates when dragging to a different panel --- src/packages/tabs/lib/tab-view.coffee | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/packages/tabs/lib/tab-view.coffee b/src/packages/tabs/lib/tab-view.coffee index fcb3a9511..6b34460e7 100644 --- a/src/packages/tabs/lib/tab-view.coffee +++ b/src/packages/tabs/lib/tab-view.coffee @@ -82,7 +82,9 @@ class TabView extends SortableList droppedNearTab = @getSortableElement(event) draggedTab = fromPane.find(".#{TabView.viewClass()} .sortable:eq(#{previousDraggedTabIndex})") - return if draggedTab[0] is droppedNearTab[0] or @containsTab(draggedTab) + return if draggedTab.is(droppedNearTab) + if fromPaneIndex != toPaneIndex + return if toPane.find('.sortable-list').view().containsTab(draggedTab) draggedTab.remove() draggedTab.insertAfter(droppedNearTab) From 0acd532428dcba739e97821a71ed8e398ccc5364 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Mon, 11 Feb 2013 17:02:34 -0800 Subject: [PATCH 35/48] Add transferEditSessionAtIndex to Editor --- src/app/editor.coffee | 3 +++ src/packages/tabs/lib/tab-view.coffee | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 36634b647..d9472f86b 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -549,6 +549,9 @@ class Editor extends View "Cancel" ) + transferEditSessionAtIndex: (fromIndex, toIndex, toEditor) -> + toEditor.editSessions.splice(toIndex, 0, @editSessions.splice(fromIndex, 1)[0]) + activateEditSessionForPath: (path) -> for editSession, index in @editSessions if editSession.buffer.getPath() == path diff --git a/src/packages/tabs/lib/tab-view.coffee b/src/packages/tabs/lib/tab-view.coffee index 6b34460e7..feffd624c 100644 --- a/src/packages/tabs/lib/tab-view.coffee +++ b/src/packages/tabs/lib/tab-view.coffee @@ -89,7 +89,7 @@ class TabView extends SortableList draggedTab.remove() draggedTab.insertAfter(droppedNearTab) currentDraggedTabIndex = draggedTab.index() - toEditor.editSessions.splice(currentDraggedTabIndex, 0, fromEditor.editSessions.splice(previousDraggedTabIndex, 1)[0]) + fromEditor.transferEditSessionAtIndex(previousDraggedTabIndex, currentDraggedTabIndex, toEditor) if !fromPane.find('.tab').length fromPane.view().remove() From 5abf17e93bf1e772f3a1600b2e9a890ec65fc14e Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 11 Feb 2013 17:00:46 -0800 Subject: [PATCH 36/48] Compare edit sessions instead of tab paths --- src/packages/tabs/lib/tab-view.coffee | 10 ++++------ src/packages/tabs/lib/tab.coffee | 3 --- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/packages/tabs/lib/tab-view.coffee b/src/packages/tabs/lib/tab-view.coffee index feffd624c..1ddf6182c 100644 --- a/src/packages/tabs/lib/tab-view.coffee +++ b/src/packages/tabs/lib/tab-view.coffee @@ -44,11 +44,9 @@ class TabView extends SortableList removeTabAtIndex: (index) -> @find(".tab:eq(#{index})").remove() - containsTab: (tab) -> - path = $(tab).view().representedPath() - paths = $.makeArray(@find('.tab')).map (e) -> $(e).view().representedPath() - - return paths.some (tabpath) -> tabpath == path + containsEditSession: (editor, editSession) -> + for session in editor.editSessions + return true if editSession.getPath() is session.getPath() shouldAllowDrag: (event) -> panes = rootView.find('.pane') @@ -84,7 +82,7 @@ class TabView extends SortableList return if draggedTab.is(droppedNearTab) if fromPaneIndex != toPaneIndex - return if toPane.find('.sortable-list').view().containsTab(draggedTab) + return if @containsEditSession(toEditor, fromEditor.editSessions[draggedTab.index()]) draggedTab.remove() draggedTab.insertAfter(droppedNearTab) diff --git a/src/packages/tabs/lib/tab.coffee b/src/packages/tabs/lib/tab.coffee index 0ef06d7d4..bcc055f1d 100644 --- a/src/packages/tabs/lib/tab.coffee +++ b/src/packages/tabs/lib/tab.coffee @@ -39,6 +39,3 @@ class Tab extends View @fileName.text(fileNameText) @fileName.attr('title', @editSession.getPath()) - - representedPath: -> - @buffer.getPath() From a104e67acd1c64255de7f9d53c81e01d5edc6330 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 11 Feb 2013 18:36:32 -0800 Subject: [PATCH 37/48] Support moving an edit session's editor index --- spec/app/editor-spec.coffee | 26 ++++++++++++++++++++++++++ src/app/editor.coffee | 6 ++++++ 2 files changed, 32 insertions(+) diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index a9f020799..f53f407fd 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -2588,3 +2588,29 @@ describe "Editor", -> expect(buffer.lineForRow(14)).toBe '' expect(buffer.lineForRow(15)).toBeUndefined() expect(editor.getCursorBufferPosition()).toEqual [14, 0] + + describe ".moveEditSessionAtIndex(fromIndex, toIndex)", -> + it "updates the edit session order", -> + jsPath = editor.getPath() + rootView.open("sample.txt") + txtPath = editor.getPath() + expect(editor.editSessions[0].getPath()).toBe jsPath + expect(editor.editSessions[1].getPath()).toBe txtPath + editor.moveEditSessionAtIndex(0, 1) + expect(editor.editSessions[0].getPath()).toBe txtPath + expect(editor.editSessions[1].getPath()).toBe jsPath + + it "fires an editor:edit-session-order-changed event", -> + eventHandler = jasmine.createSpy("eventHandler") + rootView.open("sample.txt") + editor.on "editor:edit-session-order-changed", eventHandler + editor.moveEditSessionAtIndex(0, 1) + expect(eventHandler).toHaveBeenCalled() + + it "sets the moved session as the editor's active session", -> + jsPath = editor.getPath() + rootView.open("sample.txt") + txtPath = editor.getPath() + expect(editor.activeEditSession.getPath()).toBe txtPath + editor.moveEditSessionAtIndex(0, 1) + expect(editor.activeEditSession.getPath()).toBe jsPath diff --git a/src/app/editor.coffee b/src/app/editor.coffee index d9472f86b..d002ddd16 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -549,6 +549,12 @@ class Editor extends View "Cancel" ) + moveEditSessionAtIndex: (fromIndex, toIndex) -> + editSession = @editSessions.splice(fromIndex, 1) + @editSessions.splice(toIndex, 0, editSession[0]) + @trigger 'editor:edit-session-order-changed' + @setActiveEditSessionIndex(toIndex) + transferEditSessionAtIndex: (fromIndex, toIndex, toEditor) -> toEditor.editSessions.splice(toIndex, 0, @editSessions.splice(fromIndex, 1)[0]) From 8b61c0d8f7707e4941e68b8521e5c78d8236b12d Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 11 Feb 2013 18:45:21 -0800 Subject: [PATCH 38/48] Rearrange tabs when the edit session order changes --- src/app/editor.coffee | 2 +- src/packages/tabs/lib/tab-view.coffee | 8 ++++++++ src/packages/tabs/spec/tabs-spec.coffee | 13 +++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/app/editor.coffee b/src/app/editor.coffee index d002ddd16..146063d7b 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -552,7 +552,7 @@ class Editor extends View moveEditSessionAtIndex: (fromIndex, toIndex) -> editSession = @editSessions.splice(fromIndex, 1) @editSessions.splice(toIndex, 0, editSession[0]) - @trigger 'editor:edit-session-order-changed' + @trigger 'editor:edit-session-order-changed', [editSession, fromIndex, toIndex] @setActiveEditSessionIndex(toIndex) transferEditSessionAtIndex: (fromIndex, toIndex, toEditor) -> diff --git a/src/packages/tabs/lib/tab-view.coffee b/src/packages/tabs/lib/tab-view.coffee index 1ddf6182c..5e7aefbbb 100644 --- a/src/packages/tabs/lib/tab-view.coffee +++ b/src/packages/tabs/lib/tab-view.coffee @@ -24,6 +24,14 @@ class TabView extends SortableList @editor.on 'editor:active-edit-session-changed', (e, editSession, index) => @setActiveTab(index) @editor.on 'editor:edit-session-added', (e, editSession) => @addTabForEditSession(editSession) @editor.on 'editor:edit-session-removed', (e, editSession, index) => @removeTabAtIndex(index) + @editor.on 'editor:edit-session-order-changed', (e, editSession, fromIndex, toIndex) => + fromTab = @find(".tab:eq(#{fromIndex})") + toTab = @find(".tab:eq(#{toIndex})") + fromTab.detach() + if fromIndex < toIndex + fromTab.insertAfter(toTab) + else + fromTab.insertBefore(toTab) @on 'click', '.tab', (e) => @editor.setActiveEditSessionIndex($(e.target).closest('.tab').index()) diff --git a/src/packages/tabs/spec/tabs-spec.coffee b/src/packages/tabs/spec/tabs-spec.coffee index a103714eb..1eae8f321 100644 --- a/src/packages/tabs/spec/tabs-spec.coffee +++ b/src/packages/tabs/spec/tabs-spec.coffee @@ -144,3 +144,16 @@ describe "TabView", -> expect(tabs.find('.tab:last .file-name').text()).toBe 'sample.js - tmp' editor.destroyActiveEditSession() expect(tabs.find('.tab:eq(0) .file-name').text()).toBe 'sample.js' + + describe "when an editor:edit-session-order-changed event is triggered", -> + it "updates the order of the tabs to match the new edit session order", -> + expect(tabs.find('.tab:eq(0) .file-name').text()).toBe "sample.js" + expect(tabs.find('.tab:eq(1) .file-name').text()).toBe "sample.txt" + + editor.moveEditSessionAtIndex(0, 1) + expect(tabs.find('.tab:eq(0) .file-name').text()).toBe "sample.txt" + expect(tabs.find('.tab:eq(1) .file-name').text()).toBe "sample.js" + + editor.moveEditSessionAtIndex(1, 0) + expect(tabs.find('.tab:eq(0) .file-name').text()).toBe "sample.js" + expect(tabs.find('.tab:eq(1) .file-name').text()).toBe "sample.txt" From 867e8d5678b3f4e469e0b780505c0f20a210a103 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 11 Feb 2013 20:03:28 -0800 Subject: [PATCH 39/48] Add spec for dragging/dropping tab in the same editor --- src/packages/tabs/lib/tab-view.coffee | 41 ++++++++++++++----------- src/packages/tabs/spec/tabs-spec.coffee | 23 ++++++++++++++ 2 files changed, 46 insertions(+), 18 deletions(-) diff --git a/src/packages/tabs/lib/tab-view.coffee b/src/packages/tabs/lib/tab-view.coffee index 5e7aefbbb..b86fa61fb 100644 --- a/src/packages/tabs/lib/tab-view.coffee +++ b/src/packages/tabs/lib/tab-view.coffee @@ -79,29 +79,34 @@ class TabView extends SortableList fromEditor = fromPane.find('.editor').view() if fromPaneIndex == toPaneIndex - toPane = fromPane - toEditor = fromEditor + droppedNearTab = @getSortableElement(event) + draggedTab = fromPane.find(".#{TabView.viewClass()} .sortable:eq(#{previousDraggedTabIndex})") + unless draggedTab.is(droppedNearTab) + fromIndex = draggedTab.index() + toIndex = droppedNearTab.index() + toIndex++ if fromIndex > toIndex + fromEditor.moveEditSessionAtIndex(fromIndex, toIndex) else toPane = $(rootView.find('.pane')[toPaneIndex]) toEditor = toPane.find('.editor').view() - droppedNearTab = @getSortableElement(event) - draggedTab = fromPane.find(".#{TabView.viewClass()} .sortable:eq(#{previousDraggedTabIndex})") + droppedNearTab = @getSortableElement(event) + draggedTab = fromPane.find(".#{TabView.viewClass()} .sortable:eq(#{previousDraggedTabIndex})") - return if draggedTab.is(droppedNearTab) - if fromPaneIndex != toPaneIndex - return if @containsEditSession(toEditor, fromEditor.editSessions[draggedTab.index()]) + return if draggedTab.is(droppedNearTab) + if fromPaneIndex != toPaneIndex + return if @containsEditSession(toEditor, fromEditor.editSessions[draggedTab.index()]) - draggedTab.remove() - draggedTab.insertAfter(droppedNearTab) - currentDraggedTabIndex = draggedTab.index() - fromEditor.transferEditSessionAtIndex(previousDraggedTabIndex, currentDraggedTabIndex, toEditor) + draggedTab.remove() + draggedTab.insertAfter(droppedNearTab) + currentDraggedTabIndex = draggedTab.index() + fromEditor.transferEditSessionAtIndex(previousDraggedTabIndex, currentDraggedTabIndex, toEditor) - if !fromPane.find('.tab').length - fromPane.view().remove() - else if fromPaneIndex != toPaneIndex && draggedTab.hasClass('active') - fromEditor.setActiveEditSessionIndex(0) + if !fromPane.find('.tab').length + fromPane.view().remove() + else if fromPaneIndex != toPaneIndex && draggedTab.hasClass('active') + fromEditor.setActiveEditSessionIndex(0) - @setActiveTab(currentDraggedTabIndex) - toEditor.setActiveEditSessionIndex(currentDraggedTabIndex) - toEditor.focus() + @setActiveTab(currentDraggedTabIndex) + toEditor.setActiveEditSessionIndex(currentDraggedTabIndex) + toEditor.focus() diff --git a/src/packages/tabs/spec/tabs-spec.coffee b/src/packages/tabs/spec/tabs-spec.coffee index 1eae8f321..2fbb3cef7 100644 --- a/src/packages/tabs/spec/tabs-spec.coffee +++ b/src/packages/tabs/spec/tabs-spec.coffee @@ -157,3 +157,26 @@ describe "TabView", -> editor.moveEditSessionAtIndex(1, 0) expect(tabs.find('.tab:eq(0) .file-name').text()).toBe "sample.js" expect(tabs.find('.tab:eq(1) .file-name').text()).toBe "sample.txt" + + describe "dragging and dropping tabs", -> + describe "when a tab is dragged from and dropped onto the same editor", -> + it "moves the edit session and updates the order of the tabs", -> + expect(tabs.find('.tab:eq(0) .file-name').text()).toBe "sample.js" + expect(tabs.find('.tab:eq(1) .file-name').text()).toBe "sample.txt" + + sortableElement = [tabs.find('.tab:eq(0)')] + spyOn(tabs, 'getSortableElement').andCallFake -> sortableElement[0] + event = $.Event() + event.target = tabs[0] + event.originalEvent = + dataTransfer: + data: {} + setData: (key, value) -> @data[key] = value + getData: (key) -> @data[key] + + tabs.onDragStart(event) + sortableElement = [tabs.find('.tab:eq(1)')] + tabs.onDrop(event) + + expect(tabs.find('.tab:eq(0) .file-name').text()).toBe "sample.txt" + expect(tabs.find('.tab:eq(1) .file-name').text()).toBe "sample.js" From 472b436b248a63f7eacfb10894c44d35ce8c23df Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 11 Feb 2013 20:23:53 -0800 Subject: [PATCH 40/48] Add spec for dragging/dropping tabs across editors --- src/app/editor.coffee | 8 +++++++ src/packages/tabs/lib/tab-view.coffee | 30 +++++++------------------ src/packages/tabs/spec/tabs-spec.coffee | 25 +++++++++++++++++++++ 3 files changed, 41 insertions(+), 22 deletions(-) diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 146063d7b..c6fbcc44d 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -550,11 +550,19 @@ class Editor extends View ) moveEditSessionAtIndex: (fromIndex, toIndex) -> + return if fromIndex is toIndex editSession = @editSessions.splice(fromIndex, 1) @editSessions.splice(toIndex, 0, editSession[0]) @trigger 'editor:edit-session-order-changed', [editSession, fromIndex, toIndex] @setActiveEditSessionIndex(toIndex) + moveEditSessionToEditor: (fromIndex, toEditor, toIndex) -> + fromEditSession = @editSessions[fromIndex] + toEditSession = fromEditSession.copy() + @destroyEditSessionIndex(fromIndex) + toEditor.edit(toEditSession) + toEditor.moveEditSessionAtIndex(toEditor.getActiveEditSessionIndex(), toIndex) + transferEditSessionAtIndex: (fromIndex, toIndex, toEditor) -> toEditor.editSessions.splice(toIndex, 0, @editSessions.splice(fromIndex, 1)[0]) diff --git a/src/packages/tabs/lib/tab-view.coffee b/src/packages/tabs/lib/tab-view.coffee index b86fa61fb..6cc84b63a 100644 --- a/src/packages/tabs/lib/tab-view.coffee +++ b/src/packages/tabs/lib/tab-view.coffee @@ -70,6 +70,7 @@ class TabView extends SortableList onDrop: (event) => super + droppedNearTab = @getSortableElement(event) transfer = event.originalEvent.dataTransfer previousDraggedTabIndex = transfer.getData 'sortable-index' @@ -77,36 +78,21 @@ class TabView extends SortableList toPaneIndex = rootView.indexOfPane($(event.target).closest('.pane')) fromPane = $(rootView.find('.pane')[fromPaneIndex]) fromEditor = fromPane.find('.editor').view() + draggedTab = fromPane.find(".#{TabView.viewClass()} .sortable:eq(#{previousDraggedTabIndex})") + return if draggedTab.is(droppedNearTab) if fromPaneIndex == toPaneIndex droppedNearTab = @getSortableElement(event) - draggedTab = fromPane.find(".#{TabView.viewClass()} .sortable:eq(#{previousDraggedTabIndex})") - unless draggedTab.is(droppedNearTab) - fromIndex = draggedTab.index() - toIndex = droppedNearTab.index() - toIndex++ if fromIndex > toIndex - fromEditor.moveEditSessionAtIndex(fromIndex, toIndex) + fromIndex = draggedTab.index() + toIndex = droppedNearTab.index() + toIndex++ if fromIndex > toIndex + fromEditor.moveEditSessionAtIndex(fromIndex, toIndex) else toPane = $(rootView.find('.pane')[toPaneIndex]) toEditor = toPane.find('.editor').view() - droppedNearTab = @getSortableElement(event) - draggedTab = fromPane.find(".#{TabView.viewClass()} .sortable:eq(#{previousDraggedTabIndex})") - - return if draggedTab.is(droppedNearTab) if fromPaneIndex != toPaneIndex return if @containsEditSession(toEditor, fromEditor.editSessions[draggedTab.index()]) - draggedTab.remove() - draggedTab.insertAfter(droppedNearTab) - currentDraggedTabIndex = draggedTab.index() - fromEditor.transferEditSessionAtIndex(previousDraggedTabIndex, currentDraggedTabIndex, toEditor) - - if !fromPane.find('.tab').length - fromPane.view().remove() - else if fromPaneIndex != toPaneIndex && draggedTab.hasClass('active') - fromEditor.setActiveEditSessionIndex(0) - - @setActiveTab(currentDraggedTabIndex) - toEditor.setActiveEditSessionIndex(currentDraggedTabIndex) + fromEditor.moveEditSessionToEditor(draggedTab.index(), toEditor, droppedNearTab.index() + 1) toEditor.focus() diff --git a/src/packages/tabs/spec/tabs-spec.coffee b/src/packages/tabs/spec/tabs-spec.coffee index 2fbb3cef7..1db15106e 100644 --- a/src/packages/tabs/spec/tabs-spec.coffee +++ b/src/packages/tabs/spec/tabs-spec.coffee @@ -180,3 +180,28 @@ describe "TabView", -> expect(tabs.find('.tab:eq(0) .file-name').text()).toBe "sample.txt" expect(tabs.find('.tab:eq(1) .file-name').text()).toBe "sample.js" + + describe "when a tab is dragged from one editor and dropped onto another editor", -> + it "moves the edit session and updates the order of the tabs", -> + leftTabs = tabs + editor.splitRight() + rightTabs = rootView.find('.tabs:last').view() + + sortableElement = [leftTabs.find('.tab:eq(0)')] + spyOn(tabs, 'getSortableElement').andCallFake -> sortableElement[0] + event = $.Event() + event.target = leftTabs + event.originalEvent = + dataTransfer: + data: {} + setData: (key, value) -> @data[key] = value + getData: (key) -> @data[key] + + tabs.onDragStart(event) + + event.target = rightTabs + sortableElement = [rightTabs.find('.tab:eq(0)')] + tabs.onDrop(event) + + expect(rightTabs.find('.tab:eq(0) .file-name').text()).toBe "sample.txt" + expect(rightTabs.find('.tab:eq(1) .file-name').text()).toBe "sample.js" From c9fae8537525b67941542c8ff8b0f7c6b5a60c47 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 11 Feb 2013 20:29:25 -0800 Subject: [PATCH 41/48] Rename moveEditSessionAtIndex to moveEditSessionToIndex --- spec/app/editor-spec.coffee | 8 ++++---- src/app/editor.coffee | 7 ++----- src/packages/tabs/lib/tab-view.coffee | 2 +- src/packages/tabs/spec/tabs-spec.coffee | 4 ++-- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index f53f407fd..899a73ba5 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -2589,14 +2589,14 @@ describe "Editor", -> expect(buffer.lineForRow(15)).toBeUndefined() expect(editor.getCursorBufferPosition()).toEqual [14, 0] - describe ".moveEditSessionAtIndex(fromIndex, toIndex)", -> + describe ".moveEditSessionToIndex(fromIndex, toIndex)", -> it "updates the edit session order", -> jsPath = editor.getPath() rootView.open("sample.txt") txtPath = editor.getPath() expect(editor.editSessions[0].getPath()).toBe jsPath expect(editor.editSessions[1].getPath()).toBe txtPath - editor.moveEditSessionAtIndex(0, 1) + editor.moveEditSessionToIndex(0, 1) expect(editor.editSessions[0].getPath()).toBe txtPath expect(editor.editSessions[1].getPath()).toBe jsPath @@ -2604,7 +2604,7 @@ describe "Editor", -> eventHandler = jasmine.createSpy("eventHandler") rootView.open("sample.txt") editor.on "editor:edit-session-order-changed", eventHandler - editor.moveEditSessionAtIndex(0, 1) + editor.moveEditSessionToIndex(0, 1) expect(eventHandler).toHaveBeenCalled() it "sets the moved session as the editor's active session", -> @@ -2612,5 +2612,5 @@ describe "Editor", -> rootView.open("sample.txt") txtPath = editor.getPath() expect(editor.activeEditSession.getPath()).toBe txtPath - editor.moveEditSessionAtIndex(0, 1) + editor.moveEditSessionToIndex(0, 1) expect(editor.activeEditSession.getPath()).toBe jsPath diff --git a/src/app/editor.coffee b/src/app/editor.coffee index c6fbcc44d..80ed42943 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -549,7 +549,7 @@ class Editor extends View "Cancel" ) - moveEditSessionAtIndex: (fromIndex, toIndex) -> + moveEditSessionToIndex: (fromIndex, toIndex) -> return if fromIndex is toIndex editSession = @editSessions.splice(fromIndex, 1) @editSessions.splice(toIndex, 0, editSession[0]) @@ -561,10 +561,7 @@ class Editor extends View toEditSession = fromEditSession.copy() @destroyEditSessionIndex(fromIndex) toEditor.edit(toEditSession) - toEditor.moveEditSessionAtIndex(toEditor.getActiveEditSessionIndex(), toIndex) - - transferEditSessionAtIndex: (fromIndex, toIndex, toEditor) -> - toEditor.editSessions.splice(toIndex, 0, @editSessions.splice(fromIndex, 1)[0]) + toEditor.moveEditSessionToIndex(toEditor.getActiveEditSessionIndex(), toIndex) activateEditSessionForPath: (path) -> for editSession, index in @editSessions diff --git a/src/packages/tabs/lib/tab-view.coffee b/src/packages/tabs/lib/tab-view.coffee index 6cc84b63a..b15fb40ef 100644 --- a/src/packages/tabs/lib/tab-view.coffee +++ b/src/packages/tabs/lib/tab-view.coffee @@ -86,7 +86,7 @@ class TabView extends SortableList fromIndex = draggedTab.index() toIndex = droppedNearTab.index() toIndex++ if fromIndex > toIndex - fromEditor.moveEditSessionAtIndex(fromIndex, toIndex) + fromEditor.moveEditSessionToIndex(fromIndex, toIndex) else toPane = $(rootView.find('.pane')[toPaneIndex]) toEditor = toPane.find('.editor').view() diff --git a/src/packages/tabs/spec/tabs-spec.coffee b/src/packages/tabs/spec/tabs-spec.coffee index 1db15106e..31aff09e6 100644 --- a/src/packages/tabs/spec/tabs-spec.coffee +++ b/src/packages/tabs/spec/tabs-spec.coffee @@ -150,11 +150,11 @@ describe "TabView", -> expect(tabs.find('.tab:eq(0) .file-name').text()).toBe "sample.js" expect(tabs.find('.tab:eq(1) .file-name').text()).toBe "sample.txt" - editor.moveEditSessionAtIndex(0, 1) + editor.moveEditSessionToIndex(0, 1) expect(tabs.find('.tab:eq(0) .file-name').text()).toBe "sample.txt" expect(tabs.find('.tab:eq(1) .file-name').text()).toBe "sample.js" - editor.moveEditSessionAtIndex(1, 0) + editor.moveEditSessionToIndex(1, 0) expect(tabs.find('.tab:eq(0) .file-name').text()).toBe "sample.js" expect(tabs.find('.tab:eq(1) .file-name').text()).toBe "sample.txt" From ad9114c95e5e0cf1c294069f7879ba7a044e7ec7 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 11 Feb 2013 20:35:41 -0800 Subject: [PATCH 42/48] Use octicon for drop target indicator --- static/tabs.css | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/static/tabs.css b/static/tabs.css index 814af0ce3..4bc2f787a 100644 --- a/static/tabs.css +++ b/static/tabs.css @@ -83,28 +83,16 @@ } -.tab.is-drop-target:after { - position: absolute; - top: 0; - right: -2px; - content: ""; - z-index: 999; - display: inline-block; - width: 2px; - height: 30px; - display: inline-block; - background: #0098ff; -} - .tab.is-drop-target:before { - content: ""; + content: "\f03d"; + font-family: 'Octicons Regular'; + -webkit-font-smoothing: antialiased; + font-size: 17px; + width: 17px; + height: 17px; position: absolute; - width: 4px; - height: 4px; - background: #0098ff; - right: -4px; - top: 30px; - border-radius: 4px; + color: #0098ff; + top: 19px; + right: -8px; z-index: 9999; - border: 1px solid transparent; -} \ No newline at end of file +} From 9eae796be3a649a1bbcacd7967dc80b222f6532e Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 11 Feb 2013 20:54:04 -0800 Subject: [PATCH 43/48] Add move edit session specs --- spec/app/editor-spec.coffee | 71 +++++++++++++++++++++++++------------ 1 file changed, 49 insertions(+), 22 deletions(-) diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index 899a73ba5..835c8c492 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -2590,27 +2590,54 @@ describe "Editor", -> expect(editor.getCursorBufferPosition()).toEqual [14, 0] describe ".moveEditSessionToIndex(fromIndex, toIndex)", -> - it "updates the edit session order", -> - jsPath = editor.getPath() - rootView.open("sample.txt") - txtPath = editor.getPath() - expect(editor.editSessions[0].getPath()).toBe jsPath - expect(editor.editSessions[1].getPath()).toBe txtPath - editor.moveEditSessionToIndex(0, 1) - expect(editor.editSessions[0].getPath()).toBe txtPath - expect(editor.editSessions[1].getPath()).toBe jsPath + describe "when the edit session moves to a later index", -> + it "updates the edit session order", -> + jsPath = editor.getPath() + rootView.open("sample.txt") + txtPath = editor.getPath() + expect(editor.editSessions[0].getPath()).toBe jsPath + expect(editor.editSessions[1].getPath()).toBe txtPath + editor.moveEditSessionToIndex(0, 1) + expect(editor.editSessions[0].getPath()).toBe txtPath + expect(editor.editSessions[1].getPath()).toBe jsPath - it "fires an editor:edit-session-order-changed event", -> - eventHandler = jasmine.createSpy("eventHandler") - rootView.open("sample.txt") - editor.on "editor:edit-session-order-changed", eventHandler - editor.moveEditSessionToIndex(0, 1) - expect(eventHandler).toHaveBeenCalled() + it "fires an editor:edit-session-order-changed event", -> + eventHandler = jasmine.createSpy("eventHandler") + rootView.open("sample.txt") + editor.on "editor:edit-session-order-changed", eventHandler + editor.moveEditSessionToIndex(0, 1) + expect(eventHandler).toHaveBeenCalled() - it "sets the moved session as the editor's active session", -> - jsPath = editor.getPath() - rootView.open("sample.txt") - txtPath = editor.getPath() - expect(editor.activeEditSession.getPath()).toBe txtPath - editor.moveEditSessionToIndex(0, 1) - expect(editor.activeEditSession.getPath()).toBe jsPath + it "sets the moved session as the editor's active session", -> + jsPath = editor.getPath() + rootView.open("sample.txt") + txtPath = editor.getPath() + expect(editor.activeEditSession.getPath()).toBe txtPath + editor.moveEditSessionToIndex(0, 1) + expect(editor.activeEditSession.getPath()).toBe jsPath + + describe "when the edit session moves to an earlier index", -> + it "updates the edit session order", -> + jsPath = editor.getPath() + rootView.open("sample.txt") + txtPath = editor.getPath() + expect(editor.editSessions[0].getPath()).toBe jsPath + expect(editor.editSessions[1].getPath()).toBe txtPath + editor.moveEditSessionToIndex(1, 0) + expect(editor.editSessions[0].getPath()).toBe txtPath + expect(editor.editSessions[1].getPath()).toBe jsPath + + it "fires an editor:edit-session-order-changed event", -> + eventHandler = jasmine.createSpy("eventHandler") + rootView.open("sample.txt") + editor.on "editor:edit-session-order-changed", eventHandler + editor.moveEditSessionToIndex(1, 0) + expect(eventHandler).toHaveBeenCalled() + + it "sets the moved session as the editor's active session", -> + jsPath = editor.getPath() + rootView.open("sample.txt") + txtPath = editor.getPath() + expect(editor.activeEditSession.getPath()).toBe txtPath + editor.moveEditSessionToIndex(1, 0) + expect(editor.activeEditSession.getPath()).toBe txtPath From 9057f044bfdb3c7a86507e3d40064f89d09e7dbe Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 11 Feb 2013 21:01:21 -0800 Subject: [PATCH 44/48] Add specs for Editor.moveEditSessionToEditor --- spec/app/editor-spec.coffee | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index 835c8c492..eed7563b5 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -2641,3 +2641,26 @@ describe "Editor", -> expect(editor.activeEditSession.getPath()).toBe txtPath editor.moveEditSessionToIndex(1, 0) expect(editor.activeEditSession.getPath()).toBe txtPath + + describe ".moveEditSessionToEditor(fromIndex, toEditor, toIndex)", -> + it "closes the edit session in the source editor", -> + jsPath = editor.getPath() + rootView.open("sample.txt") + txtPath = editor.getPath() + rightEditor = editor.splitRight() + expect(editor.editSessions[0].getPath()).toBe jsPath + expect(editor.editSessions[1].getPath()).toBe txtPath + editor.moveEditSessionToEditor(0, rightEditor, 1) + expect(editor.editSessions[0].getPath()).toBe txtPath + expect(editor.editSessions[1]).toBeUndefined() + + it "opens the edit session in the destination editor at the target index", -> + jsPath = editor.getPath() + rootView.open("sample.txt") + txtPath = editor.getPath() + rightEditor = editor.splitRight() + expect(rightEditor.editSessions[0].getPath()).toBe txtPath + expect(rightEditor.editSessions[1]).toBeUndefined() + editor.moveEditSessionToEditor(0, rightEditor, 0) + expect(rightEditor.editSessions[0].getPath()).toBe jsPath + expect(rightEditor.editSessions[1].getPath()).toBe txtPath From 21e5f550c84deb2345f9b73d8c1d63eba9421a60 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 11 Feb 2013 21:11:15 -0800 Subject: [PATCH 45/48] Assert editor receives focus after tab is dropped --- src/packages/tabs/lib/tab-view.coffee | 1 + src/packages/tabs/spec/tabs-spec.coffee | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/packages/tabs/lib/tab-view.coffee b/src/packages/tabs/lib/tab-view.coffee index b15fb40ef..99d171762 100644 --- a/src/packages/tabs/lib/tab-view.coffee +++ b/src/packages/tabs/lib/tab-view.coffee @@ -87,6 +87,7 @@ class TabView extends SortableList toIndex = droppedNearTab.index() toIndex++ if fromIndex > toIndex fromEditor.moveEditSessionToIndex(fromIndex, toIndex) + fromEditor.focus() else toPane = $(rootView.find('.pane')[toPaneIndex]) toEditor = toPane.find('.editor').view() diff --git a/src/packages/tabs/spec/tabs-spec.coffee b/src/packages/tabs/spec/tabs-spec.coffee index 31aff09e6..addbdda81 100644 --- a/src/packages/tabs/spec/tabs-spec.coffee +++ b/src/packages/tabs/spec/tabs-spec.coffee @@ -160,7 +160,7 @@ describe "TabView", -> describe "dragging and dropping tabs", -> describe "when a tab is dragged from and dropped onto the same editor", -> - it "moves the edit session and updates the order of the tabs", -> + it "moves the edit session, updates the order of the tabs, and focuses the editor", -> expect(tabs.find('.tab:eq(0) .file-name').text()).toBe "sample.js" expect(tabs.find('.tab:eq(1) .file-name').text()).toBe "sample.txt" @@ -174,17 +174,19 @@ describe "TabView", -> setData: (key, value) -> @data[key] = value getData: (key) -> @data[key] + editor.hiddenInput.focusout() tabs.onDragStart(event) sortableElement = [tabs.find('.tab:eq(1)')] tabs.onDrop(event) expect(tabs.find('.tab:eq(0) .file-name').text()).toBe "sample.txt" expect(tabs.find('.tab:eq(1) .file-name').text()).toBe "sample.js" + expect(editor.isFocused).toBeTruthy() describe "when a tab is dragged from one editor and dropped onto another editor", -> - it "moves the edit session and updates the order of the tabs", -> + it "moves the edit session, updates the order of the tabs, and focuses the destination editor", -> leftTabs = tabs - editor.splitRight() + rightEditor = editor.splitRight() rightTabs = rootView.find('.tabs:last').view() sortableElement = [leftTabs.find('.tab:eq(0)')] @@ -197,6 +199,7 @@ describe "TabView", -> setData: (key, value) -> @data[key] = value getData: (key) -> @data[key] + rightEditor.hiddenInput.focusout() tabs.onDragStart(event) event.target = rightTabs @@ -205,3 +208,4 @@ describe "TabView", -> expect(rightTabs.find('.tab:eq(0) .file-name').text()).toBe "sample.txt" expect(rightTabs.find('.tab:eq(1) .file-name').text()).toBe "sample.js" + expect(rightEditor.isFocused).toBeTruthy() From 728681a34e3f4afc34af5bc73fe1d4a5547c0337 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 12 Feb 2013 08:24:32 -0800 Subject: [PATCH 46/48] :lipstick: --- src/packages/tabs/lib/tab-view.coffee | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/packages/tabs/lib/tab-view.coffee b/src/packages/tabs/lib/tab-view.coffee index 99d171762..34e76496f 100644 --- a/src/packages/tabs/lib/tab-view.coffee +++ b/src/packages/tabs/lib/tab-view.coffee @@ -92,8 +92,6 @@ class TabView extends SortableList toPane = $(rootView.find('.pane')[toPaneIndex]) toEditor = toPane.find('.editor').view() - if fromPaneIndex != toPaneIndex - return if @containsEditSession(toEditor, fromEditor.editSessions[draggedTab.index()]) - - fromEditor.moveEditSessionToEditor(draggedTab.index(), toEditor, droppedNearTab.index() + 1) - toEditor.focus() + unless @containsEditSession(toEditor, fromEditor.editSessions[draggedTab.index()]) + fromEditor.moveEditSessionToEditor(draggedTab.index(), toEditor, droppedNearTab.index() + 1) + toEditor.focus() From 7e83a138cf6c3b8d99b2856e5c38691ce091a860 Mon Sep 17 00:00:00 2001 From: Justin Palmer Date: Tue, 12 Feb 2013 08:34:46 -0800 Subject: [PATCH 47/48] Revert "Use octicon for drop target indicator" This reverts commit ad9114c95e5e0cf1c294069f7879ba7a044e7ec7. --- static/tabs.css | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/static/tabs.css b/static/tabs.css index 4bc2f787a..814af0ce3 100644 --- a/static/tabs.css +++ b/static/tabs.css @@ -83,16 +83,28 @@ } -.tab.is-drop-target:before { - content: "\f03d"; - font-family: 'Octicons Regular'; - -webkit-font-smoothing: antialiased; - font-size: 17px; - width: 17px; - height: 17px; +.tab.is-drop-target:after { position: absolute; - color: #0098ff; - top: 19px; - right: -8px; - z-index: 9999; + top: 0; + right: -2px; + content: ""; + z-index: 999; + display: inline-block; + width: 2px; + height: 30px; + display: inline-block; + background: #0098ff; } + +.tab.is-drop-target:before { + content: ""; + position: absolute; + width: 4px; + height: 4px; + background: #0098ff; + right: -4px; + top: 30px; + border-radius: 4px; + z-index: 9999; + border: 1px solid transparent; +} \ No newline at end of file From a8e068ade0e2f6677a2856bc425d6492302828f4 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 12 Feb 2013 08:36:57 -0800 Subject: [PATCH 48/48] :lipstick: --- src/packages/fuzzy-finder/spec/fuzzy-finder-spec.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/packages/fuzzy-finder/spec/fuzzy-finder-spec.coffee b/src/packages/fuzzy-finder/spec/fuzzy-finder-spec.coffee index 67608bb4f..1a4dcd742 100644 --- a/src/packages/fuzzy-finder/spec/fuzzy-finder-spec.coffee +++ b/src/packages/fuzzy-finder/spec/fuzzy-finder-spec.coffee @@ -391,4 +391,4 @@ describe 'FuzzyFinder', -> expect(rootView.find('.editor').length).toBe 2 expect(editor.splitUp).toHaveBeenCalled() expect(rootView.getActiveEditor()).not.toBe editor - expect(rootView.getActiveEditor().getPath()).toBe editor.getPath() \ No newline at end of file + expect(rootView.getActiveEditor().getPath()).toBe editor.getPath()