var Dict = require('./dict').Dict; var topic_list = (function () { var exports = {}; /* Track all active widgets with a Dict. (We have at max one for now, but we may eventually allow multiple streams to be expanded.) */ var active_widgets = new Dict(); // We know whether we're zoomed or not. var zoomed = false; exports.remove_expanded_topics = function () { stream_popover.hide_topic_popover(); _.each(active_widgets.values(), function (widget) { widget.remove(); }); active_widgets.clear(); }; exports.close = function () { zoomed = false; exports.remove_expanded_topics(); }; exports.zoom_out = function () { zoomed = false; var stream_ids = active_widgets.keys(); if (stream_ids.length !== 1) { blueslip.error('Unexpected number of topic lists to zoom out.'); return; } var stream_id = stream_ids[0]; var widget = active_widgets.get(stream_id); var parent_widget = widget.get_parent(); exports.rebuild(parent_widget, 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) { var widget = active_widgets.get(stream_id); if (widget === undefined) { return; } widget.set_count(topic, count); }; exports.widget = function (parent_elem, my_stream_id) { var self = {}; self.build_list = function () { self.topic_items = new Dict({fold_case: true}); var max_topics = 5; var topic_names = topic_data.get_recent_names(my_stream_id); var ul = $('