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()
|
|
|
|
@initPageScripts()
|
|
|
|
|
|
|
|
initPageScripts: ->
|
2013-05-02 04:18:29 -04:00
|
|
|
page = $('body').attr('data-page')
|
|
|
|
|
2013-05-02 08:28:07 -04:00
|
|
|
unless page
|
|
|
|
return false
|
|
|
|
|
2013-05-02 07:36:53 -04:00
|
|
|
path = page.split(':')
|
2014-08-21 04:14:31 -04:00
|
|
|
shortcut_handler = null
|
2013-05-02 04:18:29 -04:00
|
|
|
switch page
|
2013-06-23 12:47:22 -04:00
|
|
|
when 'projects:issues:index'
|
2016-04-20 12:00:12 -04:00
|
|
|
Issuable.init()
|
2016-05-05 18:10:54 -04:00
|
|
|
new IssuableBulkActions()
|
2014-08-21 04:14:31 -04:00
|
|
|
shortcut_handler = new ShortcutsNavigation()
|
2014-02-18 06:15:43 -05:00
|
|
|
when 'projects:issues:show'
|
|
|
|
new Issue()
|
2015-04-18 15:20:15 -04:00
|
|
|
shortcut_handler = new ShortcutsIssuable()
|
2014-09-11 12:19:49 -04:00
|
|
|
new ZenMode()
|
2016-03-06 23:07:19 -05:00
|
|
|
when 'projects:milestones:show', 'groups:milestones:show', 'dashboard:milestones:show'
|
2014-06-04 11:51:01 -04:00
|
|
|
new Milestone()
|
2016-02-23 15:09:35 -05:00
|
|
|
when 'dashboard:todos:index'
|
|
|
|
new Todos()
|
2015-02-20 08:58:42 -05:00
|
|
|
when 'projects:milestones:new', 'projects:milestones:edit'
|
2014-10-01 03:10:13 -04:00
|
|
|
new ZenMode()
|
2016-04-05 05:42:38 -04:00
|
|
|
new GLForm($('.milestone-form'))
|
2015-11-16 09:07:16 -05:00
|
|
|
when 'groups:milestones:new'
|
|
|
|
new ZenMode()
|
2015-03-24 03:07:17 -04:00
|
|
|
when 'projects:compare:show'
|
|
|
|
new Diff()
|
2014-09-11 12:19:49 -04:00
|
|
|
when 'projects:issues:new','projects:issues:edit'
|
2014-08-21 04:14:31 -04:00
|
|
|
shortcut_handler = new ShortcutsNavigation()
|
2016-04-05 05:34:02 -04:00
|
|
|
new GLForm($('.issue-form'))
|
2015-06-25 10:17:06 -04:00
|
|
|
new IssuableForm($('.issue-form'))
|
2014-09-11 12:19:49 -04:00
|
|
|
when 'projects:merge_requests:new', 'projects:merge_requests:edit'
|
2014-08-02 11:12:01 -04:00
|
|
|
new Diff()
|
2014-08-21 04:14:31 -04:00
|
|
|
shortcut_handler = new ShortcutsNavigation()
|
2016-04-05 05:39:16 -04:00
|
|
|
new GLForm($('.merge-request-form'))
|
2015-06-25 10:17:06 -04:00
|
|
|
new IssuableForm($('.merge-request-form'))
|
2015-11-05 08:03:48 -05:00
|
|
|
when 'projects:tags:new'
|
|
|
|
new ZenMode()
|
2016-04-05 07:33:30 -04:00
|
|
|
new GLForm($('.tag-form'))
|
2015-11-05 06:15:25 -05:00
|
|
|
when 'projects:releases:edit'
|
|
|
|
new ZenMode()
|
2016-04-05 07:33:30 -04:00
|
|
|
new GLForm($('.release-form'))
|
2014-08-02 11:12:01 -04:00
|
|
|
when 'projects:merge_requests:show'
|
|
|
|
new Diff()
|
2015-12-27 20:34:46 -05:00
|
|
|
shortcut_handler = new ShortcutsIssuable(true)
|
2014-09-11 12:19:49 -04:00
|
|
|
new ZenMode()
|
2014-08-02 11:12:01 -04:00
|
|
|
when "projects:merge_requests:diffs"
|
|
|
|
new Diff()
|
2015-01-15 03:15:12 -05:00
|
|
|
new ZenMode()
|
2014-08-21 04:14:31 -04:00
|
|
|
when 'projects:merge_requests:index'
|
|
|
|
shortcut_handler = new ShortcutsNavigation()
|
2016-04-20 12:00:12 -04:00
|
|
|
Issuable.init()
|
2015-08-25 08:13:04 -04:00
|
|
|
when 'dashboard:activity'
|
2013-08-26 09:30:03 -04:00
|
|
|
new Activities()
|
2015-03-09 17:12:03 -04:00
|
|
|
when 'dashboard:projects:starred'
|
|
|
|
new Activities()
|
2013-06-23 12:47:22 -04:00
|
|
|
when 'projects:commit:show'
|
2013-05-02 07:36:53 -04:00
|
|
|
new Commit()
|
2014-08-02 11:12:01 -04:00
|
|
|
new Diff()
|
2015-02-20 08:58:42 -05:00
|
|
|
new ZenMode()
|
2014-08-21 04:14:31 -04:00
|
|
|
shortcut_handler = new ShortcutsNavigation()
|
|
|
|
when 'projects:commits:show'
|
|
|
|
shortcut_handler = new ShortcutsNavigation()
|
2015-07-07 10:01:12 -04:00
|
|
|
when 'projects:activity'
|
2015-07-08 06:43:46 -04:00
|
|
|
shortcut_handler = new ShortcutsNavigation()
|
2015-07-07 10:01:12 -04:00
|
|
|
when 'projects:show'
|
2014-08-21 04:14:31 -04:00
|
|
|
shortcut_handler = new ShortcutsNavigation()
|
2016-02-23 04:06:26 -05:00
|
|
|
|
2016-02-23 08:41:03 -05:00
|
|
|
new TreeView() if $('#tree-slider').length
|
2016-03-10 08:29:38 -05:00
|
|
|
when 'groups:activity'
|
2015-03-04 20:22:55 -05:00
|
|
|
new Activities()
|
2016-03-10 08:29:38 -05:00
|
|
|
when 'groups:show'
|
2015-03-04 20:22:55 -05:00
|
|
|
shortcut_handler = new ShortcutsNavigation()
|
2015-03-13 11:27:51 -04:00
|
|
|
when 'groups:group_members:index'
|
2013-06-17 09:51:43 -04:00
|
|
|
new GroupMembers()
|
2014-10-21 18:19:16 -04:00
|
|
|
new UsersSelect()
|
2015-03-13 11:30:36 -04:00
|
|
|
when 'projects:project_members:index'
|
|
|
|
new ProjectMembers()
|
|
|
|
new UsersSelect()
|
2015-12-08 08:19:39 -05:00
|
|
|
when 'groups:new', 'groups:edit', 'admin:groups:edit', 'admin:groups:new'
|
2014-10-20 18:49:59 -04:00
|
|
|
new GroupAvatar()
|
2013-06-26 09:58:56 -04:00
|
|
|
when 'projects:tree:show'
|
2016-02-23 20:04:20 -05:00
|
|
|
shortcut_handler = new ShortcutsNavigation()
|
2013-06-26 09:58:56 -04:00
|
|
|
new TreeView()
|
2016-01-07 06:56:18 -05:00
|
|
|
when 'projects:find_file:show'
|
|
|
|
shortcut_handler = true
|
2016-02-22 09:09:13 -05:00
|
|
|
when 'projects:blob:show', 'projects:blame:show'
|
2015-06-15 17:53:39 -04:00
|
|
|
new LineHighlighter()
|
2014-08-21 04:14:31 -04:00
|
|
|
shortcut_handler = new ShortcutsNavigation()
|
2014-08-18 12:23:45 -04:00
|
|
|
when 'projects:labels:new', 'projects:labels:edit'
|
2014-08-11 14:15:12 -04:00
|
|
|
new Labels()
|
2016-05-02 19:19:46 -04:00
|
|
|
when 'projects:labels:index'
|
2016-06-03 02:37:23 -04:00
|
|
|
new LabelManager() if $('.prioritized-labels').length
|
2014-08-21 04:14:31 -04: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 09:06:39 -05:00
|
|
|
when 'projects:forks:new'
|
|
|
|
new ProjectFork()
|
2016-01-21 09:51:44 -05:00
|
|
|
when 'projects:artifacts:browse'
|
|
|
|
new BuildArtifacts()
|
2016-03-11 12:37:46 -05:00
|
|
|
when 'projects:group_links:index'
|
|
|
|
new GroupsSelect()
|
2016-04-15 09:13:21 -04:00
|
|
|
when 'search:show'
|
2016-04-15 10:55:31 -04:00
|
|
|
new Search()
|
2013-05-02 07:36:53 -04:00
|
|
|
|
|
|
|
switch path.first()
|
2014-10-21 16:52:38 -04:00
|
|
|
when 'admin'
|
|
|
|
new Admin()
|
|
|
|
switch path[1]
|
2014-10-21 18:19:16 -04:00
|
|
|
when 'groups'
|
|
|
|
new UsersSelect()
|
2014-10-21 16:52:38 -04:00
|
|
|
when 'projects'
|
|
|
|
new NamespaceSelect()
|
2016-05-17 01:35:16 -04:00
|
|
|
when 'dashboard', 'root'
|
2014-08-21 04:14:31 -04:00
|
|
|
shortcut_handler = new ShortcutsDashboardNavigation()
|
2014-10-21 04:40:36 -04:00
|
|
|
when 'profiles'
|
|
|
|
new Profile()
|
2013-08-08 04:40:42 -04:00
|
|
|
when 'projects'
|
2014-10-21 16:39:34 -04:00
|
|
|
new Project()
|
2015-01-19 15:37:20 -05:00
|
|
|
new ProjectAvatar()
|
2014-08-21 04:14:31 -04:00
|
|
|
switch path[1]
|
2015-03-24 03:07:17 -04:00
|
|
|
when 'compare'
|
|
|
|
shortcut_handler = new ShortcutsNavigation()
|
2014-10-21 16:39:34 -04:00
|
|
|
when 'edit'
|
|
|
|
shortcut_handler = new ShortcutsNavigation()
|
|
|
|
new ProjectNew()
|
|
|
|
when 'new'
|
|
|
|
new ProjectNew()
|
|
|
|
when 'show'
|
|
|
|
new ProjectShow()
|
2014-08-21 04:14:31 -04:00
|
|
|
when 'wikis'
|
|
|
|
new Wikis()
|
|
|
|
shortcut_handler = new ShortcutsNavigation()
|
2014-10-01 03:10:13 -04:00
|
|
|
new ZenMode()
|
2016-04-05 07:33:30 -04:00
|
|
|
new GLForm($('.wiki-form'))
|
2015-07-21 13:15:52 -04:00
|
|
|
when 'snippets'
|
|
|
|
shortcut_handler = new ShortcutsNavigation()
|
|
|
|
new ZenMode() if path[2] == 'show'
|
|
|
|
when 'labels', 'graphs'
|
2014-08-21 04:14:31 -04:00
|
|
|
shortcut_handler = new ShortcutsNavigation()
|
2015-03-13 11:22:03 -04:00
|
|
|
when 'project_members', 'deploy_keys', 'hooks', 'services', 'protected_branches'
|
2014-08-21 04:14:31 -04:00
|
|
|
shortcut_handler = new ShortcutsNavigation()
|
|
|
|
|
|
|
|
# If we haven't installed a custom shortcut handler, install the default one
|
|
|
|
if not shortcut_handler
|
|
|
|
new Shortcuts()
|
2013-05-02 07:36:53 -04:00
|
|
|
|
2013-05-02 07:51:47 -04:00
|
|
|
initSearch: ->
|
2016-03-26 18:56:51 -04:00
|
|
|
|
|
|
|
# Only when search form is present
|
|
|
|
new SearchAutocomplete() if $('.search').length
|