summaryrefslogtreecommitdiff
path: root/app/assets
diff options
context:
space:
mode:
authorMike Greiling <mike@pixelcog.com>2017-06-27 00:10:17 -0500
committerMike Greiling <mike@pixelcog.com>2017-06-27 00:10:17 -0500
commit27a1348f20dee09758e053b465a2d2ff37ffb649 (patch)
treee6dea876edd0e44c272180b9f0c3a55552168cc7 /app/assets
parent88114c41fb4cb1c281df613ee8647c63848e37ea (diff)
downloadgitlab-ce-27a1348f20dee09758e053b465a2d2ff37ffb649.tar.gz
split emoji support methods from the async module
Diffstat (limited to 'app/assets')
-rw-r--r--app/assets/javascripts/behaviors/gl_emoji.js8
-rw-r--r--app/assets/javascripts/emoji/index.js4
-rw-r--r--app/assets/javascripts/emoji/support/index.js10
-rw-r--r--app/assets/javascripts/emoji/support/is_emoji_unicode_supported.js (renamed from app/assets/javascripts/emoji/is_emoji_unicode_supported.js)0
-rw-r--r--app/assets/javascripts/emoji/support/unicode_support_map.js (renamed from app/assets/javascripts/emoji/unicode_support_map.js)2
5 files changed, 14 insertions, 10 deletions
diff --git a/app/assets/javascripts/behaviors/gl_emoji.js b/app/assets/javascripts/behaviors/gl_emoji.js
index 3a29254cf99..17422f5cece 100644
--- a/app/assets/javascripts/behaviors/gl_emoji.js
+++ b/app/assets/javascripts/behaviors/gl_emoji.js
@@ -1,10 +1,9 @@
import installCustomElements from 'document-register-element';
-import { emojiMap, normalizeEmojiName, isEmojiUnicodeSupported, getUnicodeSupportMap } from '../emoji';
+import { emojiMap, normalizeEmojiName } from '../emoji';
+import isEmojiUnicodeSupported from '../emoji/support';
installCustomElements(window);
-const generatedUnicodeSupportMap = getUnicodeSupportMap();
-
function emojiImageTag(name, src) {
return `<img class="emoji" title=":${name}:" alt=":${name}:" src="${src}" width="20" height="20" align="absmiddle" />`;
}
@@ -82,7 +81,7 @@ function installGlEmojiElement() {
if (
emojiUnicode &&
isEmojiUnicode &&
- !isEmojiUnicodeSupported(generatedUnicodeSupportMap, emojiUnicode, unicodeVersion)
+ !isEmojiUnicodeSupported(emojiUnicode, unicodeVersion)
) {
// CSS sprite fallback takes precedence over image fallback
if (hasCssSpriteFalback) {
@@ -106,5 +105,4 @@ function installGlEmojiElement() {
export {
installGlEmojiElement,
glEmojiTag,
- emojiImageTag,
};
diff --git a/app/assets/javascripts/emoji/index.js b/app/assets/javascripts/emoji/index.js
index 70346c985e9..7c3bab1e4a9 100644
--- a/app/assets/javascripts/emoji/index.js
+++ b/app/assets/javascripts/emoji/index.js
@@ -1,7 +1,5 @@
import emojiMap from 'emojis/digests.json';
import emojiAliases from 'emojis/aliases.json';
-import getUnicodeSupportMap from './unicode_support_map';
-import isEmojiUnicodeSupported from './is_emoji_unicode_supported';
const validEmojiNames = [...Object.keys(emojiMap), ...Object.keys(emojiAliases)];
@@ -52,8 +50,6 @@ export {
filterEmojiNames,
filterEmojiNamesByAlias,
getEmojiByCategory,
- getUnicodeSupportMap,
isEmojiNameValid,
- isEmojiUnicodeSupported,
validEmojiNames,
};
diff --git a/app/assets/javascripts/emoji/support/index.js b/app/assets/javascripts/emoji/support/index.js
new file mode 100644
index 00000000000..1f7852dd487
--- /dev/null
+++ b/app/assets/javascripts/emoji/support/index.js
@@ -0,0 +1,10 @@
+import isEmojiUnicodeSupported from './is_emoji_unicode_supported';
+import getUnicodeSupportMap from './unicode_support_map';
+
+// cache browser support map between calls
+let browserUnicodeSupportMap;
+
+export default function isEmojiUnicodeSupportedByBrowser(emojiUnicode, unicodeVersion) {
+ browserUnicodeSupportMap = browserUnicodeSupportMap || getUnicodeSupportMap();
+ return isEmojiUnicodeSupported(browserUnicodeSupportMap, emojiUnicode, unicodeVersion);
+}
diff --git a/app/assets/javascripts/emoji/is_emoji_unicode_supported.js b/app/assets/javascripts/emoji/support/is_emoji_unicode_supported.js
index 3fd23efa9f8..3fd23efa9f8 100644
--- a/app/assets/javascripts/emoji/is_emoji_unicode_supported.js
+++ b/app/assets/javascripts/emoji/support/is_emoji_unicode_supported.js
diff --git a/app/assets/javascripts/emoji/unicode_support_map.js b/app/assets/javascripts/emoji/support/unicode_support_map.js
index 2a0c013a70c..755381c2f95 100644
--- a/app/assets/javascripts/emoji/unicode_support_map.js
+++ b/app/assets/javascripts/emoji/support/unicode_support_map.js
@@ -1,4 +1,4 @@
-import AccessorUtilities from '../lib/utils/accessor';
+import AccessorUtilities from '../../lib/utils/accessor';
const unicodeSupportTestMap = {
// man, student (emojione does not have any of these yet), http://emojipedia.org/emoji-zwj-sequences/