mirror of https://github.com/zulip/zulip.git
Fix problem with presence list popovers persisting
This addresses Trac #2090 (imported from commit e98a3dae8e946ec7fdb027d3619ae2b0ddbdbf51)
This commit is contained in:
parent
b8a151ca4e
commit
1a21db1170
|
@ -172,11 +172,12 @@ exports.show_streamlist_sidebar = function () {
|
||||||
|
|
||||||
var current_stream_sidebar_elem;
|
var current_stream_sidebar_elem;
|
||||||
var current_topic_sidebar_elem;
|
var current_topic_sidebar_elem;
|
||||||
var current_user_sidebar_elem;
|
var current_user_sidebar_email;
|
||||||
|
var current_user_sidebar_popover;
|
||||||
|
|
||||||
|
|
||||||
function user_sidebar_popped() {
|
function user_sidebar_popped() {
|
||||||
return current_user_sidebar_elem !== undefined;
|
return current_user_sidebar_popover !== undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
function stream_sidebar_popped() {
|
function stream_sidebar_popped() {
|
||||||
|
@ -203,8 +204,15 @@ exports.hide_topic_sidebar_popover = function () {
|
||||||
|
|
||||||
exports.hide_user_sidebar_popover = function () {
|
exports.hide_user_sidebar_popover = function () {
|
||||||
if (user_sidebar_popped()) {
|
if (user_sidebar_popped()) {
|
||||||
$(current_user_sidebar_elem).closest("li").popover("destroy");
|
// this hide_* method looks different from all the others since
|
||||||
current_user_sidebar_elem = undefined;
|
// the presence list may be redrawn. Due to funkiness with jquery's .data()
|
||||||
|
// this would confuse $.popover("destroy"), which looks at the .data() attached
|
||||||
|
// to a certain element. We thus save off the .data("popover") in the show_user_sidebar_popover
|
||||||
|
// and inject it here before calling destroy.
|
||||||
|
$('#user_presences').data("popover", current_user_sidebar_popover);
|
||||||
|
$('#user_presences').popover("destroy");
|
||||||
|
current_user_sidebar_email = undefined;
|
||||||
|
current_user_sidebar_popover = undefined;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -259,33 +267,37 @@ exports.register_click_handlers = function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#user_presences').on('click', 'span.arrow', function (e) {
|
$('#user_presences').on('click', 'span.arrow', function (e) {
|
||||||
var elt = e.target;
|
e.stopPropagation();
|
||||||
|
|
||||||
if (user_sidebar_popped() && current_user_sidebar_elem === elt) {
|
// use email of currently selected user, rather than some elem comparison,
|
||||||
// If the popover is already shown, clicking again should toggle it.
|
// as the presence list may be redrawn with new elements.
|
||||||
popovers.hide_user_sidebar_popover();
|
var target = $(this).closest('li');
|
||||||
e.stopPropagation();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
popovers.hide_all();
|
|
||||||
if (userlist_placement === "right") {
|
|
||||||
popovers.show_userlist_sidebar();
|
|
||||||
}
|
|
||||||
var target = $(elt).closest('li');
|
|
||||||
var email = target.find('a').attr('data-email');
|
var email = target.find('a').attr('data-email');
|
||||||
var name = target.find('a').attr('data-name');
|
var name = target.find('a').attr('data-name');
|
||||||
|
|
||||||
|
if (current_user_sidebar_email === email) {
|
||||||
|
// If the popover is already shown, clicking again should toggle it.
|
||||||
|
popovers.hide_all();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
popovers.hide_all();
|
||||||
|
|
||||||
|
if (userlist_placement === "right") {
|
||||||
|
popovers.show_userlist_sidebar();
|
||||||
|
}
|
||||||
|
var template_vars = {email: email, name: name};
|
||||||
|
var content = templates.render('user_sidebar_actions', template_vars);
|
||||||
|
|
||||||
target.popover({
|
target.popover({
|
||||||
content: templates.render('user_sidebar_actions', {'email': email,
|
content: content,
|
||||||
'name': name}),
|
|
||||||
placement: userlist_placement === "left" ? "right" : "left",
|
placement: userlist_placement === "left" ? "right" : "left",
|
||||||
trigger: "manual",
|
trigger: "manual",
|
||||||
fixed: true
|
fixed: true
|
||||||
});
|
});
|
||||||
target.popover("show");
|
target.popover("show");
|
||||||
current_user_sidebar_elem = elt;
|
current_user_sidebar_email = email;
|
||||||
e.stopPropagation();
|
current_user_sidebar_popover = target.data('popover');
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#stream_filters').on('click', '.topic-sidebar-arrow', function (e) {
|
$('#stream_filters').on('click', '.topic-sidebar-arrow', function (e) {
|
||||||
|
|
Loading…
Reference in New Issue