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:
Vishnu Ks
2018-02-16 01:08:06 +05:30
committed by Tim Abbott
parent 395d476435
commit a46e21ee3e
5 changed files with 67 additions and 1 deletions

View File

@@ -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() {
var html = render('announce_stream_docs');
global.write_handlebars_output("announce_stream_docs", html);

View File

@@ -779,6 +779,7 @@ exports.hide_all = function () {
emoji_picker.hide_emoji_popover();
stream_popover.hide_stream_popover();
stream_popover.hide_topic_popover();
stream_popover.hide_all_messages_popover();
popovers.hide_user_sidebar_popover();
popovers.hide_userlist_sidebar();
stream_popover.restore_stream_list_size();

View File

@@ -6,6 +6,7 @@ var exports = {};
// module. Both are popped up from the left sidebar.
var current_stream_sidebar_elem;
var current_topic_sidebar_elem;
var all_messages_sidebar_elem;
exports.stream_popped = function () {
return current_stream_sidebar_elem !== undefined;
@@ -15,6 +16,10 @@ exports.topic_popped = function () {
return current_topic_sidebar_elem !== undefined;
};
exports.all_messages_popped = function () {
return all_messages_sidebar_elem !== undefined;
};
exports.hide_stream_popover = function () {
if (exports.stream_popped()) {
$(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
// two popovers, so we could split out topic stuff to
// another module pretty easily.
@@ -154,6 +166,34 @@ function build_topic_popover(e) {
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 () {
$('#stream_filters').on('click',
'.stream-sidebar-arrow', build_stream_popover);
@@ -161,6 +201,9 @@ exports.register_click_handlers = function () {
$('#stream_filters').on('click',
'.topic-sidebar-arrow', build_topic_popover);
$('#global_filters').on('click',
'.stream-sidebar-arrow', build_all_messages_popover);
exports.register_stream_handlers();
exports.register_topic_handlers();
};
@@ -205,7 +248,7 @@ exports.register_stream_handlers = function () {
e.stopPropagation();
});
// Mark all messages as read
// Mark all messages in stream as read
$('body').on('click', '.mark_stream_as_read', function (e) {
var sub = stream_popover_sub(e);
exports.hide_stream_popover();
@@ -213,6 +256,13 @@ exports.register_stream_handlers = function () {
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
$('body').on('click', '.toggle_home', function (e) {
var sub = stream_popover_sub(e);

View 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>

View File

@@ -12,6 +12,7 @@
<span class="value"></span>
</span>
</a>
<span class="arrow stream-sidebar-arrow"><i class="icon-vector-chevron-down"></i></span>
</li>
<li data-name="private" class="global-filter" title="{{ _('Private messages') }} (P)">
<a href="#narrow/is/private">