var topic_list = (function () { var exports = {}; // We can only ever have one active widget. var active_widget; // We know whether we're zoomed or not. var zoomed = false; exports.remove_expanded_topics = function () { stream_popover.hide_topic_popover(); if (active_widget) { active_widget.remove(); active_widget = undefined; } }; exports.close = function () { zoomed = false; exports.remove_expanded_topics(); }; exports.zoom_out = function () { zoomed = false; exports.rebuild(active_widget.get_parent(), active_widget.get_stream_id()); }; function update_unread_count(unread_count_elem, count) { // unread_count_elem is a jquery element...we expect DOM // to look like this: //
//
{{unread}}
//
var value_span = unread_count_elem.find('.value'); if (value_span.length === 0) { blueslip.error('malformed dom for unread count'); return; } if (count === 0) { unread_count_elem.hide(); value_span.text(''); } else { unread_count_elem.removeClass("zero_count"); unread_count_elem.show(); value_span.text(count); } } exports.set_count = function (stream_id, topic, count) { if (active_widget && active_widget.is_for_stream(stream_id)) { active_widget.set_count(topic, count); } }; exports.build_widget = function (parent_elem, my_stream_id, active_topic, max_topics) { var self = {}; self.topic_items = new Dict({fold_case: true}); var my_stream_name = stream_data.get_sub_by_id(my_stream_id).name; function build_list(active_topic, max_topics) { var topic_names = topic_data.get_recent_names(my_stream_id); if (active_topic) { active_topic = active_topic.toLowerCase(); } var hiding_topics = false; var ul = $('