mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-11 08:25:46 +01:00
refactor: change Benchpress.parse to .render (#8856)
It has been deprecated with no warning message for a while Changing these over before enabling the warning message to reduce spam
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('admin/appearance/skins', ['translator', 'benchpress'], function (translator, Benchpress) {
|
define('admin/appearance/skins', ['translator'], function (translator) {
|
||||||
var Skins = {};
|
var Skins = {};
|
||||||
|
|
||||||
Skins.init = function () {
|
Skins.init = function () {
|
||||||
@@ -52,7 +52,7 @@ define('admin/appearance/skins', ['translator', 'benchpress'], function (transla
|
|||||||
Skins.render = function (bootswatch) {
|
Skins.render = function (bootswatch) {
|
||||||
var themeContainer = $('#bootstrap_themes');
|
var themeContainer = $('#bootstrap_themes');
|
||||||
|
|
||||||
Benchpress.parse('admin/partials/theme_list', {
|
app.parseAndTranslate('admin/partials/theme_list', {
|
||||||
themes: bootswatch.themes.map(function (theme) {
|
themes: bootswatch.themes.map(function (theme) {
|
||||||
return {
|
return {
|
||||||
type: 'bootswatch',
|
type: 'bootswatch',
|
||||||
@@ -67,7 +67,6 @@ define('admin/appearance/skins', ['translator', 'benchpress'], function (transla
|
|||||||
}),
|
}),
|
||||||
showRevert: true,
|
showRevert: true,
|
||||||
}, function (html) {
|
}, function (html) {
|
||||||
translator.translate(html, function (html) {
|
|
||||||
themeContainer.html(html);
|
themeContainer.html(html);
|
||||||
|
|
||||||
if (config['theme:src']) {
|
if (config['theme:src']) {
|
||||||
@@ -78,7 +77,6 @@ define('admin/appearance/skins', ['translator', 'benchpress'], function (transla
|
|||||||
highlightSelectedTheme(skin);
|
highlightSelectedTheme(skin);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function highlightSelectedTheme(themeId) {
|
function highlightSelectedTheme(themeId) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('admin/appearance/themes', ['translator', 'benchpress'], function (translator, Benchpress) {
|
define('admin/appearance/themes', ['translator'], function (translator) {
|
||||||
var Themes = {};
|
var Themes = {};
|
||||||
|
|
||||||
Themes.init = function () {
|
Themes.init = function () {
|
||||||
@@ -75,14 +75,12 @@ define('admin/appearance/themes', ['translator', 'benchpress'], function (transl
|
|||||||
if (!themes.length) {
|
if (!themes.length) {
|
||||||
instListEl.append($('<li/ >').addClass('no-themes').translateHtml('[[admin/appearance/themes:no-themes]]'));
|
instListEl.append($('<li/ >').addClass('no-themes').translateHtml('[[admin/appearance/themes:no-themes]]'));
|
||||||
} else {
|
} else {
|
||||||
Benchpress.parse('admin/partials/theme_list', {
|
app.parseAndTranslate('admin/partials/theme_list', {
|
||||||
themes: themes,
|
themes: themes,
|
||||||
}, function (html) {
|
}, function (html) {
|
||||||
translator.translate(html, function (html) {
|
|
||||||
instListEl.html(html);
|
instListEl.html(html);
|
||||||
highlightSelectedTheme(config['theme:id']);
|
highlightSelectedTheme(config['theme:id']);
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -343,7 +343,7 @@ define('admin/dashboard', ['Chart', 'translator', 'benchpress'], function (Chart
|
|||||||
$('[data-action="updateGraph"][data-units="custom"]').on('click', function () {
|
$('[data-action="updateGraph"][data-units="custom"]').on('click', function () {
|
||||||
var targetEl = $(this);
|
var targetEl = $(this);
|
||||||
|
|
||||||
Benchpress.parse('admin/partials/pageviews-range-select', {}, function (html) {
|
Benchpress.render('admin/partials/pageviews-range-select', {}).then(function (html) {
|
||||||
var modal = bootbox.dialog({
|
var modal = bootbox.dialog({
|
||||||
title: '[[admin/dashboard:page-views-custom]]',
|
title: '[[admin/dashboard:page-views-custom]]',
|
||||||
message: html,
|
message: html,
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ define('admin/extend/plugins', [
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pluginData.license && pluginData.active !== true) {
|
if (pluginData.license && pluginData.active !== true) {
|
||||||
Benchpress.parse('admin/partials/plugins/license', pluginData, function (html) {
|
Benchpress.render('admin/partials/plugins/license', pluginData).then(function (html) {
|
||||||
bootbox.dialog({
|
bootbox.dialog({
|
||||||
title: '[[admin/extend/plugins:license.title]]',
|
title: '[[admin/extend/plugins:license.title]]',
|
||||||
message: html,
|
message: html,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('admin/extend/rewards', ['translator', 'benchpress'], function (translator, Benchpress) {
|
define('admin/extend/rewards', [], function () {
|
||||||
var rewards = {};
|
var rewards = {};
|
||||||
|
|
||||||
|
|
||||||
@@ -139,13 +139,11 @@ define('admin/extend/rewards', ['translator', 'benchpress'], function (translato
|
|||||||
rewards: available,
|
rewards: available,
|
||||||
};
|
};
|
||||||
|
|
||||||
Benchpress.parse('admin/extend/rewards', 'active', data, function (li) {
|
app.parseAndTranslate('admin/extend/rewards', 'active', data, function (li) {
|
||||||
translator.translate(li, function (li) {
|
|
||||||
li = $(li);
|
li = $(li);
|
||||||
ul.append(li);
|
ul.append(li);
|
||||||
li.find('select').val('');
|
li.find('select').val('');
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveRewards() {
|
function saveRewards() {
|
||||||
|
|||||||
@@ -109,9 +109,9 @@ define('admin/manage/categories', [
|
|||||||
name: '[[admin/manage/categories:parent-category-none]]',
|
name: '[[admin/manage/categories:parent-category-none]]',
|
||||||
icon: 'fa-none',
|
icon: 'fa-none',
|
||||||
});
|
});
|
||||||
Benchpress.parse('admin/partials/categories/create', {
|
Benchpress.render('admin/partials/categories/create', {
|
||||||
categories: categories,
|
categories: categories,
|
||||||
}, function (html) {
|
}).then(function (html) {
|
||||||
var modal = bootbox.dialog({
|
var modal = bootbox.dialog({
|
||||||
title: '[[admin/manage/categories:alert.create]]',
|
title: '[[admin/manage/categories:alert.create]]',
|
||||||
message: html,
|
message: html,
|
||||||
@@ -261,11 +261,10 @@ define('admin/manage/categories', [
|
|||||||
}
|
}
|
||||||
|
|
||||||
function continueRender() {
|
function continueRender() {
|
||||||
Benchpress.parse('admin/partials/categories/category-rows', {
|
app.parseAndTranslate('admin/partials/categories/category-rows', {
|
||||||
cid: parentId,
|
cid: parentId,
|
||||||
categories: categories,
|
categories: categories,
|
||||||
}, function (html) {
|
}, function (html) {
|
||||||
translator.translate(html, function (html) {
|
|
||||||
container.append(html);
|
container.append(html);
|
||||||
|
|
||||||
// Handle and children categories in this level have
|
// Handle and children categories in this level have
|
||||||
@@ -284,7 +283,6 @@ define('admin/manage/categories', [
|
|||||||
onEnd: itemDragDidEnd,
|
onEnd: itemDragDidEnd,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,10 +66,10 @@ define('admin/manage/category', [
|
|||||||
$('.purge').on('click', function (e) {
|
$('.purge').on('click', function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
Benchpress.parse('admin/partials/categories/purge', {
|
Benchpress.render('admin/partials/categories/purge', {
|
||||||
name: ajaxify.data.category.name,
|
name: ajaxify.data.category.name,
|
||||||
topic_count: ajaxify.data.category.topic_count,
|
topic_count: ajaxify.data.category.topic_count,
|
||||||
}, function (html) {
|
}).then(function (html) {
|
||||||
var modal = bootbox.dialog({
|
var modal = bootbox.dialog({
|
||||||
title: '[[admin/manage/categories:purge]]',
|
title: '[[admin/manage/categories:purge]]',
|
||||||
message: html,
|
message: html,
|
||||||
@@ -119,9 +119,9 @@ define('admin/manage/category', [
|
|||||||
return app.alertError(err.message);
|
return app.alertError(err.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
Benchpress.parse('admin/partials/categories/copy-settings', {
|
Benchpress.render('admin/partials/categories/copy-settings', {
|
||||||
categories: allCategories,
|
categories: allCategories,
|
||||||
}, function (html) {
|
}).then(function (html) {
|
||||||
var selectedCid;
|
var selectedCid;
|
||||||
var modal = bootbox.dialog({
|
var modal = bootbox.dialog({
|
||||||
title: '[[modules:composer.select_category]]',
|
title: '[[modules:composer.select_category]]',
|
||||||
|
|||||||
@@ -140,17 +140,15 @@ define('admin/manage/privileges', [
|
|||||||
|
|
||||||
ajaxify.data.privileges = privileges;
|
ajaxify.data.privileges = privileges;
|
||||||
var tpl = parseInt(cid, 10) ? 'admin/partials/privileges/category' : 'admin/partials/privileges/global';
|
var tpl = parseInt(cid, 10) ? 'admin/partials/privileges/category' : 'admin/partials/privileges/global';
|
||||||
Benchpress.parse(tpl, {
|
app.parseAndTranslate(tpl, {
|
||||||
privileges: privileges,
|
privileges: privileges,
|
||||||
}, function (html) {
|
}, function (html) {
|
||||||
translator.translate(html, function (html) {
|
|
||||||
$('.privilege-table-container').html(html);
|
$('.privilege-table-container').html(html);
|
||||||
Privileges.exposeAssumedPrivileges();
|
Privileges.exposeAssumedPrivileges();
|
||||||
|
|
||||||
hightlightRowByDataAttr('data-group-name', groupToHighlight);
|
hightlightRowByDataAttr('data-group-name', groupToHighlight);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Privileges.exposeAssumedPrivileges = function () {
|
Privileges.exposeAssumedPrivileges = function () {
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ define('admin/manage/users', [
|
|||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err);
|
return app.alertError(err);
|
||||||
}
|
}
|
||||||
Benchpress.parse('admin/partials/manage_user_groups', data, function (html) {
|
Benchpress.render('admin/partials/manage_user_groups', data).then(function (html) {
|
||||||
var modal = bootbox.dialog({
|
var modal = bootbox.dialog({
|
||||||
message: html,
|
message: html,
|
||||||
title: '[[admin/manage/users:manage-groups]]',
|
title: '[[admin/manage/users:manage-groups]]',
|
||||||
@@ -134,7 +134,7 @@ define('admin/manage/users', [
|
|||||||
return false; // specifically to keep the menu open
|
return false; // specifically to keep the menu open
|
||||||
}
|
}
|
||||||
|
|
||||||
Benchpress.parse('admin/partials/temporary-ban', {}, function (html) {
|
Benchpress.render('admin/partials/temporary-ban', {}).then(function (html) {
|
||||||
bootbox.dialog({
|
bootbox.dialog({
|
||||||
className: 'ban-modal',
|
className: 'ban-modal',
|
||||||
title: '[[user:ban_account]]',
|
title: '[[user:ban_account]]',
|
||||||
@@ -321,7 +321,7 @@ define('admin/manage/users', [
|
|||||||
|
|
||||||
function handleUserCreate() {
|
function handleUserCreate() {
|
||||||
$('[data-action="create"]').on('click', function () {
|
$('[data-action="create"]').on('click', function () {
|
||||||
Benchpress.parse('admin/partials/create_user_modal', {}, function (html) {
|
Benchpress.render('admin/partials/create_user_modal', {}).then(function (html) {
|
||||||
var modal = bootbox.dialog({
|
var modal = bootbox.dialog({
|
||||||
message: html,
|
message: html,
|
||||||
title: '[[admin/manage/users:alerts.create]]',
|
title: '[[admin/manage/users:alerts.create]]',
|
||||||
@@ -426,7 +426,7 @@ define('admin/manage/users', [
|
|||||||
}
|
}
|
||||||
|
|
||||||
function renderSearchResults(data) {
|
function renderSearchResults(data) {
|
||||||
Benchpress.parse('partials/paginator', { pagination: data.pagination }, function (html) {
|
Benchpress.render('partials/paginator', { pagination: data.pagination }).then(function (html) {
|
||||||
$('.pagination-container').replaceWith(html);
|
$('.pagination-container').replaceWith(html);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -4,11 +4,10 @@
|
|||||||
define('admin/settings/navigation', [
|
define('admin/settings/navigation', [
|
||||||
'translator',
|
'translator',
|
||||||
'iconSelect',
|
'iconSelect',
|
||||||
'benchpress',
|
|
||||||
'jquery-ui/widgets/draggable',
|
'jquery-ui/widgets/draggable',
|
||||||
'jquery-ui/widgets/droppable',
|
'jquery-ui/widgets/droppable',
|
||||||
'jquery-ui/widgets/sortable',
|
'jquery-ui/widgets/sortable',
|
||||||
], function (translator, iconSelect, Benchpress) {
|
], function (translator, iconSelect) {
|
||||||
var navigation = {};
|
var navigation = {};
|
||||||
var available;
|
var available;
|
||||||
|
|
||||||
@@ -70,21 +69,17 @@ define('admin/settings/navigation', [
|
|||||||
data.title = translator.escape(data.title);
|
data.title = translator.escape(data.title);
|
||||||
data.text = translator.escape(data.text);
|
data.text = translator.escape(data.text);
|
||||||
data.groups = ajaxify.data.groups;
|
data.groups = ajaxify.data.groups;
|
||||||
Benchpress.parse('admin/settings/navigation', 'navigation', { navigation: [data] }, function (li) {
|
app.parseAndTranslate('admin/settings/navigation', 'navigation', { navigation: [data] }, function (li) {
|
||||||
translator.translate(li, function (li) {
|
|
||||||
li = $(translator.unescape(li));
|
li = $(translator.unescape(li));
|
||||||
el.after(li);
|
el.after(li);
|
||||||
el.remove();
|
el.remove();
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
Benchpress.parse('admin/settings/navigation', 'enabled', { enabled: [data] }, function (li) {
|
app.parseAndTranslate('admin/settings/navigation', 'enabled', { enabled: [data] }, function (li) {
|
||||||
translator.translate(li, function (li) {
|
|
||||||
li = $(translator.unescape(li));
|
li = $(translator.unescape(li));
|
||||||
$('#enabled').append(li);
|
$('#enabled').append(li);
|
||||||
componentHandler.upgradeDom();
|
componentHandler.upgradeDom();
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
|
|||||||
@@ -171,11 +171,12 @@ ajaxify = window.ajaxify || {};
|
|||||||
function renderTemplate(url, tpl_url, data, callback) {
|
function renderTemplate(url, tpl_url, data, callback) {
|
||||||
$(window).trigger('action:ajaxify.loadingTemplates', {});
|
$(window).trigger('action:ajaxify.loadingTemplates', {});
|
||||||
|
|
||||||
Benchpress.parse(tpl_url, data, function (template) {
|
Benchpress.render(tpl_url, data)
|
||||||
translator.translate(template, function (translatedTemplate) {
|
.then(rendered => translator.translate(rendered))
|
||||||
translatedTemplate = translator.unescape(translatedTemplate);
|
.then(function (translated) {
|
||||||
|
translated = translator.unescape(translated);
|
||||||
$('body').removeClass(previousBodyClass).addClass(data.bodyClass);
|
$('body').removeClass(previousBodyClass).addClass(data.bodyClass);
|
||||||
$('#content').html(translatedTemplate);
|
$('#content').html(translated);
|
||||||
|
|
||||||
ajaxify.end(url, tpl_url);
|
ajaxify.end(url, tpl_url);
|
||||||
|
|
||||||
@@ -189,7 +190,6 @@ ajaxify = window.ajaxify || {};
|
|||||||
updateTitle(data.title);
|
updateTitle(data.title);
|
||||||
updateTags();
|
updateTags();
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateTitle(title) {
|
function updateTitle(title) {
|
||||||
|
|||||||
@@ -727,24 +727,19 @@ app.cacheBuster = null;
|
|||||||
|
|
||||||
app.parseAndTranslate = function (template, blockName, data, callback) {
|
app.parseAndTranslate = function (template, blockName, data, callback) {
|
||||||
require(['translator', 'benchpress'], function (translator, Benchpress) {
|
require(['translator', 'benchpress'], function (translator, Benchpress) {
|
||||||
function translate(html, callback) {
|
if (typeof blockName !== 'string') {
|
||||||
translator.translate(html, function (translatedHTML) {
|
|
||||||
translatedHTML = translator.unescape(translatedHTML);
|
|
||||||
callback($(translatedHTML));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof blockName === 'string') {
|
|
||||||
Benchpress.parse(template, blockName, data, function (html) {
|
|
||||||
translate(html, callback);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
callback = data;
|
callback = data;
|
||||||
data = blockName;
|
data = blockName;
|
||||||
Benchpress.parse(template, data, function (html) {
|
blockName = undefined;
|
||||||
translate(html, callback);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Benchpress.render(template, data, blockName)
|
||||||
|
.then(rendered => translator.translate(rendered))
|
||||||
|
.then(translated => translator.unescape(translated))
|
||||||
|
.then(
|
||||||
|
result => setTimeout(callback, 0, result),
|
||||||
|
err => console.error(err)
|
||||||
|
);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -88,14 +88,13 @@ define('forum/account/edit', [
|
|||||||
return memo || cur.type === 'uploaded';
|
return memo || cur.type === 'uploaded';
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
Benchpress.parse('partials/modals/change_picture_modal', {
|
app.parseAndTranslate('partials/modals/change_picture_modal', {
|
||||||
pictures: pictures,
|
pictures: pictures,
|
||||||
uploaded: uploaded,
|
uploaded: uploaded,
|
||||||
icon: { text: ajaxify.data['icon:text'], bgColor: ajaxify.data['icon:bgColor'] },
|
icon: { text: ajaxify.data['icon:text'], bgColor: ajaxify.data['icon:bgColor'] },
|
||||||
defaultAvatar: ajaxify.data.defaultAvatar,
|
defaultAvatar: ajaxify.data.defaultAvatar,
|
||||||
allowProfileImageUploads: ajaxify.data.allowProfileImageUploads,
|
allowProfileImageUploads: ajaxify.data.allowProfileImageUploads,
|
||||||
}, function (html) {
|
}, function (html) {
|
||||||
translator.translate(html, function (html) {
|
|
||||||
var modal = bootbox.dialog({
|
var modal = bootbox.dialog({
|
||||||
className: 'picture-switcher',
|
className: 'picture-switcher',
|
||||||
title: '[[user:change_picture]]',
|
title: '[[user:change_picture]]',
|
||||||
@@ -153,7 +152,6 @@ define('forum/account/edit', [
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
@@ -247,8 +245,7 @@ define('forum/account/edit', [
|
|||||||
|
|
||||||
modal.find('[data-action="upload-url"]').on('click', function () {
|
modal.find('[data-action="upload-url"]').on('click', function () {
|
||||||
modal.modal('hide');
|
modal.modal('hide');
|
||||||
Benchpress.parse('partials/modals/upload_picture_from_url_modal', {}, function (html) {
|
app.parseAndTranslate('partials/modals/upload_picture_from_url_modal', {}, function (html) {
|
||||||
translator.translate(html, function (html) {
|
|
||||||
var uploadModal = $(html);
|
var uploadModal = $(html);
|
||||||
uploadModal.modal('show');
|
uploadModal.modal('show');
|
||||||
|
|
||||||
@@ -272,7 +269,6 @@ define('forum/account/edit', [
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ define('forum/account/header', [
|
|||||||
function banAccount(theirid, onSuccess) {
|
function banAccount(theirid, onSuccess) {
|
||||||
theirid = theirid || ajaxify.data.theirid;
|
theirid = theirid || ajaxify.data.theirid;
|
||||||
|
|
||||||
Benchpress.parse('admin/partials/temporary-ban', {}, function (html) {
|
Benchpress.render('admin/partials/temporary-ban', {}).then(function (html) {
|
||||||
bootbox.dialog({
|
bootbox.dialog({
|
||||||
className: 'ban-modal',
|
className: 'ban-modal',
|
||||||
title: '[[user:ban_account]]',
|
title: '[[user:ban_account]]',
|
||||||
|
|||||||
@@ -219,8 +219,7 @@ define('forum/chats', [
|
|||||||
var modal;
|
var modal;
|
||||||
|
|
||||||
buttonEl.on('click', function () {
|
buttonEl.on('click', function () {
|
||||||
Benchpress.parse('partials/modals/manage_room', {}, function (html) {
|
app.parseAndTranslate('partials/modals/manage_room', {}, function (html) {
|
||||||
translator.translate(html, function (html) {
|
|
||||||
modal = bootbox.dialog({
|
modal = bootbox.dialog({
|
||||||
title: '[[modules:chat.manage-room]]',
|
title: '[[modules:chat.manage-room]]',
|
||||||
message: html,
|
message: html,
|
||||||
@@ -253,7 +252,6 @@ define('forum/chats', [
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Chats.addKickHandler = function (roomId, modal) {
|
Chats.addKickHandler = function (roomId, modal) {
|
||||||
@@ -324,10 +322,9 @@ define('forum/chats', [
|
|||||||
var modal;
|
var modal;
|
||||||
|
|
||||||
buttonEl.on('click', function () {
|
buttonEl.on('click', function () {
|
||||||
Benchpress.parse('partials/modals/rename_room', {
|
app.parseAndTranslate('partials/modals/rename_room', {
|
||||||
name: roomName || ajaxify.data.roomName,
|
name: roomName || ajaxify.data.roomName,
|
||||||
}, function (html) {
|
}, function (html) {
|
||||||
translator.translate(html, function (html) {
|
|
||||||
modal = bootbox.dialog({
|
modal = bootbox.dialog({
|
||||||
title: '[[modules:chat.rename-room]]',
|
title: '[[modules:chat.rename-room]]',
|
||||||
message: html,
|
message: html,
|
||||||
@@ -341,7 +338,6 @@ define('forum/chats', [
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
function submit() {
|
function submit() {
|
||||||
socket.emit('modules.chats.renameRoom', {
|
socket.emit('modules.chats.renameRoom', {
|
||||||
@@ -478,7 +474,7 @@ define('forum/chats', [
|
|||||||
roomEl.addClass('unread');
|
roomEl.addClass('unread');
|
||||||
} else {
|
} else {
|
||||||
var recentEl = components.get('chat/recent');
|
var recentEl = components.get('chat/recent');
|
||||||
Benchpress.parse('partials/chats/recent_room', {
|
app.parseAndTranslate('partials/chats/recent_room', {
|
||||||
rooms: {
|
rooms: {
|
||||||
roomId: data.roomId,
|
roomId: data.roomId,
|
||||||
lastUser: data.message.fromUser,
|
lastUser: data.message.fromUser,
|
||||||
@@ -486,9 +482,7 @@ define('forum/chats', [
|
|||||||
unread: true,
|
unread: true,
|
||||||
},
|
},
|
||||||
}, function (html) {
|
}, function (html) {
|
||||||
translator.translate(html, function (translated) {
|
recentEl.prepend(html);
|
||||||
recentEl.prepend(translated);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,13 +102,13 @@ define('forum/chats/messages', ['components', 'translator', 'benchpress'], funct
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Array.isArray(data)) {
|
if (Array.isArray(data)) {
|
||||||
Benchpress.parse('partials/chats/message' + (Array.isArray(data) ? 's' : ''), {
|
Benchpress.render('partials/chats/message' + (Array.isArray(data) ? 's' : ''), {
|
||||||
messages: data,
|
messages: data,
|
||||||
}, done);
|
}).then(done);
|
||||||
} else {
|
} else {
|
||||||
Benchpress.parse('partials/chats/' + (data.system ? 'system-message' : 'message'), {
|
Benchpress.render('partials/chats/' + (data.system ? 'system-message' : 'message'), {
|
||||||
messages: data,
|
messages: data,
|
||||||
}, done);
|
}).then(done);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -144,9 +144,9 @@ define('forum/flags/detail', ['forum/flags/list', 'components', 'translator', 'b
|
|||||||
|
|
||||||
Detail.reloadNotes = function (notes) {
|
Detail.reloadNotes = function (notes) {
|
||||||
ajaxify.data.notes = notes;
|
ajaxify.data.notes = notes;
|
||||||
Benchpress.parse('flags/detail', 'notes', {
|
Benchpress.render('flags/detail', 'notes', {
|
||||||
notes: notes,
|
notes: notes,
|
||||||
}, function (html) {
|
}).then(function (html) {
|
||||||
var wrapperEl = components.get('flag/notes');
|
var wrapperEl = components.get('flag/notes');
|
||||||
wrapperEl.empty();
|
wrapperEl.empty();
|
||||||
wrapperEl.html(html);
|
wrapperEl.html(html);
|
||||||
@@ -156,16 +156,14 @@ define('forum/flags/detail', ['forum/flags/list', 'components', 'translator', 'b
|
|||||||
};
|
};
|
||||||
|
|
||||||
Detail.reloadHistory = function (history) {
|
Detail.reloadHistory = function (history) {
|
||||||
Benchpress.parse('flags/detail', 'history', {
|
app.parseAndTranslate('flags/detail', 'history', {
|
||||||
history: history,
|
history: history,
|
||||||
}, function (html) {
|
}, function (html) {
|
||||||
translator.translate(html, function (translated) {
|
|
||||||
var wrapperEl = components.get('flag/history');
|
var wrapperEl = components.get('flag/history');
|
||||||
wrapperEl.empty();
|
wrapperEl.empty();
|
||||||
wrapperEl.html(translated);
|
wrapperEl.html(html);
|
||||||
wrapperEl.find('span.timeago').timeago();
|
wrapperEl.find('span.timeago').timeago();
|
||||||
});
|
});
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return Detail;
|
return Detail;
|
||||||
|
|||||||
@@ -41,9 +41,9 @@ define('forum/groups/list', [
|
|||||||
after: $('[component="groups/container"]').attr('data-nextstart'),
|
after: $('[component="groups/container"]').attr('data-nextstart'),
|
||||||
}, function (data, done) {
|
}, function (data, done) {
|
||||||
if (data && data.groups.length) {
|
if (data && data.groups.length) {
|
||||||
Benchpress.parse('partials/groups/list', {
|
Benchpress.render('partials/groups/list', {
|
||||||
groups: data.groups,
|
groups: data.groups,
|
||||||
}, function (html) {
|
}).then(function (html) {
|
||||||
$('#groups-list').append(html);
|
$('#groups-list').append(html);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@@ -77,9 +77,9 @@ define('forum/groups/list', [
|
|||||||
groups = groups.filter(function (group) {
|
groups = groups.filter(function (group) {
|
||||||
return group.name !== 'registered-users' && group.name !== 'guests';
|
return group.name !== 'registered-users' && group.name !== 'guests';
|
||||||
});
|
});
|
||||||
Benchpress.parse('partials/groups/list', {
|
Benchpress.render('partials/groups/list', {
|
||||||
groups: groups,
|
groups: groups,
|
||||||
}, function (html) {
|
}).then(function (html) {
|
||||||
groupsEl.empty().append(html);
|
groupsEl.empty().append(html);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ define('forum/ip-blacklist', ['Chart', 'benchpress'], function (Chart, Benchpres
|
|||||||
return app.alertError(err.message);
|
return app.alertError(err.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
Benchpress.parse('admin/partials/blacklist-validate', data, function (html) {
|
Benchpress.render('admin/partials/blacklist-validate', data).then(function (html) {
|
||||||
bootbox.alert(html);
|
bootbox.alert(html);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('forum/topic/diffs', ['forum/topic/images', 'benchpress', 'translator'], function (Images, Benchpress, translator) {
|
define('forum/topic/diffs', ['forum/topic/images'], function () {
|
||||||
var Diffs = {};
|
var Diffs = {};
|
||||||
|
|
||||||
Diffs.open = function (pid) {
|
Diffs.open = function (pid) {
|
||||||
@@ -15,7 +15,7 @@ define('forum/topic/diffs', ['forum/topic/images', 'benchpress', 'translator'],
|
|||||||
return app.alertError(err.message);
|
return app.alertError(err.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
Benchpress.parse('partials/modals/post_history', {
|
app.parseAndTranslate('partials/modals/post_history', {
|
||||||
diffs: data.revisions.map(function (revision) {
|
diffs: data.revisions.map(function (revision) {
|
||||||
var timestamp = parseInt(revision.timestamp, 10);
|
var timestamp = parseInt(revision.timestamp, 10);
|
||||||
|
|
||||||
@@ -28,7 +28,6 @@ define('forum/topic/diffs', ['forum/topic/images', 'benchpress', 'translator'],
|
|||||||
numDiffs: data.timestamps.length,
|
numDiffs: data.timestamps.length,
|
||||||
editable: data.editable,
|
editable: data.editable,
|
||||||
}, function (html) {
|
}, function (html) {
|
||||||
translator.translate(html, function (html) {
|
|
||||||
var modal = bootbox.dialog({
|
var modal = bootbox.dialog({
|
||||||
title: '[[topic:diffs.title]]',
|
title: '[[topic:diffs.title]]',
|
||||||
message: html,
|
message: html,
|
||||||
@@ -58,7 +57,6 @@ define('forum/topic/diffs', ['forum/topic/images', 'benchpress', 'translator'],
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Diffs.load = function (pid, since, postContainer) {
|
Diffs.load = function (pid, since, postContainer) {
|
||||||
|
|||||||
@@ -139,19 +139,17 @@ define('forum/topic/events', [
|
|||||||
editedISO: utils.toISOString(data.post.edited),
|
editedISO: utils.toISOString(data.post.edited),
|
||||||
};
|
};
|
||||||
|
|
||||||
Benchpress.parse('partials/topic/post-editor', editData, function (html) {
|
app.parseAndTranslate('partials/topic/post-editor', editData, function (html) {
|
||||||
translator.translate(html, function (translated) {
|
html = $(html);
|
||||||
html = $(translated);
|
|
||||||
editorEl.replaceWith(html);
|
editorEl.replaceWith(html);
|
||||||
$('[data-pid="' + data.post.pid + '"] [component="post/editor"] .timeago').timeago();
|
$('[data-pid="' + data.post.pid + '"] [component="post/editor"] .timeago').timeago();
|
||||||
$(window).trigger('action:posts.edited', data);
|
$(window).trigger('action:posts.edited', data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.topic.tags && tagsUpdated(data.topic.tags)) {
|
if (data.topic.tags && tagsUpdated(data.topic.tags)) {
|
||||||
Benchpress.parse('partials/topic/tags', { tags: data.topic.tags }, function (html) {
|
Benchpress.render('partials/topic/tags', { tags: data.topic.tags }).then(function (html) {
|
||||||
var tags = $('.tags');
|
var tags = $('.tags');
|
||||||
|
|
||||||
tags.fadeOut(250, function () {
|
tags.fadeOut(250, function () {
|
||||||
|
|||||||
@@ -80,11 +80,10 @@ define('forum/topic/votes', [
|
|||||||
return app.alertError(err.message);
|
return app.alertError(err.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
Benchpress.parse('partials/modals/votes_modal', data, function (html) {
|
app.parseAndTranslate('partials/modals/votes_modal', data, function (html) {
|
||||||
translator.translate(html, function (translated) {
|
|
||||||
var dialog = bootbox.dialog({
|
var dialog = bootbox.dialog({
|
||||||
title: '[[global:voters]]',
|
title: '[[global:voters]]',
|
||||||
message: translated,
|
message: html,
|
||||||
className: 'vote-modal',
|
className: 'vote-modal',
|
||||||
show: true,
|
show: true,
|
||||||
});
|
});
|
||||||
@@ -94,7 +93,6 @@ define('forum/topic/votes', [
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ define('forum/users', [
|
|||||||
}
|
}
|
||||||
|
|
||||||
function renderSearchResults(data) {
|
function renderSearchResults(data) {
|
||||||
Benchpress.parse('partials/paginator', { pagination: data.pagination }, function (html) {
|
Benchpress.render('partials/paginator', { pagination: data.pagination }).then(function (html) {
|
||||||
$('.pagination-container').replaceWith(html);
|
$('.pagination-container').replaceWith(html);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -112,14 +112,12 @@ define('forum/users', [
|
|||||||
}
|
}
|
||||||
|
|
||||||
data.isAdminOrGlobalMod = app.user.isAdmin || app.user.isGlobalMod;
|
data.isAdminOrGlobalMod = app.user.isAdmin || app.user.isGlobalMod;
|
||||||
Benchpress.parse('users', 'users', data, function (html) {
|
app.parseAndTranslate('users', 'users', data, function (translated) {
|
||||||
translator.translate(html, function (translated) {
|
|
||||||
translated = $(translated);
|
translated = $(translated);
|
||||||
$('#users-container').html(translated);
|
$('#users-container').html(translated);
|
||||||
translated.find('span.timeago').timeago();
|
translated.find('span.timeago').timeago();
|
||||||
$('[component="user/search/icon"]').addClass('fa-search').removeClass('fa-spinner fa-spin');
|
$('[component="user/search/icon"]').addClass('fa-search').removeClass('fa-spinner fa-spin');
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onUserStatusChange(data) {
|
function onUserStatusChange(data) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('alerts', ['translator', 'components', 'benchpress'], function (translator, components, Benchpress) {
|
define('alerts', ['translator', 'components'], function (translator, components) {
|
||||||
var module = {};
|
var module = {};
|
||||||
|
|
||||||
module.alert = function (params) {
|
module.alert = function (params) {
|
||||||
@@ -19,13 +19,12 @@ define('alerts', ['translator', 'components', 'benchpress'], function (translato
|
|||||||
};
|
};
|
||||||
|
|
||||||
function createNew(params) {
|
function createNew(params) {
|
||||||
Benchpress.parse('alert', params, function (alertTpl) {
|
app.parseAndTranslate('alert', params, function (html) {
|
||||||
translator.translate(alertTpl, function (translatedHTML) {
|
|
||||||
var alert = $('#' + params.alert_id);
|
var alert = $('#' + params.alert_id);
|
||||||
if (alert.length) {
|
if (alert.length) {
|
||||||
return updateAlert(alert, params);
|
return updateAlert(alert, params);
|
||||||
}
|
}
|
||||||
alert = $(translatedHTML);
|
alert = $(html);
|
||||||
alert.fadeIn(200);
|
alert.fadeIn(200);
|
||||||
|
|
||||||
components.get('toaster/tray').prepend(alert);
|
components.get('toaster/tray').prepend(alert);
|
||||||
@@ -55,7 +54,6 @@ define('alerts', ['translator', 'components', 'benchpress'], function (translato
|
|||||||
|
|
||||||
$(window).trigger('action:alert.new', { alert: alert, params: params });
|
$(window).trigger('action:alert.new', { alert: alert, params: params });
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.remove = function (id) {
|
module.remove = function (id) {
|
||||||
|
|||||||
@@ -48,10 +48,9 @@ define('categorySelector', ['benchpress', 'translator', 'categorySearch'], funct
|
|||||||
callback = categories;
|
callback = categories;
|
||||||
categories = ajaxify.data.allCategories;
|
categories = ajaxify.data.allCategories;
|
||||||
}
|
}
|
||||||
Benchpress.parse('admin/partials/categories/select-category', {
|
app.parseAndTranslate('admin/partials/categories/select-category', {
|
||||||
categories: categories,
|
categories: categories,
|
||||||
}, function (html) {
|
}, function (html) {
|
||||||
translator.translate(html, function (html) {
|
|
||||||
var modal = bootbox.dialog({
|
var modal = bootbox.dialog({
|
||||||
title: '[[modules:composer.select_category]]',
|
title: '[[modules:composer.select_category]]',
|
||||||
message: html,
|
message: html,
|
||||||
@@ -75,7 +74,6 @@ define('categorySelector', ['benchpress', 'translator', 'categorySearch'], funct
|
|||||||
|
|
||||||
modal.find('form').on('submit', submit);
|
modal.find('form').on('submit', submit);
|
||||||
});
|
});
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return categorySelector;
|
return categorySelector;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ define('iconSelect', ['benchpress'], function (Benchpress) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Benchpress.parse('partials/fontawesome', {}, function (html) {
|
Benchpress.render('partials/fontawesome', {}).then(function (html) {
|
||||||
html = $(html);
|
html = $(html);
|
||||||
html.find('.fa-icons').prepend($('<i class="fa fa-nbb-none"></i>'));
|
html.find('.fa-icons').prepend($('<i class="fa fa-nbb-none"></i>'));
|
||||||
|
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ define('notifications', [
|
|||||||
notifs[i].timeago = $.timeago(new Date(parseInt(notifs[i].datetime, 10)));
|
notifs[i].timeago = $.timeago(new Date(parseInt(notifs[i].datetime, 10)));
|
||||||
}
|
}
|
||||||
translator.toggleTimeagoShorthand();
|
translator.toggleTimeagoShorthand();
|
||||||
Benchpress.parse('partials/notifications_list', { notifications: notifs }, function (html) {
|
app.parseAndTranslate('partials/notifications_list', { notifications: notifs }, function (html) {
|
||||||
notifList.translateHtml(html);
|
notifList.html(html);
|
||||||
notifList.off('click').on('click', '[data-nid]', function (ev) {
|
notifList.off('click').on('click', '[data-nid]', function (ev) {
|
||||||
var notifEl = $(this);
|
var notifEl = $(this);
|
||||||
if (scrollToPostIndexIfOnPage(notifEl)) {
|
if (scrollToPostIndexIfOnPage(notifEl)) {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ define('settings/sorted-list', [
|
|||||||
var key = $container.attr('data-sorted-list');
|
var key = $container.attr('data-sorted-list');
|
||||||
var formTpl = $container.attr('data-form-template');
|
var formTpl = $container.attr('data-form-template');
|
||||||
|
|
||||||
benchpress.parse(formTpl, {}, function (formHtml) {
|
benchpress.render(formTpl, {}).then(function (formHtml) {
|
||||||
var addBtn = $('[data-sorted-list="' + key + '"] [data-type="add"]');
|
var addBtn = $('[data-sorted-list="' + key + '"] [data-type="add"]');
|
||||||
|
|
||||||
addBtn.on('click', function () {
|
addBtn.on('click', function () {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ define('taskbar', ['benchpress', 'translator'], function (Benchpress, translator
|
|||||||
taskbar.init = function () {
|
taskbar.init = function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
Benchpress.parse('modules/taskbar', {}, function (html) {
|
Benchpress.render('modules/taskbar', {}).then(function (html) {
|
||||||
self.taskbar = $(html);
|
self.taskbar = $(html);
|
||||||
self.tasklist = self.taskbar.find('ul');
|
self.tasklist = self.taskbar.find('ul');
|
||||||
$(document.body).append(self.taskbar);
|
$(document.body).append(self.taskbar);
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('uploader', ['translator', 'benchpress', 'jquery-form'], function (translator, Benchpress) {
|
define('uploader', ['jquery-form'], function () {
|
||||||
var module = {};
|
var module = {};
|
||||||
|
|
||||||
module.show = function (data, callback) {
|
module.show = function (data, callback) {
|
||||||
var fileSize = data.hasOwnProperty('fileSize') && data.fileSize !== undefined ? parseInt(data.fileSize, 10) : false;
|
var fileSize = data.hasOwnProperty('fileSize') && data.fileSize !== undefined ? parseInt(data.fileSize, 10) : false;
|
||||||
parseModal({
|
app.parseAndTranslate('partials/modals/upload_file_modal', {
|
||||||
showHelp: data.hasOwnProperty('showHelp') && data.showHelp !== undefined ? data.showHelp : true,
|
showHelp: data.hasOwnProperty('showHelp') && data.showHelp !== undefined ? data.showHelp : true,
|
||||||
fileSize: fileSize,
|
fileSize: fileSize,
|
||||||
title: data.title || '[[global:upload_file]]',
|
title: data.title || '[[global:upload_file]]',
|
||||||
@@ -96,12 +96,6 @@ define('uploader', ['translator', 'benchpress', 'jquery-form'], function (transl
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function parseModal(tplVals, callback) {
|
|
||||||
Benchpress.parse('partials/modals/upload_file_modal', tplVals, function (html) {
|
|
||||||
translator.translate(html, callback);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function maybeParse(response) {
|
function maybeParse(response) {
|
||||||
if (typeof response === 'string') {
|
if (typeof response === 'string') {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user