gitlab-org--gitlab-foss/app/assets/javascripts/dispatcher.js.coffee

64 lines
1.6 KiB
CoffeeScript
Raw Normal View History

$ ->
new Dispatcher()
class Dispatcher
constructor: () ->
@initSearch()
@initHighlight()
@initPageScripts()
initPageScripts: ->
page = $('body').attr('data-page')
2013-05-02 11:36:53 +00:00
project_id = $('body').attr('data-project-id')
unless page
return false
2013-05-02 11:36:53 +00:00
path = page.split(':')
switch page
when 'projects:issues:index'
2013-05-02 11:36:53 +00:00
Issues.init()
when 'projects:issues:new', 'projects:merge_requests:new'
GitLab.GfmAutoComplete.setup()
2013-05-02 11:36:53 +00:00
when 'dashboard:show'
new Dashboard()
new Activities()
when 'projects:commit:show'
2013-05-02 11:36:53 +00:00
new Commit()
when 'groups:show', 'projects:show'
new Activities()
when 'projects:new', 'projects:edit'
2013-05-02 11:36:53 +00:00
new Project()
when 'projects:walls:show'
2013-05-02 11:36:53 +00:00
new Wall(project_id)
when 'projects:teams:members:index'
2013-05-30 07:57:10 +00:00
new TeamMembers()
2013-07-12 16:01:39 +00:00
when 'groups:members'
new GroupMembers()
when 'projects:tree:show'
new TreeView()
when 'projects:blob:show'
new BlobView()
2013-05-02 11:36:53 +00:00
switch path.first()
when 'admin' then new Admin()
2013-08-08 08:40:42 +00:00
when 'projects'
new Wikis() if path[1] == 'wikis'
2013-05-02 11:36:53 +00:00
initSearch: ->
opts = $('.search-autocomplete-opts')
path = opts.data('autocomplete-path')
project_id = opts.data('autocomplete-project-id')
project_ref = opts.data('autocomplete-project-ref')
new SearchAutocomplete(path, project_id, project_ref)
initHighlight: ->
$('pre code').each (i, e) ->
hljs.highlightBlock(e)
$(e).html($.map($(e).html().split("\n"), (line, i) ->
"<div class='line' id='LC" + (i + 1) + "'>" + line + "</div>"
).join("\n"))