mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
refactor: use alerts module
This commit is contained in:
@@ -3,5 +3,9 @@
|
|||||||
"alert.confirm-restart": "Are you sure you wish to restart NodeBB?",
|
"alert.confirm-restart": "Are you sure you wish to restart NodeBB?",
|
||||||
|
|
||||||
"acp-title": "%1 | NodeBB Admin Control Panel",
|
"acp-title": "%1 | NodeBB Admin Control Panel",
|
||||||
"settings-header-contents": "Contents"
|
"settings-header-contents": "Contents",
|
||||||
|
"changes-saved": "Changed Saved",
|
||||||
|
"changes-saved-message": "Your changes to the NodeBB configuration have been saved.",
|
||||||
|
"changes-not-saved": "Changes Not Saved",
|
||||||
|
"changes-not-saved-message": "NodeBB encountered a problem saving your changes. (%1)"
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('admin/appearance/skins', ['translator'], function (translator) {
|
define('admin/appearance/skins', ['translator', 'alerts'], function (translator, alerts) {
|
||||||
const Skins = {};
|
const Skins = {};
|
||||||
|
|
||||||
Skins.init = function () {
|
Skins.init = function () {
|
||||||
@@ -33,11 +33,11 @@ define('admin/appearance/skins', ['translator'], function (translator) {
|
|||||||
src: cssSrc,
|
src: cssSrc,
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
highlightSelectedTheme(themeId);
|
highlightSelectedTheme(themeId);
|
||||||
|
|
||||||
app.alert({
|
alerts.alert({
|
||||||
alert_id: 'admin:theme',
|
alert_id: 'admin:theme',
|
||||||
type: 'info',
|
type: 'info',
|
||||||
title: '[[admin/appearance/skins:skin-updated]]',
|
title: '[[admin/appearance/skins:skin-updated]]',
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('admin/appearance/themes', ['bootbox', 'translator'], function (bootbox, translator) {
|
define('admin/appearance/themes', ['bootbox', 'translator', 'alerts'], function (bootbox, translator, alerts) {
|
||||||
const Themes = {};
|
const Themes = {};
|
||||||
|
|
||||||
Themes.init = function () {
|
Themes.init = function () {
|
||||||
@@ -21,12 +21,12 @@ define('admin/appearance/themes', ['bootbox', 'translator'], function (bootbox,
|
|||||||
src: cssSrc,
|
src: cssSrc,
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
config['theme:id'] = themeId;
|
config['theme:id'] = themeId;
|
||||||
highlightSelectedTheme(themeId);
|
highlightSelectedTheme(themeId);
|
||||||
|
|
||||||
app.alert({
|
alerts.alert({
|
||||||
alert_id: 'admin:theme',
|
alert_id: 'admin:theme',
|
||||||
type: 'info',
|
type: 'info',
|
||||||
title: '[[admin/appearance/themes:theme-changed]]',
|
title: '[[admin/appearance/themes:theme-changed]]',
|
||||||
@@ -50,10 +50,10 @@ define('admin/appearance/themes', ['bootbox', 'translator'], function (bootbox,
|
|||||||
id: 'nodebb-theme-persona',
|
id: 'nodebb-theme-persona',
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
highlightSelectedTheme('nodebb-theme-persona');
|
highlightSelectedTheme('nodebb-theme-persona');
|
||||||
app.alert({
|
alerts.alert({
|
||||||
alert_id: 'admin:theme',
|
alert_id: 'admin:theme',
|
||||||
type: 'success',
|
type: 'success',
|
||||||
title: '[[admin/appearance/themes:theme-changed]]',
|
title: '[[admin/appearance/themes:theme-changed]]',
|
||||||
@@ -67,7 +67,7 @@ define('admin/appearance/themes', ['bootbox', 'translator'], function (bootbox,
|
|||||||
|
|
||||||
socket.emit('admin.themes.getInstalled', function (err, themes) {
|
socket.emit('admin.themes.getInstalled', function (err, themes) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
const instListEl = $('#installed_themes');
|
const instListEl = $('#installed_themes');
|
||||||
|
|||||||
@@ -5,8 +5,9 @@ define('admin/extend/plugins', [
|
|||||||
'translator',
|
'translator',
|
||||||
'benchpress',
|
'benchpress',
|
||||||
'bootbox',
|
'bootbox',
|
||||||
|
'alerts',
|
||||||
'jquery-ui/widgets/sortable',
|
'jquery-ui/widgets/sortable',
|
||||||
], function (translator, Benchpress, bootbox) {
|
], function (translator, Benchpress, bootbox, alerts) {
|
||||||
const Plugins = {};
|
const Plugins = {};
|
||||||
Plugins.init = function () {
|
Plugins.init = function () {
|
||||||
const pluginsList = $('.plugins');
|
const pluginsList = $('.plugins');
|
||||||
@@ -33,7 +34,7 @@ define('admin/extend/plugins', [
|
|||||||
function toggleActivate() {
|
function toggleActivate() {
|
||||||
socket.emit('admin.plugins.toggleActive', pluginID, function (err, status) {
|
socket.emit('admin.plugins.toggleActive', pluginID, function (err, status) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
translator.translate('<i class="fa fa-power-off"></i> [[admin/extend/plugins:plugin-item.' + (status.active ? 'deactivate' : 'activate') + ']]', function (buttonText) {
|
translator.translate('<i class="fa fa-power-off"></i> [[admin/extend/plugins:plugin-item.' + (status.active ? 'deactivate' : 'activate') + ']]', function (buttonText) {
|
||||||
btn.html(buttonText);
|
btn.html(buttonText);
|
||||||
@@ -47,7 +48,7 @@ define('admin/extend/plugins', [
|
|||||||
// Toggle active state in template data
|
// Toggle active state in template data
|
||||||
pluginData.active = !pluginData.active;
|
pluginData.active = !pluginData.active;
|
||||||
|
|
||||||
app.alert({
|
alerts.alert({
|
||||||
alert_id: 'plugin_toggled',
|
alert_id: 'plugin_toggled',
|
||||||
title: '[[admin/extend/plugins:alert.' + (status.active ? 'enabled' : 'disabled') + ']]',
|
title: '[[admin/extend/plugins:alert.' + (status.active ? 'enabled' : 'disabled') + ']]',
|
||||||
message: '[[admin/extend/plugins:alert.' + (status.active ? 'activate-success' : 'deactivate-success') + ']]',
|
message: '[[admin/extend/plugins:alert.' + (status.active ? 'activate-success' : 'deactivate-success') + ']]',
|
||||||
@@ -213,11 +214,11 @@ define('admin/extend/plugins', [
|
|||||||
|
|
||||||
socket.emit('admin.plugins.orderActivePlugins', data, function (err) {
|
socket.emit('admin.plugins.orderActivePlugins', data, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
$('#order-active-plugins-modal').modal('hide');
|
$('#order-active-plugins-modal').modal('hide');
|
||||||
|
|
||||||
app.alert({
|
alerts.alert({
|
||||||
alert_id: 'plugin_reordered',
|
alert_id: 'plugin_reordered',
|
||||||
title: '[[admin/extend/plugins:alert.reorder]]',
|
title: '[[admin/extend/plugins:alert.reorder]]',
|
||||||
message: '[[admin/extend/plugins:alert.reorder-success]]',
|
message: '[[admin/extend/plugins:alert.reorder-success]]',
|
||||||
@@ -250,14 +251,14 @@ define('admin/extend/plugins', [
|
|||||||
version: version,
|
version: version,
|
||||||
}, function (err, isActive) {
|
}, function (err, isActive) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
const parent = btn.parents('li');
|
const parent = btn.parents('li');
|
||||||
parent.find('.fa-exclamation-triangle').remove();
|
parent.find('.fa-exclamation-triangle').remove();
|
||||||
parent.find('.currentVersion').text(version);
|
parent.find('.currentVersion').text(version);
|
||||||
btn.remove();
|
btn.remove();
|
||||||
if (isActive) {
|
if (isActive) {
|
||||||
app.alert({
|
alerts.alert({
|
||||||
alert_id: 'plugin_upgraded',
|
alert_id: 'plugin_upgraded',
|
||||||
title: '[[admin/extend/plugins:alert.upgraded]]',
|
title: '[[admin/extend/plugins:alert.upgraded]]',
|
||||||
message: '[[admin/extend/plugins:alert.upgrade-success]]',
|
message: '[[admin/extend/plugins:alert.upgrade-success]]',
|
||||||
@@ -283,12 +284,12 @@ define('admin/extend/plugins', [
|
|||||||
}, function (err, pluginData) {
|
}, function (err, pluginData) {
|
||||||
if (err) {
|
if (err) {
|
||||||
btn.removeAttr('disabled');
|
btn.removeAttr('disabled');
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
ajaxify.refresh();
|
ajaxify.refresh();
|
||||||
|
|
||||||
app.alert({
|
alerts.alert({
|
||||||
alert_id: 'plugin_toggled',
|
alert_id: 'plugin_toggled',
|
||||||
title: '[[admin/extend/plugins:alert.' + (pluginData.installed ? 'installed' : 'uninstalled') + ']]',
|
title: '[[admin/extend/plugins:alert.' + (pluginData.installed ? 'installed' : 'uninstalled') + ']]',
|
||||||
message: '[[admin/extend/plugins:alert.' + (pluginData.installed ? 'install-success' : 'uninstall-success') + ']]',
|
message: '[[admin/extend/plugins:alert.' + (pluginData.installed ? 'install-success' : 'uninstall-success') + ']]',
|
||||||
|
|||||||
@@ -3,11 +3,12 @@
|
|||||||
|
|
||||||
define('admin/extend/widgets', [
|
define('admin/extend/widgets', [
|
||||||
'bootbox',
|
'bootbox',
|
||||||
|
'alerts',
|
||||||
'jquery-ui/widgets/sortable',
|
'jquery-ui/widgets/sortable',
|
||||||
'jquery-ui/widgets/draggable',
|
'jquery-ui/widgets/draggable',
|
||||||
'jquery-ui/widgets/droppable',
|
'jquery-ui/widgets/droppable',
|
||||||
'jquery-ui/widgets/datepicker',
|
'jquery-ui/widgets/datepicker',
|
||||||
], function (bootbox) {
|
], function (bootbox, alerts) {
|
||||||
const Widgets = {};
|
const Widgets = {};
|
||||||
|
|
||||||
Widgets.init = function () {
|
Widgets.init = function () {
|
||||||
@@ -126,10 +127,10 @@ define('admin/extend/widgets', [
|
|||||||
|
|
||||||
socket.emit('admin.widgets.set', saveData, function (err) {
|
socket.emit('admin.widgets.set', saveData, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
app.alertError(err.message);
|
alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.alert({
|
alerts.alert({
|
||||||
alert_id: 'admin:widgets',
|
alert_id: 'admin:widgets',
|
||||||
type: 'success',
|
type: 'success',
|
||||||
title: '[[admin/extend/widgets:alert.updated]]',
|
title: '[[admin/extend/widgets:alert.updated]]',
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ define('admin/manage/categories', [
|
|||||||
'api',
|
'api',
|
||||||
'Sortable',
|
'Sortable',
|
||||||
'bootbox',
|
'bootbox',
|
||||||
], function (translator, Benchpress, categorySelector, api, Sortable, bootbox) {
|
'alerts',
|
||||||
|
], function (translator, Benchpress, categorySelector, api, Sortable, bootbox, alerts) {
|
||||||
const Categories = {};
|
const Categories = {};
|
||||||
let newCategoryId = -1;
|
let newCategoryId = -1;
|
||||||
let sortables;
|
let sortables;
|
||||||
@@ -143,10 +144,10 @@ define('admin/manage/categories', [
|
|||||||
Categories.create = function (payload) {
|
Categories.create = function (payload) {
|
||||||
api.post('/categories', payload, function (err, data) {
|
api.post('/categories', payload, function (err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.alert({
|
alerts.alert({
|
||||||
alert_id: 'category_created',
|
alert_id: 'category_created',
|
||||||
title: '[[admin/manage/categories:alert.created]]',
|
title: '[[admin/manage/categories:alert.created]]',
|
||||||
message: '[[admin/manage/categories:alert.create-success]]',
|
message: '[[admin/manage/categories:alert.create-success]]',
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ define('admin/manage/category', [
|
|||||||
'benchpress',
|
'benchpress',
|
||||||
'api',
|
'api',
|
||||||
'bootbox',
|
'bootbox',
|
||||||
], function (uploader, iconSelect, categorySelector, Benchpress, api, bootbox) {
|
'alerts',
|
||||||
|
], function (uploader, iconSelect, categorySelector, Benchpress, api, bootbox, alerts) {
|
||||||
const Category = {};
|
const Category = {};
|
||||||
let updateHash = {};
|
let updateHash = {};
|
||||||
|
|
||||||
@@ -55,14 +56,14 @@ define('admin/manage/category', [
|
|||||||
const cid = ajaxify.data.category.cid;
|
const cid = ajaxify.data.category.cid;
|
||||||
api.put('/categories/' + cid, updateHash).then((res) => {
|
api.put('/categories/' + cid, updateHash).then((res) => {
|
||||||
app.flags._unsaved = false;
|
app.flags._unsaved = false;
|
||||||
app.alert({
|
alerts.alert({
|
||||||
title: 'Updated Categories',
|
title: 'Updated Categories',
|
||||||
message: 'Category "' + res.name + '" was successfully updated.',
|
message: 'Category "' + res.name + '" was successfully updated.',
|
||||||
type: 'success',
|
type: 'success',
|
||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
});
|
});
|
||||||
updateHash = {};
|
updateHash = {};
|
||||||
}).catch(app.alertError);
|
}).catch(alerts.error);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,11 +4,12 @@ define('admin/manage/privileges', [
|
|||||||
'api',
|
'api',
|
||||||
'autocomplete',
|
'autocomplete',
|
||||||
'bootbox',
|
'bootbox',
|
||||||
|
'alerts',
|
||||||
'translator',
|
'translator',
|
||||||
'categorySelector',
|
'categorySelector',
|
||||||
'mousetrap',
|
'mousetrap',
|
||||||
'admin/modules/checkboxRowSelector',
|
'admin/modules/checkboxRowSelector',
|
||||||
], function (api, autocomplete, bootbox, translator, categorySelector, mousetrap, checkboxRowSelector) {
|
], function (api, autocomplete, bootbox, alerts, translator, categorySelector, mousetrap, checkboxRowSelector) {
|
||||||
const Privileges = {};
|
const Privileges = {};
|
||||||
|
|
||||||
let cid;
|
let cid;
|
||||||
@@ -267,7 +268,7 @@ define('admin/manage/privileges', [
|
|||||||
|
|
||||||
autocomplete.group(inputEl, function (ev, ui) {
|
autocomplete.group(inputEl, function (ev, ui) {
|
||||||
if (ui.item.group.name === 'administrators') {
|
if (ui.item.group.name === 'administrators') {
|
||||||
return app.alert({
|
return alerts.alert({
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
message: '[[admin/manage/privileges:alert.admin-warning]]',
|
message: '[[admin/manage/privileges:alert.admin-warning]]',
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('admin/manage/users', [
|
define('admin/manage/users', [
|
||||||
'translator', 'benchpress', 'autocomplete', 'api', 'slugify', 'bootbox', 'accounts/invite',
|
'translator', 'benchpress', 'autocomplete', 'api', 'slugify', 'bootbox', 'alerts', 'accounts/invite',
|
||||||
], function (translator, Benchpress, autocomplete, api, slugify, bootbox, AccountInvite) {
|
], function (translator, Benchpress, autocomplete, api, slugify, bootbox, alerts, AccountInvite) {
|
||||||
const Users = {};
|
const Users = {};
|
||||||
|
|
||||||
Users.init = function () {
|
Users.init = function () {
|
||||||
@@ -15,8 +15,8 @@ define('admin/manage/users', [
|
|||||||
|
|
||||||
$('.export-csv').on('click', function () {
|
$('.export-csv').on('click', function () {
|
||||||
socket.once('event:export-users-csv', function () {
|
socket.once('event:export-users-csv', function () {
|
||||||
app.removeAlert('export-users-start');
|
alerts.remove('export-users-start');
|
||||||
app.alert({
|
alerts.alert({
|
||||||
alert_id: 'export-users',
|
alert_id: 'export-users',
|
||||||
type: 'success',
|
type: 'success',
|
||||||
title: '[[global:alert.success]]',
|
title: '[[global:alert.success]]',
|
||||||
@@ -29,9 +29,9 @@ define('admin/manage/users', [
|
|||||||
});
|
});
|
||||||
socket.emit('admin.user.exportUsersCSV', {}, function (err) {
|
socket.emit('admin.user.exportUsersCSV', {}, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
app.alert({
|
alerts.alert({
|
||||||
alert_id: 'export-users-start',
|
alert_id: 'export-users-start',
|
||||||
message: '[[admin/manage/users:export-users-started]]',
|
message: '[[admin/manage/users:export-users-started]]',
|
||||||
timeout: (ajaxify.data.userCount / 5000) * 500,
|
timeout: (ajaxify.data.userCount / 5000) * 500,
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('admin/modules/instance', [
|
define('admin/modules/instance', [
|
||||||
|
'alerts',
|
||||||
// need to preload the compiled alert template
|
// need to preload the compiled alert template
|
||||||
// otherwise it can be unloaded when rebuild & restart is run
|
// otherwise it can be unloaded when rebuild & restart is run
|
||||||
// the client can't fetch the template file, resulting in an error
|
// the client can't fetch the template file, resulting in an error
|
||||||
config.relative_path + '/assets/templates/alert.js',
|
config.relative_path + '/assets/templates/alert.js',
|
||||||
], function () {
|
], function (alerts) {
|
||||||
const instance = {};
|
const instance = {};
|
||||||
|
|
||||||
instance.rebuildAndRestart = function (callback) {
|
instance.rebuildAndRestart = function (callback) {
|
||||||
app.alert({
|
alerts.alert({
|
||||||
alert_id: 'instance_rebuild_and_restart',
|
alert_id: 'instance_rebuild_and_restart',
|
||||||
type: 'info',
|
type: 'info',
|
||||||
title: 'Rebuilding... <i class="fa fa-spin fa-refresh"></i>',
|
title: 'Rebuilding... <i class="fa fa-spin fa-refresh"></i>',
|
||||||
@@ -17,7 +18,7 @@ define('admin/modules/instance', [
|
|||||||
});
|
});
|
||||||
|
|
||||||
$(window).one('action:reconnected', function () {
|
$(window).one('action:reconnected', function () {
|
||||||
app.alert({
|
alerts.alert({
|
||||||
alert_id: 'instance_rebuild_and_restart',
|
alert_id: 'instance_rebuild_and_restart',
|
||||||
type: 'success',
|
type: 'success',
|
||||||
title: '<i class="fa fa-check"></i> Success',
|
title: '<i class="fa fa-check"></i> Success',
|
||||||
@@ -31,7 +32,7 @@ define('admin/modules/instance', [
|
|||||||
});
|
});
|
||||||
|
|
||||||
socket.emit('admin.reload', function () {
|
socket.emit('admin.reload', function () {
|
||||||
app.alert({
|
alerts.alert({
|
||||||
alert_id: 'instance_rebuild_and_restart',
|
alert_id: 'instance_rebuild_and_restart',
|
||||||
type: 'info',
|
type: 'info',
|
||||||
title: 'Build Complete!... <i class="fa fa-spin fa-refresh"></i>',
|
title: 'Build Complete!... <i class="fa fa-spin fa-refresh"></i>',
|
||||||
@@ -41,7 +42,7 @@ define('admin/modules/instance', [
|
|||||||
};
|
};
|
||||||
|
|
||||||
instance.restart = function (callback) {
|
instance.restart = function (callback) {
|
||||||
app.alert({
|
alerts.alert({
|
||||||
alert_id: 'instance_restart',
|
alert_id: 'instance_restart',
|
||||||
type: 'info',
|
type: 'info',
|
||||||
title: 'Restarting... <i class="fa fa-spin fa-refresh"></i>',
|
title: 'Restarting... <i class="fa fa-spin fa-refresh"></i>',
|
||||||
@@ -49,7 +50,7 @@ define('admin/modules/instance', [
|
|||||||
});
|
});
|
||||||
|
|
||||||
$(window).one('action:reconnected', function () {
|
$(window).one('action:reconnected', function () {
|
||||||
app.alert({
|
alerts.alert({
|
||||||
alert_id: 'instance_restart',
|
alert_id: 'instance_restart',
|
||||||
type: 'success',
|
type: 'success',
|
||||||
title: '<i class="fa fa-check"></i> Success',
|
title: '<i class="fa fa-check"></i> Success',
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('admin/settings', ['uploader', 'mousetrap', 'hooks'], function (uploader, mousetrap, hooks) {
|
define('admin/settings', ['uploader', 'mousetrap', 'hooks', 'alerts'], function (uploader, mousetrap, hooks, alerts) {
|
||||||
const Settings = {};
|
const Settings = {};
|
||||||
|
|
||||||
Settings.populateTOC = function () {
|
Settings.populateTOC = function () {
|
||||||
@@ -68,22 +68,22 @@ define('admin/settings', ['uploader', 'mousetrap', 'hooks'], function (uploader,
|
|||||||
|
|
||||||
saveFields(fields, function onFieldsSaved(err) {
|
saveFields(fields, function onFieldsSaved(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alert({
|
return alerts.alert({
|
||||||
alert_id: 'config_status',
|
alert_id: 'config_status',
|
||||||
timeout: 2500,
|
timeout: 2500,
|
||||||
title: 'Changes Not Saved',
|
title: '[[admin/admin:changes-not-saved]]',
|
||||||
message: 'NodeBB encountered a problem saving your changes. (' + err.message + ')',
|
message: `[[admin/admin:changes-not-saved-message, ${err.message}]]`,
|
||||||
type: 'danger',
|
type: 'danger',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
app.flags._unsaved = false;
|
app.flags._unsaved = false;
|
||||||
|
|
||||||
app.alert({
|
alerts.alert({
|
||||||
alert_id: 'config_status',
|
alert_id: 'config_status',
|
||||||
timeout: 2500,
|
timeout: 2500,
|
||||||
title: 'Changes Saved',
|
title: '[[admin/admin:changes-saved]]',
|
||||||
message: 'Your changes to the NodeBB configuration have been saved.',
|
message: '[[admin/admin:changes-saved-message]]',
|
||||||
type: 'success',
|
type: 'success',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('admin/settings/api', ['settings'], function (settings) {
|
define('admin/settings/api', ['settings', 'alerts'], function (settings, alerts) {
|
||||||
const ACP = {};
|
const ACP = {};
|
||||||
|
|
||||||
ACP.init = function () {
|
ACP.init = function () {
|
||||||
@@ -20,7 +20,7 @@ define('admin/settings/api', ['settings'], function (settings) {
|
|||||||
|
|
||||||
function saveSettings() {
|
function saveSettings() {
|
||||||
settings.save('core.api', $('.core-api-settings'), function () {
|
settings.save('core.api', $('.core-api-settings'), function () {
|
||||||
app.alert({
|
alerts.alert({
|
||||||
type: 'success',
|
type: 'success',
|
||||||
alert_id: 'core.api-saved',
|
alert_id: 'core.api-saved',
|
||||||
title: 'Settings Saved',
|
title: 'Settings Saved',
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
|
|
||||||
define('forum/chats/messages', [
|
define('forum/chats/messages', [
|
||||||
'components', 'translator', 'benchpress', 'hooks', 'bootbox', 'messages',
|
'components', 'translator', 'benchpress', 'hooks', 'bootbox', 'alerts', 'messages',
|
||||||
], function (components, translator, Benchpress, hooks, bootbox, messagesModule) {
|
], function (components, translator, Benchpress, hooks, bootbox, alerts, messagesModule) {
|
||||||
const messages = {};
|
const messages = {};
|
||||||
|
|
||||||
messages.sendMessage = function (roomId, inputEl) {
|
messages.sendMessage = function (roomId, inputEl) {
|
||||||
@@ -35,7 +35,7 @@ define('forum/chats/messages', [
|
|||||||
return messagesModule.showEmailConfirmWarning(err.message);
|
return messagesModule.showEmailConfirmWarning(err.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
return app.alert({
|
return alerts.alert({
|
||||||
alert_id: 'chat_spam_error',
|
alert_id: 'chat_spam_error',
|
||||||
title: '[[global:alert.error]]',
|
title: '[[global:alert.error]]',
|
||||||
message: err.message,
|
message: err.message,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('forum/ip-blacklist', ['Chart', 'benchpress', 'bootbox'], function (Chart, Benchpress, bootbox) {
|
define('forum/ip-blacklist', ['Chart', 'benchpress', 'bootbox', 'alerts'], function (Chart, Benchpress, bootbox, alerts) {
|
||||||
const Blacklist = {};
|
const Blacklist = {};
|
||||||
|
|
||||||
Blacklist.init = function () {
|
Blacklist.init = function () {
|
||||||
@@ -14,9 +14,9 @@ define('forum/ip-blacklist', ['Chart', 'benchpress', 'bootbox'], function (Chart
|
|||||||
$('[data-action="apply"]').on('click', function () {
|
$('[data-action="apply"]').on('click', function () {
|
||||||
socket.emit('blacklist.save', blacklist.val(), function (err) {
|
socket.emit('blacklist.save', blacklist.val(), function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
app.alert({
|
alerts.alert({
|
||||||
type: 'success',
|
type: 'success',
|
||||||
alert_id: 'blacklist-saved',
|
alert_id: 'blacklist-saved',
|
||||||
title: '[[ip-blacklist:alerts.applied-success]]',
|
title: '[[ip-blacklist:alerts.applied-success]]',
|
||||||
@@ -29,7 +29,7 @@ define('forum/ip-blacklist', ['Chart', 'benchpress', 'bootbox'], function (Chart
|
|||||||
rules: blacklist.val(),
|
rules: blacklist.val(),
|
||||||
}, function (err, data) {
|
}, function (err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
Benchpress.render('admin/partials/blacklist-validate', data).then(function (html) {
|
Benchpress.render('admin/partials/blacklist-validate', data).then(function (html) {
|
||||||
|
|||||||
@@ -13,10 +13,11 @@ define('forum/topic', [
|
|||||||
'storage',
|
'storage',
|
||||||
'hooks',
|
'hooks',
|
||||||
'api',
|
'api',
|
||||||
|
'alerts',
|
||||||
], function (
|
], function (
|
||||||
infinitescroll, threadTools, postTools,
|
infinitescroll, threadTools, postTools,
|
||||||
events, posts, navigator, sort,
|
events, posts, navigator, sort,
|
||||||
components, storage, hooks, api
|
components, storage, hooks, api, alerts
|
||||||
) {
|
) {
|
||||||
const Topic = {};
|
const Topic = {};
|
||||||
let currentUrl = '';
|
let currentUrl = '';
|
||||||
@@ -113,7 +114,7 @@ define('forum/topic', [
|
|||||||
!config.usePagination ||
|
!config.usePagination ||
|
||||||
(config.usePagination && ajaxify.data.pagination.currentPage === 1)
|
(config.usePagination && ajaxify.data.pagination.currentPage === 1)
|
||||||
) && ajaxify.data.postcount > ajaxify.data.bookmarkThreshold) {
|
) && ajaxify.data.postcount > ajaxify.data.bookmarkThreshold) {
|
||||||
app.alert({
|
alerts.alert({
|
||||||
alert_id: 'bookmark',
|
alert_id: 'bookmark',
|
||||||
message: '[[topic:bookmark_instructions]]',
|
message: '[[topic:bookmark_instructions]]',
|
||||||
timeout: 0,
|
timeout: 0,
|
||||||
@@ -126,7 +127,7 @@ define('forum/topic', [
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
app.removeAlert('bookmark');
|
alerts.remove('bookmark');
|
||||||
}, 10000);
|
}, 10000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('forum/topic/fork', ['components', 'postSelect'], function (components, postSelect) {
|
define('forum/topic/fork', ['components', 'postSelect', 'alerts'], function (components, postSelect, alerts) {
|
||||||
const Fork = {};
|
const Fork = {};
|
||||||
let forkModal;
|
let forkModal;
|
||||||
let forkCommit;
|
let forkCommit;
|
||||||
@@ -57,10 +57,10 @@ define('forum/topic/fork', ['components', 'postSelect'], function (components, p
|
|||||||
}
|
}
|
||||||
forkCommit.removeAttr('disabled');
|
forkCommit.removeAttr('disabled');
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.alert({
|
alerts.alert({
|
||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
title: '[[global:alert.success]]',
|
title: '[[global:alert.success]]',
|
||||||
message: '[[topic:fork_success]]',
|
message: '[[topic:fork_success]]',
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ define('forum/topic/threadTools', [
|
|||||||
'api',
|
'api',
|
||||||
'hooks',
|
'hooks',
|
||||||
'bootbox',
|
'bootbox',
|
||||||
], function (components, translator, handleBack, posts, api, hooks, bootbox) {
|
'alerts',
|
||||||
|
], function (components, translator, handleBack, posts, api, hooks, bootbox, alerts) {
|
||||||
const ThreadTools = {};
|
const ThreadTools = {};
|
||||||
|
|
||||||
ThreadTools.init = function (tid, topicContainer) {
|
ThreadTools.init = function (tid, topicContainer) {
|
||||||
@@ -149,7 +150,7 @@ define('forum/topic/threadTools', [
|
|||||||
|
|
||||||
setFollowState(type);
|
setFollowState(type);
|
||||||
|
|
||||||
app.alert({
|
alerts.alert({
|
||||||
alert_id: 'follow_thread',
|
alert_id: 'follow_thread',
|
||||||
message: message,
|
message: message,
|
||||||
type: 'success',
|
type: 'success',
|
||||||
@@ -158,7 +159,7 @@ define('forum/topic/threadTools', [
|
|||||||
|
|
||||||
hooks.fire('action:topics.changeWatching', { tid: tid, type: type });
|
hooks.fire('action:topics.changeWatching', { tid: tid, type: type });
|
||||||
}, () => {
|
}, () => {
|
||||||
app.alert({
|
alerts.alert({
|
||||||
type: 'danger',
|
type: 'danger',
|
||||||
alert_id: 'topic_follow',
|
alert_id: 'topic_follow',
|
||||||
title: '[[global:please_log_in]]',
|
title: '[[global:please_log_in]]',
|
||||||
|
|||||||
@@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
|
|
||||||
define('coverPhoto', [
|
define('coverPhoto', [
|
||||||
|
'alerts',
|
||||||
'vendor/jquery/draggable-background/backgroundDraggable',
|
'vendor/jquery/draggable-background/backgroundDraggable',
|
||||||
], function () {
|
], function (alerts) {
|
||||||
const coverPhoto = {
|
const coverPhoto = {
|
||||||
coverEl: null,
|
coverEl: null,
|
||||||
saveFn: null,
|
saveFn: null,
|
||||||
@@ -58,7 +59,7 @@ define('coverPhoto', [
|
|||||||
units: 'percent',
|
units: 'percent',
|
||||||
});
|
});
|
||||||
|
|
||||||
app.alert({
|
alerts.alert({
|
||||||
alert_id: 'drag_start',
|
alert_id: 'drag_start',
|
||||||
title: '[[modules:cover.dragging_title]]',
|
title: '[[modules:cover.dragging_title]]',
|
||||||
message: '[[modules:cover.dragging_message]]',
|
message: '[[modules:cover.dragging_message]]',
|
||||||
@@ -75,9 +76,9 @@ define('coverPhoto', [
|
|||||||
coverPhoto.coverEl.backgroundDraggable('disable');
|
coverPhoto.coverEl.backgroundDraggable('disable');
|
||||||
coverPhoto.coverEl.off('dragover', coverPhoto.onDragOver);
|
coverPhoto.coverEl.off('dragover', coverPhoto.onDragOver);
|
||||||
coverPhoto.coverEl.off('drop', coverPhoto.onDrop);
|
coverPhoto.coverEl.off('drop', coverPhoto.onDrop);
|
||||||
app.alertSuccess('[[modules:cover.saved]]');
|
alerts.success('[[modules:cover.saved]]');
|
||||||
} else {
|
} else {
|
||||||
app.alertError(err.message);
|
alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
coverPhoto.coverEl.removeClass('saving');
|
coverPhoto.coverEl.removeClass('saving');
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ define('messages', ['bootbox', 'translator', 'storage', 'alerts'], function (boo
|
|||||||
app.removeAlert('email_confirm');
|
app.removeAlert('email_confirm');
|
||||||
ajaxify.go('user/' + app.user.userslug + '/edit/email');
|
ajaxify.go('user/' + app.user.userslug + '/edit/email');
|
||||||
};
|
};
|
||||||
app.alert(msg);
|
alerts.alert(msg);
|
||||||
} else if (!app.user['email:confirmed'] && !app.user.isEmailConfirmSent) {
|
} else if (!app.user['email:confirmed'] && !app.user.isEmailConfirmSent) {
|
||||||
msg.message = message || '[[error:email-not-confirmed]]';
|
msg.message = message || '[[error:email-not-confirmed]]';
|
||||||
msg.clickfn = function () {
|
msg.clickfn = function () {
|
||||||
@@ -43,10 +43,10 @@ define('messages', ['bootbox', 'translator', 'storage', 'alerts'], function (boo
|
|||||||
app.alertSuccess('[[notifications:email-confirm-sent]]');
|
app.alertSuccess('[[notifications:email-confirm-sent]]');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
app.alert(msg);
|
alerts.alert(msg);
|
||||||
} else if (!app.user['email:confirmed'] && app.user.isEmailConfirmSent) {
|
} else if (!app.user['email:confirmed'] && app.user.isEmailConfirmSent) {
|
||||||
msg.message = '[[error:email-not-confirmed-email-sent]]';
|
msg.message = '[[error:email-not-confirmed-email-sent]]';
|
||||||
app.alert(msg);
|
alerts.alert(msg);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('search', ['translator', 'storage', 'hooks'], function (translator, storage, hooks) {
|
define('search', ['translator', 'storage', 'hooks', 'alerts'], function (translator, storage, hooks, alerts) {
|
||||||
const Search = {
|
const Search = {
|
||||||
current: {},
|
current: {},
|
||||||
};
|
};
|
||||||
@@ -45,7 +45,7 @@ define('search', ['translator', 'storage', 'hooks'], function (translator, stora
|
|||||||
|
|
||||||
searchButton.off('click').on('click', function (e) {
|
searchButton.off('click').on('click', function (e) {
|
||||||
if (!config.loggedIn && !app.user.privileges['search:content']) {
|
if (!config.loggedIn && !app.user.privileges['search:content']) {
|
||||||
app.alert({
|
alerts.alert({
|
||||||
message: '[[error:search-requires-login]]',
|
message: '[[error:search-requires-login]]',
|
||||||
timeout: 3000,
|
timeout: 3000,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('settings', ['hooks'], function (hooks) {
|
define('settings', ['hooks', 'alerts'], function (hooks, alerts) {
|
||||||
const DEFAULT_PLUGINS = [
|
const DEFAULT_PLUGINS = [
|
||||||
'settings/checkbox',
|
'settings/checkbox',
|
||||||
'settings/number',
|
'settings/number',
|
||||||
@@ -310,17 +310,17 @@ define('settings', ['hooks'], function (hooks) {
|
|||||||
}, function (err) {
|
}, function (err) {
|
||||||
if (notify) {
|
if (notify) {
|
||||||
if (err) {
|
if (err) {
|
||||||
app.alert({
|
alerts.alert({
|
||||||
title: 'Settings Not Saved',
|
title: '[[admin/admin:changes-not-saved]]',
|
||||||
type: 'danger',
|
type: 'danger',
|
||||||
message: 'NodeBB failed to save the settings.',
|
message: `[[admin/admin/changes-not-saved-message, ${err.message}]]`,
|
||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
app.alert({
|
alerts.alert({
|
||||||
title: 'Settings Saved',
|
title: '[[admin/admin:changes-saved]]',
|
||||||
type: 'success',
|
type: 'success',
|
||||||
message: 'Settings have been successfully saved',
|
message: '[[admin/admin:changes-saved-message]]',
|
||||||
timeout: 2500,
|
timeout: 2500,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -460,7 +460,7 @@ define('settings', ['hooks'], function (hooks) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (notSaved.length) {
|
if (notSaved.length) {
|
||||||
app.alert({
|
alerts.alert({
|
||||||
title: 'Attributes Not Saved',
|
title: 'Attributes Not Saved',
|
||||||
message: "'" + (notSaved.join(', ')) + "' could not be saved. Please contact the plugin-author!",
|
message: "'" + (notSaved.join(', ')) + "' could not be saved. Please contact the plugin-author!",
|
||||||
type: 'danger',
|
type: 'danger',
|
||||||
@@ -554,13 +554,13 @@ define('settings', ['hooks'], function (hooks) {
|
|||||||
if (typeof callback === 'function') {
|
if (typeof callback === 'function') {
|
||||||
callback(err);
|
callback(err);
|
||||||
} else if (err) {
|
} else if (err) {
|
||||||
app.alert({
|
alerts.alert({
|
||||||
title: 'Error while saving settings',
|
title: 'Error while saving settings',
|
||||||
type: 'error',
|
type: 'error',
|
||||||
timeout: 2500,
|
timeout: 2500,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
app.alert({
|
alerts.alert({
|
||||||
title: 'Settings Saved',
|
title: 'Settings Saved',
|
||||||
type: 'success',
|
type: 'success',
|
||||||
timeout: 2500,
|
timeout: 2500,
|
||||||
|
|||||||
@@ -99,7 +99,9 @@ socket = window.socket;
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
socket.on('event:alert', function (params) {
|
socket.on('event:alert', function (params) {
|
||||||
app.alert(params);
|
require(['alerts'], function (alerts) {
|
||||||
|
alerts.alert(params);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
socket.on('event:deprecated_call', function (data) {
|
socket.on('event:deprecated_call', function (data) {
|
||||||
console.warn('[socket.io] ', data.eventName, 'is now deprecated in favour of', data.replacement);
|
console.warn('[socket.io] ', data.eventName, 'is now deprecated in favour of', data.replacement);
|
||||||
@@ -109,8 +111,8 @@ socket = window.socket;
|
|||||||
socket.on('event:nodebb.ready', function (data) {
|
socket.on('event:nodebb.ready', function (data) {
|
||||||
if ((data.hostname === app.upstreamHost) && (!app.cacheBuster || app.cacheBuster !== data['cache-buster'])) {
|
if ((data.hostname === app.upstreamHost) && (!app.cacheBuster || app.cacheBuster !== data['cache-buster'])) {
|
||||||
app.cacheBuster = data['cache-buster'];
|
app.cacheBuster = data['cache-buster'];
|
||||||
|
require(['alerts'], function (alerts) {
|
||||||
app.alert({
|
alerts.alert({
|
||||||
alert_id: 'forum_updated',
|
alert_id: 'forum_updated',
|
||||||
title: '[[global:updated.title]]',
|
title: '[[global:updated.title]]',
|
||||||
message: '[[global:updated.message]]',
|
message: '[[global:updated.message]]',
|
||||||
@@ -119,6 +121,7 @@ socket = window.socket;
|
|||||||
},
|
},
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
socket.on('event:livereload', function () {
|
socket.on('event:livereload', function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user