summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/dispatcher.js.coffee
blob: fb149b7f67786072582b64fb663b7cf83f18b911 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
$ ->
  new Dispatcher()
  
class Dispatcher
  constructor: () ->
    @initSearch()
    @initPageScripts()

  initPageScripts: ->
    page = $('body').attr('data-page')
    project_id = $('body').attr('data-project-id')

    console.log(page)
 
    unless page
      return false

    path = page.split(':')

    switch page
      when 'issues:index'
        Issues.init()
      when 'dashboard:show'
        new Dashboard()
      when 'commit:show'
        new Commit()
      when 'groups:show', 'teams:show', 'projects:show'
        Pager.init(20, true)
      when 'projects:new', 'projects:edit'
        new Project()
      when 'walls:show'
        new Wall(project_id)
      when 'teams:members:index'
        new TeamMembers()

    switch path.first()
      when 'admin' then new Admin()
      when 'wikis' then new Wikis()

  initSearch: ->
    autocomplete_json = $('.search-autocomplete-json').data('autocomplete-opts')
    new SearchAutocomplete(autocomplete_json)