Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorconnorshea <connor.james.shea@gmail.com>2016-04-08 02:40:22 +0300
committerconnorshea <connor.james.shea@gmail.com>2016-04-09 02:38:31 +0300
commit3a196317abe1899b2b3c61fa97bed797c80456b9 (patch)
treed2f7eff3d3d2319c49ca1569b5461447d35e79d6 /app/helpers/issues_helper.rb
parent8419f355d6166a9e44c5141c35069cd164c23ad0 (diff)
Add "sprite" parameter to emoji_icon helper
The emoji_icon helper used to display the award emoji in Issue and Merge Request views. By default the spritesheet is used, but passing `sprite: false` to the `emoji_icon` helper makes the emoji render as separate images. For award emoji displayed by default (e.g. thumbs-up, thumbs-down, and any that have been awarded to the issue/MR) the independent images are used. Only when the full emoji menu is opened does the full spritesheet load. On a normal issue this change decreases the page load by 670KB or 250KB depending on pixel density. Resolves #14334.
Diffstat (limited to 'app/helpers/issues_helper.rb')
-rw-r--r--app/helpers/issues_helper.rb33
1 files changed, 24 insertions, 9 deletions
diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb
index 24b90fef4fe..bcf8639c829 100644
--- a/app/helpers/issues_helper.rb
+++ b/app/helpers/issues_helper.rb
@@ -115,17 +115,32 @@ module IssuesHelper
icon('eye-slash') if issue.confidential?
end
- def emoji_icon(name, unicode = nil, aliases = [])
+ def emoji_icon(name, unicode = nil, aliases = [], sprite: true)
unicode ||= Emoji.emoji_filename(name) rescue ""
- content_tag :div, "",
- class: "icon emoji-icon emoji-#{unicode}",
- title: name,
- data: {
- aliases: aliases.join(' '),
- emoji: name,
- unicode_name: unicode
- }
+ data = {
+ aliases: aliases.join(" "),
+ emoji: name,
+ unicode_name: unicode
+ }
+
+ if sprite
+ # Emoji icons for the emoji menu, these use a spritesheet.
+ content_tag :div, "",
+ class: "icon emoji-icon emoji-#{unicode}",
+ title: name,
+ data: data
+ else
+ # Emoji icons displayed separately, used for the awards already given
+ # to an issue or merge request.
+ content_tag :img, "",
+ class: "icon emoji",
+ title: name,
+ height: "20px",
+ width: "20px",
+ src: url_to_image("#{unicode}.png"),
+ data: data
+ end
end
def emoji_author_list(notes, current_user)