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
|
2016-04-02 18:10:28 +05:30
|
|
|
when 'explore:projects:index', 'explore:projects:starred', 'explore:projects:trending'
|
|
|
|
Dashboard.init()
|
2014-09-02 18:07:02 +05:30
|
|
|
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-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()
|
|
|
|
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'))
|
2015-11-26 14:37:03 +05:30
|
|
|
when 'projects:tags:new'
|
|
|
|
new ZenMode()
|
|
|
|
new DropzoneInput($('.tag-form'))
|
|
|
|
when 'projects:releases:edit'
|
|
|
|
new ZenMode()
|
|
|
|
new DropzoneInput($('.release-form'))
|
2014-09-02 18:07:02 +05:30
|
|
|
when 'projects:merge_requests:show'
|
|
|
|
new Diff()
|
2016-01-14 18:37:52 +05:30
|
|
|
shortcut_handler = new ShortcutsIssuable(true)
|
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'
|
2016-04-02 18:10:28 +05:30
|
|
|
Dashboard.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()
|
|
|
|
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()
|
|
|
|
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()
|
2016-01-14 18:37:52 +05:30
|
|
|
when 'projects:find_file:show'
|
|
|
|
shortcut_handler = true
|
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()
|
2016-01-29 22:53:50 +05:30
|
|
|
when 'projects:artifacts:browse'
|
|
|
|
new BuildArtifacts()
|
2015-04-26 12:48:37 +05:30
|
|
|
when 'users:show'
|
|
|
|
new User()
|
|
|
|
new Activities()
|
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)
|