posts_list.tpl changes

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

@ -2,47 +2,16 @@
/* 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 = {};
Favourites.init = function() {
header.init();
$('.user-favourite-posts img').addClass('img-responsive');
$('[component="post/content"] img').addClass('img-responsive');
if (!config.usePagination) {
infinitescroll.init(loadMore);
}
posts.handleInfiniteScroll('posts.loadMoreFavourites', 'account/favourites');
};
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;
});

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

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

Loading…
Cancel
Save