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.
41 lines
1.0 KiB
JavaScript
41 lines
1.0 KiB
JavaScript
'use strict';
|
|
|
|
|
|
define('forum/popular', ['forum/recent', 'components', 'forum/infinitescroll'], function (recent, components, infinitescroll) {
|
|
var Popular = {};
|
|
|
|
Popular.init = function () {
|
|
app.enterRoom('popular_topics');
|
|
|
|
components.get('popular/tab')
|
|
.removeClass('active')
|
|
.find('a[href="' + window.location.pathname + '"]')
|
|
.parent().addClass('active');
|
|
|
|
if (!config.usePagination) {
|
|
infinitescroll.init(loadMoreTopics);
|
|
}
|
|
};
|
|
|
|
function loadMoreTopics(direction) {
|
|
if (direction < 0 || !$('[component="category"]').length) {
|
|
return;
|
|
}
|
|
|
|
infinitescroll.loadMore('topics.loadMorePopularTopics', {
|
|
after: $('[component="category"]').attr('data-nextstart'),
|
|
count: config.topicsPerPage,
|
|
term: ajaxify.data.term,
|
|
}, function (data, done) {
|
|
if (data.topics && data.topics.length) {
|
|
recent.onTopicsLoaded('popular', data.topics, false, done);
|
|
$('[component="category"]').attr('data-nextstart', data.nextStart);
|
|
} else {
|
|
done();
|
|
}
|
|
});
|
|
}
|
|
|
|
return Popular;
|
|
});
|