diff --git a/frontend_tests/node_tests/templates.js b/frontend_tests/node_tests/templates.js index 817a9f6e61..27ffb1a4ad 100644 --- a/frontend_tests/node_tests/templates.js +++ b/frontend_tests/node_tests/templates.js @@ -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); diff --git a/static/js/popovers.js b/static/js/popovers.js index d4e45ec75f..fecc6b4008 100644 --- a/static/js/popovers.js +++ b/static/js/popovers.js @@ -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(); diff --git a/static/js/stream_popover.js b/static/js/stream_popover.js index 47ca489acc..7d5b9abca5 100644 --- a/static/js/stream_popover.js +++ b/static/js/stream_popover.js @@ -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); diff --git a/static/templates/all_messages_sidebar_actions.handlebars b/static/templates/all_messages_sidebar_actions.handlebars new file mode 100644 index 0000000000..1992cd0ac4 --- /dev/null +++ b/static/templates/all_messages_sidebar_actions.handlebars @@ -0,0 +1,9 @@ +{{! Contents of the "all messages sidebar" popup }} +
diff --git a/templates/zerver/left_sidebar.html b/templates/zerver/left_sidebar.html index d1bc595768..2d0f4e6222 100644 --- a/templates/zerver/left_sidebar.html +++ b/templates/zerver/left_sidebar.html @@ -12,6 +12,7 @@ +