2012-10-16 07:01:40 -04:00
|
|
|
# Creates the variables for setting up GFM auto-completion
|
2012-10-09 18:16:52 -04:00
|
|
|
|
2012-11-21 14:02:03 -05:00
|
|
|
window.GitLab ?= {}
|
2012-12-10 18:04:47 -05:00
|
|
|
GitLab.GfmAutoComplete =
|
2013-05-03 11:39:18 -04:00
|
|
|
dataSource: ''
|
2015-04-19 16:22:23 -04:00
|
|
|
|
2012-10-16 07:01:40 -04:00
|
|
|
# Emoji
|
2012-12-10 18:04:47 -05:00
|
|
|
Emoji:
|
2015-04-19 16:22:23 -04:00
|
|
|
template: '<li>${name} <img alt="${name}" height="20" src="${path}" width="20" /></li>'
|
2012-10-09 18:16:52 -04:00
|
|
|
|
2012-10-16 07:01:40 -04:00
|
|
|
# Team Members
|
2012-12-10 18:04:47 -05:00
|
|
|
Members:
|
2015-06-02 08:56:50 -04:00
|
|
|
template: '<li>${username} <small>${title}</small></li>'
|
2012-12-10 18:04:47 -05:00
|
|
|
|
2014-03-05 23:24:03 -05:00
|
|
|
# Issues and MergeRequests
|
2013-05-03 11:39:18 -04:00
|
|
|
Issues:
|
2015-04-19 16:22:23 -04:00
|
|
|
template: '<li><small>${id}</small> ${title}</li>'
|
2013-05-03 11:39:18 -04:00
|
|
|
|
2012-12-10 18:04:47 -05:00
|
|
|
# Add GFM auto-completion to all input fields, that accept GFM input.
|
|
|
|
setup: ->
|
|
|
|
input = $('.js-gfm-input')
|
|
|
|
|
|
|
|
# Emoji
|
2013-05-03 11:39:18 -04:00
|
|
|
input.atwho
|
|
|
|
at: ':'
|
2015-04-19 16:22:23 -04:00
|
|
|
displayTpl: @Emoji.template
|
|
|
|
insertTpl: ':${name}:'
|
2012-12-10 18:04:47 -05:00
|
|
|
|
|
|
|
# Team Members
|
2013-05-03 11:39:18 -04:00
|
|
|
input.atwho
|
|
|
|
at: '@'
|
2015-04-19 16:22:23 -04:00
|
|
|
displayTpl: @Members.template
|
|
|
|
insertTpl: '${atwho-at}${username}'
|
|
|
|
searchKey: 'search'
|
2013-05-03 11:39:18 -04:00
|
|
|
callbacks:
|
2015-04-19 16:22:23 -04:00
|
|
|
beforeSave: (members) ->
|
2016-01-06 05:43:21 -05:00
|
|
|
$.map members, (m) ->
|
2015-06-02 08:56:50 -04:00
|
|
|
title = m.name
|
|
|
|
title += " (#{m.count})" if m.count
|
|
|
|
|
|
|
|
username: m.username
|
|
|
|
title: sanitize(title)
|
|
|
|
search: sanitize("#{m.username} #{m.name}")
|
2013-05-03 11:39:18 -04:00
|
|
|
|
|
|
|
input.atwho
|
|
|
|
at: '#'
|
|
|
|
alias: 'issues'
|
2015-04-19 16:22:23 -04:00
|
|
|
searchKey: 'search'
|
|
|
|
displayTpl: @Issues.template
|
|
|
|
insertTpl: '${atwho-at}${id}'
|
2013-05-03 11:39:18 -04:00
|
|
|
callbacks:
|
2015-04-19 16:22:23 -04:00
|
|
|
beforeSave: (issues) ->
|
2016-01-06 05:43:21 -05:00
|
|
|
$.map issues, (i) ->
|
2015-06-02 08:56:50 -04:00
|
|
|
id: i.iid
|
|
|
|
title: sanitize(i.title)
|
|
|
|
search: "#{i.iid} #{i.title}"
|
2012-12-10 18:04:47 -05:00
|
|
|
|
2014-03-05 23:24:03 -05:00
|
|
|
input.atwho
|
|
|
|
at: '!'
|
|
|
|
alias: 'mergerequests'
|
2015-04-19 16:22:23 -04:00
|
|
|
searchKey: 'search'
|
|
|
|
displayTpl: @Issues.template
|
|
|
|
insertTpl: '${atwho-at}${id}'
|
2014-03-05 23:24:03 -05:00
|
|
|
callbacks:
|
2015-04-19 16:22:23 -04:00
|
|
|
beforeSave: (merges) ->
|
2016-01-06 05:43:21 -05:00
|
|
|
$.map merges, (m) ->
|
2015-06-02 08:56:50 -04:00
|
|
|
id: m.iid
|
|
|
|
title: sanitize(m.title)
|
|
|
|
search: "#{m.iid} #{m.title}"
|
2014-03-05 23:24:03 -05:00
|
|
|
|
2016-01-11 05:06:00 -05:00
|
|
|
if @dataSource
|
|
|
|
$.getJSON(@dataSource).done (data) ->
|
|
|
|
# load members
|
|
|
|
input.atwho 'load', '@', data.members
|
|
|
|
# load issues
|
|
|
|
input.atwho 'load', 'issues', data.issues
|
|
|
|
# load merge requests
|
|
|
|
input.atwho 'load', 'mergerequests', data.mergerequests
|
|
|
|
# load emojis
|
|
|
|
input.atwho 'load', ':', data.emojis
|