fixed pagination, and loading of template blocks on cold load (temp solution)

v1.18.x
psychobunny 11 years ago
parent 6ea4d89edc
commit 857df86726

@ -74,10 +74,13 @@ define(['forum/accountheader'], function(header) {
socket.emit('user.isOnline', theirid, Account.handleUserOnline);
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);
$('.user-recent-posts').prepend(html);
$('.user-recent-posts span.timeago').timeago();
});
});
});
};

@ -34,6 +34,8 @@ define(['forum/accountheader'], function(header) {
}
function onTopicsLoaded(posts) {
templates.preload_template('accountposts', function() {
templates['accountposts'].parse(posts: []);
var html = templates.prepare(templates['accountposts'].blocks['posts']).parse({
posts: posts
});
@ -49,6 +51,7 @@ define(['forum/accountheader'], function(header) {
app.createUserTooltips();
app.makeNumbersHumanReadable(html.find('.human-readable-number'));
});
});
}
return AccountPosts;

@ -117,6 +117,8 @@ define(['uploader'], function(uploader) {
timeout: 2000
});
templates.preload_template('admin/categories', function() {
templates['admin/categories'].parse({categories:[]});
var html = templates.prepare(templates['admin/categories'].blocks['categories']).parse({
categories: [data]
});
@ -126,6 +128,7 @@ define(['uploader'], function(uploader) {
$('#entry-container').append(html);
$('#new-category-modal').modal('hide');
});
});
}
function enableColorPicker(idx, inputEl) {

@ -62,6 +62,8 @@ define(function() {
var btnEl = $('#topics_loadmore');
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({
topics: topics
}),
@ -76,6 +78,7 @@ define(function() {
btnEl.html('Load More Topics');
$('span.timeago').timeago();
});
} else {
// Exhausted all topics
btnEl.addClass('disabled');

@ -190,6 +190,8 @@ define(function() {
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({
users: data.users
}),
@ -212,6 +214,7 @@ define(function() {
updateButtons();
});
});
}, 250);
});
@ -220,6 +223,8 @@ define(function() {
handleUserCreate();
function onUsersLoaded(users) {
templates.preload_template('admin/users', function() {
templates['admin/users'].parse({users:[]});
var html = templates.prepare(templates['admin/users'].blocks['users']).parse({
users: users
});
@ -228,6 +233,7 @@ define(function() {
updateUserBanButtons(html.find('.ban-btn'));
updateUserAdminButtons(html.find('.admin-btn'));
});
}
function loadMoreUsers() {

@ -162,7 +162,8 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
Category.onNewTopic = function(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({
topics: [data]
});
@ -202,6 +203,7 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
$(window).trigger('action:categories.new_topic.loaded');
});
});
};
Category.onTopicsLoaded = function(topics, callback) {
@ -239,6 +241,8 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
findInsertionPoint();
templates.preload_template('category', function() {
templates['category'].parse({topics:[]});
var html = templates.prepare(templates['category'].blocks['topics']).parse({
topics: topics
});
@ -270,6 +274,7 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
callback(topics);
}
});
});
};
Category.loadMoreTopics = function(cid, after, callback) {

@ -33,6 +33,8 @@ define(['forum/accountheader'], function(header) {
}
function onTopicsLoaded(posts) {
templates.preload_template('favourites', function() {
templates['favourites'].parse({posts:[]});
var html = templates.prepare(templates['favourites'].blocks['posts']).parse({
posts: posts
});
@ -48,6 +50,7 @@ define(['forum/accountheader'], function(header) {
app.createUserTooltips();
app.makeNumbersHumanReadable(html.find('.human-readable-number'));
});
});
}
return Favourites;

@ -116,6 +116,8 @@ define(function() {
}
Recent.onTopicsLoaded = function(template, topics) {
templates.preload_template(template, function() {
templates[template].parse({topics:[]});
var html = templates.prepare(templates[template].blocks['topics']).parse({
topics: topics
});
@ -130,6 +132,7 @@ define(function() {
app.createUserTooltips();
app.makeNumbersHumanReadable(html.find('.human-readable-number'));
});
});
}
return Recent;

@ -1233,8 +1233,11 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
}
function parseAndTranslatePosts(data, callback) {
templates.preload_template('topic', function() {
templates['topic'].parse({posts: []});
var html = templates.prepare(templates['topic'].blocks['posts']).parse(data);
translator.translate(html, callback);
});
}

@ -59,6 +59,8 @@ define(function() {
return;
}
templates.preload_template('users', function() {
templates['users'].parse({users:[]});
var html = templates.prepare(templates['users'].blocks['users']).parse({
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').parent().addClass('btn-success label-success');
}
});
});
}, 500); //replace this with global throttling function/constant
@ -108,6 +110,8 @@ define(function() {
}
function onUsersLoaded(users, emptyContainer) {
templates.preload_template('users', function() {
templates['useres'].parse({users:[]});
var html = templates.prepare(templates['users'].blocks['users']).parse({
users: users
});
@ -120,6 +124,7 @@ define(function() {
$('#users-container').append(translated);
$('#users-container .anon-user').appendTo($('#users-container'));
});
});
}
function loadMoreUsers() {

Loading…
Cancel
Save