Move AtomWindow to it's own file

This commit is contained in:
probablycorey
2013-05-24 14:46:25 -07:00
parent 7aa6c1c08e
commit 6b08d18f4b
3 changed files with 39 additions and 31 deletions

32
src/atom-window.coffee Normal file
View File

@@ -0,0 +1,32 @@
BrowserWindow = require 'browser_window'
ipc = require 'ipc'
module.exports =
class AtomWindow
browserWindow: null
constructor: ({bootstrapScript, resourcePath, pathToOpen, exitWhenDone, @isSpec}) ->
@browserWindow = new BrowserWindow show: false, title: 'Atom'
@handleEvents()
url = "file://#{resourcePath}/static/index.html?bootstrapScript=#{bootstrapScript}&resourcePath=#{resourcePath}"
url += "&pathToOpen=#{pathToOpen}" if pathToOpen
url += '&exitWhenDone=1' if exitWhenDone
@browserWindow.loadUrl url
handleEvents: ->
@browserWindow.on 'destroyed', =>
require('atom-application').removeWindow(this)
if @isSpec
# Spec window's web view should always have focus
@browserWindow.on 'blur', =>
@browserWindow.focusOnWebView()
else
@browserWindow.on 'close', (event) =>
event.preventDefault()
@sendCommand 'window:close'
sendCommand: (command) ->
ipc.sendChannel @browserWindow.getProcessId(), @browserWindow.getRoutingId(), 'command', command