2014-11-28 20:49:41 -05:00
|
|
|
CocoView = require 'views/core/CocoView'
|
2014-11-29 16:36:41 -05:00
|
|
|
template = require 'templates/editor/docs/systems-documentation-view'
|
2014-08-29 01:32:55 -04:00
|
|
|
CocoCollection = require 'collections/CocoCollection'
|
|
|
|
LevelSystem = require 'models/LevelSystem'
|
|
|
|
|
|
|
|
class SystemDocsCollection extends CocoCollection
|
|
|
|
url: '/db/level.system?project=name,description,code'
|
|
|
|
model: LevelSystem
|
|
|
|
comparator: 'name'
|
|
|
|
|
|
|
|
module.exports = class SystemsDocumentationView extends CocoView
|
|
|
|
id: 'systems-documentation-view'
|
|
|
|
template: template
|
|
|
|
className: 'tab-pane'
|
|
|
|
collapsed: true
|
|
|
|
|
|
|
|
events:
|
|
|
|
'click #toggle-all-system-code': 'onToggleAllCode'
|
|
|
|
|
2014-08-31 02:04:45 -04:00
|
|
|
subscriptions:
|
|
|
|
'editor:view-switched': 'onViewSwitched'
|
|
|
|
|
2014-08-29 01:32:55 -04:00
|
|
|
constructor: (options) ->
|
|
|
|
super(options)
|
|
|
|
@systemDocs = new SystemDocsCollection()
|
2014-08-31 02:04:45 -04:00
|
|
|
@loadDocs() unless options.lazy
|
|
|
|
|
|
|
|
loadDocs: ->
|
|
|
|
return if @loadingDocs
|
2014-08-29 01:32:55 -04:00
|
|
|
@supermodel.loadCollection @systemDocs, 'systems'
|
2014-08-31 02:04:45 -04:00
|
|
|
@loadingDocs = true
|
|
|
|
@render()
|
2014-08-29 01:32:55 -04:00
|
|
|
|
|
|
|
getRenderData: ->
|
|
|
|
c = super()
|
|
|
|
c.systems = @systemDocs.models
|
|
|
|
c.marked = marked
|
2014-09-25 16:17:41 -04:00
|
|
|
c.codeLanguage = me.get('aceConfig')?.language ? 'python'
|
2014-08-29 01:32:55 -04:00
|
|
|
c
|
|
|
|
|
|
|
|
onToggleAllCode: (e) ->
|
|
|
|
@collapsed = not @collapsed
|
|
|
|
@$el.find('.collapse').collapse(if @collapsed then 'hide' else 'show')
|
|
|
|
@$el.find('#toggle-all-system-code').toggleClass 'active', not @collapsed
|
2014-08-31 02:04:45 -04:00
|
|
|
|
|
|
|
onViewSwitched: (e) ->
|
|
|
|
return unless e.targetURL is '#editor-level-documentation'
|
|
|
|
@loadDocs()
|