mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-06 04:21:17 +01:00
moved infinitescroll.parseAndTranslate to app.parseAndTranslate
This commit is contained in:
@@ -88,7 +88,7 @@ define('admin/manage/flags', [
|
||||
after: $('[data-next]').attr('data-next')
|
||||
}, function(data, done) {
|
||||
if (data.posts && data.posts.length) {
|
||||
infinitescroll.parseAndTranslate('admin/manage/flags', 'posts', {posts: data.posts}, function(html) {
|
||||
app.parseAndTranslate('admin/manage/flags', 'posts', {posts: data.posts}, function(html) {
|
||||
$('[data-next]').attr('data-next', data.next);
|
||||
$('.post-container').append(html);
|
||||
html.find('img:not(.not-responsive)').addClass('img-responsive');
|
||||
|
||||
@@ -30,7 +30,7 @@ define('admin/manage/tags', [
|
||||
return app.alertError(err.message);
|
||||
}
|
||||
|
||||
infinitescroll.parseAndTranslate('admin/manage/tags', 'tags', {tags: result.tags}, function(html) {
|
||||
app.parseAndTranslate('admin/manage/tags', 'tags', {tags: result.tags}, function(html) {
|
||||
$('.tag-list').html(html);
|
||||
utils.makeNumbersHumanReadable(html.find('.human-readable-number'));
|
||||
timeoutId = 0;
|
||||
|
||||
@@ -497,5 +497,20 @@ app.cacheBuster = null;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
app.parseAndTranslate = function(template, blockName, data, callback) {
|
||||
if (typeof blockName === 'string') {
|
||||
templates.parse(template, blockName, data, function(html) {
|
||||
translator.translate(html, function(translatedHTML) {
|
||||
callback($(translatedHTML));
|
||||
});
|
||||
});
|
||||
} else {
|
||||
callback = data, data = blockName;
|
||||
templates.parse(template, data, function(html) {
|
||||
translator.translate(html, function(translatedHTML) {
|
||||
callback($(translatedHTML));
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
}());
|
||||
|
||||
@@ -32,7 +32,7 @@ define('forum/account/followers', ['forum/account/header', 'forum/infinitescroll
|
||||
};
|
||||
|
||||
function onUsersLoaded(tpl, users, callback) {
|
||||
infinitescroll.parseAndTranslate(tpl, 'users', {users: users}, function(html) {
|
||||
app.parseAndTranslate(tpl, 'users', {users: users}, function(html) {
|
||||
$('#users-container').append(html);
|
||||
utils.addCommasToNumbers(html.find('.formatted-number'));
|
||||
callback();
|
||||
|
||||
@@ -41,7 +41,7 @@ define('forum/account/posts', ['forum/account/header', 'forum/infinitescroll'],
|
||||
}
|
||||
|
||||
function onPostsLoaded(posts, callback) {
|
||||
infinitescroll.parseAndTranslate(template, 'posts', {posts: posts}, function(html) {
|
||||
app.parseAndTranslate(template, 'posts', {posts: posts}, function(html) {
|
||||
$('[component="posts"]').append(html);
|
||||
html.find('img:not(.not-responsive)').addClass('img-responsive');
|
||||
html.find('.timeago').timeago();
|
||||
|
||||
@@ -112,7 +112,7 @@ define('forum/account/profile', [
|
||||
return callback();
|
||||
}
|
||||
|
||||
infinitescroll.parseAndTranslate('account/profile', 'posts', {posts: posts}, function(html) {
|
||||
app.parseAndTranslate('account/profile', 'posts', {posts: posts}, function(html) {
|
||||
|
||||
$('[component="posts"]').append(html);
|
||||
html.find('.timeago').timeago();
|
||||
|
||||
@@ -41,7 +41,7 @@ define('forum/account/topics', ['forum/account/header', 'forum/infinitescroll'],
|
||||
}
|
||||
|
||||
function onTopicsLoaded(topics, callback) {
|
||||
infinitescroll.parseAndTranslate('account/topics', 'topics', {topics: topics}, function(html) {
|
||||
app.parseAndTranslate('account/topics', 'topics', {topics: topics}, function(html) {
|
||||
$('[component="category"]').append(html);
|
||||
html.find('.timeago').timeago();
|
||||
app.createUserTooltips();
|
||||
|
||||
@@ -305,7 +305,7 @@ define('forum/category', [
|
||||
before = topics.first();
|
||||
}
|
||||
|
||||
infinitescroll.parseAndTranslate('category', 'topics', data, function(html) {
|
||||
app.parseAndTranslate('category', 'topics', data, function(html) {
|
||||
$('[component="category"]').removeClass('hidden');
|
||||
$('.category-sidebar').removeClass('hidden');
|
||||
|
||||
|
||||
@@ -366,7 +366,7 @@ define('forum/chats', ['components', 'string', 'sounds', 'forum/infinitescroll',
|
||||
return callback();
|
||||
}
|
||||
|
||||
infinitescroll.parseAndTranslate('chats', 'chats', {chats: users}, function(html) {
|
||||
app.parseAndTranslate('chats', 'chats', {chats: users}, function(html) {
|
||||
$('.recent-chats').append(html);
|
||||
callback();
|
||||
});
|
||||
|
||||
@@ -85,7 +85,7 @@ define('forum/groups/memberlist', ['components', 'forum/infinitescroll'], functi
|
||||
}
|
||||
|
||||
function parseAndTranslate(users, callback) {
|
||||
infinitescroll.parseAndTranslate('groups/details', 'members', {
|
||||
app.parseAndTranslate('groups/details', 'members', {
|
||||
group: {
|
||||
members: users,
|
||||
isOwner: ajaxify.data.group.isOwner
|
||||
|
||||
@@ -60,14 +60,6 @@ define('forum/infinitescroll', ['translator'], function(translator) {
|
||||
});
|
||||
};
|
||||
|
||||
scroll.parseAndTranslate = function(template, blockName, data, callback) {
|
||||
templates.parse(template, blockName, data, function(html) {
|
||||
translator.translate(html, function(translatedHTML) {
|
||||
callback($(translatedHTML));
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
scroll.removeExtra = function(els, direction, count) {
|
||||
if (els.length <= count) {
|
||||
return;
|
||||
|
||||
@@ -47,7 +47,7 @@ define('forum/notifications', ['components', 'notifications', 'forum/infinitescr
|
||||
if (!data.notifications || !data.notifications.length) {
|
||||
return done();
|
||||
}
|
||||
infinitescroll.parseAndTranslate('notifications', 'notifications', {notifications: data.notifications}, function(html) {
|
||||
app.parseAndTranslate('notifications', 'notifications', {notifications: data.notifications}, function(html) {
|
||||
notifList.append(html);
|
||||
html.find('.timeago').timeago();
|
||||
done();
|
||||
|
||||
@@ -110,7 +110,7 @@ define('forum/recent', ['forum/infinitescroll', 'components'], function(infinite
|
||||
return callback();
|
||||
}
|
||||
|
||||
infinitescroll.parseAndTranslate(templateName, 'topics', {topics: topics, showSelect: showSelect}, function(html) {
|
||||
app.parseAndTranslate(templateName, 'topics', {topics: topics, showSelect: showSelect}, function(html) {
|
||||
$('#category-no-topics').remove();
|
||||
|
||||
$('[component="category"]').append(html);
|
||||
|
||||
@@ -64,7 +64,7 @@ define('forum/tags', ['forum/infinitescroll'], function(infinitescroll) {
|
||||
|
||||
function onTagsLoaded(tags, replace, callback) {
|
||||
callback = callback || function() {};
|
||||
infinitescroll.parseAndTranslate('tags', 'tags', {tags: tags}, function(html) {
|
||||
app.parseAndTranslate('tags', 'tags', {tags: tags}, function(html) {
|
||||
$('.tag-list')[replace ? 'html' : 'append'](html);
|
||||
utils.makeNumbersHumanReadable(html.find('.human-readable-number'));
|
||||
callback();
|
||||
|
||||
@@ -145,7 +145,7 @@ define('forum/topic/posts', [
|
||||
|
||||
$(window).trigger('action:posts.loading', {posts: data.posts, after: after, before: before});
|
||||
|
||||
infinitescroll.parseAndTranslate('topic', 'posts', data, function(html) {
|
||||
app.parseAndTranslate('topic', 'posts', data, function(html) {
|
||||
if (after) {
|
||||
html.insertAfter(after);
|
||||
} else if (before) {
|
||||
|
||||
Reference in New Issue
Block a user