dispatcher.js.coffee 974 字节
Newer Older
1 2 3 4 5
$ ->
  new Dispatcher()
  
class Dispatcher
  constructor: () ->
6 7 8 9
    @initSearch()
    @initPageScripts()

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

    console.log(page)
14
 
15 16 17
    unless page
      return false

18
    path = page.split(':')
19 20

    switch page
21 22 23 24 25 26
      when 'issues:index'
        Issues.init()
      when 'dashboard:show'
        new Dashboard()
      when 'commit:show'
        new Commit()
27 28 29
      when 'groups:show', 'teams:show', 'projects:show'
        Pager.init(20, true)
      when 'projects:new', 'projects:edit'
30 31 32
        new Project()
      when 'walls:show'
        new Wall(project_id)
D
Dmitriy Zaporozhets 已提交
33 34
      when 'teams:members:index'
        new TeamMembers()
35 36

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

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