RootView.initialize no longer assigns window.rootView or calls open

This commit is contained in:
Corey Johnson & Nathan Sobo
2013-02-19 17:18:25 -07:00
parent 0b5ea8578f
commit 9e8831f710
30 changed files with 129 additions and 215 deletions

View File

@@ -27,49 +27,13 @@ class RootView extends View
@deserialize: ({ panesViewState, packageStates, projectPath }) ->
atom.atomPackageStates = packageStates ? {}
rootView = new RootView(null, suppressOpen: true)
rootView = new RootView
rootView.setRootPane(deserialize(panesViewState)) if panesViewState
rootView
title: null
pathToOpenIsFile: false
initialize: (projectOrPathToOpen, { suppressOpen } = {}) ->
window.rootView = this
@handleEvents()
if not projectOrPathToOpen or _.isString(projectOrPathToOpen)
pathToOpen = projectOrPathToOpen
else
pathToOpen = project.getPath()
@pathToOpenIsFile = pathToOpen and fs.isFile(pathToOpen)
config.load()
unless suppressOpen
if pathToOpen
@open(pathToOpen) if @pathToOpenIsFile
else
@open()
serialize: ->
panesViewState: @panes.children().view()?.serialize()
packageStates: atom.serializeAtomPackages()
handleFocus: (e) ->
if @getActiveEditor()
@getActiveEditor().focus()
false
else
@setTitle(null)
focusableChild = this.find("[tabindex=-1]:visible:first")
if focusableChild.length
focusableChild.focus()
false
else
true
handleEvents: ->
initialize: ->
@command 'toggle-dev-tools', => atom.toggleDevTools()
@on 'focus', (e) => @handleFocus(e)
@subscribe $(window), 'focus', (e) =>
@@ -101,6 +65,24 @@ class RootView extends View
@command 'window:toggle-auto-indent-on-paste', =>
config.set("editor.autoIndentOnPaste", !config.get("editor.autoIndentOnPaste"))
serialize: ->
deserializer: 'RootView'
panesViewState: @panes.children().view()?.serialize()
packageStates: atom.serializeAtomPackages()
handleFocus: (e) ->
if @getActiveEditor()
@getActiveEditor().focus()
false
else
@setTitle(null)
focusableChild = this.find("[tabindex=-1]:visible:first")
if focusableChild.length
focusableChild.focus()
false
else
true
afterAttach: (onDom) ->
@focus() if onDom

View File

@@ -30,10 +30,10 @@ windowAdditions =
$(document).on 'keydown', keymap.handleKeyEvent
keymap.bindDefaultKeys()
$(window).on 'core:close', => @close()
$(window).on 'core:close', => window.close()
handleWindowEvents: ->
$(window).command 'window:close', => @close()
$(window).command 'window:close', => window.close()
$(window).command 'window:toggle-full-screen', => atom.toggleFullScreen()
$(window).on 'focus', -> $("body").removeClass('is-blurred')
$(window).on 'blur', -> $("body").addClass('is-blurred')
@@ -42,6 +42,7 @@ windowAdditions =
# Note: RootView assigns itself on window on initialization so that
# window.rootView is available when loading user configuration
startApplication: ->
handleWindowEvents()
config.load()
buildProjectAndRootView()
keymap.loadBundledKeymaps()
@@ -51,6 +52,9 @@ windowAdditions =
$(window).on 'beforeunload', -> stopApplication(); false
$(window).focus()
pathToOpen = atom.getPathToOpen()
rootView.open(pathToOpen) if !pathToOpen or fs.isFile(pathToOpen)
buildProjectAndRootView: ->
RootView = require 'root-view'
Project = require 'project'
@@ -60,7 +64,7 @@ windowAdditions =
window.rootView = deserialize(windowState.rootView)
else
window.project = new Project(atom.getPathToOpen())
window.rootView = new RootView(atom.getPathToOpen())
window.rootView = new RootView
$(rootViewParentSelector).append(rootView)
stopApplication: ->