mirror of
https://github.com/atom/atom.git
synced 2026-01-25 06:48:28 -05:00
Start on tabs extension
This commit is contained in:
1
src/extensions/tabs/index.coffee
Normal file
1
src/extensions/tabs/index.coffee
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require 'tabs/src/tabs'
|
||||
34
src/extensions/tabs/spec/tabs-spec.coffee
Normal file
34
src/extensions/tabs/spec/tabs-spec.coffee
Normal file
@@ -0,0 +1,34 @@
|
||||
$ = require 'jquery'
|
||||
_ = require 'underscore'
|
||||
RootView = require 'root-view'
|
||||
Tabs = require 'tabs'
|
||||
|
||||
describe "Tabs", ->
|
||||
[rootView, editor, statusBar, buffer, tabs] = []
|
||||
|
||||
beforeEach ->
|
||||
rootView = new RootView(require.resolve('fixtures/sample.js'))
|
||||
rootView.open('sample.txt')
|
||||
rootView.simulateDomAttachment()
|
||||
rootView.activateExtension(Tabs)
|
||||
editor = rootView.getActiveEditor()
|
||||
tabs = rootView.find('.tabs').view()
|
||||
|
||||
afterEach ->
|
||||
rootView.remove()
|
||||
|
||||
describe "@activate", ->
|
||||
fit "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()
|
||||
expect(rootView.find('.pane').length).toBe 2
|
||||
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", ->
|
||||
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()
|
||||
25
src/extensions/tabs/src/tabs.coffee
Normal file
25
src/extensions/tabs/src/tabs.coffee
Normal file
@@ -0,0 +1,25 @@
|
||||
{View, $$} = require 'space-pen'
|
||||
|
||||
module.exports =
|
||||
class Tabs extends View
|
||||
@activate: (rootView) ->
|
||||
requireStylesheet 'tabs/src/tabs.css'
|
||||
|
||||
for editor in rootView.getEditors()
|
||||
@prependToEditorPane(rootView, editor) if rootView.parents('html').length
|
||||
|
||||
rootView.on 'editor-open', (e, editor) =>
|
||||
@prependToEditorPane(rootView, editor)
|
||||
|
||||
@prependToEditorPane: (rootView, editor) ->
|
||||
if pane = editor.pane()
|
||||
pane.prepend(new Tabs(editor))
|
||||
|
||||
@content: ->
|
||||
@div class: 'tabs'
|
||||
|
||||
initialize: (@editor) ->
|
||||
for editSession in @editor.editSessions
|
||||
@append $$ ->
|
||||
@div class: 'tab', =>
|
||||
@div editSession.buffer.getBaseName(), class: 'file-name'
|
||||
20
src/extensions/tabs/src/tabs.css
Normal file
20
src/extensions/tabs/src/tabs.css
Normal file
@@ -0,0 +1,20 @@
|
||||
.tabs {
|
||||
background: #222;
|
||||
border-bottom: 4px solid #555;
|
||||
}
|
||||
|
||||
.tab {
|
||||
float: left;
|
||||
margin: 4px;
|
||||
margin-bottom: 0;
|
||||
margin-right: 0;
|
||||
padding: 4px;
|
||||
background: #555;
|
||||
color: white;
|
||||
-webkit-border-top-left-radius: 4px;
|
||||
-webkit-border-top-right-radius: 4px;
|
||||
}
|
||||
|
||||
.tab:last-child {
|
||||
margin-right: 4px;
|
||||
}
|
||||
Reference in New Issue
Block a user