2013-05-02 08:18:29 +00:00
|
|
|
$ ->
|
|
|
|
new Dispatcher()
|
2013-06-24 15:40:23 +00:00
|
|
|
|
2013-05-02 08:18:29 +00:00
|
|
|
class Dispatcher
|
|
|
|
constructor: () ->
|
2013-05-02 11:51:47 +00:00
|
|
|
@initSearch()
|
|
|
|
@initPageScripts()
|
|
|
|
|
|
|
|
initPageScripts: ->
|
2013-05-02 08:18:29 +00:00
|
|
|
page = $('body').attr('data-page')
|
|
|
|
|
2013-05-02 12:28:07 +00:00
|
|
|
unless page
|
|
|
|
return false
|
|
|
|
|
2013-05-02 11:36:53 +00:00
|
|
|
path = page.split(':')
|
2014-08-21 08:14:31 +00:00
|
|
|
shortcut_handler = null
|
2013-05-02 08:18:29 +00:00
|
|
|
|
|
|
|
switch page
|
2013-06-23 16:47:22 +00:00
|
|
|
when 'projects:issues:index'
|
2013-05-02 11:36:53 +00:00
|
|
|
Issues.init()
|
2014-08-21 08:14:31 +00:00
|
|
|
shortcut_handler = new ShortcutsNavigation()
|
2014-02-18 11:15:43 +00:00
|
|
|
when 'projects:issues:show'
|
|
|
|
new Issue()
|
2015-04-18 19:20:15 +00:00
|
|
|
shortcut_handler = new ShortcutsIssuable()
|
2014-09-11 16:19:49 +00:00
|
|
|
new ZenMode()
|
2014-06-04 15:51:01 +00:00
|
|
|
when 'projects:milestones:show'
|
|
|
|
new Milestone()
|
2015-02-20 13:58:42 +00:00
|
|
|
when 'projects:milestones:new', 'projects:milestones:edit'
|
2014-10-01 07:10:13 +00:00
|
|
|
new ZenMode()
|
2015-05-26 04:41:47 +00:00
|
|
|
new DropzoneInput($('.milestone-form'))
|
2015-03-24 07:07:17 +00:00
|
|
|
when 'projects:compare:show'
|
|
|
|
new Diff()
|
2014-09-11 16:19:49 +00:00
|
|
|
when 'projects:issues:new','projects:issues:edit'
|
2014-08-21 08:14:31 +00:00
|
|
|
shortcut_handler = new ShortcutsNavigation()
|
2015-01-15 07:18:21 +00:00
|
|
|
new DropzoneInput($('.issue-form'))
|
2015-06-25 14:17:06 +00:00
|
|
|
new IssuableForm($('.issue-form'))
|
2014-09-11 16:19:49 +00:00
|
|
|
when 'projects:merge_requests:new', 'projects:merge_requests:edit'
|
2014-08-02 15:12:01 +00:00
|
|
|
new Diff()
|
2014-08-21 08:14:31 +00:00
|
|
|
shortcut_handler = new ShortcutsNavigation()
|
2015-01-15 07:18:21 +00:00
|
|
|
new DropzoneInput($('.merge-request-form'))
|
2015-06-25 14:17:06 +00:00
|
|
|
new IssuableForm($('.merge-request-form'))
|
2015-11-05 13:03:48 +00:00
|
|
|
when 'projects:tags:new'
|
|
|
|
new ZenMode()
|
|
|
|
new DropzoneInput($('.tag-form'))
|
2015-11-05 11:15:25 +00:00
|
|
|
when 'projects:releases:edit'
|
|
|
|
new ZenMode()
|
|
|
|
new DropzoneInput($('.release-form'))
|
2014-08-02 15:12:01 +00:00
|
|
|
when 'projects:merge_requests:show'
|
|
|
|
new Diff()
|
2015-04-18 19:20:15 +00:00
|
|
|
shortcut_handler = new ShortcutsIssuable()
|
2014-09-11 16:19:49 +00:00
|
|
|
new ZenMode()
|
2014-08-02 15:12:01 +00:00
|
|
|
when "projects:merge_requests:diffs"
|
|
|
|
new Diff()
|
2015-01-15 08:15:12 +00:00
|
|
|
new ZenMode()
|
2014-08-21 08:14:31 +00:00
|
|
|
when 'projects:merge_requests:index'
|
|
|
|
shortcut_handler = new ShortcutsNavigation()
|
2015-03-12 23:20:58 +00:00
|
|
|
MergeRequests.init()
|
2015-06-10 08:36:09 +00:00
|
|
|
when 'dashboard:show', 'root:show'
|
2013-05-02 11:36:53 +00:00
|
|
|
new Dashboard()
|
2015-08-25 12:13:04 +00:00
|
|
|
when 'dashboard:activity'
|
2013-08-26 13:30:03 +00:00
|
|
|
new Activities()
|
2015-03-09 21:12:03 +00:00
|
|
|
when 'dashboard:projects:starred'
|
|
|
|
new Activities()
|
2013-06-23 16:47:22 +00:00
|
|
|
when 'projects:commit:show'
|
2013-05-02 11:36:53 +00:00
|
|
|
new Commit()
|
2014-08-02 15:12:01 +00:00
|
|
|
new Diff()
|
2015-02-20 13:58:42 +00:00
|
|
|
new ZenMode()
|
2014-08-21 08:14:31 +00:00
|
|
|
shortcut_handler = new ShortcutsNavigation()
|
|
|
|
when 'projects:commits:show'
|
|
|
|
shortcut_handler = new ShortcutsNavigation()
|
2015-07-07 14:01:12 +00:00
|
|
|
when 'projects:activity'
|
2015-07-08 10:43:46 +00:00
|
|
|
shortcut_handler = new ShortcutsNavigation()
|
2015-07-07 14:01:12 +00:00
|
|
|
when 'projects:show'
|
2014-08-21 08:14:31 +00:00
|
|
|
shortcut_handler = new ShortcutsNavigation()
|
2015-03-05 01:22:55 +00:00
|
|
|
when 'groups:show'
|
|
|
|
new Activities()
|
|
|
|
shortcut_handler = new ShortcutsNavigation()
|
2015-03-13 15:27:51 +00:00
|
|
|
when 'groups:group_members:index'
|
2013-06-17 13:51:43 +00:00
|
|
|
new GroupMembers()
|
2014-10-21 22:19:16 +00:00
|
|
|
new UsersSelect()
|
2015-03-13 15:30:36 +00:00
|
|
|
when 'projects:project_members:index'
|
|
|
|
new ProjectMembers()
|
|
|
|
new UsersSelect()
|
2014-10-20 22:49:59 +00:00
|
|
|
when 'groups:new', 'groups:edit', 'admin:groups:edit'
|
|
|
|
new GroupAvatar()
|
2013-06-26 13:58:56 +00:00
|
|
|
when 'projects:tree:show'
|
|
|
|
new TreeView()
|
2014-08-21 08:14:31 +00:00
|
|
|
shortcut_handler = new ShortcutsNavigation()
|
2013-06-26 13:58:56 +00:00
|
|
|
when 'projects:blob:show'
|
2015-06-15 21:53:39 +00:00
|
|
|
new LineHighlighter()
|
2014-08-21 08:14:31 +00:00
|
|
|
shortcut_handler = new ShortcutsNavigation()
|
2014-08-18 16:23:45 +00:00
|
|
|
when 'projects:labels:new', 'projects:labels:edit'
|
2014-08-11 18:15:12 +00:00
|
|
|
new Labels()
|
2014-08-21 08:14:31 +00:00
|
|
|
when 'projects:network:show'
|
|
|
|
# Ensure we don't create a particular shortcut handler here. This is
|
|
|
|
# already created, where the network graph is created.
|
|
|
|
shortcut_handler = true
|
2014-11-14 14:06:39 +00:00
|
|
|
when 'projects:forks:new'
|
|
|
|
new ProjectFork()
|
2014-10-21 08:40:36 +00:00
|
|
|
when 'users:show'
|
|
|
|
new User()
|
2015-03-22 22:40:26 +00:00
|
|
|
new Activities()
|
2013-05-02 11:36:53 +00:00
|
|
|
|
|
|
|
switch path.first()
|
2014-10-21 20:52:38 +00:00
|
|
|
when 'admin'
|
|
|
|
new Admin()
|
|
|
|
switch path[1]
|
2014-10-21 22:19:16 +00:00
|
|
|
when 'groups'
|
|
|
|
new UsersSelect()
|
2014-10-21 20:52:38 +00:00
|
|
|
when 'projects'
|
|
|
|
new NamespaceSelect()
|
2014-08-21 08:14:31 +00:00
|
|
|
when 'dashboard'
|
|
|
|
shortcut_handler = new ShortcutsDashboardNavigation()
|
2014-10-21 08:40:36 +00:00
|
|
|
when 'profiles'
|
|
|
|
new Profile()
|
2013-08-08 08:40:42 +00:00
|
|
|
when 'projects'
|
2014-10-21 20:39:34 +00:00
|
|
|
new Project()
|
2015-01-19 20:37:20 +00:00
|
|
|
new ProjectAvatar()
|
2014-08-21 08:14:31 +00:00
|
|
|
switch path[1]
|
2015-03-24 07:07:17 +00:00
|
|
|
when 'compare'
|
|
|
|
shortcut_handler = new ShortcutsNavigation()
|
2014-10-21 20:39:34 +00:00
|
|
|
when 'edit'
|
|
|
|
shortcut_handler = new ShortcutsNavigation()
|
|
|
|
new ProjectNew()
|
|
|
|
when 'new'
|
|
|
|
new ProjectNew()
|
|
|
|
when 'show'
|
|
|
|
new ProjectShow()
|
2014-08-21 08:14:31 +00:00
|
|
|
when 'wikis'
|
|
|
|
new Wikis()
|
|
|
|
shortcut_handler = new ShortcutsNavigation()
|
2014-10-01 07:10:13 +00:00
|
|
|
new ZenMode()
|
2015-01-15 07:18:21 +00:00
|
|
|
new DropzoneInput($('.wiki-form'))
|
2015-07-21 17:15:52 +00:00
|
|
|
when 'snippets'
|
|
|
|
shortcut_handler = new ShortcutsNavigation()
|
|
|
|
new ZenMode() if path[2] == 'show'
|
|
|
|
when 'labels', 'graphs'
|
2014-08-21 08:14:31 +00:00
|
|
|
shortcut_handler = new ShortcutsNavigation()
|
2015-03-13 15:22:03 +00:00
|
|
|
when 'project_members', 'deploy_keys', 'hooks', 'services', 'protected_branches'
|
2014-08-21 08:14:31 +00:00
|
|
|
shortcut_handler = new ShortcutsNavigation()
|
|
|
|
|
2013-08-08 08:40:42 +00:00
|
|
|
|
2014-08-21 08:14:31 +00:00
|
|
|
# If we haven't installed a custom shortcut handler, install the default one
|
|
|
|
if not shortcut_handler
|
|
|
|
new Shortcuts()
|
2013-05-02 11:36:53 +00:00
|
|
|
|
2013-05-02 11:51:47 +00:00
|
|
|
initSearch: ->
|
2014-01-18 12:16:46 +00: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)
|