mirror of
https://github.com/zulip/zulip.git
synced 2025-11-12 09:58:06 +00:00
bankruptcy: Add UI widget to mark all messages as read.
This is the natural analog of the similar streams UI feature. Fixes #7585.
This commit is contained in:
@@ -401,6 +401,11 @@ function render(template_name, args) {
|
|||||||
|
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
(function all_messages_sidebar_actions() {
|
||||||
|
var html = render('all_messages_sidebar_actions');
|
||||||
|
global.write_handlebars_output("all_messages_sidebar_actions", html);
|
||||||
|
}());
|
||||||
|
|
||||||
(function announce_stream_docs() {
|
(function announce_stream_docs() {
|
||||||
var html = render('announce_stream_docs');
|
var html = render('announce_stream_docs');
|
||||||
global.write_handlebars_output("announce_stream_docs", html);
|
global.write_handlebars_output("announce_stream_docs", html);
|
||||||
|
|||||||
@@ -779,6 +779,7 @@ exports.hide_all = function () {
|
|||||||
emoji_picker.hide_emoji_popover();
|
emoji_picker.hide_emoji_popover();
|
||||||
stream_popover.hide_stream_popover();
|
stream_popover.hide_stream_popover();
|
||||||
stream_popover.hide_topic_popover();
|
stream_popover.hide_topic_popover();
|
||||||
|
stream_popover.hide_all_messages_popover();
|
||||||
popovers.hide_user_sidebar_popover();
|
popovers.hide_user_sidebar_popover();
|
||||||
popovers.hide_userlist_sidebar();
|
popovers.hide_userlist_sidebar();
|
||||||
stream_popover.restore_stream_list_size();
|
stream_popover.restore_stream_list_size();
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ var exports = {};
|
|||||||
// module. Both are popped up from the left sidebar.
|
// module. Both are popped up from the left sidebar.
|
||||||
var current_stream_sidebar_elem;
|
var current_stream_sidebar_elem;
|
||||||
var current_topic_sidebar_elem;
|
var current_topic_sidebar_elem;
|
||||||
|
var all_messages_sidebar_elem;
|
||||||
|
|
||||||
exports.stream_popped = function () {
|
exports.stream_popped = function () {
|
||||||
return current_stream_sidebar_elem !== undefined;
|
return current_stream_sidebar_elem !== undefined;
|
||||||
@@ -15,6 +16,10 @@ exports.topic_popped = function () {
|
|||||||
return current_topic_sidebar_elem !== undefined;
|
return current_topic_sidebar_elem !== undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.all_messages_popped = function () {
|
||||||
|
return all_messages_sidebar_elem !== undefined;
|
||||||
|
};
|
||||||
|
|
||||||
exports.hide_stream_popover = function () {
|
exports.hide_stream_popover = function () {
|
||||||
if (exports.stream_popped()) {
|
if (exports.stream_popped()) {
|
||||||
$(current_stream_sidebar_elem).popover("destroy");
|
$(current_stream_sidebar_elem).popover("destroy");
|
||||||
@@ -29,6 +34,13 @@ exports.hide_topic_popover = function () {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.hide_all_messages_popover = function () {
|
||||||
|
if (exports.all_messages_popped()) {
|
||||||
|
$(all_messages_sidebar_elem).popover("destroy");
|
||||||
|
all_messages_sidebar_elem = undefined;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// These are the only two functions that is really shared by the
|
// These are the only two functions that is really shared by the
|
||||||
// two popovers, so we could split out topic stuff to
|
// two popovers, so we could split out topic stuff to
|
||||||
// another module pretty easily.
|
// another module pretty easily.
|
||||||
@@ -154,6 +166,34 @@ function build_topic_popover(e) {
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function build_all_messages_popover(e) {
|
||||||
|
var elt = e.target;
|
||||||
|
|
||||||
|
if (exports.all_messages_popped()
|
||||||
|
&& all_messages_sidebar_elem === elt) {
|
||||||
|
exports.hide_all_messages_popover();
|
||||||
|
e.stopPropagation();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
popovers.hide_all();
|
||||||
|
|
||||||
|
var content = templates.render(
|
||||||
|
'all_messages_sidebar_actions'
|
||||||
|
);
|
||||||
|
|
||||||
|
$(elt).popover({
|
||||||
|
content: content,
|
||||||
|
trigger: "manual",
|
||||||
|
fixed: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
$(elt).popover("show");
|
||||||
|
all_messages_sidebar_elem = elt;
|
||||||
|
e.stopPropagation();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
exports.register_click_handlers = function () {
|
exports.register_click_handlers = function () {
|
||||||
$('#stream_filters').on('click',
|
$('#stream_filters').on('click',
|
||||||
'.stream-sidebar-arrow', build_stream_popover);
|
'.stream-sidebar-arrow', build_stream_popover);
|
||||||
@@ -161,6 +201,9 @@ exports.register_click_handlers = function () {
|
|||||||
$('#stream_filters').on('click',
|
$('#stream_filters').on('click',
|
||||||
'.topic-sidebar-arrow', build_topic_popover);
|
'.topic-sidebar-arrow', build_topic_popover);
|
||||||
|
|
||||||
|
$('#global_filters').on('click',
|
||||||
|
'.stream-sidebar-arrow', build_all_messages_popover);
|
||||||
|
|
||||||
exports.register_stream_handlers();
|
exports.register_stream_handlers();
|
||||||
exports.register_topic_handlers();
|
exports.register_topic_handlers();
|
||||||
};
|
};
|
||||||
@@ -205,7 +248,7 @@ exports.register_stream_handlers = function () {
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Mark all messages as read
|
// Mark all messages in stream as read
|
||||||
$('body').on('click', '.mark_stream_as_read', function (e) {
|
$('body').on('click', '.mark_stream_as_read', function (e) {
|
||||||
var sub = stream_popover_sub(e);
|
var sub = stream_popover_sub(e);
|
||||||
exports.hide_stream_popover();
|
exports.hide_stream_popover();
|
||||||
@@ -213,6 +256,13 @@ exports.register_stream_handlers = function () {
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Mark all messages as read
|
||||||
|
$('body').on('click', '#mark_all_messages_as_read', function (e) {
|
||||||
|
exports.hide_all_messages_popover();
|
||||||
|
pointer.fast_forward_pointer();
|
||||||
|
e.stopPropagation();
|
||||||
|
});
|
||||||
|
|
||||||
// Mute/unmute
|
// Mute/unmute
|
||||||
$('body').on('click', '.toggle_home', function (e) {
|
$('body').on('click', '.toggle_home', function (e) {
|
||||||
var sub = stream_popover_sub(e);
|
var sub = stream_popover_sub(e);
|
||||||
|
|||||||
9
static/templates/all_messages_sidebar_actions.handlebars
Normal file
9
static/templates/all_messages_sidebar_actions.handlebars
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{{! Contents of the "all messages sidebar" popup }}
|
||||||
|
<ul class="nav nav-list">
|
||||||
|
<li>
|
||||||
|
<a id="mark_all_messages_as_read">
|
||||||
|
<i class="icon-vector-book"></i>
|
||||||
|
{{#tr this}}Mark all messages as read{{/tr}}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
<span class="value"></span>
|
<span class="value"></span>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
|
<span class="arrow stream-sidebar-arrow"><i class="icon-vector-chevron-down"></i></span>
|
||||||
</li>
|
</li>
|
||||||
<li data-name="private" class="global-filter" title="{{ _('Private messages') }} (P)">
|
<li data-name="private" class="global-filter" title="{{ _('Private messages') }} (P)">
|
||||||
<a href="#narrow/is/private">
|
<a href="#narrow/is/private">
|
||||||
|
|||||||
Reference in New Issue
Block a user