Extract command panel as an extension

This commit is contained in:
Corey Johnson
2012-05-08 13:49:06 -07:00
parent 935ae3323e
commit 77baa7be09
4 changed files with 30 additions and 18 deletions

View File

@@ -5,6 +5,22 @@ Editor = require 'editor'
module.exports =
class CommandPanel extends View
@activate: (rootView, state) ->
requireStylesheet 'command-panel.css'
if state?
@instance = CommandPanel.deserialize(state, rootView)
else
@instance = new CommandPanel(rootView)
@serialize: ->
text: @instance.editor.getText()
visible: @instance.hasParent()
@deserialize: (state, rootView) ->
commandPanel = new CommandPanel(rootView)
commandPanel.show(state.text) if state.visible
commandPanel
@content: ->
@div class: 'command-panel', =>
@div ':', class: 'prompt', outlet: 'prompt'
@@ -14,9 +30,7 @@ class CommandPanel extends View
history: null
historyIndex: 0
initialize: ({@rootView})->
requireStylesheet 'command-panel.css'
initialize: (@rootView)->
@commandInterpreter = new CommandInterpreter()
@history = []