mirror of
https://github.com/atom/atom.git
synced 2026-02-09 06:05:11 -05:00
Unbind default events in window.shutDown to prevent spurious triggering in specs
This commit is contained in:
@@ -10,10 +10,10 @@ class App
|
||||
|
||||
constructor: (@loadPath, nativeMethods)->
|
||||
@windows = []
|
||||
@setupKeymap()
|
||||
@setUpKeymap()
|
||||
@tabText = " "
|
||||
|
||||
setupKeymap: ->
|
||||
setUpKeymap: ->
|
||||
@keymap = new GlobalKeymap()
|
||||
$(document).on 'keydown', (e) => @keymap.handleKeyEvent(e)
|
||||
@keymap.bindDefaultKeys()
|
||||
|
||||
@@ -14,11 +14,18 @@ class GlobalKeymap
|
||||
'meta-n': 'newWindow'
|
||||
'meta-o': 'open'
|
||||
|
||||
$(document).on 'newWindow', => $native.newWindow()
|
||||
$(document).on 'open', =>
|
||||
@_newWindow = => $native.newWindow()
|
||||
@_open = =>
|
||||
url = $native.openDialog()
|
||||
atom.open(url) if url
|
||||
|
||||
$(document).on 'newWindow', @_newWindow
|
||||
$(document).on 'open', @_open
|
||||
|
||||
unbindDefaultKeys: ->
|
||||
$(document).unbind 'newWindow', @_newWindow
|
||||
$(document).unbind 'open', @_open
|
||||
|
||||
bindKeys: (selector, bindings) ->
|
||||
@bindingSets.unshift(new BindingSet(selector, bindings))
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ windowAdditions =
|
||||
keymap: null
|
||||
|
||||
startup: (url) ->
|
||||
@setupKeymap()
|
||||
@setUpKeymap()
|
||||
@attachRootView(url)
|
||||
|
||||
$(window).on 'close', =>
|
||||
@@ -30,11 +30,18 @@ windowAdditions =
|
||||
$(window).unbind('focus')
|
||||
$(window).unbind('blur')
|
||||
atom.windowClosed this
|
||||
@tearDownKeymap()
|
||||
|
||||
setupKeymap: ->
|
||||
setUpKeymap: ->
|
||||
@keymap = new GlobalKeymap()
|
||||
@keymap.bindDefaultKeys()
|
||||
$(document).on 'keydown', (e) => @keymap.handleKeyEvent(e)
|
||||
|
||||
@_handleKeyEvent = (e) => @keymap.handleKeyEvent(e)
|
||||
$(document).on 'keydown', @_handleKeyEvent
|
||||
|
||||
tearDownKeymap: ->
|
||||
@keymap.unbindDefaultKeys()
|
||||
$(document).off 'keydown', @_handleKeyEvent
|
||||
|
||||
attachRootView: (url) ->
|
||||
@rootView = new RootView {url}
|
||||
|
||||
Reference in New Issue
Block a user