Commit 85bbb914 authored by Robert Speicher's avatar Robert Speicher

Fix GfmAutoComplete for jquery-atwho 1.0

parent d086e76c
......@@ -2,19 +2,19 @@
window.GitLab ?= {}
GitLab.GfmAutoComplete =
# private_token: ''
dataSource: ''
# Emoji
Emoji:
template: '<li data-value="${insert}">${name} <img alt="${name}" height="20" src="${image}" width="20" /></li>'
template: '<li>${name} <img alt="${name}" height="20" src="${path}" width="20" /></li>'
# Team Members
Members:
template: '<li data-value="${username}">${username} <small>${name}</small></li>'
template: '<li>${username} <small>${name}</small></li>'
# Issues and MergeRequests
Issues:
template: '<li data-value="${id}"><small>${id}</small> ${title} </li>'
template: '<li><small>${id}</small> ${title}</li>'
# Add GFM auto-completion to all input fields, that accept GFM input.
setup: ->
......@@ -23,45 +23,46 @@ GitLab.GfmAutoComplete =
# Emoji
input.atwho
at: ':'
tpl: @Emoji.template
callbacks:
before_save: (emojis) =>
$.map emojis, (em) => name: em.name, insert: em.name+ ':', image: em.path
displayTpl: @Emoji.template
insertTpl: ':${name}:'
# Team Members
input.atwho
at: '@'
tpl: @Members.template
search_key: 'search'
displayTpl: @Members.template
insertTpl: '${atwho-at}${username}'
searchKey: 'search'
callbacks:
before_save: (members) =>
$.map members, (m) => name: m.name, username: m.username, search: "#{m.username} #{m.name}"
beforeSave: (members) ->
$.map members, (m) -> name: m.name, username: m.username, search: "#{m.username} #{m.name}"
input.atwho
at: '#'
alias: 'issues'
search_key: 'search'
tpl: @Issues.template
searchKey: 'search'
displayTpl: @Issues.template
insertTpl: '${atwho-at}${id}'
callbacks:
before_save: (issues) ->
beforeSave: (issues) ->
$.map issues, (i) -> id: i.iid, title: sanitize(i.title), search: "#{i.iid} #{i.title}"
input.atwho
at: '!'
alias: 'mergerequests'
search_key: 'search'
tpl: @Issues.template
searchKey: 'search'
displayTpl: @Issues.template
insertTpl: '${atwho-at}${id}'
callbacks:
before_save: (merges) ->
beforeSave: (merges) ->
$.map merges, (m) -> id: m.iid, title: sanitize(m.title), search: "#{m.iid} #{m.title}"
input.one "focus", =>
input.one 'focus', =>
$.getJSON(@dataSource).done (data) ->
# load members
input.atwho 'load', "@", data.members
input.atwho 'load', '@', data.members
# load issues
input.atwho 'load', "issues", data.issues
input.atwho 'load', 'issues', data.issues
# load merge requests
input.atwho 'load', "mergerequests", data.mergerequests
input.atwho 'load', 'mergerequests', data.mergerequests
# load emojis
input.atwho 'load', ":", data.emojis
input.atwho 'load', ':', data.emojis
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment