mirror of
https://github.com/atom/atom.git
synced 2026-01-25 06:48:28 -05:00
Modernize command-palette package with package.cson
This commit is contained in:
committed by
Corey Johnson & Kevin Sawicki
parent
34c570bed5
commit
f522b2da63
@@ -1,10 +0,0 @@
|
||||
DeferredAtomPackage = require 'deferred-atom-package'
|
||||
|
||||
module.exports =
|
||||
class CommandPalette extends DeferredAtomPackage
|
||||
|
||||
loadEvents: ['command-palette:toggle']
|
||||
|
||||
instanceClass: 'command-palette/src/command-palette-view'
|
||||
|
||||
onLoadEvent: (event, instance) -> instance.attach()
|
||||
@@ -5,8 +5,8 @@ _ = require 'underscore'
|
||||
|
||||
module.exports =
|
||||
class CommandPaletteView extends SelectList
|
||||
@activate: (rootView) ->
|
||||
@instance = new CommandPaletteView(rootView)
|
||||
@activate: ->
|
||||
new CommandPaletteView
|
||||
|
||||
@viewClass: ->
|
||||
"#{super} command-palette overlay from-top"
|
||||
@@ -16,12 +16,17 @@ class CommandPaletteView extends SelectList
|
||||
previouslyFocusedElement: null
|
||||
keyBindings: null
|
||||
|
||||
initialize: (@rootView) ->
|
||||
@command 'command-palette:toggle', =>
|
||||
@cancel()
|
||||
false
|
||||
initialize: ->
|
||||
super
|
||||
|
||||
rootView.command 'command-palette:toggle', => @toggle()
|
||||
|
||||
toggle: ->
|
||||
if @hasParent()
|
||||
@cancel()
|
||||
else
|
||||
@attach()
|
||||
|
||||
attach: ->
|
||||
super
|
||||
|
||||
@@ -34,7 +39,7 @@ class CommandPaletteView extends SelectList
|
||||
events = _.sortBy events, (e) -> e.eventDescription
|
||||
|
||||
@setArray(events)
|
||||
@appendTo(@rootView)
|
||||
@appendTo(rootView)
|
||||
@miniEditor.focus()
|
||||
|
||||
itemForElement: ({eventName, eventDescription}) ->
|
||||
2
src/packages/command-palette/package.cson
Normal file
2
src/packages/command-palette/package.cson
Normal file
@@ -0,0 +1,2 @@
|
||||
'main': 'lib/command-palette-view'
|
||||
'activationEvents': ['command-palette:toggle']
|
||||
@@ -1,17 +1,17 @@
|
||||
RootView = require 'root-view'
|
||||
CommandPalette = require 'command-palette/src/command-palette-view'
|
||||
CommandPalette = require 'command-palette/lib/command-palette-view'
|
||||
$ = require 'jquery'
|
||||
_ = require 'underscore'
|
||||
|
||||
describe "CommandPalette", ->
|
||||
[rootView, palette] = []
|
||||
[palette] = []
|
||||
|
||||
beforeEach ->
|
||||
rootView = new RootView(require.resolve('fixtures/sample.js'))
|
||||
atom.loadPackage("command-palette").getInstance()
|
||||
palette = CommandPalette.instance
|
||||
atom.loadPackage("command-palette")
|
||||
rootView.attachToDom().focus()
|
||||
rootView.trigger 'command-palette:toggle'
|
||||
palette = rootView.find('.command-palette').view()
|
||||
|
||||
afterEach ->
|
||||
rootView.remove()
|
||||
|
||||
Reference in New Issue
Block a user