emoji.js: Refactor to make better use of initialize().

This commit is contained in:
Aditya Bansal
2017-08-17 01:30:19 +05:30
committed by showell
parent 505262ca0b
commit 245d571ae9
3 changed files with 23 additions and 17 deletions

View File

@@ -44,6 +44,11 @@ add_dependencies({
util: 'js/util.js',
});
set_global('Image', function () {
return {};
});
emoji.initialize();
var doc = "";
set_global('document', doc);

View File

@@ -19,19 +19,6 @@ var zulip_emoji = {
deactivated: false,
};
_.each(emoji_codes.names, function (value) {
var base_name = emoji_codes.name_to_codepoint[value];
default_emojis.push({emoji_name: value,
codepoint: emoji_codes.name_to_codepoint[value],
emoji_url: "/static/generated/emoji/images/emoji/unicode/" + base_name + ".png"});
});
_.each(emoji_codes.codepoints, function (value) {
default_unicode_emojis.push({emoji_name: value,
codepoint: value,
emoji_url: "/static/generated/emoji/images/emoji/unicode/" + value + ".png"});
});
exports.update_emojis = function update_emojis(realm_emojis) {
// exports.all_realm_emojis is emptied before adding the realm-specific emoji to it.
// This makes sure that in case of deletion, the deleted realm_emojis don't
@@ -79,14 +66,28 @@ exports.update_emojis = function update_emojis(realm_emojis) {
};
exports.initialize = function initialize() {
_.each(emoji_codes.names, function (value) {
var base_name = emoji_codes.name_to_codepoint[value];
default_emojis.push({emoji_name: value,
codepoint: emoji_codes.name_to_codepoint[value],
emoji_url: "/static/generated/emoji/images/emoji/unicode/" + base_name + ".png"});
});
_.each(emoji_codes.codepoints, function (value) {
default_unicode_emojis.push({emoji_name: value,
codepoint: value,
emoji_url: "/static/generated/emoji/images/emoji/unicode/" + value + ".png"});
});
exports.update_emojis(page_params.realm_emoji);
// Load the sprite image in the background so that the browser
// can cache it for later use.
var sprite = new Image();
sprite.src = '/static/generated/emoji/sheet_google_32.png';
};
exports.update_emojis(page_params.realm_emoji);
exports.build_emoji_upload_widget = function () {
var get_file_input = function () {

View File

@@ -251,7 +251,8 @@ $(function () {
people.initialize();
bot_data.initialize(); // Must happen after people.initialize()
message_fetch.initialize();
markdown.initialize();
emoji.initialize();
markdown.initialize(); // Must happen after emoji.initialize()
composebox_typeahead.initialize();
search.initialize();
tutorial.initialize();
@@ -262,7 +263,6 @@ $(function () {
pointer.initialize();
unread_ui.initialize();
activity.initialize();
emoji.initialize();
emoji_picker.initialize();
compose_fade.initialize();
pm_list.initialize();