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

147 lines
4.6 KiB
CoffeeScript
Raw Normal View History

$ ->
new Dispatcher()
class Dispatcher
constructor: () ->
@initSearch()
@initPageScripts()
initPageScripts: ->
page = $('body').attr('data-page')
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
switch page
when 'projects:issues:index'
2013-05-02 07:36:53 -04:00
Issues.init()
2014-08-21 04:14:31 -04:00
shortcut_handler = new ShortcutsNavigation()
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()
when 'projects:milestones:show'
new Milestone()
when 'projects:milestones:new', 'projects:milestones:edit'
2014-10-01 03:10:13 -04:00
new ZenMode()
new DropzoneInput($('.milestone-form'))
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()
new DropzoneInput($('.issue-form'))
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()
new DropzoneInput($('.merge-request-form'))
new IssuableForm($('.merge-request-form'))
2014-08-02 11:12:01 -04:00
when 'projects:merge_requests:show'
new Diff()
2015-04-18 15:20:15 -04:00
shortcut_handler = new ShortcutsIssuable()
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()
new ZenMode()
2014-08-21 04:14:31 -04:00
when 'projects:merge_requests:index'
shortcut_handler = new ShortcutsNavigation()
MergeRequests.init()
when 'dashboard:show', 'root:show'
2013-05-02 07:36:53 -04:00
new Dashboard()
new Activities()
2015-03-09 17:12:03 -04:00
when 'dashboard:projects:starred'
new Activities()
new ProjectsList()
when 'projects:commit:show'
2013-05-02 07:36:53 -04:00
new Commit()
2014-08-02 11:12:01 -04:00
new Diff()
new ZenMode()
2014-08-21 04:14:31 -04:00
shortcut_handler = new ShortcutsNavigation()
when 'projects:commits:show'
shortcut_handler = new ShortcutsNavigation()
when 'projects:show'
new Activities()
2014-08-21 04:14:31 -04:00
shortcut_handler = new ShortcutsNavigation()
when 'groups:show'
new Activities()
shortcut_handler = new ShortcutsNavigation()
new ProjectsList()
when 'groups:group_members:index'
new GroupMembers()
new UsersSelect()
when 'projects:project_members:index'
new ProjectMembers()
new UsersSelect()
when 'groups:new', 'groups:edit', 'admin:groups:edit'
new GroupAvatar()
when 'projects:tree:show'
new TreeView()
2014-08-21 04:14:31 -04:00
shortcut_handler = new ShortcutsNavigation()
when 'projects:blob:show'
2015-06-15 17:53:39 -04:00
new LineHighlighter()
2014-08-21 04:14:31 -04:00
shortcut_handler = new ShortcutsNavigation()
when 'projects:labels:new', 'projects:labels:edit'
new Labels()
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
when 'projects:forks:new'
new ProjectFork()
when 'users:show'
new User()
new Activities()
2015-03-24 11:04:30 -04:00
when 'admin:users:show'
new ProjectsList()
2013-05-02 07:36:53 -04:00
switch path.first()
when 'admin'
new Admin()
switch path[1]
when 'groups'
new UsersSelect()
when 'projects'
new NamespaceSelect()
2014-08-21 04:14:31 -04:00
when 'dashboard'
shortcut_handler = new ShortcutsDashboardNavigation()
when 'profiles'
new Profile()
2013-08-08 04:40:42 -04:00
when 'projects'
new Project()
new ProjectAvatar()
2014-08-21 04:14:31 -04:00
switch path[1]
when 'compare'
shortcut_handler = new ShortcutsNavigation()
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()
new DropzoneInput($('.wiki-form'))
2014-08-21 04:14:31 -04:00
when 'snippets', 'labels', 'graphs'
shortcut_handler = new ShortcutsNavigation()
when 'project_members', 'deploy_keys', 'hooks', 'services', 'protected_branches'
2014-08-21 04:14:31 -04:00
shortcut_handler = new ShortcutsNavigation()
2013-08-08 04:40:42 -04:00
2014-08-21 04:14:31 -04:00
# 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
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)