mirror of
https://github.com/atom/atom.git
synced 2026-02-18 10:31:54 -05:00
Only show events w/ descriptions in EventPalette
Also, auto-generate human readable event name in editor. This is a good example of how we could do this automatically for some kind of `onCommand`, `command`, `onInteractiveEvent` method that combines the event name, documentation string, and handler in one shot.
This commit is contained in:
@@ -13,7 +13,7 @@ class EventPalette extends SelectList
|
||||
@viewClass: ->
|
||||
"#{super} event-palette"
|
||||
|
||||
filterKey: 0 # filter on the event name for now
|
||||
filterKey: 'eventDescription'
|
||||
|
||||
initialize: (@rootView) ->
|
||||
@on 'event-palette:toggle', => @cancel()
|
||||
@@ -21,29 +21,22 @@ class EventPalette extends SelectList
|
||||
|
||||
attach: ->
|
||||
@previouslyFocusedElement = $(':focus')
|
||||
@setArray(@previouslyFocusedElement.events())
|
||||
events = []
|
||||
for eventName, eventDescription of @previouslyFocusedElement.events()
|
||||
events.push({eventName, eventDescription}) if eventDescription
|
||||
@setArray(events)
|
||||
@appendTo(@rootView)
|
||||
@miniEditor.setText('')
|
||||
@miniEditor.focus()
|
||||
|
||||
itemForElement: ([eventName, description]) ->
|
||||
itemForElement: ({eventName, eventDescription}) ->
|
||||
$$ ->
|
||||
@li class: 'event', =>
|
||||
@li class: 'event', 'data-event-name': eventName, =>
|
||||
@div eventDescription, class: 'event-description'
|
||||
@div eventName, class: 'event-name'
|
||||
@div description, class: 'event-description'
|
||||
@div class: 'clear-float'
|
||||
|
||||
populateEventList: ->
|
||||
events = @previouslyFocusedElement.events()
|
||||
table = $$ ->
|
||||
@table =>
|
||||
for [event, description] in events
|
||||
@tr class: 'event', =>
|
||||
@td event, class: 'event-name'
|
||||
@td description if description
|
||||
|
||||
@eventList.html(table)
|
||||
|
||||
confirmed: ([eventName, description]) ->
|
||||
confirmed: ({eventName}) ->
|
||||
@cancel()
|
||||
@previouslyFocusedElement.trigger(eventName)
|
||||
|
||||
|
||||
@@ -6,3 +6,13 @@
|
||||
.event-palette ol {
|
||||
max-height: 300px;
|
||||
}
|
||||
|
||||
.event-palette ol .event-description {
|
||||
float: left;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.event-palette ol .event-name {
|
||||
float: right;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user