You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.0 KiB
JavaScript
46 lines
1.0 KiB
JavaScript
define(['forum/recent'], function(recent) {
|
|
var Popular = {},
|
|
loadingMoreTopics = false,
|
|
active = '';
|
|
|
|
Popular.init = function() {
|
|
app.enterRoom('recent_posts');
|
|
|
|
$('#new-topics-alert').on('click', function() {
|
|
$(this).addClass('hide');
|
|
});
|
|
|
|
recent.watchForNewPosts();
|
|
|
|
active = recent.selectActivePill();
|
|
|
|
app.enableInfiniteLoading(function() {
|
|
if(!loadingMoreTopics) {
|
|
loadMoreTopics();
|
|
}
|
|
});
|
|
|
|
function loadMoreTopics() {
|
|
loadingMoreTopics = true;
|
|
socket.emit('topics.loadMoreFromSet', {
|
|
set: 'topics:' + $('.nav-pills .active a').html().toLowerCase(),
|
|
after: $('#topics-container').attr('data-nextstart')
|
|
}, function(err, data) {
|
|
if(err) {
|
|
return app.alertError(err.message);
|
|
}
|
|
|
|
if (data.topics && data.topics.length) {
|
|
recent.onTopicsLoaded('popular', data.topics);
|
|
$('#topics-container').attr('data-nextstart', data.nextStart);
|
|
} else {
|
|
$('#load-more-btn').hide();
|
|
}
|
|
|
|
loadingMoreTopics = false;
|
|
});
|
|
}
|
|
};
|
|
|
|
return Popular;
|
|
}); |