2013-05-02 04:18:29 -04:00
|
|
|
$ ->
|
|
|
|
new Dispatcher()
|
2013-06-24 11:40:23 -04:00
|
|
|
|
2013-05-02 04:18:29 -04:00
|
|
|
class Dispatcher
|
|
|
|
constructor: () ->
|
2013-05-02 07:51:47 -04:00
|
|
|
@initSearch()
|
2014-01-27 07:21:40 -05:00
|
|
|
@initHighlight()
|
2013-05-02 07:51:47 -04:00
|
|
|
@initPageScripts()
|
|
|
|
|
|
|
|
initPageScripts: ->
|
2013-05-02 04:18:29 -04:00
|
|
|
page = $('body').attr('data-page')
|
2013-05-02 07:36:53 -04:00
|
|
|
project_id = $('body').attr('data-project-id')
|
2013-05-02 04:18:29 -04:00
|
|
|
|
2013-05-02 08:28:07 -04:00
|
|
|
unless page
|
|
|
|
return false
|
|
|
|
|
2013-05-02 07:36:53 -04:00
|
|
|
path = page.split(':')
|
2013-05-02 04:18:29 -04:00
|
|
|
|
|
|
|
switch page
|
2013-06-23 12:47:22 -04:00
|
|
|
when 'projects:issues:index'
|
2013-05-02 07:36:53 -04:00
|
|
|
Issues.init()
|
2014-02-18 06:15:43 -05:00
|
|
|
when 'projects:issues:show'
|
|
|
|
new Issue()
|
2013-09-09 10:11:58 -04:00
|
|
|
when 'projects:issues:new', 'projects:merge_requests:new'
|
|
|
|
GitLab.GfmAutoComplete.setup()
|
2013-05-02 07:36:53 -04:00
|
|
|
when 'dashboard:show'
|
|
|
|
new Dashboard()
|
2013-08-26 09:30:03 -04:00
|
|
|
new Activities()
|
2013-06-23 12:47:22 -04:00
|
|
|
when 'projects:commit:show'
|
2013-05-02 07:36:53 -04:00
|
|
|
new Commit()
|
2013-06-23 12:47:22 -04:00
|
|
|
when 'groups:show', 'projects:show'
|
2013-08-26 09:30:03 -04:00
|
|
|
new Activities()
|
2013-05-02 04:46:45 -04:00
|
|
|
when 'projects:new', 'projects:edit'
|
2013-05-02 07:36:53 -04:00
|
|
|
new Project()
|
2013-06-23 12:47:22 -04:00
|
|
|
when 'projects:walls:show'
|
2013-05-02 07:36:53 -04:00
|
|
|
new Wall(project_id)
|
2013-06-23 12:47:22 -04:00
|
|
|
when 'projects:teams:members:index'
|
2013-05-30 03:57:10 -04:00
|
|
|
new TeamMembers()
|
2013-07-12 12:01:39 -04:00
|
|
|
when 'groups:members'
|
2013-06-17 09:51:43 -04:00
|
|
|
new GroupMembers()
|
2013-06-26 09:58:56 -04:00
|
|
|
when 'projects:tree:show'
|
|
|
|
new TreeView()
|
|
|
|
when 'projects:blob:show'
|
|
|
|
new BlobView()
|
2013-05-02 07:36:53 -04:00
|
|
|
|
|
|
|
switch path.first()
|
2013-05-02 07:51:47 -04:00
|
|
|
when 'admin' then new Admin()
|
2013-08-08 04:40:42 -04:00
|
|
|
when 'projects'
|
|
|
|
new Wikis() if path[1] == 'wikis'
|
|
|
|
|
2013-05-02 07:36:53 -04:00
|
|
|
|
2013-05-02 07:51:47 -04:00
|
|
|
initSearch: ->
|
2014-01-18 07:16:46 -05:00
|
|
|
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)
|
2014-01-27 07:21:40 -05:00
|
|
|
|
|
|
|
initHighlight: ->
|
2014-01-27 11:18:18 -05:00
|
|
|
$('.highlight pre code').each (i, e) ->
|
2014-01-27 07:21:40 -05:00
|
|
|
hljs.highlightBlock(e)
|
|
|
|
$(e).html($.map($(e).html().split("\n"), (line, i) ->
|
|
|
|
"<div class='line' id='LC" + (i + 1) + "'>" + line + "</div>"
|
|
|
|
).join("\n"))
|