Moved default bindings from Global keymap constructor to a separate method.

This commit is contained in:
Corey Johnson
2012-03-06 14:51:11 -08:00
parent 8129183486
commit a4011ef6d5
3 changed files with 8 additions and 8 deletions

View File

@@ -15,8 +15,8 @@ class App
setupKeymap: ->
@keymap = new GlobalKeymap()
$(document).on 'keydown', (e) => @keymap.handleKeyEvent(e)
@keymap.bindDefaultKeys()
open: (url) ->
$native.open url

View File

@@ -9,15 +9,15 @@ class GlobalKeymap
constructor: ->
@bindingSets = []
bindDefaultKeys: ->
@bindKeys "*",
'meta-n': 'newWindow'
'meta-o': 'open'
$(document).on 'newWindow', => $native.newWindow()
$(document).on 'open', =>
$(document).on 'open', =>
url = $native.openDialog()
atom.open(url) if url
bindKeys: (selector, bindings) ->
@bindingSets.unshift(new BindingSet(selector, bindings))
@@ -29,7 +29,7 @@ class GlobalKeymap
handleKeyEvent: (event) ->
event.keystroke = @keystrokeStringForEvent(event)
currentNode = $(event.target)
currentNode = $(event.target)
while currentNode.length
candidateBindingSets = @bindingSets.filter (set) -> currentNode.is(set.selector)
candidateBindingSets.sort (a, b) -> b.specificity - a.specificity

View File

@@ -15,11 +15,11 @@ windowAdditions =
startup: (url) ->
@setupKeymap()
@attachRootView(url)
$(window).on 'close', =>
$(window).on 'close', =>
@shutdown()
@close()
$(window).focus()
atom.windowOpened this
@@ -31,7 +31,7 @@ windowAdditions =
setupKeymap: ->
@keymap = new GlobalKeymap()
@keymap.bindDefaultKeys()
$(document).on 'keydown', (e) => @keymap.handleKeyEvent(e)
attachRootView: (url) ->