debian-mirror-gitlab/app/assets/javascripts/dispatcher.js.coffee

172 lines
5.6 KiB
CoffeeScript
Raw Normal View History

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