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).
This commit is contained in:
lonerz 2016-12-28 05:29:13 +00:00 committed by Tim Abbott
parent 0847515203
commit c80bad5b55
3 changed files with 33 additions and 2 deletions

View File

@ -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();

View File

@ -1,5 +1,5 @@
{{! Contents of the "message info" popup }}
<ul class="nav nav-list actions_popover sender_info_popover" data-email="{{message.sender_email}}">
<ul class="nav nav-list actions_popover sender_info_popover" data-email="{{message.sender_email}}" data-user-id="{{message.sender_id}}">
<div class="popover_info">
<li>{{#tr this}}Sent by <b>__message.sender_full_name__</b>{{/tr}}</li>
<li class='my_email'>{{message.sender_email}}</li>
@ -27,4 +27,9 @@
<i class="icon-vector-bullhorn"></i> {{#tr this}}Narrow to messages sent by __message.sender_full_name__{{/tr}}
</a>
</li>
<li>
<a class="mention_user">
{{#tr this}}@ Compose a reply @-mentioning __message.sender_full_name__{{/tr}}
</a>
</li>
</ul>

View File

@ -18,5 +18,9 @@
{{#tr this}}Compose a message to <b>__name__</b>{{/tr}}
</a>
</li>
<li>
<a class="mention_user">
{{#tr this}}@ Compose a message @-mentioning <b>__name__</b>{{/tr}}
</a>
</li>
</ul>