2012-10-16 13:01:40 +02:00
|
|
|
# Creates the variables for setting up GFM auto-completion
|
2012-10-10 00:16:52 +02:00
|
|
|
|
2012-11-21 20:02:03 +01:00
|
|
|
window.GitLab ?= {}
|
2012-12-11 00:04:47 +01:00
|
|
|
GitLab.GfmAutoComplete =
|
2012-10-16 13:01:40 +02:00
|
|
|
# Emoji
|
2012-12-11 00:04:47 +01:00
|
|
|
Emoji:
|
|
|
|
data: []
|
|
|
|
template: '<li data-value="${insert}">${name} <img alt="${name}" height="20" src="${image}" width="20" /></li>'
|
2012-10-10 00:16:52 +02:00
|
|
|
|
2012-10-16 13:01:40 +02:00
|
|
|
# Team Members
|
2012-12-11 00:04:47 +01:00
|
|
|
Members:
|
|
|
|
data: []
|
|
|
|
url: ''
|
|
|
|
params:
|
|
|
|
private_token: ''
|
|
|
|
template: '<li data-value="${username}">${username} <small>${name}</small></li>'
|
|
|
|
|
|
|
|
# Add GFM auto-completion to all input fields, that accept GFM input.
|
|
|
|
setup: ->
|
|
|
|
input = $('.js-gfm-input')
|
|
|
|
|
|
|
|
# Emoji
|
|
|
|
input.atWho ':',
|
|
|
|
data: @Emoji.data
|
|
|
|
tpl: @Emoji.template
|
|
|
|
|
|
|
|
# Team Members
|
|
|
|
input.atWho '@',
|
|
|
|
tpl: @Members.template
|
|
|
|
callback: (query, callback) =>
|
2012-12-18 19:52:18 +01:00
|
|
|
request_params = $.extend({}, @Members.params, query: query)
|
|
|
|
$.getJSON(@Members.url, request_params).done (members) =>
|
|
|
|
new_members_data = $.map(members, (m) ->
|
|
|
|
username: m.username,
|
|
|
|
name: m.name
|
|
|
|
)
|
|
|
|
callback(new_members_data)
|
2012-12-11 00:04:47 +01:00
|
|
|
|