posts_list.tpl changes

v1.18.x
barisusakli 10 years ago
parent 275a9ef476
commit 17dfb4df94

@ -2,47 +2,16 @@
/* globals define, app, utils */ /* globals define, app, utils */
define('forum/account/favourites', ['forum/account/header', 'forum/infinitescroll'], function(header, infinitescroll) { define('forum/account/favourites', ['forum/account/header', 'forum/account/posts'], function(header, posts) {
var Favourites = {}; var Favourites = {};
Favourites.init = function() { Favourites.init = function() {
header.init(); header.init();
$('.user-favourite-posts img').addClass('img-responsive'); $('[component="post/content"] img').addClass('img-responsive');
if (!config.usePagination) { posts.handleInfiniteScroll('posts.loadMoreFavourites', 'account/favourites');
infinitescroll.init(loadMore);
}
}; };
function loadMore(direction) {
if (direction < 0) {
return;
}
infinitescroll.loadMore('posts.loadMoreFavourites', {
uid: ajaxify.variables.get('theirid'),
after: $('.user-favourite-posts').attr('data-nextstart')
}, function(data, done) {
if (data.posts && data.posts.length) {
onPostsLoaded(data.posts, done);
} else {
done();
}
$('.user-favourite-posts').attr('data-nextstart', data.nextStart);
});
}
function onPostsLoaded(posts, callback) {
infinitescroll.parseAndTranslate('account/favourites', 'posts', {posts: posts}, function(html) {
$('.user-favourite-posts').append(html);
html.find('img').addClass('img-responsive');
html.find('.timeago').timeago();
app.createUserTooltips();
utils.makeNumbersHumanReadable(html.find('.human-readable-number'));
callback();
});
}
return Favourites; return Favourites;
}); });

@ -1,15 +1,22 @@
'use strict'; 'use strict';
/* globals define, app, socket, utils */ /* globals define, app, socket, utils, config, ajaxify */
define('forum/account/posts', ['forum/account/header', 'forum/infinitescroll'], function(header, infinitescroll) { define('forum/account/posts', ['forum/account/header', 'forum/infinitescroll'], function(header, infinitescroll) {
var AccountPosts = {}; var AccountPosts = {};
var method, template;
AccountPosts.init = function() { AccountPosts.init = function() {
header.init(); header.init();
$('.user-favourite-posts img').addClass('img-responsive'); $('[component="post/content"] img').addClass('img-responsive');
AccountPosts.handleInfiniteScroll('posts.loadMoreUserPosts', 'account/posts');
};
AccountPosts.handleInfiniteScroll = function(_method, _template) {
method = _method;
template = _template;
if (!config.usePagination) { if (!config.usePagination) {
infinitescroll.init(loadMore); infinitescroll.init(loadMore);
} }
@ -20,22 +27,22 @@ define('forum/account/posts', ['forum/account/header', 'forum/infinitescroll'],
return; return;
} }
infinitescroll.loadMore('posts.loadMoreUserPosts', { infinitescroll.loadMore(method, {
uid: $('.account-username-box').attr('data-uid'), uid: ajaxify.variables.get('theirid'),
after: $('.user-favourite-posts').attr('data-nextstart') after: $('[component="posts"]').attr('data-nextstart')
}, 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);
} else { } else {
done(); done();
} }
$('.user-favourite-posts').attr('data-nextstart', data.nextStart); $('[component="posts"]').attr('data-nextstart', data.nextStart);
}); });
} }
function onPostsLoaded(posts, callback) { function onPostsLoaded(posts, callback) {
infinitescroll.parseAndTranslate('account/posts', 'posts', {posts: posts}, function(html) { infinitescroll.parseAndTranslate(template, 'posts', {posts: posts}, function(html) {
$('.user-favourite-posts').append(html); $('[component="posts"]').append(html);
html.find('img').addClass('img-responsive'); html.find('img').addClass('img-responsive');
html.find('.timeago').timeago(); html.find('.timeago').timeago();
app.createUserTooltips(); app.createUserTooltips();

@ -40,10 +40,10 @@ define('forum/account/profile', ['forum/account/header', 'forum/infinitescroll',
}; };
function processPage() { function processPage() {
$('.user-recent-posts img, .post-signature img').addClass('img-responsive'); $('[component="posts"] img').addClass('img-responsive');
$('.user-recent-posts blockquote').prev('p').remove(); $('[component="post/content"] blockquote').prev('p').remove();
$('.user-recent-posts blockquote').remove(); $('[component="post/content"] blockquote').remove();
} }
function updateButtons() { function updateButtons() {
@ -57,7 +57,7 @@ define('forum/account/profile', ['forum/account/header', 'forum/infinitescroll',
socket.emit('user.' + type, { socket.emit('user.' + type, {
uid: theirid uid: theirid
}, function(err) { }, function(err) {
if(err) { if (err) {
return app.alertError(err.message); return app.alertError(err.message);
} }
@ -77,29 +77,29 @@ define('forum/account/profile', ['forum/account/header', 'forum/infinitescroll',
} }
function loadMorePosts(direction) { function loadMorePosts(direction) {
if(direction < 0 || !$('.user-recent-posts').length) { if (direction < 0 || !$('[component="posts"]').length) {
return; return;
} }
$('.loading-indicator').removeClass('hidden'); $('[component="posts/loading"]').removeClass('hidden');
infinitescroll.loadMore('posts.loadMoreUserPosts', { infinitescroll.loadMore('posts.loadMoreUserPosts', {
after: $('.user-recent-posts').attr('data-nextstart'), after: $('[component="posts"]').attr('data-nextstart'),
uid: theirid uid: theirid
}, 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-recent-posts').attr('data-nextstart', data.nextStart);
} else { } else {
done(); done();
} }
$('.loading-indicator').addClass('hidden'); $('[component="posts"]').attr('data-nextstart', data.nextStart);
$('[component="posts/loading"]').addClass('hidden');
}); });
} }
function onPostsLoaded(posts, callback) { function onPostsLoaded(posts, callback) {
posts = posts.filter(function(post) { posts = posts.filter(function(post) {
return !$('.user-recent-posts div[data-pid=' + post.pid + ']').length; return !$('[component="posts"] [data-pid=' + post.pid + ']').length;
}); });
if (!posts.length) { if (!posts.length) {
@ -108,7 +108,7 @@ define('forum/account/profile', ['forum/account/header', 'forum/infinitescroll',
infinitescroll.parseAndTranslate('account/profile', 'posts', {posts: posts}, function(html) { infinitescroll.parseAndTranslate('account/profile', 'posts', {posts: posts}, function(html) {
$('.user-recent-posts .loading-indicator').before(html); $('[component="posts"]').append(html);
html.find('.timeago').timeago(); html.find('.timeago').timeago();
callback(); callback();

Loading…
Cancel
Save