popovers: Fix two click handler attached to (rightbar) user_popovers.

No need to have separate click handler for user_popovers and
message_info_popovers as the same user-id can be extracted similarly
from the target of both the click events.

Another refactor, `sender_info_popover` was confusing as it doesn't
fix into the context of rightbar user popovers so changed it to
`info_popover_actions` since that section of popovers contains popover
actions.
This commit is contained in:
Shubham Dhama 2018-02-28 01:10:07 +05:30 committed by Tim Abbott
parent 2d8c1f6d93
commit c995c1a36a
3 changed files with 11 additions and 38 deletions

View File

@ -532,37 +532,28 @@ exports.register_click_handlers = function () {
} }
}); });
$('body').on('click', '.user_popover .narrow_to_private_messages', function (e) {
$('body').on('click', '.info_popover_actions .narrow_to_private_messages', function (e) {
var user_id = $(e.target).parents('ul').attr('data-user-id'); var user_id = $(e.target).parents('ul').attr('data-user-id');
var email = people.get_person_from_user_id(user_id).email; var email = people.get_person_from_user_id(user_id).email;
popovers.hide_message_info_popover();
popovers.hide_user_sidebar_popover();
narrow.by('pm-with', email, {select_first_unread: true, trigger: 'user sidebar popover'}); narrow.by('pm-with', email, {select_first_unread: true, trigger: 'user sidebar popover'});
e.stopPropagation(); e.stopPropagation();
e.preventDefault();
}); });
$('body').on('click', '.user_popover .narrow_to_messages_sent', function (e) { $('body').on('click', '.info_popover_actions .narrow_to_messages_sent', function (e) {
var user_id = $(e.target).parents('ul').attr('data-user-id'); var user_id = $(e.target).parents('ul').attr('data-user-id');
var email = people.get_person_from_user_id(user_id).email; var email = people.get_person_from_user_id(user_id).email;
popovers.hide_message_info_popover();
popovers.hide_user_sidebar_popover();
narrow.by('sender', email, {select_first_unread: true, trigger: 'user sidebar popover'}); narrow.by('sender', email, {select_first_unread: true, trigger: 'user sidebar popover'});
e.stopPropagation(); e.stopPropagation();
});
$('body').on('click', '.user_popover .compose_private_message', function (e) {
var user_id = $(e.target).parents('ul').attr('data-user-id');
var email = people.get_person_from_user_id(user_id).email;
popovers.hide_user_sidebar_popover();
compose_actions.start('private', {private_message_recipient: email, trigger: 'sidebar user actions'});
e.stopPropagation();
e.preventDefault(); e.preventDefault();
}); });
$('body').on('click', '.user_popover .mention_user', function (e) { $('body').on('click', '.user_popover .mention_user', function (e) {
var user_id = $(e.target).parents('ul').attr('data-user-id');
compose_actions.start('stream', {trigger: 'sidebar user actions'}); compose_actions.start('stream', {trigger: 'sidebar user actions'});
var user_id = $(e.target).parents('ul').attr('data-user-id');
var name = people.get_person_from_user_id(user_id).full_name; var name = people.get_person_from_user_id(user_id).full_name;
var textarea = $("#compose-textarea"); var textarea = $("#compose-textarea");
textarea.val('@**' + name + '** '); textarea.val('@**' + name + '** ');
@ -571,25 +562,7 @@ exports.register_click_handlers = function () {
e.preventDefault(); e.preventDefault();
}); });
$('body').on('click', '.sender_info_popover .narrow_to_private_messages', function (e) { $('body').on('click', '.message-info-popover .mention_user', function (e) {
var user_id = $(e.target).parents('ul').attr('data-user-id');
var email = people.get_person_from_user_id(user_id).email;
narrow.by('pm-with', email, {select_first_unread: true, trigger: 'user sidebar popover'});
popovers.hide_message_info_popover();
e.stopPropagation();
e.preventDefault();
});
$('body').on('click', '.sender_info_popover .narrow_to_messages_sent', function (e) {
var user_id = $(e.target).parents('ul').attr('data-user-id');
var email = people.get_person_from_user_id(user_id).email;
narrow.by('sender', email, {select_first_unread: true, trigger: 'user sidebar popover'});
popovers.hide_message_info_popover();
e.stopPropagation();
e.preventDefault();
});
$('body').on('click', '.sender_info_popover .mention_user', function (e) {
compose_actions.respond_to_message({trigger: 'user sidebar popover'}); compose_actions.respond_to_message({trigger: 'user sidebar popover'});
var user_id = $(e.target).parents('ul').attr('data-user-id'); var user_id = $(e.target).parents('ul').attr('data-user-id');
var name = people.get_person_from_user_id(user_id).full_name; var name = people.get_person_from_user_id(user_id).full_name;
@ -731,7 +704,7 @@ exports.register_click_handlers = function () {
reminder_click_handler(datestr, e); reminder_click_handler(datestr, e);
}); });
$('body').on('click', '.respond_personal_button', function (e) { $('body').on('click', '.respond_personal_button, .compose_private_message', function (e) {
var user_id = $(e.target).parents('ul').attr('data-user-id'); var user_id = $(e.target).parents('ul').attr('data-user-id');
var email = people.get_person_from_user_id(user_id).email; var email = people.get_person_from_user_id(user_id).email;
compose_actions.start('private', { compose_actions.start('private', {

View File

@ -66,7 +66,7 @@
float: none; float: none;
} }
ul.sender_info_popover i { ul.info_popover_actions i {
display: inline-block; display: inline-block;
width: 14px; width: 14px;
text-align: center; text-align: center;

View File

@ -1,5 +1,5 @@
{{! Contents of the "message info" popup }} {{! Contents of the "message info" popup }}
<ul class="nav nav-list actions_popover sender_info_popover" data-user-id="{{user_id}}"> <ul class="nav nav-list actions_popover info_popover_actions" data-user-id="{{user_id}}">
<div class="popover_info"> <div class="popover_info">
<li class="user_{{presence_status}}"> <li class="user_{{presence_status}}">
<b>{{user_full_name}}</b> <b>{{user_full_name}}</b>