Skip to content
Snippets Groups Projects
Commit 453ad603 authored by Christian Fusco's avatar Christian Fusco Committed by Gabriel Engel
Browse files

Emoji's by themselves appear 3x as large. (#3072)

* Added the ability to create larger emojis by editing sprites.css.
Changed renderMessageBody.js so that if a user's message contained only an emoji, it appears 3x as large.

* Fixed spacing and equality issues.

* Update renderMessageBody.js

Cosmetic fixes
parent 31273aea
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,24 @@
overflow: hidden;
}
.big_emojione {
image-rendering: optimizeQuality;
font-size: inherit;
height: 66px;
width: 66px;
position: relative;
display: inline-block;
margin: 0 .15em;
line-height: normal;
vertical-align: middle;
background-image: url("../../packages/emojione_emojione/assets/sprites/emojione.sprites.png");
background-size: 4100% 4000%;
background-repeat: no-repeat;
text-indent: 100%;
white-space: nowrap;
overflow: hidden;
}
.emojione-0023-20e3 {
background-position: 2.5% 0%; }
......
......@@ -22,5 +22,46 @@ renderMessageBody = function(msg) {
msg.html = message.html.replace(/\n/gm, '<br/>');
if (singleEmojiCheck(msg)) {
msg.html = (msg.html).replace('emojione ', 'big_emojione ');
}
return msg.html;
};
/**
*Checks to see if a message contains only an emoji span
*@para {msg} some html message
*@return {false} the html message either doesn't
*contain an emoji span, or contains other characters
*/
singleEmojiCheck = function(msg) {
var str = msg.html;
str = str.trim();
//checks to make sure it's a span
if (!str.includes('<') || !str.includes('>')) {
return false;
}
if (str.charAt(0) !== '<' || str.charAt(str.length - 1) !== '>') {
return false;
}
if (str.indexOf('>') === str.lastIndexOf('>')) {
return false;
}
//checks to make sure it's the only span
str = str.substring(str.indexOf('<') + 1, str.lastIndexOf('>') - 1);
if (!str.includes('<') || !str.includes('>')) {
return false;
}
if (str.indexOf('<') < str.lastIndexOf('>')) {
return false;
}
return true;
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment