From c80bad5b554ac512c4c5ddbf822866815edeb37b Mon Sep 17 00:00:00 2001 From: lonerz Date: Wed, 28 Dec 2016 05:29:13 +0000 Subject: [PATCH] popovers: Add popover actions to mention a user. This adds actions to the user and message popovers to mention the user (either the sender of a message or the selected user). --- static/js/popovers.js | 22 +++++++++++++++++++ .../message_info_popover_content.handlebars | 7 +++++- .../templates/user_sidebar_actions.handlebars | 6 ++++- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/static/js/popovers.js b/static/js/popovers.js index 92746c2eec..1f6010f52e 100644 --- a/static/js/popovers.js +++ b/static/js/popovers.js @@ -375,6 +375,17 @@ exports.register_click_handlers = function () { e.stopPropagation(); }); + $('body').on('click', '.user_popover .mention_user', function (e) { + var user_id = $(e.target).parents('ul').attr('data-user-id'); + compose.start('stream', {trigger: 'sidebar user actions'}); + var name = people.get_person_from_user_id(user_id).full_name; + var textarea = $("#new_message_content"); + textarea.val('@**' + name + '** '); + popovers.hide_user_sidebar_popover(); + e.stopPropagation(); + e.preventDefault(); + }); + $('body').on('click', '.sender_info_popover .narrow_to_private_messages', function (e) { var email = $(e.target).parents('ul').attr('data-email'); narrow.by('pm-with', email, {select_first_unread: true, trigger: 'user sidebar popover'}); @@ -391,6 +402,17 @@ exports.register_click_handlers = function () { e.preventDefault(); }); + $('body').on('click', '.sender_info_popover .mention_user', function (e) { + compose.respond_to_message({trigger: 'user sidebar popover'}); + var user_id = $(e.target).parents('ul').attr('data-user-id'); + var name = people.get_person_from_user_id(user_id).full_name; + var textarea = $("#new_message_content"); + textarea.val('@**' + name + '** '); + popovers.hide_message_info_popover(); + e.stopPropagation(); + e.preventDefault(); + }); + $('#user_presences').on('click', 'span.arrow', function (e) { e.stopPropagation(); diff --git a/static/templates/message_info_popover_content.handlebars b/static/templates/message_info_popover_content.handlebars index 539205f6ed..fb1a03490c 100644 --- a/static/templates/message_info_popover_content.handlebars +++ b/static/templates/message_info_popover_content.handlebars @@ -1,5 +1,5 @@ {{! Contents of the "message info" popup }} -