mirror of
https://github.com/atom/atom.git
synced 2026-02-14 16:45:14 -05:00
RootView.initialize no longer assigns window.rootView or calls open
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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: ->
|
||||
|
||||
Reference in New Issue
Block a user