Extract topic_list.update_count_in_dom().

This creates the new topic_list.js module, and the first
function that we extract is topic_list.update_count_in_dom().

This function needed to be decoupled from some non-topic-list
stuff which was overly complicated.
This commit is contained in:
Steve Howell
2016-10-26 16:02:41 -07:00
committed by Tim Abbott
parent 86e933a4a1
commit 4f38cfdc7f
4 changed files with 23 additions and 3 deletions

View File

@@ -362,8 +362,7 @@ exports.set_subject_count = function (stream, subject, count) {
return;
}
count_span.removeClass("zero_count");
update_count_in_dom(count_span, value_span, count);
topic_list.update_count_in_dom(count_span, value_span, count);
};

20
static/js/topic_list.js Normal file
View File

@@ -0,0 +1,20 @@
var topic_list = (function () {
var exports = {};
exports.update_count_in_dom = function (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);
}
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = topic_list;
}

View File

@@ -29,7 +29,7 @@ var globals =
+ ' avatar feature_flags search_suggestion referral stream_color Dict'
+ ' Filter summary admin stream_data muting WinChan muting_ui Socket channel gear_menu'
+ ' message_flags bot_data loading favicon resize scroll_bar condense floating_recipient_bar'
+ ' copy_and_paste click_handlers'
+ ' copy_and_paste click_handlers topic_list'
// colorspace.js
+ ' colorspace'

View File

@@ -760,6 +760,7 @@ JS_SPECS = {
'js/viewport.js',
'js/rows.js',
'js/unread.js',
'js/topic_list.js',
'js/stream_list.js',
'js/filter.js',
'js/message_list_view.js',