diff --git a/frontend_tests/node_tests/dispatch.js b/frontend_tests/node_tests/dispatch.js index cd9b039a29..7bfdd15ba5 100644 --- a/frontend_tests/node_tests/dispatch.js +++ b/frontend_tests/node_tests/dispatch.js @@ -390,12 +390,6 @@ var event_fixtures = { setting: true, }, - update_display_settings__emoji_alt_code: { - type: 'update_display_settings', - setting_name: 'emoji_alt_code', - setting: true, - }, - update_display_settings__twenty_four_hour_time: { type: 'update_display_settings', setting_name: 'twenty_four_hour_time', @@ -805,11 +799,6 @@ with_overrides(function (override) { dispatch(event); assert_same(page_params.twenty_four_hour_time, true); - event = event_fixtures.update_display_settings__emoji_alt_code; - page_params.emoji_alt_code = false; - dispatch(event); - assert_same(page_params.emoji_alt_code, true); - }); with_overrides(function (override) { diff --git a/frontend_tests/node_tests/reactions.js b/frontend_tests/node_tests/reactions.js index 38a6acac0a..8ba69f455c 100644 --- a/frontend_tests/node_tests/reactions.js +++ b/frontend_tests/node_tests/reactions.js @@ -166,7 +166,7 @@ set_global('current_msg_list', { count: 1, user_ids: [7], title: 'Cali reacted with :frown:', - emoji_alt_code: undefined, + emoji_alt_code: false, class: 'message_reaction', }, { @@ -177,7 +177,7 @@ set_global('current_msg_list', { count: 1, user_ids: [5], title: 'You (click to remove) reacted with :inactive_realm_emoji:', - emoji_alt_code: undefined, + emoji_alt_code: false, is_realm_emoji: true, url: 'TBD', class: 'message_reaction reacted', @@ -190,7 +190,7 @@ set_global('current_msg_list', { count: 2, user_ids: [5, 6], title: 'You (click to remove) and Bob van Roberts reacted with :smile:', - emoji_alt_code: undefined, + emoji_alt_code: false, class: 'message_reaction reacted', }, ]; diff --git a/static/js/compose.js b/static/js/compose.js index 40bc3d94a5..203da15824 100644 --- a/static/js/compose.js +++ b/static/js/compose.js @@ -820,7 +820,7 @@ exports.initialize = function () { preview_html = rendered_content; } $("#preview_content").html(preview_html); - if (page_params.emoji_alt_code) { + if (page_params.emojiset === "text") { $("#preview_content").find(".emoji").replaceWith(function () { var text = $(this).attr("title"); return ":" + text + ":"; diff --git a/static/js/message_list_view.js b/static/js/message_list_view.js index 1f66937ace..782d1aa051 100644 --- a/static/js/message_list_view.js +++ b/static/js/message_list_view.js @@ -433,8 +433,8 @@ MessageListView.prototype = { } // Display emoji (including realm emoji) as text if - // page_params.emoji_alt_code is set - if (page_params.emoji_alt_code) { + // page_params.emojiset is 'text'. + if (page_params.emojiset === 'text') { row.find(".emoji").replaceWith(function () { var text = $(this).attr("title"); return ":" + text + ":"; diff --git a/static/js/reactions.js b/static/js/reactions.js index 83cb9fa1f1..31c2fe828f 100644 --- a/static/js/reactions.js +++ b/static/js/reactions.js @@ -275,8 +275,8 @@ exports.view.insert_new_reaction = function (opts) { context.count = 1; context.title = new_title; - context.emoji_alt_code = page_params.emoji_alt_code; context.local_id = exports.get_local_reaction_id(opts); + context.emoji_alt_code = (page_params.emojiset === 'text'); if (opts.user_id === page_params.user_id) { context.class = "message_reaction reacted"; @@ -406,7 +406,7 @@ exports.get_message_reactions = function (message) { reaction.emoji_code = reaction.emoji_code; reaction.count = reaction.user_ids.length; reaction.title = generate_title(reaction.emoji_name, reaction.user_ids); - reaction.emoji_alt_code = page_params.emoji_alt_code; + reaction.emoji_alt_code = (page_params.emojiset === 'text'); if (reaction.reaction_type !== 'unicode_emoji') { reaction.is_realm_emoji = true; diff --git a/static/js/server_events_dispatch.js b/static/js/server_events_dispatch.js index 493094cba2..844600e897 100644 --- a/static/js/server_events_dispatch.js +++ b/static/js/server_events_dispatch.js @@ -278,7 +278,6 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) { case 'update_display_settings': var user_display_settings = [ 'default_language', - 'emoji_alt_code', 'emojiset', 'high_contrast_mode', 'night_mode', @@ -310,13 +309,6 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) { $("body").fadeIn(300); }, 300); } - if (event.setting_name === 'emoji_alt_code') { - // Rerender the whole message list UI - home_msg_list.rerender(); - if (current_msg_list === message_list.narrowed) { - message_list.narrowed.rerender(); - } - } if (event.setting_name === 'left_side_userlist') { // TODO: Make this change the view immediately rather // than requiring a reload or page resize. @@ -326,17 +318,32 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) { // than requiring a reload or page resize. } if (event.setting_name === 'emojiset') { - var sprite = new Image(); - sprite.onload = function () { - $("#emoji-spritesheet").attr('href', "/static/generated/emoji/" + page_params.emojiset + "_sprite.css"); + if (page_params.emojiset === 'text') { + // destroy the spinner and display success message if ($("#display-settings-status").length) { loading.destroy_indicator($("#emojiset_spinner")); $("#emojiset_select").val(page_params.emojiset); ui_report.success(i18n.t("Emojiset changed successfully!!"), $('#display-settings-status').expectOne()); } - }; - sprite.src = "/static/generated/emoji/sheet_" + page_params.emojiset + "_32.png"; + } else { + var sprite = new Image(); + sprite.onload = function () { + $("#emoji-spritesheet").attr('href', "/static/generated/emoji/" + page_params.emojiset + "_sprite.css"); + if ($("#display-settings-status").length) { + loading.destroy_indicator($("#emojiset_spinner")); + $("#emojiset_select").val(page_params.emojiset); + ui_report.success(i18n.t("Emojiset changed successfully!!"), + $('#display-settings-status').expectOne()); + } + }; + sprite.src = "/static/generated/emoji/sheet_" + page_params.emojiset + "_32.png"; + } + // Rerender the whole message list UI + home_msg_list.rerender(); + if (current_msg_list === message_list.narrowed) { + message_list.narrowed.rerender(); + } } if ($("#settings.tab-pane.active").length) { settings_display.update_page(); diff --git a/static/js/settings_display.js b/static/js/settings_display.js index a235c57781..dbade5f1ec 100644 --- a/static/js/settings_display.js +++ b/static/js/settings_display.js @@ -126,30 +126,6 @@ exports.set_up = function () { }); }); - $("#emoji_alt_code").change(function () { - var emoji_alt_code = this.checked; - var data = {}; - data.emoji_alt_code = JSON.stringify(emoji_alt_code); - var context = {}; - if (data.emoji_alt_code === "true") { - context.text_or_images = i18n.t('text'); - } else { - context.text_or_images = i18n.t('images'); - } - - channel.patch({ - url: '/json/settings/display', - data: data, - success: function () { - ui_report.success(i18n.t("Emoji reactions will appear as __text_or_images__!", context), - $('#display-settings-status').expectOne()); - }, - error: function (xhr) { - ui_report.error(i18n.t("Error updating emoji appearance setting"), xhr, $('#display-settings-status').expectOne()); - }, - }); - }); - $("#twenty_four_hour_time").change(function () { var data = {}; var setting_value = $("#twenty_four_hour_time").is(":checked"); @@ -213,7 +189,6 @@ exports.set_up = function () { function _update_page() { $("#twenty_four_hour_time").prop('checked', page_params.twenty_four_hour_time); $("#left_side_userlist").prop('checked', page_params.left_side_userlist); - $("#emoji_alt_code").prop('checked', page_params.emoji_alt_code); $("#default_language_name").text(page_params.default_language_name); } diff --git a/static/styles/settings.css b/static/styles/settings.css index c421554df5..aaa72c0aa4 100644 --- a/static/styles/settings.css +++ b/static/styles/settings.css @@ -786,6 +786,10 @@ input[type=checkbox].inline-block { min-width: initial !important; } +.right.show .emoji_alt_code { + font-size: 1.2em; +} + #user-settings-avatar { border-radius: 5px; box-shadow: 0px 0px 10px hsla(0, 0%, 0%, 0.1); diff --git a/static/templates/settings/display-settings.handlebars b/static/templates/settings/display-settings.handlebars index dc0e86455a..d5b6a5448a 100644 --- a/static/templates/settings/display-settings.handlebars +++ b/static/templates/settings/display-settings.handlebars @@ -50,17 +50,6 @@ - -