RootView is initialized with a url and opens it with its editor

This commit is contained in:
Corey Johnson & Nathan Sobo
2012-01-03 13:57:10 -08:00
parent 2cfea9fa42
commit f8b04cd902
3 changed files with 20 additions and 8 deletions

View File

@@ -6,6 +6,21 @@ describe "RootView", ->
rootView = null
beforeEach -> rootView = RootView.build()
describe "initialize", ->
describe "when called with a url", ->
it "opens the given url in the editor", ->
url = require.resolve 'fixtures/sample.txt'
rootView = RootView.build {url}
expect(rootView.editor.buffer.url).toBe url
describe "when not called with a url", ->
it "opens an empty buffer", ->
url = null
rootView = RootView.build {url}
expect(rootView.editor.buffer.url).toBeNull()
describe ".addPane(view)", ->
it "adds the given view to the rootView (at the bottom by default)", ->
expect(rootView.vertical.children().length).toBe 1

View File

@@ -7,11 +7,6 @@ Template = require 'template'
module.exports =
class RootView extends Template
@attach: ->
view = @build()
$('body').append view
view
content: ->
@link rel: 'stylesheet', href: "#{require.resolve('atom.css')}?#{(new Date).getTime()}"
@div id: 'app-horizontal', =>
@@ -20,11 +15,13 @@ class RootView extends Template
@subview 'editor', Editor.build()
viewProperties:
initialize: ->
initialize: ({url}) ->
@bindKey 'meta+s', => @editor.save()
@bindKey 'meta+w', => window.close()
@bindKey 'meta+t', => @toggleFileFinder()
@editor.open url
addPane: (view) ->
pane = $('<div class="pane">')
pane.append(view)

View File

@@ -13,8 +13,8 @@ windowAdditions =
startup: ->
@menuItemActions = {}
@rootView = RootView.attach()
@rootView.editor.open $atomController.url?.toString()
@rootView = RootView.build(url: $atomController.url?.toString())
$('body').append @rootView
@registerEventHandlers()
@bindMenuItems()
$(window).focus()