Merge branch 'master' of github.com:designcreateplay/NodeBB
commit
25b48c43eb
@ -1,9 +1,51 @@
|
||||
define(['forum/accountheader'], function(header) {
|
||||
var AccountHeader = {};
|
||||
var Favourites = {},
|
||||
loadingMore = false;
|
||||
|
||||
AccountHeader.init = function() {
|
||||
Favourites.init = function() {
|
||||
header.init();
|
||||
|
||||
app.enableInfiniteLoading(function() {
|
||||
if(!loadingMore) {
|
||||
loadMore();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return AccountHeader;
|
||||
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) {
|
||||
var html = templates.prepare(templates['favourites'].blocks['posts']).parse({
|
||||
posts: posts
|
||||
});
|
||||
|
||||
translator.translate(html, function(translatedHTML) {
|
||||
|
||||
$('#category-no-topics').remove();
|
||||
|
||||
html = $(translatedHTML);
|
||||
$('.user-favourite-posts').append(html);
|
||||
$('span.timeago').timeago();
|
||||
app.createUserTooltips();
|
||||
app.makeNumbersHumanReadable(html.find('.human-readable-number'));
|
||||
});
|
||||
}
|
||||
|
||||
return Favourites;
|
||||
});
|
Loading…
Reference in New Issue