mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-24 08:08:15 -05:00
48 lines
1.4 KiB
CoffeeScript
48 lines
1.4 KiB
CoffeeScript
CocoView = require 'views/kinds/CocoView'
|
|
template = require 'templates/docs/components-documentation-view'
|
|
CocoCollection = require 'collections/CocoCollection'
|
|
LevelComponent = require 'models/LevelComponent'
|
|
|
|
class ComponentDocsCollection extends CocoCollection
|
|
url: '/db/level.component?project=system,name,description,dependencies,propertyDocumentation,code'
|
|
model: LevelComponent
|
|
comparator: 'system'
|
|
|
|
module.exports = class ComponentsDocumentationView extends CocoView
|
|
id: 'components-documentation-view'
|
|
template: template
|
|
className: 'tab-pane'
|
|
collapsed: true
|
|
|
|
events:
|
|
'click #toggle-all-component-code': 'onToggleAllCode'
|
|
|
|
subscriptions:
|
|
'editor:view-switched': 'onViewSwitched'
|
|
|
|
constructor: (options) ->
|
|
super(options)
|
|
@componentDocs = new ComponentDocsCollection()
|
|
@loadDocs() unless options.lazy
|
|
|
|
loadDocs: ->
|
|
return if @loadingDocs
|
|
@supermodel.loadCollection @componentDocs, 'components'
|
|
@loadingDocs = true
|
|
@render()
|
|
|
|
getRenderData: ->
|
|
c = super()
|
|
c.components = @componentDocs.models
|
|
c.marked = marked
|
|
c.codeLanguage = me.get('aceConfig')?.language ? 'python'
|
|
c
|
|
|
|
onToggleAllCode: (e) ->
|
|
@collapsed = not @collapsed
|
|
@$el.find('.collapse').collapse(if @collapsed then 'hide' else 'show')
|
|
@$el.find('#toggle-all-component-code').toggleClass 'active', not @collapsed
|
|
|
|
onViewSwitched: (e) ->
|
|
return unless e.targetURL is '#editor-level-documentation'
|
|
@loadDocs()
|