Include window events in event-palette

Previously these weren't displayed since event the
documentation loop stopped at the document element and
window events weren't included even though they are
applicable for the currently focused element.
This commit is contained in:
Kevin Sawicki
2013-01-07 13:57:57 -08:00
parent 0e082878f3
commit 1f1e0aac78
2 changed files with 15 additions and 1 deletions

View File

@@ -30,6 +30,20 @@ describe "EventPalette", ->
else
expect(eventLi).not.toExist()
it "displays all events registerd on the window", ->
editorEvents = rootView.getActiveEditor().events()
windowEvents = $(window).events()
expect(_.isEmpty(windowEvents)).toBeFalsy()
for eventName, description of windowEvents
eventLi = palette.list.children("[data-event-name='#{eventName}']")
description = editorEvents[eventName] unless description
if description
expect(eventLi).toExist()
expect(eventLi.find('.event-name')).toHaveText(eventName)
expect(eventLi.find('.event-description')).toHaveText(description)
else
expect(eventLi).not.toExist()
it "focuses the mini-editor and selects the first event", ->
expect(palette.miniEditor.isFocused).toBeTruthy()
expect(palette.find('.event:first')).toHaveClass 'selected'

View File

@@ -28,7 +28,7 @@ class EventPalette extends SelectList
@keyBindings = _.losslessInvert(keymap.bindingsForElement(@previouslyFocusedElement))
events = []
for eventName, eventDescription of @previouslyFocusedElement.events()
for eventName, eventDescription of _.extend($(window).events(), @previouslyFocusedElement.events())
events.push({eventName, eventDescription}) if eventDescription
events = _.sortBy events, (e) -> e.eventDescription