var topic_list = (function () { var exports = {}; var widgets = new Dict({fold_case: true}); // key is stream_name exports.remove_expanded_topics = function () { popovers.hide_topic_sidebar_popover(); $("ul.topic-list").remove(); }; function update_count_in_dom(count_span, value_span, count) { if (count === 0) { count_span.hide(); value_span.text(''); } else { count_span.removeClass("zero_count"); count_span.show(); value_span.text(count); } } exports.set_count = function (stream_name, topic, count) { if (!widgets.has(stream_name)) { // fail silently here...sometimes we haven't build // the widget yet, especially during page loading return; } var widget = widgets.get(stream_name); widget.set_count(topic, count); }; exports.build_widget = function (stream, active_topic, max_topics) { var self = {}; self.topic_items = new Dict({fold_case: true}); function build_list(stream, active_topic, max_topics) { var topics = stream_data.get_recent_topics(stream) || []; if (active_topic) { active_topic = active_topic.toLowerCase(); } var hiding_topics = false; var ul = $('