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.
57 lines
1.3 KiB
JavaScript
57 lines
1.3 KiB
JavaScript
define(['forum/accountheader'], function(header) {
|
|
var Favourites = {},
|
|
loadingMore = false;
|
|
|
|
Favourites.init = function() {
|
|
header.init();
|
|
|
|
$('.user-favourite-posts img').addClass('img-responsive');
|
|
|
|
app.enableInfiniteLoading(function() {
|
|
if(!loadingMore) {
|
|
loadMore();
|
|
}
|
|
});
|
|
};
|
|
|
|
function loadMore() {
|
|
loadingMore = true;
|
|
socket.emit('posts.loadMoreFavourites', {
|
|
after: $('.user-favourite-posts').attr('data-nextstart')
|
|
}, function(err, data) {
|
|
if(err) {
|
|
return app.alertError(err.message);
|
|
}
|
|
|
|
if (data.posts && data.posts.length) {
|
|
onTopicsLoaded(data.posts);
|
|
$('.user-favourite-posts').attr('data-nextstart', data.nextStart);
|
|
}
|
|
|
|
loadingMore = false;
|
|
});
|
|
}
|
|
|
|
function onTopicsLoaded(posts) {
|
|
templates.preload_template('favourites', function() {
|
|
templates['favourites'].parse({posts:[]});
|
|
var html = templates.prepare(templates['favourites'].blocks['posts']).parse({
|
|
posts: posts
|
|
});
|
|
|
|
translator.translate(html, function(translatedHTML) {
|
|
|
|
$('#category-no-topics').remove();
|
|
|
|
html = $(translatedHTML);
|
|
html.find('img').addClass('img-responsive');
|
|
$('.user-favourite-posts').append(html);
|
|
$('span.timeago').timeago();
|
|
app.createUserTooltips();
|
|
app.makeNumbersHumanReadable(html.find('.human-readable-number'));
|
|
});
|
|
});
|
|
}
|
|
|
|
return Favourites;
|
|
}); |