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

151 lines
4.8 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'
Issues.init()
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()
2014-09-02 18:07:02 +05:30
when 'projects:milestones:show'
new Milestone()
2015-04-26 12:48:37 +05:30
when 'projects:milestones:new', 'projects:milestones:edit'
new ZenMode()
2015-09-11 14:41:01 +05:30
new DropzoneInput($('.milestone-form'))
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()
new DropzoneInput($('.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()
new DropzoneInput($('.merge-request-form'))
2015-09-11 14:41:01 +05:30
new IssuableForm($('.merge-request-form'))
2014-09-02 18:07:02 +05:30
when 'projects:merge_requests:show'
new Diff()
2015-09-11 14:41:01 +05:30
shortcut_handler = new ShortcutsIssuable()
2015-04-26 12:48:37 +05:30
new ZenMode()
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()
when 'projects:merge_requests:index'
shortcut_handler = new ShortcutsNavigation()
MergeRequests.init()
2015-09-11 14:41:01 +05:30
when 'dashboard:show', 'root:show'
2014-09-02 18:07:02 +05:30
new Dashboard()
new Activities()
2015-04-26 12:48:37 +05:30
when 'dashboard:projects:starred'
new Activities()
new ProjectsList()
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()
when 'projects:commits:show'
shortcut_handler = new ShortcutsNavigation()
2015-09-11 14:41:01 +05:30
when 'projects:activity'
shortcut_handler = new ShortcutsNavigation()
2015-04-26 12:48:37 +05:30
when 'projects:show'
shortcut_handler = new ShortcutsNavigation()
when 'groups:show'
new Activities()
shortcut_handler = new ShortcutsNavigation()
new ProjectsList()
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()
when 'groups:new', 'groups:edit', 'admin:groups:edit'
new GroupAvatar()
2014-09-02 18:07:02 +05:30
when 'projects:tree:show'
new TreeView()
2015-04-26 12:48:37 +05:30
shortcut_handler = new ShortcutsNavigation()
2014-09-02 18:07:02 +05:30
when 'projects:blob:show'
2015-09-11 14:41:01 +05:30
new LineHighlighter()
2015-04-26 12:48:37 +05:30
shortcut_handler = new ShortcutsNavigation()
2014-09-02 18:07:02 +05:30
when 'projects:labels:new', 'projects:labels:edit'
new Labels()
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()
when 'users:show'
new User()
new Activities()
when 'admin:users:show'
new ProjectsList()
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'
new NamespaceSelect()
when 'dashboard'
shortcut_handler = new ShortcutsDashboardNavigation()
when 'profiles'
new Profile()
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]
when 'compare'
shortcut_handler = new ShortcutsNavigation()
when 'edit'
shortcut_handler = new ShortcutsNavigation()
new ProjectNew()
when 'new'
new ProjectNew()
when 'show'
new ProjectShow()
when 'wikis'
new Wikis()
shortcut_handler = new ShortcutsNavigation()
new ZenMode()
new DropzoneInput($('.wiki-form'))
2015-09-11 14:41:01 +05:30
when 'snippets'
shortcut_handler = new ShortcutsNavigation()
new ZenMode() if path[2] == 'show'
when 'labels', 'graphs'
2015-04-26 12:48:37 +05:30
shortcut_handler = new ShortcutsNavigation()
when 'project_members', 'deploy_keys', 'hooks', 'services', 'protected_branches'
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: ->
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)