.category-box and .post-preview now components

v1.18.x
psychobunny 10 years ago
parent 1b2da78fd8
commit 4d414d0b63

@ -29,23 +29,19 @@ define('forum/categories', ['components', 'translator'], function(components, tr
}; };
function renderNewPost(cid, post) { function renderNewPost(cid, post) {
var category = components.get('category/topic', 'cid', cid); var category = components.get('categories/category', 'cid', cid);
if (!category.length) {
return;
}
var categoryBox = category.find('.category-box');
var numRecentReplies = category.attr('data-numRecentReplies'); var numRecentReplies = category.attr('data-numRecentReplies');
if (!numRecentReplies || !parseInt(numRecentReplies, 10)) { if (!numRecentReplies || !parseInt(numRecentReplies, 10)) {
return; return;
} }
var recentPosts = categoryBox.find('.post-preview'); var recentPosts = category.find('[component="category/posts"]');
var insertBefore = recentPosts.first(); var insertBefore = recentPosts.first();
parseAndTranslate([post], function(html) { parseAndTranslate([post], function(html) {
html.hide(); html.hide();
if(recentPosts.length === 0) { if(recentPosts.length === 0) {
html.appendTo(categoryBox); html.appendTo(category);
} else { } else {
html.insertBefore(recentPosts.first()); html.insertBefore(recentPosts.first());
} }
@ -54,7 +50,7 @@ define('forum/categories', ['components', 'translator'], function(components, tr
app.createUserTooltips(); app.createUserTooltips();
if (categoryBox.find('.post-preview').length > parseInt(numRecentReplies, 10)) { if (category.find('[component="category/posts"]').length > parseInt(numRecentReplies, 10)) {
recentPosts.last().remove(); recentPosts.last().remove();
} }

@ -30,7 +30,11 @@ define('components', function() {
}, },
'category/topic': function(name, value) { 'category/topic': function(name, value) {
return $('[data-' + name + '="' + value + '"]'); return $('[component="category/topic"][data-' + name + '="' + value + '"]');
},
'categories/category': function(name, value) {
return $('[component="categories/category"][data-' + name + '="' + value + '"]');
} }
}; };

Loading…
Cancel
Save