Commit 5e985a7e authored by Marin Jankovski's avatar Marin Jankovski

Use emoji assets on autocomplete.

parent a87f0376
...@@ -6,7 +6,6 @@ GitLab.GfmAutoComplete = ...@@ -6,7 +6,6 @@ GitLab.GfmAutoComplete =
dataSource: '' dataSource: ''
# Emoji # Emoji
Emoji: Emoji:
assetBase: ''
template: '<li data-value="${insert}">${name} <img alt="${name}" height="20" src="${image}" width="20" /></li>' template: '<li data-value="${insert}">${name} <img alt="${name}" height="20" src="${image}" width="20" /></li>'
# Team Members # Team Members
...@@ -27,7 +26,7 @@ GitLab.GfmAutoComplete = ...@@ -27,7 +26,7 @@ GitLab.GfmAutoComplete =
tpl: @Emoji.template tpl: @Emoji.template
callbacks: callbacks:
before_save: (emojis) => before_save: (emojis) =>
$.map emojis, (em) => name: em, insert: em+ ':', image: "#{@Emoji.assetBase}/#{em}.png" $.map emojis, (em) => name: em.name, insert: em.name+ ':', image: em.path
# Team Members # Team Members
input.atwho input.atwho
......
...@@ -124,7 +124,7 @@ class ProjectsController < ApplicationController ...@@ -124,7 +124,7 @@ class ProjectsController < ApplicationController
def autocomplete_sources def autocomplete_sources
@suggestions = { @suggestions = {
emojis: Emoji.names, emojis: Emoji.names.map { |e| { name: e, path: view_context.image_url("emoji/#{e}.png") } },
issues: @project.issues.select([:iid, :title, :description]), issues: @project.issues.select([:iid, :title, :description]),
mergerequests: @project.merge_requests.select([:iid, :title, :description]), mergerequests: @project.merge_requests.select([:iid, :title, :description]),
members: @project.team.members.sort_by(&:username).map { |user| { username: user.username, name: user.name } } members: @project.team.members.sort_by(&:username).map { |user| { username: user.username, name: user.name } }
......
:javascript :javascript
GitLab.GfmAutoComplete.dataSource = "#{autocomplete_sources_project_path(@project)}" GitLab.GfmAutoComplete.dataSource = "#{autocomplete_sources_project_path(@project)}"
GitLab.GfmAutoComplete.Emoji.assetBase = "#{Gitlab.config.gitlab.relative_url_root + Emoji.asset_path}"
GitLab.GfmAutoComplete.setup(); GitLab.GfmAutoComplete.setup();
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