v1.18.x
barisusakli 10 years ago
parent 6dfb229c66
commit dd61bdb9c6

@ -10,7 +10,9 @@ define('forum/account/favourites', ['forum/account/header', 'forum/infinitescrol
$('.user-favourite-posts img').addClass('img-responsive');
infinitescroll.init(loadMore);
if (!config.usePagination) {
infinitescroll.init(loadMore);
}
};
function loadMore(direction) {
@ -24,10 +26,10 @@ define('forum/account/favourites', ['forum/account/header', 'forum/infinitescrol
}, function(data, done) {
if (data.posts && data.posts.length) {
onPostsLoaded(data.posts, done);
$('.user-favourite-posts').attr('data-nextstart', data.nextStart);
} else {
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');
infinitescroll.init(loadMore);
if (!config.usePagination) {
infinitescroll.init(loadMore);
}
};
function loadMore(direction) {
@ -24,10 +26,10 @@ define('forum/account/posts', ['forum/account/header', 'forum/infinitescroll'],
}, function(data, done) {
if (data.posts && data.posts.length) {
onPostsLoaded(data.posts, done);
$('.user-favourite-posts').attr('data-nextstart', data.nextStart);
} else {
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() {
header.init();
infinitescroll.init(loadMore);
if (!config.usePagination) {
infinitescroll.init(loadMore);
}
};
function loadMore(direction) {
@ -23,10 +25,10 @@ define('forum/account/topics', ['forum/account/header', 'forum/infinitescroll'],
if (data.topics && data.topics.length) {
onTopicsLoaded(data.topics, done);
$('[component="category"]').attr('data-nextstart', data.nextStart);
} else {
done();
}
$('[component="category"]').attr('data-nextstart', data.nextStart);
});
}

@ -7,7 +7,9 @@ define('forum/account/watched', ['forum/account/header', 'forum/infinitescroll']
AccountWatched.init = function() {
header.init();
infinitescroll.init(loadMore);
if (!config.usePagination) {
infinitescroll.init(loadMore);
}
};
function loadMore(direction) {
@ -21,10 +23,10 @@ define('forum/account/watched', ['forum/account/header', 'forum/infinitescroll']
}, function(data, done) {
if (data.topics && data.topics.length) {
onTopicsLoaded(data.topics, done);
$('[component="category"]').attr('data-nextstart', data.nextStart);
} else {
done();
}
$('[component="category"]').attr('data-nextstart', data.nextStart);
});
}

@ -342,17 +342,16 @@ define('forum/category', [
after: after,
author: utils.params().author
}, function (data, done) {
if (data.topics && data.topics.length) {
Category.onTopicsLoaded(data, function() {
done();
callback();
});
$('[component="category"]').attr('data-nextstart', data.nextStart);
} else {
done();
}
$('[component="category"]').attr('data-nextstart', data.nextStart);
$(window).trigger('action:categories.loaded');
});
}

@ -93,10 +93,10 @@ define('forum/recent', ['forum/infinitescroll', 'components'], function(infinite
}, function(data, done) {
if (data.topics && data.topics.length) {
Recent.onTopicsLoaded('recent', data.topics, false, done);
$('[component="category"]').attr('data-nextstart', data.nextStart);
} else {
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) {
if (data.topics && data.topics.length) {
recent.onTopicsLoaded('tag', data.topics, false, done);
$('[component="category"]').attr('data-nextstart', data.nextStart);
} else {
done();
$('#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) {
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) {
return next(err);
}
var userData = results.userData;
if (!userData) {
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) {
return next(err);
}
userData[type] = data[type];
userData.nextStart = data.nextStart;
userData[type] = results.data[type];
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);
});

@ -13,7 +13,7 @@ pagination.create = function(currentPage, pageCount, queryObj) {
pages: []
};
}
pageCount = parseInt(pageCount, 10);
var pagesToShow = [1, 2, pageCount - 1, pageCount];
currentPage = parseInt(currentPage, 10) || 1;

Loading…
Cancel
Save