mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
RootView is initialized with a url and opens it with its editor
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user