Reuse existing windows when opening paths from command line

This commit is contained in:
Corey Johnson & Kevin Sawicki
2013-05-28 14:45:54 -07:00
parent ba60324426
commit 7bc905d352
3 changed files with 40 additions and 17 deletions

View File

@@ -2,14 +2,19 @@ $ = require 'jquery'
_ = require 'underscore'
ipc = require 'ipc'
Subscriber = require 'subscriber'
fsUtils = require 'fs-utils'
module.exports =
class WindowEventHandler
constructor: ->
@subscribe ipc, 'command', (command) -> $(window).trigger command
@subscribe ipc, 'command', (command, args...) ->
$(window).trigger(command, args...)
@subscribe $(window), 'focus', -> $("body").removeClass('is-blurred')
@subscribe $(window), 'blur', -> $("body").addClass('is-blurred')
@subscribe $(window), 'window:open-path', (event, pathToOpen) ->
rootView.open(pathToOpen) unless fsUtils.isDirectory(pathToOpen)
@subscribeToCommand $(window), 'window:toggle-full-screen', => atom.toggleFullScreen()
@subscribeToCommand $(window), 'window:close', =>
if rootView?
@@ -30,6 +35,7 @@ class WindowEventHandler
@subscribe $(document), 'click', 'a', @openLink
openLink: (event) =>
location = $(event.target).attr('href')
return unless location