summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2016-04-09 00:17:12 +0000
committerRobert Speicher <robert@gitlab.com>2016-04-09 00:17:12 +0000
commit9e2032173ce2d1b41b08d38fc22b89b52de6a823 (patch)
tree16ac50902cec6ceb71d7de789b3df63910998b06
parent17a7419d90ee47c0802ed1133bfc07a1482af662 (diff)
parent3a196317abe1899b2b3c61fa97bed797c80456b9 (diff)
downloadgitlab-ce-9e2032173ce2d1b41b08d38fc22b89b52de6a823.tar.gz
Merge branch 'efficient-emoji-loading' into 'master'
Only load emoji spritesheet when necessary On a normal issue where the only award emoji displayed by default are the thumbs-up and thumbs-down emoji, this decreases the page load by 670KB or 250KB depending on pixel density. Resolves #14334. See merge request !3449
-rw-r--r--CHANGELOG1
-rw-r--r--app/helpers/issues_helper.rb33
-rw-r--r--app/views/votes/_votes_block.html.haml2
3 files changed, 26 insertions, 10 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 35c5417da22..c25ee3c71d3 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
Please view this file on the master branch, on stable branches it's out of date.
v 8.7.0 (unreleased)
+ - Load award emoji images separately unless opening the full picker. Saves several hundred KBs of data for most pages. (Connor Shea)
- All images in discussions and wikis now link to their source files !3464 (Connor Shea).
- Return status code 303 after a branch DELETE operation to avoid project deletion (Stan Hu)
- Improved Markdown rendering performance !3389 (Yorick Peterse)
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)
diff --git a/app/views/votes/_votes_block.html.haml b/app/views/votes/_votes_block.html.haml
index 8ffcdc4a327..49cfcd53d74 100644
--- a/app/views/votes/_votes_block.html.haml
+++ b/app/views/votes/_votes_block.html.haml
@@ -1,7 +1,7 @@
.awards.votes-block
- awards_sort(votable.notes.awards.grouped_awards).each do |emoji, notes|
%button.btn.award-control.js-emoji-btn.has-tooltip{class: (note_active_class(notes, current_user)), title: emoji_author_list(notes, current_user), data: {placement: "top"}}
- = emoji_icon(emoji)
+ = emoji_icon(emoji, sprite: false)
%span.award-control-text.js-counter
= notes.count