summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/backbone/controllers/tutorials_controller.js.coffee
blob: 6881735b82cb93377890775007bbb998caa9c8ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class CakeSide.Controllers.TutorialsController extends Marionette.Controller
  views: CakeSide.Views.Tutorials
  initialize: (options) ->
    @content_region = CakeSide.Application.content_region
    @tutorials = CakeSide.Application.request('TutorialsRepository')
    @comment_view = CakeSide.Application.request('CommentView')

  index: ->
    @selectTab()
    @comment_view.hide()
    @content_region.show(new @views.IndexView(collection: @tutorials))

  new: ->
    @selectTab()
    @comment_view.hide()
    @content_region.show(new @views.NewView(collection: @tutorials))

  selectTab: ->
    $('.nav-tabs').children().removeClass('active')
    $('#tutorial-tab').addClass('active')