Highlight the tab for the initial active edit session

This commit is contained in:
Nathan Sobo
2012-11-20 15:06:09 -07:00
parent 031c0e7ee0
commit 2d8ffef96b
3 changed files with 16 additions and 4 deletions

View File

@@ -18,7 +18,7 @@ describe "Tabs", ->
rootView.remove()
describe "@activate", ->
fit "appends a status bear to all existing and new editors", ->
it "appends a status bear to all existing and new editors", ->
expect(rootView.panes.find('.pane').length).toBe 1
expect(rootView.panes.find('.pane > .tabs').length).toBe 1
editor.splitRight()
@@ -26,9 +26,13 @@ describe "Tabs", ->
expect(rootView.panes.find('.pane > .tabs').length).toBe 2
describe "#initialize()", ->
fit "creates a tab for each edit session on the editor to which the tab-strip belongs", ->
it "creates a tab for each edit session on the editor to which the tab-strip belongs", ->
expect(editor.editSessions.length).toBe 2
expect(tabs.find('.tab').length).toBe 2
expect(tabs.find('.tab:eq(0) .file-name').text()).toBe editor.editSessions[0].buffer.getBaseName()
expect(tabs.find('.tab:eq(1) .file-name').text()).toBe editor.editSessions[1].buffer.getBaseName()
it "highlights the tab for the current active edit session", ->
expect(editor.getActiveEditSessionIndex()).toBe 1
expect(tabs.find('.tab:eq(1)')).toHaveClass 'active'

View File

@@ -19,7 +19,10 @@ class Tabs extends View
@div class: 'tabs'
initialize: (@editor) ->
for editSession in @editor.editSessions
for editSession, index in @editor.editSessions
@append $$ ->
@div class: 'tab', =>
@div editSession.buffer.getBaseName(), class: 'file-name'
activeIndex = @editor.getActiveEditSessionIndex()
@children(":eq(#{activeIndex})").addClass('active')

View File

@@ -9,12 +9,17 @@
margin-bottom: 0;
margin-right: 0;
padding: 4px;
background: #555;
background: #3a3a3a;
color: white;
-webkit-border-top-left-radius: 4px;
-webkit-border-top-right-radius: 4px;
}
.tab.active {
background: #555;
}
.tab:last-child {
margin-right: 4px;
}