document.coffee 842 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. class app.views.Document extends app.View
  2. @el: document
  3. @shortcuts:
  4. help: 'onHelp'
  5. escape: 'onEscape'
  6. superLeft: 'onBack'
  7. superRight: 'onForward'
  8. init: ->
  9. @addSubview @nav = new app.views.Nav,
  10. @addSubview @sidebar = new app.views.Sidebar
  11. @addSubview @content = new app.views.Content
  12. @addSubview @path = new app.views.Path unless app.isSingleDoc() or app.isMobile()
  13. @setTitle()
  14. @activate()
  15. return
  16. setTitle: (title) ->
  17. @el.title = if title then "DevDocs/#{title}" else 'DevDocs'
  18. onHelp: ->
  19. app.router.show '/help#shortcuts'
  20. onEscape: ->
  21. path = if !app.isSingleDoc() or location.pathname is app.doc.fullPath()
  22. '/'
  23. else
  24. app.doc.fullPath()
  25. app.router.show(path)
  26. onBack: ->
  27. history.back()
  28. onForward: ->
  29. history.forward()