Make Atom SpacePen view's default to empty object (where needed)

This commit is contained in:
Corey Johnson
2012-05-16 10:35:50 -07:00
parent a866d53e96
commit 399fc71b3c
13 changed files with 20 additions and 20 deletions

View File

@@ -20,7 +20,7 @@ describe "Editor", ->
cachedLineHeight
beforeEach ->
rootView = new RootView(pathToOpen: require.resolve('fixtures/sample.js'))
rootView = new RootView(require.resolve('fixtures/sample.js'))
project = rootView.project
editor = rootView.activeEditor()
buffer = editor.buffer

View File

@@ -11,7 +11,7 @@ describe "RootView", ->
beforeEach ->
path = require.resolve 'fixtures/dir/a'
rootView = new RootView(pathToOpen: path)
rootView = new RootView(path)
rootView.enableKeymap()
rootView.focus()
project = rootView.project
@@ -30,7 +30,7 @@ describe "RootView", ->
describe "when pathToOpen references a directory", ->
it "creates a project for the directory and sets the document.title, but does not open an editor", ->
path = require.resolve 'fixtures/dir'
rootView = new RootView(pathToOpen: path)
rootView = new RootView(path)
rootView.focus()
expect(rootView.project.getPath()).toBe path
@@ -113,7 +113,7 @@ describe "RootView", ->
describe "focus", ->
it "can receive focus if there is no active editor, but otherwise hands off focus to the active editor", ->
rootView = new RootView(pathToOpen: require.resolve 'fixtures')
rootView = new RootView(require.resolve 'fixtures')
rootView.attachToDom()
expect(rootView).toMatchSelector(':focus')

View File

@@ -6,7 +6,7 @@ describe "StatusBar", ->
[rootView, editor, statusBar] = []
beforeEach ->
rootView = new RootView(pathToOpen: require.resolve('fixtures/sample.js'))
rootView = new RootView(require.resolve('fixtures/sample.js'))
rootView.simulateDomAttachment()
StatusBar.activate(rootView)
editor = rootView.activeEditor()

View File

@@ -17,7 +17,7 @@ describe "Autocomplete", ->
describe "@activate(rootView)", ->
it "activates autocomplete on all existing and future editors (but not on autocomplete's own mini editor)", ->
rootView = new RootView(pathToOpen: require.resolve('fixtures/sample.js'))
rootView = new RootView(require.resolve('fixtures/sample.js'))
rootView.simulateDomAttachment()
Autocomplete.activate(rootView)
leftEditor = rootView.activeEditor()

View File

@@ -7,7 +7,7 @@ describe 'FileFinder', ->
[rootView, finder] = []
beforeEach ->
rootView = new RootView(pathToOpen: require.resolve('fixtures/sample.js'))
rootView = new RootView(require.resolve('fixtures/sample.js'))
rootView.enableKeymap()
rootView.activateExtension(FileFinder)
finder = FileFinder.instance

View File

@@ -10,7 +10,7 @@ describe "TreeView", ->
[rootView, project, treeView, sampleJs, sampleTxt] = []
beforeEach ->
rootView = new RootView(pathToOpen: require.resolve('fixtures/'))
rootView = new RootView(require.resolve('fixtures/'))
project = rootView.project
rootView.activateExtension(TreeView)
@@ -421,7 +421,7 @@ describe "TreeView", ->
fs.makeDirectory(dirPath)
fs.write(filePath, "doesn't matter")
rootView = new RootView(pathToOpen: rootDirPath)
rootView = new RootView(rootDirPath)
project = rootView.project
treeView = new TreeView(rootView)
treeView.root = treeView.root

View File

@@ -13,7 +13,7 @@ class Cursor extends View
editor: null
wordRegex: /(\w+)|([^\w\s]+)/g
initialize: ({editor, screenPosition}) ->
initialize: ({editor, screenPosition} = {}) ->
@editor = editor
@anchor = new Anchor(@editor, screenPosition)
@selection = @editor.compositeSelection.addSelectionForCursor(this)

View File

@@ -24,7 +24,7 @@ class Editor extends View
@div class: 'vertical-scrollbar', outlet: 'verticalScrollbar', =>
@div outlet: 'verticalScrollbarContent'
@classes: ({mini}) ->
@classes: ({mini} = {}) ->
classes = ['editor']
classes.push 'mini' if mini
classes.join(' ')
@@ -57,7 +57,7 @@ class Editor extends View
new Editor(viewState)
initialize: ({editSessions, activeEditSessionIndex, buffer, isFocused, @mini}) ->
initialize: ({editSessions, activeEditSessionIndex, buffer, isFocused, @mini} = {}) ->
requireStylesheet 'editor.css'
requireStylesheet 'theme/twilight.css'

View File

@@ -21,7 +21,7 @@ class RootView extends View
@div id: 'panes', outlet: 'panes'
@deserialize: ({ projectPath, panesViewState, extensionStates }) ->
rootView = new RootView(pathToOpen: projectPath)
rootView = new RootView(projectPath)
rootView.setRootPane(rootView.deserializeView(panesViewState)) if panesViewState
rootView.extensionStates = extensionStates if extensionStates
rootView
@@ -30,7 +30,7 @@ class RootView extends View
extensionStates: null
fontSize: 18
initialize: ({ pathToOpen }) ->
initialize: (pathToOpen) ->
@extensions = {}
@extensionStates = {}
@project = new Project(pathToOpen)

View File

@@ -14,7 +14,7 @@ class Selection extends View
retainSelection: null
regions: null
initialize: ({@editor, @cursor}) ->
initialize: ({@editor, @cursor} = {}) ->
@regions = []
handleBufferChange: (e) ->

View File

@@ -42,7 +42,7 @@ windowAdditions =
if rootViewState
@rootView = RootView.deserialize(rootViewState)
else
@rootView = new RootView(pathToOpen: pathToOpen)
@rootView = new RootView(pathToOpen)
@rootView.open() unless pathToOpen
$(@rootViewParentSelector).append @rootView

View File

@@ -5,12 +5,12 @@ $ = require 'jquery'
module.exports =
class Dialog extends View
@content: ({prompt}) ->
@content: ({prompt} = {}) ->
@div class: 'tree-view-dialog', =>
@div prompt, outlet: 'prompt'
@subview 'miniEditor', new Editor(mini: true)
initialize: ({path, @onConfirm, select}) ->
initialize: ({path, @onConfirm, select} = {}) ->
@miniEditor.focus()
@on 'tree-view:confirm', => @confirm()
@on 'tree-view:cancel', => @cancel()

View File

@@ -5,7 +5,7 @@ $ = require 'jquery'
module.exports =
class DirectoryView extends View
@content: ({directory, isExpanded}) ->
@content: ({directory, isExpanded} = {}) ->
@li class: 'directory entry', =>
@div outlet: 'header', class: 'header', =>
@span '', class: 'disclosure-arrow', outlet: 'disclosureArrow'
@@ -15,7 +15,7 @@ class DirectoryView extends View
entries: null
header: null
initialize: ({@directory, isExpanded}) ->
initialize: ({@directory, isExpanded} = {}) ->
@expand() if isExpanded
@disclosureArrow.on 'click', => @toggleExpansion()