|
|
|
@ -46,12 +46,12 @@ define('forum/category', [
|
|
|
|
|
enableInfiniteLoadingOrPagination();
|
|
|
|
|
|
|
|
|
|
if (!config.usePagination) {
|
|
|
|
|
navigator.init('#topics-container > .category-item', ajaxify.variables.get('topic_count'), Category.toTop, Category.toBottom, Category.navigatorCallback);
|
|
|
|
|
navigator.init('[component="category/topic"]', ajaxify.variables.get('topic_count'), Category.toTop, Category.toBottom, Category.navigatorCallback);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$('#topics-container').on('click', '[component="post/header"]', function() {
|
|
|
|
|
$('[component="category"]').on('click', '[component="post/header"]', function() {
|
|
|
|
|
var clickedIndex = $(this).parents('[data-index]').attr('data-index');
|
|
|
|
|
$('#topics-container li.category-item').each(function(index, el) {
|
|
|
|
|
$('[component="category/topic"]').each(function(index, el) {
|
|
|
|
|
if ($(el).offset().top - $(window).scrollTop() > 0) {
|
|
|
|
|
localStorage.setItem('category:' + cid + ':bookmark', $(el).attr('data-index'));
|
|
|
|
|
localStorage.setItem('category:' + cid + ':bookmark:clicked', clickedIndex);
|
|
|
|
@ -129,7 +129,7 @@ define('forum/category', [
|
|
|
|
|
bookmarkIndex = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$('#topics-container').empty();
|
|
|
|
|
$('[component="category"]').empty();
|
|
|
|
|
|
|
|
|
|
loadTopicsAfter(bookmarkIndex, function() {
|
|
|
|
|
Category.scrollToTopic(bookmarkIndex, clickedIndex, 0);
|
|
|
|
@ -139,7 +139,7 @@ define('forum/category', [
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Category.highlightTopic = function(topicIndex) {
|
|
|
|
|
var highlight = $('#topics-container [data-index="' + topicIndex + '"]');
|
|
|
|
|
var highlight = components.get('category/topic', 'index', topicIndex);
|
|
|
|
|
if (highlight.length && !highlight.hasClass('highlight')) {
|
|
|
|
|
highlight.addClass('highlight');
|
|
|
|
|
setTimeout(function() {
|
|
|
|
@ -157,7 +157,7 @@ define('forum/category', [
|
|
|
|
|
offset = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var scrollTo = $('#topics-container [data-index="' + bookmarkIndex + '"]');
|
|
|
|
|
var scrollTo = components.get('category/topic', 'index', bookmarkIndex);
|
|
|
|
|
var cid = ajaxify.variables.get('category_id');
|
|
|
|
|
if (scrollTo.length && cid) {
|
|
|
|
|
$('html, body').animate({
|
|
|
|
@ -192,11 +192,12 @@ define('forum/category', [
|
|
|
|
|
}, function(html) {
|
|
|
|
|
translator.translate(html, function(translatedHTML) {
|
|
|
|
|
var topic = $(translatedHTML),
|
|
|
|
|
container = $('#topics-container'),
|
|
|
|
|
topics = $('#topics-container').children('.category-item'),
|
|
|
|
|
container = $('[component="category"]'),
|
|
|
|
|
topics = $('[component="category/topic"]'),
|
|
|
|
|
numTopics = topics.length;
|
|
|
|
|
|
|
|
|
|
$('#topics-container, .category-sidebar').removeClass('hidden');
|
|
|
|
|
$('[component="category"]').removeClass('hidden');
|
|
|
|
|
$('.category-sidebar').removeClass('hidden');
|
|
|
|
|
|
|
|
|
|
var noTopicsWarning = $('#category-no-topics');
|
|
|
|
|
if (noTopicsWarning.length) {
|
|
|
|
@ -247,7 +248,7 @@ define('forum/category', [
|
|
|
|
|
|
|
|
|
|
function removeAlreadyAddedTopics(topics) {
|
|
|
|
|
return topics.filter(function(topic) {
|
|
|
|
|
return $('#topics-container li[data-tid="' + topic.tid +'"]').length === 0;
|
|
|
|
|
return components.get('category/topic', 'tid', topic.tid).length === 0;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -255,16 +256,20 @@ define('forum/category', [
|
|
|
|
|
before = null;
|
|
|
|
|
|
|
|
|
|
function findInsertionPoint() {
|
|
|
|
|
if (!$('#topics-container .category-item[data-tid]').length) {
|
|
|
|
|
var topics = components.get('category/topic');
|
|
|
|
|
|
|
|
|
|
if (!topics.length) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var last = $('#topics-container .category-item[data-tid]').last();
|
|
|
|
|
var lastIndex = last.attr('data-index');
|
|
|
|
|
var firstIndex = data.topics[data.topics.length - 1].index;
|
|
|
|
|
|
|
|
|
|
var last = topics.last(),
|
|
|
|
|
lastIndex = last.attr('data-index'),
|
|
|
|
|
firstIndex = data.topics[data.topics.length - 1].index;
|
|
|
|
|
|
|
|
|
|
if (firstIndex > lastIndex) {
|
|
|
|
|
after = last;
|
|
|
|
|
} else {
|
|
|
|
|
before = $('#topics-container .category-item[data-tid]').first();
|
|
|
|
|
before = topics.first();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -277,10 +282,12 @@ define('forum/category', [
|
|
|
|
|
|
|
|
|
|
templates.parse('category', 'topics', data, function(html) {
|
|
|
|
|
translator.translate(html, function(translatedHTML) {
|
|
|
|
|
var container = $('#topics-container'),
|
|
|
|
|
var container = $('[component="category"]'),
|
|
|
|
|
html = $(translatedHTML);
|
|
|
|
|
|
|
|
|
|
$('#topics-container, .category-sidebar').removeClass('hidden');
|
|
|
|
|
$('[component="category"]').removeClass('hidden');
|
|
|
|
|
$('.category-sidebar').removeClass('hidden');
|
|
|
|
|
|
|
|
|
|
$('#category-no-topics').remove();
|
|
|
|
|
|
|
|
|
|
if(config.usePagination) {
|
|
|
|
@ -306,11 +313,11 @@ define('forum/category', [
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Category.loadMoreTopics = function(direction) {
|
|
|
|
|
if (!$('#topics-container').length || !$('#topics-container').children().length) {
|
|
|
|
|
if (!$('[component="category"]').length || !$('[component="category"]').children().length) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
infinitescroll.calculateAfter(direction, '#topics-container .category-item[data-tid]', config.topicsPerPage, false, function(after, offset, el) {
|
|
|
|
|
infinitescroll.calculateAfter(direction, components.get('category/topic'), config.topicsPerPage, false, function(after, offset, el) {
|
|
|
|
|
loadTopicsAfter(after, function() {
|
|
|
|
|
if (direction < 0 && el) {
|
|
|
|
|
Category.scrollToTopic(el.attr('data-index'), null, 0, offset);
|
|
|
|
@ -320,7 +327,7 @@ define('forum/category', [
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function loadTopicsAfter(after, callback) {
|
|
|
|
|
if(!utils.isNumber(after) || (after === 0 && $('#topics-container li.category-item[data-index="0"]').length)) {
|
|
|
|
|
if(!utils.isNumber(after) || (after === 0 && components.get('category/topic', 'index', 0).length)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -336,7 +343,7 @@ define('forum/category', [
|
|
|
|
|
done();
|
|
|
|
|
callback();
|
|
|
|
|
});
|
|
|
|
|
$('#topics-container').attr('data-nextstart', data.nextStart);
|
|
|
|
|
$('[component="category"]').attr('data-nextstart', data.nextStart);
|
|
|
|
|
} else {
|
|
|
|
|
done();
|
|
|
|
|
}
|
|
|
|
|