mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 03:55:55 +01:00
closes #3038
This commit is contained in:
@@ -10,7 +10,9 @@ define('forum/account/favourites', ['forum/account/header', 'forum/infinitescrol
|
|||||||
|
|
||||||
$('.user-favourite-posts img').addClass('img-responsive');
|
$('.user-favourite-posts img').addClass('img-responsive');
|
||||||
|
|
||||||
infinitescroll.init(loadMore);
|
if (!config.usePagination) {
|
||||||
|
infinitescroll.init(loadMore);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function loadMore(direction) {
|
function loadMore(direction) {
|
||||||
@@ -24,10 +26,10 @@ define('forum/account/favourites', ['forum/account/header', 'forum/infinitescrol
|
|||||||
}, function(data, done) {
|
}, function(data, done) {
|
||||||
if (data.posts && data.posts.length) {
|
if (data.posts && data.posts.length) {
|
||||||
onPostsLoaded(data.posts, done);
|
onPostsLoaded(data.posts, done);
|
||||||
$('.user-favourite-posts').attr('data-nextstart', data.nextStart);
|
|
||||||
} else {
|
} else {
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
$('.user-favourite-posts').attr('data-nextstart', data.nextStart);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ define('forum/account/posts', ['forum/account/header', 'forum/infinitescroll'],
|
|||||||
|
|
||||||
$('.user-favourite-posts img').addClass('img-responsive');
|
$('.user-favourite-posts img').addClass('img-responsive');
|
||||||
|
|
||||||
infinitescroll.init(loadMore);
|
if (!config.usePagination) {
|
||||||
|
infinitescroll.init(loadMore);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function loadMore(direction) {
|
function loadMore(direction) {
|
||||||
@@ -24,10 +26,10 @@ define('forum/account/posts', ['forum/account/header', 'forum/infinitescroll'],
|
|||||||
}, function(data, done) {
|
}, function(data, done) {
|
||||||
if (data.posts && data.posts.length) {
|
if (data.posts && data.posts.length) {
|
||||||
onPostsLoaded(data.posts, done);
|
onPostsLoaded(data.posts, done);
|
||||||
$('.user-favourite-posts').attr('data-nextstart', data.nextStart);
|
|
||||||
} else {
|
} else {
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
$('.user-favourite-posts').attr('data-nextstart', data.nextStart);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ define('forum/account/topics', ['forum/account/header', 'forum/infinitescroll'],
|
|||||||
AccountTopics.init = function() {
|
AccountTopics.init = function() {
|
||||||
header.init();
|
header.init();
|
||||||
|
|
||||||
infinitescroll.init(loadMore);
|
if (!config.usePagination) {
|
||||||
|
infinitescroll.init(loadMore);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function loadMore(direction) {
|
function loadMore(direction) {
|
||||||
@@ -23,10 +25,10 @@ define('forum/account/topics', ['forum/account/header', 'forum/infinitescroll'],
|
|||||||
|
|
||||||
if (data.topics && data.topics.length) {
|
if (data.topics && data.topics.length) {
|
||||||
onTopicsLoaded(data.topics, done);
|
onTopicsLoaded(data.topics, done);
|
||||||
$('[component="category"]').attr('data-nextstart', data.nextStart);
|
|
||||||
} else {
|
} else {
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
$('[component="category"]').attr('data-nextstart', data.nextStart);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ define('forum/account/watched', ['forum/account/header', 'forum/infinitescroll']
|
|||||||
AccountWatched.init = function() {
|
AccountWatched.init = function() {
|
||||||
header.init();
|
header.init();
|
||||||
|
|
||||||
infinitescroll.init(loadMore);
|
if (!config.usePagination) {
|
||||||
|
infinitescroll.init(loadMore);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function loadMore(direction) {
|
function loadMore(direction) {
|
||||||
@@ -21,10 +23,10 @@ define('forum/account/watched', ['forum/account/header', 'forum/infinitescroll']
|
|||||||
}, function(data, done) {
|
}, function(data, done) {
|
||||||
if (data.topics && data.topics.length) {
|
if (data.topics && data.topics.length) {
|
||||||
onTopicsLoaded(data.topics, done);
|
onTopicsLoaded(data.topics, done);
|
||||||
$('[component="category"]').attr('data-nextstart', data.nextStart);
|
|
||||||
} else {
|
} else {
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
$('[component="category"]').attr('data-nextstart', data.nextStart);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -342,17 +342,16 @@ define('forum/category', [
|
|||||||
after: after,
|
after: after,
|
||||||
author: utils.params().author
|
author: utils.params().author
|
||||||
}, function (data, done) {
|
}, function (data, done) {
|
||||||
|
|
||||||
if (data.topics && data.topics.length) {
|
if (data.topics && data.topics.length) {
|
||||||
Category.onTopicsLoaded(data, function() {
|
Category.onTopicsLoaded(data, function() {
|
||||||
done();
|
done();
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
$('[component="category"]').attr('data-nextstart', data.nextStart);
|
|
||||||
} else {
|
} else {
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$('[component="category"]').attr('data-nextstart', data.nextStart);
|
||||||
$(window).trigger('action:categories.loaded');
|
$(window).trigger('action:categories.loaded');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,10 +93,10 @@ define('forum/recent', ['forum/infinitescroll', 'components'], function(infinite
|
|||||||
}, function(data, done) {
|
}, function(data, done) {
|
||||||
if (data.topics && data.topics.length) {
|
if (data.topics && data.topics.length) {
|
||||||
Recent.onTopicsLoaded('recent', data.topics, false, done);
|
Recent.onTopicsLoaded('recent', data.topics, false, done);
|
||||||
$('[component="category"]').attr('data-nextstart', data.nextStart);
|
|
||||||
} else {
|
} else {
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
$('[component="category"]').attr('data-nextstart', data.nextStart);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -29,11 +29,11 @@ define('forum/tag', ['forum/recent', 'forum/infinitescroll'], function(recent, i
|
|||||||
}, function(data, done) {
|
}, function(data, done) {
|
||||||
if (data.topics && data.topics.length) {
|
if (data.topics && data.topics.length) {
|
||||||
recent.onTopicsLoaded('tag', data.topics, false, done);
|
recent.onTopicsLoaded('tag', data.topics, false, done);
|
||||||
$('[component="category"]').attr('data-nextstart', data.nextStart);
|
|
||||||
} else {
|
} else {
|
||||||
done();
|
done();
|
||||||
$('#load-more-btn').hide();
|
$('#load-more-btn').hide();
|
||||||
}
|
}
|
||||||
|
$('[component="category"]').attr('data-nextstart', data.nextStart);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -255,22 +255,48 @@ accountsController.getGroups = function(req, res, next) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function getFromUserSet(tpl, set, method, type, req, res, next) {
|
function getFromUserSet(tpl, set, method, type, req, res, next) {
|
||||||
accountsController.getBaseUser(req.params.userslug, req.uid, function(err, userData) {
|
async.parallel({
|
||||||
|
settings: function(next) {
|
||||||
|
user.getSettings(req.uid, next);
|
||||||
|
},
|
||||||
|
userData: function(next) {
|
||||||
|
accountsController.getBaseUser(req.params.userslug, req.uid, next);
|
||||||
|
}
|
||||||
|
}, function(err, results) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
var userData = results.userData;
|
||||||
if (!userData) {
|
if (!userData) {
|
||||||
return helpers.notFound(req, res);
|
return helpers.notFound(req, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
method('uid:' + userData.uid + ':' + set, req.uid, 0, 19, function(err, data) {
|
var setName = 'uid:' + userData.uid + ':' + set;
|
||||||
|
|
||||||
|
var page = Math.max(1, parseInt(req.query.page, 10) || 1);
|
||||||
|
var itemsPerPage = (tpl === 'account/topics' || tpl === 'account/watched') ? results.settings.topicsPerPage : results.settings.postsPerPage;
|
||||||
|
itemsPerPage = parseInt(itemsPerPage, 10);
|
||||||
|
|
||||||
|
async.parallel({
|
||||||
|
count: function(next) {
|
||||||
|
db.sortedSetCard(setName, next);
|
||||||
|
},
|
||||||
|
data: function(next) {
|
||||||
|
var start = (page - 1) * itemsPerPage;
|
||||||
|
var stop = start + itemsPerPage;
|
||||||
|
method(setName, req.uid, start, stop, next);
|
||||||
|
}
|
||||||
|
}, function(err, results) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
userData[type] = data[type];
|
userData[type] = results.data[type];
|
||||||
userData.nextStart = data.nextStart;
|
userData.nextStart = results.data.nextStart;
|
||||||
|
var pageCount = Math.ceil(results.count / itemsPerPage);
|
||||||
|
|
||||||
|
var pagination = require('../pagination');
|
||||||
|
userData.pagination = pagination.create(page, pageCount);
|
||||||
|
|
||||||
res.render(tpl, userData);
|
res.render(tpl, userData);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ pagination.create = function(currentPage, pageCount, queryObj) {
|
|||||||
pages: []
|
pages: []
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
pageCount = parseInt(pageCount, 10);
|
||||||
var pagesToShow = [1, 2, pageCount - 1, pageCount];
|
var pagesToShow = [1, 2, pageCount - 1, pageCount];
|
||||||
|
|
||||||
currentPage = parseInt(currentPage, 10) || 1;
|
currentPage = parseInt(currentPage, 10) || 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user