mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-11 16:35:47 +01:00
fixed pagination, and loading of template blocks on cold load (temp solution)
This commit is contained in:
@@ -74,10 +74,13 @@ define(['forum/accountheader'], function(header) {
|
|||||||
socket.emit('user.isOnline', theirid, Account.handleUserOnline);
|
socket.emit('user.isOnline', theirid, Account.handleUserOnline);
|
||||||
|
|
||||||
socket.on('event:new_post', function(data) {
|
socket.on('event:new_post', function(data) {
|
||||||
|
templates.preload_template('account', function() {
|
||||||
|
templates['account'].parse({posts:[]});
|
||||||
var html = templates.prepare(templates['account'].blocks['posts']).parse(data);
|
var html = templates.prepare(templates['account'].blocks['posts']).parse(data);
|
||||||
$('.user-recent-posts').prepend(html);
|
$('.user-recent-posts').prepend(html);
|
||||||
$('.user-recent-posts span.timeago').timeago();
|
$('.user-recent-posts span.timeago').timeago();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ define(['forum/accountheader'], function(header) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onTopicsLoaded(posts) {
|
function onTopicsLoaded(posts) {
|
||||||
|
templates.preload_template('accountposts', function() {
|
||||||
|
templates['accountposts'].parse(posts: []);
|
||||||
var html = templates.prepare(templates['accountposts'].blocks['posts']).parse({
|
var html = templates.prepare(templates['accountposts'].blocks['posts']).parse({
|
||||||
posts: posts
|
posts: posts
|
||||||
});
|
});
|
||||||
@@ -49,6 +51,7 @@ define(['forum/accountheader'], function(header) {
|
|||||||
app.createUserTooltips();
|
app.createUserTooltips();
|
||||||
app.makeNumbersHumanReadable(html.find('.human-readable-number'));
|
app.makeNumbersHumanReadable(html.find('.human-readable-number'));
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return AccountPosts;
|
return AccountPosts;
|
||||||
|
|||||||
@@ -117,6 +117,8 @@ define(['uploader'], function(uploader) {
|
|||||||
timeout: 2000
|
timeout: 2000
|
||||||
});
|
});
|
||||||
|
|
||||||
|
templates.preload_template('admin/categories', function() {
|
||||||
|
templates['admin/categories'].parse({categories:[]});
|
||||||
var html = templates.prepare(templates['admin/categories'].blocks['categories']).parse({
|
var html = templates.prepare(templates['admin/categories'].blocks['categories']).parse({
|
||||||
categories: [data]
|
categories: [data]
|
||||||
});
|
});
|
||||||
@@ -126,6 +128,7 @@ define(['uploader'], function(uploader) {
|
|||||||
$('#entry-container').append(html);
|
$('#entry-container').append(html);
|
||||||
$('#new-category-modal').modal('hide');
|
$('#new-category-modal').modal('hide');
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function enableColorPicker(idx, inputEl) {
|
function enableColorPicker(idx, inputEl) {
|
||||||
|
|||||||
@@ -62,6 +62,8 @@ define(function() {
|
|||||||
var btnEl = $('#topics_loadmore');
|
var btnEl = $('#topics_loadmore');
|
||||||
|
|
||||||
if (topics.length > 0) {
|
if (topics.length > 0) {
|
||||||
|
templates.preload_template('admin/topics', function() {
|
||||||
|
templates['admin/topics'].parse({topics:[]});
|
||||||
var html = templates.prepare(templates['admin/topics'].blocks['topics']).parse({
|
var html = templates.prepare(templates['admin/topics'].blocks['topics']).parse({
|
||||||
topics: topics
|
topics: topics
|
||||||
}),
|
}),
|
||||||
@@ -76,6 +78,7 @@ define(function() {
|
|||||||
|
|
||||||
btnEl.html('Load More Topics');
|
btnEl.html('Load More Topics');
|
||||||
$('span.timeago').timeago();
|
$('span.timeago').timeago();
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
// Exhausted all topics
|
// Exhausted all topics
|
||||||
btnEl.addClass('disabled');
|
btnEl.addClass('disabled');
|
||||||
|
|||||||
@@ -190,6 +190,8 @@ define(function() {
|
|||||||
return app.alertError(err.message);
|
return app.alertError(err.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
templates.preload_template('admin/users', function() {
|
||||||
|
templates['admin/users'].parse({users:[]});
|
||||||
var html = templates.prepare(templates['admin/users'].blocks['users']).parse({
|
var html = templates.prepare(templates['admin/users'].blocks['users']).parse({
|
||||||
users: data.users
|
users: data.users
|
||||||
}),
|
}),
|
||||||
@@ -212,6 +214,7 @@ define(function() {
|
|||||||
|
|
||||||
updateButtons();
|
updateButtons();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}, 250);
|
}, 250);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -220,6 +223,8 @@ define(function() {
|
|||||||
handleUserCreate();
|
handleUserCreate();
|
||||||
|
|
||||||
function onUsersLoaded(users) {
|
function onUsersLoaded(users) {
|
||||||
|
templates.preload_template('admin/users', function() {
|
||||||
|
templates['admin/users'].parse({users:[]});
|
||||||
var html = templates.prepare(templates['admin/users'].blocks['users']).parse({
|
var html = templates.prepare(templates['admin/users'].blocks['users']).parse({
|
||||||
users: users
|
users: users
|
||||||
});
|
});
|
||||||
@@ -228,6 +233,7 @@ define(function() {
|
|||||||
|
|
||||||
updateUserBanButtons(html.find('.ban-btn'));
|
updateUserBanButtons(html.find('.ban-btn'));
|
||||||
updateUserAdminButtons(html.find('.admin-btn'));
|
updateUserAdminButtons(html.find('.admin-btn'));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadMoreUsers() {
|
function loadMoreUsers() {
|
||||||
|
|||||||
@@ -162,7 +162,8 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
|
|||||||
|
|
||||||
Category.onNewTopic = function(data) {
|
Category.onNewTopic = function(data) {
|
||||||
$(window).trigger('filter:categories.new_topic', data);
|
$(window).trigger('filter:categories.new_topic', data);
|
||||||
|
templates.preload_template('category', function() {
|
||||||
|
templates['category'].parse({topics:[]});
|
||||||
var html = templates.prepare(templates['category'].blocks['topics']).parse({
|
var html = templates.prepare(templates['category'].blocks['topics']).parse({
|
||||||
topics: [data]
|
topics: [data]
|
||||||
});
|
});
|
||||||
@@ -202,6 +203,7 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
|
|||||||
|
|
||||||
$(window).trigger('action:categories.new_topic.loaded');
|
$(window).trigger('action:categories.new_topic.loaded');
|
||||||
});
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Category.onTopicsLoaded = function(topics, callback) {
|
Category.onTopicsLoaded = function(topics, callback) {
|
||||||
@@ -239,6 +241,8 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
|
|||||||
|
|
||||||
findInsertionPoint();
|
findInsertionPoint();
|
||||||
|
|
||||||
|
templates.preload_template('category', function() {
|
||||||
|
templates['category'].parse({topics:[]});
|
||||||
var html = templates.prepare(templates['category'].blocks['topics']).parse({
|
var html = templates.prepare(templates['category'].blocks['topics']).parse({
|
||||||
topics: topics
|
topics: topics
|
||||||
});
|
});
|
||||||
@@ -270,6 +274,7 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
|
|||||||
callback(topics);
|
callback(topics);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Category.loadMoreTopics = function(cid, after, callback) {
|
Category.loadMoreTopics = function(cid, after, callback) {
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ define(['forum/accountheader'], function(header) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onTopicsLoaded(posts) {
|
function onTopicsLoaded(posts) {
|
||||||
|
templates.preload_template('favourites', function() {
|
||||||
|
templates['favourites'].parse({posts:[]});
|
||||||
var html = templates.prepare(templates['favourites'].blocks['posts']).parse({
|
var html = templates.prepare(templates['favourites'].blocks['posts']).parse({
|
||||||
posts: posts
|
posts: posts
|
||||||
});
|
});
|
||||||
@@ -48,6 +50,7 @@ define(['forum/accountheader'], function(header) {
|
|||||||
app.createUserTooltips();
|
app.createUserTooltips();
|
||||||
app.makeNumbersHumanReadable(html.find('.human-readable-number'));
|
app.makeNumbersHumanReadable(html.find('.human-readable-number'));
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return Favourites;
|
return Favourites;
|
||||||
|
|||||||
@@ -116,6 +116,8 @@ define(function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Recent.onTopicsLoaded = function(template, topics) {
|
Recent.onTopicsLoaded = function(template, topics) {
|
||||||
|
templates.preload_template(template, function() {
|
||||||
|
templates[template].parse({topics:[]});
|
||||||
var html = templates.prepare(templates[template].blocks['topics']).parse({
|
var html = templates.prepare(templates[template].blocks['topics']).parse({
|
||||||
topics: topics
|
topics: topics
|
||||||
});
|
});
|
||||||
@@ -130,6 +132,7 @@ define(function() {
|
|||||||
app.createUserTooltips();
|
app.createUserTooltips();
|
||||||
app.makeNumbersHumanReadable(html.find('.human-readable-number'));
|
app.makeNumbersHumanReadable(html.find('.human-readable-number'));
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return Recent;
|
return Recent;
|
||||||
|
|||||||
@@ -1233,8 +1233,11 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function parseAndTranslatePosts(data, callback) {
|
function parseAndTranslatePosts(data, callback) {
|
||||||
|
templates.preload_template('topic', function() {
|
||||||
|
templates['topic'].parse({posts: []});
|
||||||
var html = templates.prepare(templates['topic'].blocks['posts']).parse(data);
|
var html = templates.prepare(templates['topic'].blocks['posts']).parse(data);
|
||||||
translator.translate(html, callback);
|
translator.translate(html, callback);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,8 @@ define(function() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
templates.preload_template('users', function() {
|
||||||
|
templates['users'].parse({users:[]});
|
||||||
var html = templates.prepare(templates['users'].blocks['users']).parse({
|
var html = templates.prepare(templates['users'].blocks['users']).parse({
|
||||||
users: data.users
|
users: data.users
|
||||||
}),
|
}),
|
||||||
@@ -74,7 +76,7 @@ define(function() {
|
|||||||
$('#user-notfound-notify').html(data.users.length + ' user' + (data.users.length > 1 ? 's' : '') + ' found! Search took ' + data.timing + ' ms.');
|
$('#user-notfound-notify').html(data.users.length + ' user' + (data.users.length > 1 ? 's' : '') + ' found! Search took ' + data.timing + ' ms.');
|
||||||
$('#user-notfound-notify').parent().addClass('btn-success label-success');
|
$('#user-notfound-notify').parent().addClass('btn-success label-success');
|
||||||
}
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}, 500); //replace this with global throttling function/constant
|
}, 500); //replace this with global throttling function/constant
|
||||||
|
|
||||||
@@ -108,6 +110,8 @@ define(function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onUsersLoaded(users, emptyContainer) {
|
function onUsersLoaded(users, emptyContainer) {
|
||||||
|
templates.preload_template('users', function() {
|
||||||
|
templates['useres'].parse({users:[]});
|
||||||
var html = templates.prepare(templates['users'].blocks['users']).parse({
|
var html = templates.prepare(templates['users'].blocks['users']).parse({
|
||||||
users: users
|
users: users
|
||||||
});
|
});
|
||||||
@@ -120,6 +124,7 @@ define(function() {
|
|||||||
$('#users-container').append(translated);
|
$('#users-container').append(translated);
|
||||||
$('#users-container .anon-user').appendTo($('#users-container'));
|
$('#users-container .anon-user').appendTo($('#users-container'));
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadMoreUsers() {
|
function loadMoreUsers() {
|
||||||
|
|||||||
Reference in New Issue
Block a user