mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 09:06:15 +01:00
refactor: use alerts.error/success
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('admin/advanced/cache', function () {
|
define('admin/advanced/cache', ['alerts'], function (alerts) {
|
||||||
const Cache = {};
|
const Cache = {};
|
||||||
Cache.init = function () {
|
Cache.init = function () {
|
||||||
require(['admin/settings'], function (Settings) {
|
require(['admin/settings'], function (Settings) {
|
||||||
@@ -11,7 +11,7 @@ define('admin/advanced/cache', function () {
|
|||||||
const name = $(this).attr('data-name');
|
const name = $(this).attr('data-name');
|
||||||
socket.emit('admin.cache.clear', { name: name }, function (err) {
|
socket.emit('admin.cache.clear', { name: name }, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
ajaxify.refresh();
|
ajaxify.refresh();
|
||||||
});
|
});
|
||||||
@@ -23,7 +23,7 @@ define('admin/advanced/cache', function () {
|
|||||||
const name = $(this).attr('data-name');
|
const name = $(this).attr('data-name');
|
||||||
socket.emit('admin.cache.toggle', { name: name, enabled: flag }, function (err) {
|
socket.emit('admin.cache.toggle', { name: name, enabled: flag }, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('admin/advanced/errors', ['bootbox', 'Chart'], function (bootbox, Chart) {
|
define('admin/advanced/errors', ['bootbox', 'alerts', 'Chart'], function (bootbox, alerts, Chart) {
|
||||||
const Errors = {};
|
const Errors = {};
|
||||||
|
|
||||||
Errors.init = function () {
|
Errors.init = function () {
|
||||||
@@ -15,11 +15,11 @@ define('admin/advanced/errors', ['bootbox', 'Chart'], function (bootbox, Chart)
|
|||||||
if (ok) {
|
if (ok) {
|
||||||
socket.emit('admin.errors.clear', {}, function (err) {
|
socket.emit('admin.errors.clear', {}, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
ajaxify.refresh();
|
ajaxify.refresh();
|
||||||
app.alertSuccess('[[admin/advanced/errors:clear404-success]]');
|
alerts.success('[[admin/advanced/errors:clear404-success]]');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('admin/advanced/events', ['bootbox'], function (bootbox) {
|
define('admin/advanced/events', ['bootbox', 'alerts'], function (bootbox, alerts) {
|
||||||
const Events = {};
|
const Events = {};
|
||||||
|
|
||||||
Events.init = function () {
|
Events.init = function () {
|
||||||
@@ -10,7 +10,7 @@ define('admin/advanced/events', ['bootbox'], function (bootbox) {
|
|||||||
if (confirm) {
|
if (confirm) {
|
||||||
socket.emit('admin.deleteAllEvents', function (err) {
|
socket.emit('admin.deleteAllEvents', function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
$('.events-list').empty();
|
$('.events-list').empty();
|
||||||
});
|
});
|
||||||
@@ -23,7 +23,7 @@ define('admin/advanced/events', ['bootbox'], function (bootbox) {
|
|||||||
const eid = $parentEl.attr('data-eid');
|
const eid = $parentEl.attr('data-eid');
|
||||||
socket.emit('admin.deleteEvents', [eid], function (err) {
|
socket.emit('admin.deleteEvents', [eid], function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
$parentEl.remove();
|
$parentEl.remove();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('admin/advanced/logs', function () {
|
define('admin/advanced/logs', ['alerts'], function (alerts) {
|
||||||
const Logs = {};
|
const Logs = {};
|
||||||
|
|
||||||
Logs.init = function () {
|
Logs.init = function () {
|
||||||
@@ -21,7 +21,7 @@ define('admin/advanced/logs', function () {
|
|||||||
logsEl.text(logs);
|
logsEl.text(logs);
|
||||||
logsEl.scrollTop(logsEl.prop('scrollHeight'));
|
logsEl.scrollTop(logsEl.prop('scrollHeight'));
|
||||||
} else {
|
} else {
|
||||||
app.alertError(err.message);
|
alerts.error(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
@@ -29,8 +29,10 @@ define('admin/advanced/logs', function () {
|
|||||||
case 'clear':
|
case 'clear':
|
||||||
socket.emit('admin.logs.clear', function (err) {
|
socket.emit('admin.logs.clear', function (err) {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
app.alertSuccess('[[admin/advanced/logs:clear-success]]');
|
alerts.success('[[admin/advanced/logs:clear-success]]');
|
||||||
btnEl.prev().click();
|
btnEl.prev().click();
|
||||||
|
} else {
|
||||||
|
alerts.error(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('admin/dashboard', ['Chart', 'translator', 'benchpress', 'bootbox'], function (Chart, translator, Benchpress, bootbox) {
|
define('admin/dashboard', [
|
||||||
|
'Chart', 'translator', 'benchpress', 'bootbox', 'alerts',
|
||||||
|
], function (Chart, translator, Benchpress, bootbox, alerts) {
|
||||||
const Admin = {};
|
const Admin = {};
|
||||||
const intervals = {
|
const intervals = {
|
||||||
rooms: false,
|
rooms: false,
|
||||||
@@ -53,7 +55,7 @@ define('admin/dashboard', ['Chart', 'translator', 'benchpress', 'bootbox'], func
|
|||||||
|
|
||||||
Admin.updateRoomUsage = function (err, data) {
|
Admin.updateRoomUsage = function (err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (JSON.stringify(graphData.rooms) === JSON.stringify(data)) {
|
if (JSON.stringify(graphData.rooms) === JSON.stringify(data)) {
|
||||||
@@ -425,7 +427,7 @@ define('admin/dashboard', ['Chart', 'translator', 'benchpress', 'bootbox'], func
|
|||||||
amount: amount,
|
amount: amount,
|
||||||
}, function (err, data) {
|
}, function (err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
if (JSON.stringify(graphData.traffic) === JSON.stringify(data)) {
|
if (JSON.stringify(graphData.traffic) === JSON.stringify(data)) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ define('admin/extend/plugins', [
|
|||||||
submitPluginUsage: $(this).prop('checked') ? '1' : '0',
|
submitPluginUsage: $(this).prop('checked') ? '1' : '0',
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -178,7 +178,7 @@ define('admin/extend/plugins', [
|
|||||||
$('#order-active-plugins-modal').modal('show');
|
$('#order-active-plugins-modal').modal('show');
|
||||||
socket.emit('admin.plugins.getActive', function (err, activePlugins) {
|
socket.emit('admin.plugins.getActive', function (err, activePlugins) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
let html = '';
|
let html = '';
|
||||||
activePlugins.forEach(function (plugin) {
|
activePlugins.forEach(function (plugin) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('admin/extend/rewards', [], function () {
|
define('admin/extend/rewards', ['alerts'], function (alerts) {
|
||||||
const rewards = {};
|
const rewards = {};
|
||||||
|
|
||||||
|
|
||||||
@@ -30,9 +30,9 @@ define('admin/extend/rewards', [], function () {
|
|||||||
|
|
||||||
socket.emit('admin.rewards.delete', { id: id }, function (err) {
|
socket.emit('admin.rewards.delete', { id: id }, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
app.alertError(err.message);
|
alerts.error(err);
|
||||||
} else {
|
} else {
|
||||||
app.alertSuccess('[[admin/extend/rewards:alert.delete-success]]');
|
alerts.success('[[admin/extend/rewards:alert.delete-success]]');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ define('admin/extend/rewards', [], function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!inputs) {
|
if (!inputs) {
|
||||||
return app.alertError('[[admin/extend/rewards:alert.no-inputs-found]] ' + el.attr('data-selected'));
|
return alerts.error('[[admin/extend/rewards:alert.no-inputs-found]] ' + el.attr('data-selected'));
|
||||||
}
|
}
|
||||||
|
|
||||||
inputs.forEach(function (input) {
|
inputs.forEach(function (input) {
|
||||||
@@ -169,9 +169,9 @@ define('admin/extend/rewards', [], function () {
|
|||||||
|
|
||||||
socket.emit('admin.rewards.save', activeRewards, function (err, result) {
|
socket.emit('admin.rewards.save', activeRewards, function (err, result) {
|
||||||
if (err) {
|
if (err) {
|
||||||
app.alertError(err.message);
|
alerts.error(err);
|
||||||
} else {
|
} else {
|
||||||
app.alertSuccess('[[admin/extend/rewards:alert.save-success]]');
|
alerts.success('[[admin/extend/rewards:alert.save-success]]');
|
||||||
// newly added rewards are missing data-id, update to prevent rewards getting duplicated
|
// newly added rewards are missing data-id, update to prevent rewards getting duplicated
|
||||||
$('#active li').each(function (index) {
|
$('#active li').each(function (index) {
|
||||||
if (!$(this).attr('data-id')) {
|
if (!$(this).attr('data-id')) {
|
||||||
|
|||||||
@@ -245,7 +245,7 @@ define('admin/extend/widgets', [
|
|||||||
cloneBtn.on('click', function () {
|
cloneBtn.on('click', function () {
|
||||||
const template = cloneBtn.attr('data-template');
|
const template = cloneBtn.attr('data-template');
|
||||||
if (!template) {
|
if (!template) {
|
||||||
return app.alertError('[[admin/extend/widgets:error.select-clone]]');
|
return alerts.error('[[admin/extend/widgets:error.select-clone]]');
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentTemplate = $('#active-widgets .active.tab-pane[data-template] .area');
|
const currentTemplate = $('#active-widgets .active.tab-pane[data-template] .area');
|
||||||
@@ -274,7 +274,7 @@ define('admin/extend/widgets', [
|
|||||||
clone(location);
|
clone(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.alertSuccess('[[admin/extend/widgets:alert.clone-success]]');
|
alerts.success('[[admin/extend/widgets:alert.clone-success]]');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('admin/manage/admins-mods', [
|
define('admin/manage/admins-mods', [
|
||||||
'autocomplete', 'api', 'bootbox', 'categorySelector',
|
'autocomplete', 'api', 'bootbox', 'alerts', 'categorySelector',
|
||||||
], function (autocomplete, api, bootbox, categorySelector) {
|
], function (autocomplete, api, bootbox, alerts, categorySelector) {
|
||||||
const AdminsMods = {};
|
const AdminsMods = {};
|
||||||
|
|
||||||
AdminsMods.init = function () {
|
AdminsMods.init = function () {
|
||||||
autocomplete.user($('#admin-search'), function (ev, ui) {
|
autocomplete.user($('#admin-search'), function (ev, ui) {
|
||||||
socket.emit('admin.user.makeAdmins', [ui.item.user.uid], function (err) {
|
socket.emit('admin.user.makeAdmins', [ui.item.user.uid], function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
app.alertSuccess('[[admin/manage/users:alerts.make-admin-success]]');
|
alerts.success('[[admin/manage/users:alerts.make-admin-success]]');
|
||||||
$('#admin-search').val('');
|
$('#admin-search').val('');
|
||||||
|
|
||||||
if ($('.administrator-area [data-uid="' + ui.item.user.uid + '"]').length) {
|
if ($('.administrator-area [data-uid="' + ui.item.user.uid + '"]').length) {
|
||||||
@@ -28,15 +28,15 @@ define('admin/manage/admins-mods', [
|
|||||||
const userCard = $(this).parents('[data-uid]');
|
const userCard = $(this).parents('[data-uid]');
|
||||||
const uid = userCard.attr('data-uid');
|
const uid = userCard.attr('data-uid');
|
||||||
if (parseInt(uid, 10) === parseInt(app.user.uid, 10)) {
|
if (parseInt(uid, 10) === parseInt(app.user.uid, 10)) {
|
||||||
return app.alertError('[[admin/manage/users:alerts.no-remove-yourself-admin]]');
|
return alerts.error('[[admin/manage/users:alerts.no-remove-yourself-admin]]');
|
||||||
}
|
}
|
||||||
bootbox.confirm('[[admin/manage/users:alerts.confirm-remove-admin]]', function (confirm) {
|
bootbox.confirm('[[admin/manage/users:alerts.confirm-remove-admin]]', function (confirm) {
|
||||||
if (confirm) {
|
if (confirm) {
|
||||||
socket.emit('admin.user.removeAdmins', [uid], function (err) {
|
socket.emit('admin.user.removeAdmins', [uid], function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err.message);
|
||||||
}
|
}
|
||||||
app.alertSuccess('[[admin/manage/users:alerts.remove-admin-success]]');
|
alerts.success('[[admin/manage/users:alerts.remove-admin-success]]');
|
||||||
userCard.remove();
|
userCard.remove();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,7 @@ define('admin/manage/admins-mods', [
|
|||||||
|
|
||||||
autocomplete.user($('#global-mod-search'), function (ev, ui) {
|
autocomplete.user($('#global-mod-search'), function (ev, ui) {
|
||||||
api.put('/groups/global-moderators/membership/' + ui.item.user.uid).then(() => {
|
api.put('/groups/global-moderators/membership/' + ui.item.user.uid).then(() => {
|
||||||
app.alertSuccess('[[admin/manage/users:alerts.make-global-mod-success]]');
|
alerts.success('[[admin/manage/users:alerts.make-global-mod-success]]');
|
||||||
$('#global-mod-search').val('');
|
$('#global-mod-search').val('');
|
||||||
|
|
||||||
if ($('.global-moderator-area [data-uid="' + ui.item.user.uid + '"]').length) {
|
if ($('.global-moderator-area [data-uid="' + ui.item.user.uid + '"]').length) {
|
||||||
@@ -56,7 +56,7 @@ define('admin/manage/admins-mods', [
|
|||||||
$('.global-moderator-area').prepend(html);
|
$('.global-moderator-area').prepend(html);
|
||||||
$('#no-global-mods-warning').addClass('hidden');
|
$('#no-global-mods-warning').addClass('hidden');
|
||||||
});
|
});
|
||||||
}).catch(app.alertError);
|
}).catch(alerts.error);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.global-moderator-area').on('click', '.remove-user-icon', function () {
|
$('.global-moderator-area').on('click', '.remove-user-icon', function () {
|
||||||
@@ -66,12 +66,12 @@ define('admin/manage/admins-mods', [
|
|||||||
bootbox.confirm('[[admin/manage/users:alerts.confirm-remove-global-mod]]', function (confirm) {
|
bootbox.confirm('[[admin/manage/users:alerts.confirm-remove-global-mod]]', function (confirm) {
|
||||||
if (confirm) {
|
if (confirm) {
|
||||||
api.del('/groups/global-moderators/membership/' + uid).then(() => {
|
api.del('/groups/global-moderators/membership/' + uid).then(() => {
|
||||||
app.alertSuccess('[[admin/manage/users:alerts.remove-global-mod-success]]');
|
alerts.success('[[admin/manage/users:alerts.remove-global-mod-success]]');
|
||||||
userCard.remove();
|
userCard.remove();
|
||||||
if (!$('.global-moderator-area').children().length) {
|
if (!$('.global-moderator-area').children().length) {
|
||||||
$('#no-global-mods-warning').removeClass('hidden');
|
$('#no-global-mods-warning').removeClass('hidden');
|
||||||
}
|
}
|
||||||
}).catch(app.alertError);
|
}).catch(alerts.error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -94,9 +94,9 @@ define('admin/manage/admins-mods', [
|
|||||||
member: ui.item.user.uid,
|
member: ui.item.user.uid,
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
app.alertSuccess('[[admin/manage/users:alerts.make-moderator-success]]');
|
alerts.success('[[admin/manage/users:alerts.make-moderator-success]]');
|
||||||
input.val('');
|
input.val('');
|
||||||
|
|
||||||
if ($('.moderator-area[data-cid="' + cid + '"] [data-uid="' + ui.item.user.uid + '"]').length) {
|
if ($('.moderator-area[data-cid="' + cid + '"] [data-uid="' + ui.item.user.uid + '"]').length) {
|
||||||
@@ -125,9 +125,9 @@ define('admin/manage/admins-mods', [
|
|||||||
member: uid,
|
member: uid,
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
app.alertSuccess('[[admin/manage/users:alerts.remove-moderator-success]]');
|
alerts.success('[[admin/manage/users:alerts.remove-moderator-success]]');
|
||||||
userCard.remove();
|
userCard.remove();
|
||||||
if (!moderatorArea.children().length) {
|
if (!moderatorArea.children().length) {
|
||||||
$('.no-moderator-warning[data-cid="' + cid + '"]').removeClass('hidden');
|
$('.no-moderator-warning[data-cid="' + cid + '"]').removeClass('hidden');
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ define('admin/manage/categories', [
|
|||||||
modified[cid] = { order: Math.max(1, parseInt(val, 10)) };
|
modified[cid] = { order: Math.max(1, parseInt(val, 10)) };
|
||||||
api.put('/categories/' + cid, modified[cid]).then(function () {
|
api.put('/categories/' + cid, modified[cid]).then(function () {
|
||||||
ajaxify.refresh();
|
ajaxify.refresh();
|
||||||
}).catch(err => app.alertError(err));
|
}).catch(alerts.error);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -183,7 +183,7 @@ define('admin/manage/categories', [
|
|||||||
const categoryEl = listEl.querySelector(`li[data-cid="${cid}"]`);
|
const categoryEl = listEl.querySelector(`li[data-cid="${cid}"]`);
|
||||||
categoryEl.classList[disabled ? 'add' : 'remove']('disabled');
|
categoryEl.classList[disabled ? 'add' : 'remove']('disabled');
|
||||||
$(categoryEl).find('li a[data-action="toggle"]').first().translateText(disabled ? '[[admin/manage/categories:enable]]' : '[[admin/manage/categories:disable]]');
|
$(categoryEl).find('li a[data-action="toggle"]').first().translateText(disabled ? '[[admin/manage/categories:enable]]' : '[[admin/manage/categories:disable]]');
|
||||||
}).catch(app.alertError)));
|
}).catch(alerts.error)));
|
||||||
};
|
};
|
||||||
|
|
||||||
function itemDidAdd(e) {
|
function itemDidAdd(e) {
|
||||||
@@ -209,7 +209,7 @@ define('admin/manage/categories', [
|
|||||||
}
|
}
|
||||||
|
|
||||||
newCategoryId = -1;
|
newCategoryId = -1;
|
||||||
api.put('/categories/' + cid, modified[cid]).catch(app.alertError);
|
api.put('/categories/' + cid, modified[cid]).catch(alerts.error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ define('admin/manage/category', [
|
|||||||
$('#save').on('click', function () {
|
$('#save').on('click', function () {
|
||||||
const tags = $('#tag-whitelist').val() ? $('#tag-whitelist').val().split(',') : [];
|
const tags = $('#tag-whitelist').val() ? $('#tag-whitelist').val().split(',') : [];
|
||||||
if (tags.length && tags.length < parseInt($('#cid-min-tags').val(), 10)) {
|
if (tags.length && tags.length < parseInt($('#cid-min-tags').val(), 10)) {
|
||||||
return app.alertError('[[admin/manage/categories:alert.not-enough-whitelisted-tags]]');
|
return alerts.error('[[admin/manage/categories:alert.not-enough-whitelisted-tags]]');
|
||||||
}
|
}
|
||||||
|
|
||||||
const cid = ajaxify.data.category.cid;
|
const cid = ajaxify.data.category.cid;
|
||||||
@@ -89,7 +89,7 @@ define('admin/manage/category', [
|
|||||||
const intervalId = setInterval(function () {
|
const intervalId = setInterval(function () {
|
||||||
socket.emit('categories.getTopicCount', ajaxify.data.category.cid, function (err, count) {
|
socket.emit('categories.getTopicCount', ajaxify.data.category.cid, function (err, count) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
let percent = 0;
|
let percent = 0;
|
||||||
@@ -106,9 +106,9 @@ define('admin/manage/category', [
|
|||||||
clearInterval(intervalId);
|
clearInterval(intervalId);
|
||||||
}
|
}
|
||||||
modal.modal('hide');
|
modal.modal('hide');
|
||||||
app.alertSuccess('[[admin/manage/categories:alert.purge-success]]');
|
alerts.success('[[admin/manage/categories:alert.purge-success]]');
|
||||||
ajaxify.go('admin/manage/categories');
|
ajaxify.go('admin/manage/categories');
|
||||||
}).catch(app.alertError);
|
}).catch(alerts.error);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
@@ -139,11 +139,11 @@ define('admin/manage/category', [
|
|||||||
copyParent: modal.find('#copyParent').prop('checked'),
|
copyParent: modal.find('#copyParent').prop('checked'),
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
modal.modal('hide');
|
modal.modal('hide');
|
||||||
app.alertSuccess('[[admin/manage/categories:alert.copy-success]]');
|
alert.success('[[admin/manage/categories:alert.copy-success]]');
|
||||||
ajaxify.refresh();
|
ajaxify.refresh();
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
@@ -215,7 +215,7 @@ define('admin/manage/category', [
|
|||||||
$('button[data-action="removeParent"]').parent().addClass('hide');
|
$('button[data-action="removeParent"]').parent().addClass('hide');
|
||||||
$('button[data-action="changeParent"]').parent().addClass('hide');
|
$('button[data-action="changeParent"]').parent().addClass('hide');
|
||||||
$('button[data-action="setParent"]').removeClass('hide');
|
$('button[data-action="setParent"]').removeClass('hide');
|
||||||
}).catch(app.alertError);
|
}).catch(alerts.error);
|
||||||
});
|
});
|
||||||
$('button[data-action="toggle"]').on('click', function () {
|
$('button[data-action="toggle"]').on('click', function () {
|
||||||
const $this = $(this);
|
const $this = $(this);
|
||||||
@@ -226,7 +226,7 @@ define('admin/manage/category', [
|
|||||||
$this.translateText(!disabled ? '[[admin/manage/categories:enable]]' : '[[admin/manage/categories:disable]]');
|
$this.translateText(!disabled ? '[[admin/manage/categories:enable]]' : '[[admin/manage/categories:disable]]');
|
||||||
$this.toggleClass('btn-primary', !disabled).toggleClass('btn-danger', disabled);
|
$this.toggleClass('btn-primary', !disabled).toggleClass('btn-danger', disabled);
|
||||||
$this.attr('data-disabled', disabled ? 0 : 1);
|
$this.attr('data-disabled', disabled ? 0 : 1);
|
||||||
}).catch(app.alertError);
|
}).catch(alerts.error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -298,7 +298,7 @@ define('admin/manage/category', [
|
|||||||
|
|
||||||
$('button[data-action="removeParent"]').parent().removeClass('hide');
|
$('button[data-action="removeParent"]').parent().removeClass('hide');
|
||||||
$('button[data-action="setParent"]').addClass('hide');
|
$('button[data-action="setParent"]').addClass('hide');
|
||||||
}).catch(app.alertError);
|
}).catch(alerts.error);
|
||||||
},
|
},
|
||||||
showLinks: true,
|
showLinks: true,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('admin/manage/digest', ['bootbox'], function (bootbox) {
|
define('admin/manage/digest', ['bootbox', 'alerts'], function (bootbox, alerts) {
|
||||||
const Digest = {};
|
const Digest = {};
|
||||||
|
|
||||||
Digest.init = function () {
|
Digest.init = function () {
|
||||||
@@ -15,20 +15,20 @@ define('admin/manage/digest', ['bootbox'], function (bootbox) {
|
|||||||
if (ok) {
|
if (ok) {
|
||||||
Digest.send(action, undefined, function (err) {
|
Digest.send(action, undefined, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.alertSuccess('[[admin/manage/digest:resent-' + interval + ']]');
|
alerts.success('[[admin/manage/digest:resent-' + interval + ']]');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
Digest.send(action, uid, function (err) {
|
Digest.send(action, uid, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.alertSuccess('[[admin/manage/digest:resent-single]]');
|
alerts.success('[[admin/manage/digest:resent-single]]');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ define('admin/manage/group', [
|
|||||||
'slugify',
|
'slugify',
|
||||||
'api',
|
'api',
|
||||||
'bootbox',
|
'bootbox',
|
||||||
], function (memberList, iconSelect, translator, categorySelector, groupSearch, slugify, api, bootbox) {
|
'alerts',
|
||||||
|
], function (memberList, iconSelect, translator, categorySelector, groupSearch, slugify, api, bootbox, alerts) {
|
||||||
const Groups = {};
|
const Groups = {};
|
||||||
|
|
||||||
Groups.init = function () {
|
Groups.init = function () {
|
||||||
@@ -104,8 +105,8 @@ define('admin/manage/group', [
|
|||||||
ajaxify.go('admin/manage/groups/' + encodeURIComponent(newName), undefined, true);
|
ajaxify.go('admin/manage/groups/' + encodeURIComponent(newName), undefined, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.alertSuccess('[[admin/manage/groups:edit.save-success]]');
|
alerts.success('[[admin/manage/groups:edit.save-success]]');
|
||||||
}).catch(app.alertError);
|
}).catch(alerts.error);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -123,7 +124,7 @@ define('admin/manage/group', [
|
|||||||
case 'toggleOwnership':
|
case 'toggleOwnership':
|
||||||
api[isOwner ? 'del' : 'put'](`/groups/${ajaxify.data.group.slug}/ownership/${uid}`, {}).then(() => {
|
api[isOwner ? 'del' : 'put'](`/groups/${ajaxify.data.group.slug}/ownership/${uid}`, {}).then(() => {
|
||||||
ownerFlagEl.toggleClass('invisible');
|
ownerFlagEl.toggleClass('invisible');
|
||||||
}).catch(app.alertError);
|
}).catch(alerts.error);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'kick':
|
case 'kick':
|
||||||
@@ -133,7 +134,7 @@ define('admin/manage/group', [
|
|||||||
}
|
}
|
||||||
api.del('/groups/' + ajaxify.data.group.slug + '/membership/' + uid).then(() => {
|
api.del('/groups/' + ajaxify.data.group.slug + '/membership/' + uid).then(() => {
|
||||||
userRow.slideUp().remove();
|
userRow.slideUp().remove();
|
||||||
}).catch(app.alertError);
|
}).catch(alerts.error);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ define('admin/manage/groups', [
|
|||||||
'slugify',
|
'slugify',
|
||||||
'api',
|
'api',
|
||||||
'bootbox',
|
'bootbox',
|
||||||
], function (categorySelector, slugify, api, bootbox) {
|
'alerts',
|
||||||
|
], function (categorySelector, slugify, api, bootbox, alerts) {
|
||||||
const Groups = {};
|
const Groups = {};
|
||||||
|
|
||||||
Groups.init = function () {
|
Groups.init = function () {
|
||||||
@@ -61,7 +62,7 @@ define('admin/manage/groups', [
|
|||||||
case 'delete':
|
case 'delete':
|
||||||
bootbox.confirm('[[admin/manage/groups:alerts.confirm-delete]]', function (confirm) {
|
bootbox.confirm('[[admin/manage/groups:alerts.confirm-delete]]', function (confirm) {
|
||||||
if (confirm) {
|
if (confirm) {
|
||||||
api.del(`/groups/${slugify(groupName)}`, {}).then(ajaxify.refresh).catch(app.alertError);
|
api.del(`/groups/${slugify(groupName)}`, {}).then(ajaxify.refresh).catch(alerts.error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
@@ -99,7 +100,7 @@ define('admin/manage/groups', [
|
|||||||
},
|
},
|
||||||
}, function (err, groups) {
|
}, function (err, groups) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.parseAndTranslate('admin/manage/groups', 'groups', {
|
app.parseAndTranslate('admin/manage/groups', 'groups', {
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ define('admin/manage/privileges', [
|
|||||||
}
|
}
|
||||||
checkboxRowSelector.updateState($checkboxEl);
|
checkboxRowSelector.updateState($checkboxEl);
|
||||||
} else {
|
} else {
|
||||||
app.alertError('[[error:invalid-data]]');
|
alerts.error('[[error:invalid-data]]');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -167,17 +167,17 @@ define('admin/manage/privileges', [
|
|||||||
const rejects = results.filter(r => r.status === 'rejected');
|
const rejects = results.filter(r => r.status === 'rejected');
|
||||||
if (rejects.length) {
|
if (rejects.length) {
|
||||||
rejects.forEach((result) => {
|
rejects.forEach((result) => {
|
||||||
app.alertError(result.reason);
|
alerts.error(result.reason);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
app.alertSuccess('[[admin/manage/privileges:alert.saved]]');
|
alerts.success('[[admin/manage/privileges:alert.saved]]');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Privileges.discard = function () {
|
Privileges.discard = function () {
|
||||||
Privileges.refreshPrivilegeTable();
|
Privileges.refreshPrivilegeTable();
|
||||||
app.alertSuccess('[[admin/manage/privileges:alert.discarded]]');
|
alerts.success('[[admin/manage/privileges:alert.discarded]]');
|
||||||
};
|
};
|
||||||
|
|
||||||
Privileges.refreshPrivilegeTable = function (groupToHighlight) {
|
Privileges.refreshPrivilegeTable = function (groupToHighlight) {
|
||||||
@@ -199,7 +199,7 @@ define('admin/manage/privileges', [
|
|||||||
|
|
||||||
hightlightRowByDataAttr('data-group-name', groupToHighlight);
|
hightlightRowByDataAttr('data-group-name', groupToHighlight);
|
||||||
});
|
});
|
||||||
}).catch(app.alertError);
|
}).catch(alert.error);
|
||||||
};
|
};
|
||||||
|
|
||||||
Privileges.exposeAssumedPrivileges = function () {
|
Privileges.exposeAssumedPrivileges = function () {
|
||||||
@@ -284,9 +284,9 @@ define('admin/manage/privileges', [
|
|||||||
const filter = getPrivilegeFilter();
|
const filter = getPrivilegeFilter();
|
||||||
socket.emit('admin.categories.copyPrivilegesToChildren', { cid, group, filter }, function (err) {
|
socket.emit('admin.categories.copyPrivilegesToChildren', { cid, group, filter }, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err.message);
|
||||||
}
|
}
|
||||||
app.alertSuccess('[[admin/manage/categories:privileges.copy-success]]');
|
alerts.success('[[admin/manage/categories:privileges.copy-success]]');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -309,7 +309,7 @@ define('admin/manage/privileges', [
|
|||||||
group: group,
|
group: group,
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
ajaxify.refresh();
|
ajaxify.refresh();
|
||||||
});
|
});
|
||||||
@@ -321,9 +321,9 @@ define('admin/manage/privileges', [
|
|||||||
const filter = getPrivilegeFilter();
|
const filter = getPrivilegeFilter();
|
||||||
socket.emit('admin.categories.copyPrivilegesToAllCategories', { cid, group, filter }, function (err) {
|
socket.emit('admin.categories.copyPrivilegesToAllCategories', { cid, group, filter }, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
app.alertSuccess('[[admin/manage/categories:privileges.copy-success]]');
|
alerts.success('[[admin/manage/categories:privileges.copy-success]]');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('admin/manage/registration', ['bootbox'], function (bootbox) {
|
define('admin/manage/registration', ['bootbox', 'alerts'], function (bootbox, alerts) {
|
||||||
const Registration = {};
|
const Registration = {};
|
||||||
|
|
||||||
Registration.init = function () {
|
Registration.init = function () {
|
||||||
@@ -13,7 +13,7 @@ define('admin/manage/registration', ['bootbox'], function (bootbox) {
|
|||||||
|
|
||||||
socket.emit(method, { username: username }, function (err) {
|
socket.emit(method, { username: username }, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
parent.remove();
|
parent.remove();
|
||||||
});
|
});
|
||||||
@@ -41,7 +41,7 @@ define('admin/manage/registration', ['bootbox'], function (bootbox) {
|
|||||||
if (confirm) {
|
if (confirm) {
|
||||||
socket.emit(method, { email: email, invitedBy: invitedBy }, function (err) {
|
socket.emit(method, { email: email, invitedBy: invitedBy }, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
removeRow();
|
removeRow();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
define('admin/manage/tags', [
|
define('admin/manage/tags', [
|
||||||
'bootbox',
|
'bootbox',
|
||||||
'forum/infinitescroll',
|
'alerts',
|
||||||
'admin/modules/selectable',
|
'admin/modules/selectable',
|
||||||
], function (bootbox, infinitescroll, selectable) {
|
], function (bootbox, alerts, selectable) {
|
||||||
const Tags = {};
|
const Tags = {};
|
||||||
|
|
||||||
Tags.init = function () {
|
Tags.init = function () {
|
||||||
@@ -40,7 +40,7 @@ define('admin/manage/tags', [
|
|||||||
tag: createTagName.val(),
|
tag: createTagName.val(),
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
createTagName.val('');
|
createTagName.val('');
|
||||||
@@ -58,7 +58,7 @@ define('admin/manage/tags', [
|
|||||||
query: $('#tag-search').val(),
|
query: $('#tag-search').val(),
|
||||||
}, function (err, result) {
|
}, function (err, result) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.parseAndTranslate('admin/manage/tags', 'tags', {
|
app.parseAndTranslate('admin/manage/tags', 'tags', {
|
||||||
@@ -98,9 +98,9 @@ define('admin/manage/tags', [
|
|||||||
|
|
||||||
socket.emit('admin.tags.rename', data, function (err) {
|
socket.emit('admin.tags.rename', data, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
app.alertSuccess('[[admin/manage/tags:alerts.update-success]]');
|
alerts.success('[[admin/manage/tags:alerts.update-success]]');
|
||||||
ajaxify.refresh();
|
ajaxify.refresh();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -129,7 +129,7 @@ define('admin/manage/tags', [
|
|||||||
tags: tags,
|
tags: tags,
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
tagsToDelete.remove();
|
tagsToDelete.remove();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('admin/manage/uploads', ['api', 'bootbox', 'uploader'], function (api, bootbox, uploader) {
|
define('admin/manage/uploads', ['api', 'bootbox', 'alerts', 'uploader'], function (api, bootbox, alerts, uploader) {
|
||||||
const Uploads = {};
|
const Uploads = {};
|
||||||
|
|
||||||
Uploads.init = function () {
|
Uploads.init = function () {
|
||||||
@@ -25,7 +25,7 @@ define('admin/manage/uploads', ['api', 'bootbox', 'uploader'], function (api, bo
|
|||||||
path: file.attr('data-path'),
|
path: file.attr('data-path'),
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
file.remove();
|
file.remove();
|
||||||
}).catch(app.alertError);
|
}).catch(alerts.error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ define('admin/manage/uploads', ['api', 'bootbox', 'uploader'], function (api, bo
|
|||||||
folderName: newFolderName,
|
folderName: newFolderName,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
ajaxify.refresh();
|
ajaxify.refresh();
|
||||||
}).catch(app.alertError);
|
}).catch(alerts.error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -76,9 +76,9 @@ define('admin/manage/users', [
|
|||||||
function done(successMessage, className, flag) {
|
function done(successMessage, className, flag) {
|
||||||
return function (err) {
|
return function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
app.alertSuccess(successMessage);
|
alerts.success(successMessage);
|
||||||
if (className) {
|
if (className) {
|
||||||
update(className, flag);
|
update(className, flag);
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,7 @@ define('admin/manage/users', [
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onSuccess(successMessage, className, flag) {
|
function onSuccess(successMessage, className, flag) {
|
||||||
app.alertSuccess(successMessage);
|
alerts.success(successMessage);
|
||||||
if (className) {
|
if (className) {
|
||||||
update(className, flag);
|
update(className, flag);
|
||||||
}
|
}
|
||||||
@@ -101,12 +101,12 @@ define('admin/manage/users', [
|
|||||||
$('.manage-groups').on('click', function () {
|
$('.manage-groups').on('click', function () {
|
||||||
const uids = getSelectedUids();
|
const uids = getSelectedUids();
|
||||||
if (!uids.length) {
|
if (!uids.length) {
|
||||||
app.alertError('[[error:no-users-selected]]');
|
alerts.error('[[error:no-users-selected]]');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
socket.emit('admin.user.loadGroups', uids, function (err, data) {
|
socket.emit('admin.user.loadGroups', uids, function (err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
Benchpress.render('admin/partials/manage_user_groups', data).then(function (html) {
|
Benchpress.render('admin/partials/manage_user_groups', data).then(function (html) {
|
||||||
const modal = bootbox.dialog({
|
const modal = bootbox.dialog({
|
||||||
@@ -122,7 +122,7 @@ define('admin/manage/users', [
|
|||||||
app.parseAndTranslate('admin/partials/manage_user_groups', { users: [{ groups: [ui.item.group] }] }, function (html) {
|
app.parseAndTranslate('admin/partials/manage_user_groups', { users: [{ groups: [ui.item.group] }] }, function (html) {
|
||||||
$('[data-uid=' + uid + '] .group-area').append(html.find('.group-area').html());
|
$('[data-uid=' + uid + '] .group-area').append(html.find('.group-area').html());
|
||||||
});
|
});
|
||||||
}).catch(app.alertError);
|
}).catch(alerts.error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
modal.on('click', '.group-area a', function () {
|
modal.on('click', '.group-area a', function () {
|
||||||
@@ -134,7 +134,7 @@ define('admin/manage/users', [
|
|||||||
const uid = $(this).parents('[data-uid]').attr('data-uid');
|
const uid = $(this).parents('[data-uid]').attr('data-uid');
|
||||||
api.del('/groups/' + slugify(groupName) + '/membership/' + uid).then(() => {
|
api.del('/groups/' + slugify(groupName) + '/membership/' + uid).then(() => {
|
||||||
groupCard.remove();
|
groupCard.remove();
|
||||||
}).catch(app.alertError);
|
}).catch(alerts.error);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -144,7 +144,7 @@ define('admin/manage/users', [
|
|||||||
$('.ban-user').on('click', function () {
|
$('.ban-user').on('click', function () {
|
||||||
const uids = getSelectedUids();
|
const uids = getSelectedUids();
|
||||||
if (!uids.length) {
|
if (!uids.length) {
|
||||||
app.alertError('[[error:no-users-selected]]');
|
alerts.error('[[error:no-users-selected]]');
|
||||||
return false; // specifically to keep the menu open
|
return false; // specifically to keep the menu open
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,7 +154,7 @@ define('admin/manage/users', [
|
|||||||
return api.put('/users/' + uid + '/ban');
|
return api.put('/users/' + uid + '/ban');
|
||||||
})).then(() => {
|
})).then(() => {
|
||||||
onSuccess('[[admin/manage/users:alerts.ban-success]]', '.ban', true);
|
onSuccess('[[admin/manage/users:alerts.ban-success]]', '.ban', true);
|
||||||
}).catch(app.alertError);
|
}).catch(alerts.error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -162,7 +162,7 @@ define('admin/manage/users', [
|
|||||||
$('.ban-user-temporary').on('click', function () {
|
$('.ban-user-temporary').on('click', function () {
|
||||||
const uids = getSelectedUids();
|
const uids = getSelectedUids();
|
||||||
if (!uids.length) {
|
if (!uids.length) {
|
||||||
app.alertError('[[error:no-users-selected]]');
|
alerts.error('[[error:no-users-selected]]');
|
||||||
return false; // specifically to keep the menu open
|
return false; // specifically to keep the menu open
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,7 +195,7 @@ define('admin/manage/users', [
|
|||||||
});
|
});
|
||||||
})).then(() => {
|
})).then(() => {
|
||||||
onSuccess('[[admin/manage/users:alerts.ban-success]]', '.ban', true);
|
onSuccess('[[admin/manage/users:alerts.ban-success]]', '.ban', true);
|
||||||
}).catch(app.alertError);
|
}).catch(alerts.error);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -206,7 +206,7 @@ define('admin/manage/users', [
|
|||||||
$('.unban-user').on('click', function () {
|
$('.unban-user').on('click', function () {
|
||||||
const uids = getSelectedUids();
|
const uids = getSelectedUids();
|
||||||
if (!uids.length) {
|
if (!uids.length) {
|
||||||
app.alertError('[[error:no-users-selected]]');
|
alerts.error('[[error:no-users-selected]]');
|
||||||
return false; // specifically to keep the menu open
|
return false; // specifically to keep the menu open
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,9 +238,9 @@ define('admin/manage/users', [
|
|||||||
}
|
}
|
||||||
socket.emit('admin.user.validateEmail', uids, function (err) {
|
socket.emit('admin.user.validateEmail', uids, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
app.alertSuccess('[[admin/manage/users:alerts.validate-email-success]]');
|
alerts.success('[[admin/manage/users:alerts.validate-email-success]]');
|
||||||
update('.notvalidated', false);
|
update('.notvalidated', false);
|
||||||
update('.validated', true);
|
update('.validated', true);
|
||||||
unselectAll();
|
unselectAll();
|
||||||
@@ -255,9 +255,9 @@ define('admin/manage/users', [
|
|||||||
}
|
}
|
||||||
socket.emit('admin.user.sendValidationEmail', uids, function (err) {
|
socket.emit('admin.user.sendValidationEmail', uids, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
app.alertSuccess('[[notifications:email-confirm-sent]]');
|
alerts.success('[[notifications:email-confirm-sent]]');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -331,15 +331,15 @@ define('admin/manage/users', [
|
|||||||
)
|
)
|
||||||
).then(() => {
|
).then(() => {
|
||||||
if (path !== '/content') {
|
if (path !== '/content') {
|
||||||
app.alertSuccess('[[admin/manage/users:alerts.delete-success]]');
|
alerts.success('[[admin/manage/users:alerts.delete-success]]');
|
||||||
} else {
|
} else {
|
||||||
app.alertSuccess('[[admin/manage/users:alerts.delete-content-success]]');
|
alerts.success('[[admin/manage/users:alerts.delete-content-success]]');
|
||||||
}
|
}
|
||||||
unselectAll();
|
unselectAll();
|
||||||
if (!$('.users-table [component="user/select/single"]').length) {
|
if (!$('.users-table [component="user/select/single"]').length) {
|
||||||
ajaxify.refresh();
|
ajaxify.refresh();
|
||||||
}
|
}
|
||||||
}).catch(app.alertError);
|
}).catch(alerts.error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -399,7 +399,7 @@ define('admin/manage/users', [
|
|||||||
modal.on('hidden.bs.modal', function () {
|
modal.on('hidden.bs.modal', function () {
|
||||||
ajaxify.refresh();
|
ajaxify.refresh();
|
||||||
});
|
});
|
||||||
app.alertSuccess('[[admin/manage/users:alerts.create-success]]');
|
alerts.success('[[admin/manage/users:alerts.create-success]]');
|
||||||
})
|
})
|
||||||
.catch(err => errorEl.translateHtml('[[admin/manage/users:alerts.error-x, ' + err.status.message + ']]').removeClass('hidden'));
|
.catch(err => errorEl.translateHtml('[[admin/manage/users:alerts.error-x, ' + err.status.message + ']]').removeClass('hidden'));
|
||||||
}
|
}
|
||||||
@@ -441,7 +441,7 @@ define('admin/manage/users', [
|
|||||||
}
|
}
|
||||||
}).fail(function (xhrErr) {
|
}).fail(function (xhrErr) {
|
||||||
if (xhrErr && xhrErr.responseJSON && xhrErr.responseJSON.error) {
|
if (xhrErr && xhrErr.responseJSON && xhrErr.responseJSON.error) {
|
||||||
app.alertError(xhrErr.responseJSON.error);
|
alerts.error(xhrErr.responseJSON.error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('admin/modules/search', ['mousetrap'], function (mousetrap) {
|
define('admin/modules/search', ['mousetrap', 'alerts'], function (mousetrap, alerts) {
|
||||||
const search = {};
|
const search = {};
|
||||||
|
|
||||||
function find(dict, term) {
|
function find(dict, term) {
|
||||||
@@ -52,7 +52,7 @@ define('admin/modules/search', ['mousetrap'], function (mousetrap) {
|
|||||||
|
|
||||||
socket.emit('admin.getSearchDict', {}, function (err, dict) {
|
socket.emit('admin.getSearchDict', {}, function (err, dict) {
|
||||||
if (err) {
|
if (err) {
|
||||||
app.alertError(err);
|
alerts.error(err);
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
setupACPSearch(dict);
|
setupACPSearch(dict);
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ define('admin/settings', ['uploader', 'mousetrap', 'hooks', 'alerts'], function
|
|||||||
|
|
||||||
$('#clear-sitemap-cache').off('click').on('click', function () {
|
$('#clear-sitemap-cache').off('click').on('click', function () {
|
||||||
socket.emit('admin.settings.clearSitemapCache', function () {
|
socket.emit('admin.settings.clearSitemapCache', function () {
|
||||||
app.alertSuccess('Sitemap Cache Cleared!');
|
alerts.success('Sitemap Cache Cleared!');
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('admin/settings/cookies', function () {
|
define('admin/settings/cookies', ['alerts'], function (alerts) {
|
||||||
const Module = {};
|
const Module = {};
|
||||||
|
|
||||||
Module.init = function () {
|
Module.init = function () {
|
||||||
$('#delete-all-sessions').on('click', function () {
|
$('#delete-all-sessions').on('click', function () {
|
||||||
socket.emit('admin.deleteAllSessions', function (err) {
|
socket.emit('admin.deleteAllSessions', function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
window.location.href = config.relative_path + '/login';
|
window.location.href = config.relative_path + '/login';
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('admin/settings/email', ['ace/ace', 'admin/settings'], function (ace) {
|
define('admin/settings/email', ['ace/ace', 'alerts', 'admin/settings'], function (ace, alerts) {
|
||||||
const module = {};
|
const module = {};
|
||||||
let emailEditor;
|
let emailEditor;
|
||||||
|
|
||||||
@@ -23,9 +23,9 @@ define('admin/settings/email', ['ace/ace', 'admin/settings'], function (ace) {
|
|||||||
socket.emit('admin.email.test', { template: $('#test-email').val() }, function (err) {
|
socket.emit('admin.email.test', { template: $('#test-email').val() }, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err.message);
|
console.error(err.message);
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
app.alertSuccess('Test Email Sent');
|
alerts.success('Test Email Sent');
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
@@ -85,7 +85,7 @@ define('admin/settings/email', ['ace/ace', 'admin/settings'], function (ace) {
|
|||||||
|
|
||||||
socket.emit('admin.getServerTime', {}, function (err, now) {
|
socket.emit('admin.getServerTime', {}, function (err, now) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
const date = new Date(now.timestamp);
|
const date = new Date(now.timestamp);
|
||||||
|
|||||||
@@ -5,10 +5,11 @@ define('admin/settings/navigation', [
|
|||||||
'translator',
|
'translator',
|
||||||
'iconSelect',
|
'iconSelect',
|
||||||
'benchpress',
|
'benchpress',
|
||||||
|
'alerts',
|
||||||
'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, Benchpress, alerts) {
|
||||||
const navigation = {};
|
const navigation = {};
|
||||||
let available;
|
let available;
|
||||||
|
|
||||||
@@ -128,9 +129,9 @@ define('admin/settings/navigation', [
|
|||||||
|
|
||||||
socket.emit('admin.navigation.save', nav, function (err) {
|
socket.emit('admin.navigation.save', nav, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
app.alertError(err.message);
|
alerts.error(err);
|
||||||
} else {
|
} else {
|
||||||
app.alertSuccess('Successfully saved navigation');
|
alerts.success('Successfully saved navigation');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('admin/settings/social', [], function () {
|
define('admin/settings/social', ['alerts'], function (alerts) {
|
||||||
const social = {};
|
const social = {};
|
||||||
|
|
||||||
social.init = function () {
|
social.init = function () {
|
||||||
@@ -15,10 +15,10 @@ define('admin/settings/social', [], function () {
|
|||||||
|
|
||||||
socket.emit('admin.social.savePostSharingNetworks', networks, function (err) {
|
socket.emit('admin.social.savePostSharingNetworks', networks, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.alertSuccess('[[admin/settings/social:save-success]]');
|
alerts.success('[[admin/settings/social:save-success]]');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -156,7 +156,9 @@ ajaxify = window.ajaxify || {};
|
|||||||
$('#footer, #content').removeClass('hide').addClass('ajaxifying');
|
$('#footer, #content').removeClass('hide').addClass('ajaxifying');
|
||||||
return renderTemplate(url, status.toString(), data.responseJSON || {}, callback);
|
return renderTemplate(url, status.toString(), data.responseJSON || {}, callback);
|
||||||
} else if (status === 401) {
|
} else if (status === 401) {
|
||||||
app.alertError('[[global:please_log_in]]');
|
require(['alerts'], function (alerts) {
|
||||||
|
alerts.error('[[global:please_log_in]]');
|
||||||
|
});
|
||||||
app.previousUrl = url;
|
app.previousUrl = url;
|
||||||
window.location.href = config.relative_path + '/login';
|
window.location.href = config.relative_path + '/login';
|
||||||
} else if (status === 302 || status === 308) {
|
} else if (status === 302 || status === 308) {
|
||||||
@@ -174,7 +176,9 @@ ajaxify = window.ajaxify || {};
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (textStatus !== 'abort') {
|
} else if (textStatus !== 'abort') {
|
||||||
app.alertError(data.responseJSON.error);
|
require(['alerts'], function (alerts) {
|
||||||
|
alerts.error(data.responseJSON.error);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -172,7 +172,10 @@ app.flags = {};
|
|||||||
}, function (err) {
|
}, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
app.currentRoom = previousRoom;
|
app.currentRoom = previousRoom;
|
||||||
return app.alertError(err.message);
|
require(['alerts'], function (alerts) {
|
||||||
|
alerts.error(err);
|
||||||
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
callback();
|
callback();
|
||||||
@@ -189,7 +192,9 @@ app.flags = {};
|
|||||||
socket.emit('meta.rooms.leaveCurrent', function (err) {
|
socket.emit('meta.rooms.leaveCurrent', function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
app.currentRoom = previousRoom;
|
app.currentRoom = previousRoom;
|
||||||
return app.alertError(err.message);
|
require(['alerts'], function (alerts) {
|
||||||
|
alerts.error(err);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ define('forum/account/blocks', [
|
|||||||
'forum/account/header',
|
'forum/account/header',
|
||||||
'api',
|
'api',
|
||||||
'hooks',
|
'hooks',
|
||||||
], function (header, api, hooks) {
|
'alerts',
|
||||||
|
], function (header, api, hooks, alerts) {
|
||||||
const Blocks = {};
|
const Blocks = {};
|
||||||
|
|
||||||
Blocks.init = function () {
|
Blocks.init = function () {
|
||||||
@@ -19,7 +20,7 @@ define('forum/account/blocks', [
|
|||||||
paginate: false,
|
paginate: false,
|
||||||
}, function (err, data) {
|
}, function (err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only show first 10 matches
|
// Only show first 10 matches
|
||||||
@@ -46,7 +47,7 @@ define('forum/account/blocks', [
|
|||||||
|
|
||||||
Blocks.refreshList = function (err) {
|
Blocks.refreshList = function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
$.get(config.relative_path + '/api/' + ajaxify.currentPage)
|
$.get(config.relative_path + '/api/' + ajaxify.currentPage)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('forum/account/categories', ['forum/account/header'], function (header) {
|
define('forum/account/categories', ['forum/account/header', 'alerts'], function (header, alerts) {
|
||||||
const Categories = {};
|
const Categories = {};
|
||||||
|
|
||||||
Categories.init = function () {
|
Categories.init = function () {
|
||||||
@@ -20,7 +20,7 @@ define('forum/account/categories', ['forum/account/header'], function (header) {
|
|||||||
|
|
||||||
socket.emit('categories.setWatchState', { cid: cids, state: state, uid: ajaxify.data.uid }, function (err, modified_cids) {
|
socket.emit('categories.setWatchState', { cid: cids, state: state, uid: ajaxify.data.uid }, function (err, modified_cids) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
updateDropdowns(modified_cids, state);
|
updateDropdowns(modified_cids, state);
|
||||||
});
|
});
|
||||||
@@ -35,11 +35,11 @@ define('forum/account/categories', ['forum/account/header'], function (header) {
|
|||||||
|
|
||||||
socket.emit('categories.setWatchState', { cid: cid, state: state, uid: ajaxify.data.uid }, function (err, modified_cids) {
|
socket.emit('categories.setWatchState', { cid: cid, state: state, uid: ajaxify.data.uid }, function (err, modified_cids) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
updateDropdowns(modified_cids, state);
|
updateDropdowns(modified_cids, state);
|
||||||
|
|
||||||
app.alertSuccess('[[category:' + state + '.message]]');
|
alerts.success('[[category:' + state + '.message]]');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('forum/account/consent', ['forum/account/header'], function (header) {
|
define('forum/account/consent', ['forum/account/header', 'alerts'], function (header, alerts) {
|
||||||
const Consent = {};
|
const Consent = {};
|
||||||
|
|
||||||
Consent.init = function () {
|
Consent.init = function () {
|
||||||
@@ -10,7 +10,7 @@ define('forum/account/consent', ['forum/account/header'], function (header) {
|
|||||||
$('[data-action="consent"]').on('click', function () {
|
$('[data-action="consent"]').on('click', function () {
|
||||||
socket.emit('user.gdpr.consent', {}, function (err) {
|
socket.emit('user.gdpr.consent', {}, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
ajaxify.refresh();
|
ajaxify.refresh();
|
||||||
@@ -25,9 +25,9 @@ define('forum/account/consent', ['forum/account/header'], function (header) {
|
|||||||
el.on('click', function () {
|
el.on('click', function () {
|
||||||
socket.emit(method, { uid: ajaxify.data.uid }, function (err) {
|
socket.emit(method, { uid: ajaxify.data.uid }, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
app.alertSuccess(success);
|
alerts.success(success);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ define('forum/account/edit', [
|
|||||||
'api',
|
'api',
|
||||||
'hooks',
|
'hooks',
|
||||||
'bootbox',
|
'bootbox',
|
||||||
], function (header, picture, translator, api, hooks, bootbox) {
|
'alerts',
|
||||||
|
], function (header, picture, translator, api, hooks, bootbox, alerts) {
|
||||||
const AccountEdit = {};
|
const AccountEdit = {};
|
||||||
|
|
||||||
AccountEdit.init = function () {
|
AccountEdit.init = function () {
|
||||||
@@ -42,14 +43,14 @@ define('forum/account/edit', [
|
|||||||
hooks.fire('action:profile.update', userData);
|
hooks.fire('action:profile.update', userData);
|
||||||
|
|
||||||
api.put('/users/' + userData.uid, userData).then((res) => {
|
api.put('/users/' + userData.uid, userData).then((res) => {
|
||||||
app.alertSuccess('[[user:profile_update_success]]');
|
alerts.success('[[user:profile_update_success]]');
|
||||||
|
|
||||||
if (res.picture) {
|
if (res.picture) {
|
||||||
$('#user-current-picture').attr('src', res.picture);
|
$('#user-current-picture').attr('src', res.picture);
|
||||||
}
|
}
|
||||||
|
|
||||||
picture.updateHeader(res.picture);
|
picture.updateHeader(res.picture);
|
||||||
}).catch(app.alertError);
|
}).catch(alerts.error);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -85,7 +86,7 @@ define('forum/account/edit', [
|
|||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
restoreButton();
|
restoreButton();
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
confirmBtn.html('<i class="fa fa-check"></i>');
|
confirmBtn.html('<i class="fa fa-check"></i>');
|
||||||
@@ -111,9 +112,9 @@ define('forum/account/edit', [
|
|||||||
socket.emit('user.emailConfirm', {}, function (err) {
|
socket.emit('user.emailConfirm', {}, function (err) {
|
||||||
btn.removeAttr('disabled');
|
btn.removeAttr('disabled');
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
app.alertSuccess('[[notifications:email-confirm-sent]]');
|
alerts.success('[[notifications:email-confirm-sent]]');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('forum/account/edit/email', ['forum/account/header', 'api'], function (header, api) {
|
define('forum/account/edit/email', ['forum/account/header', 'api', 'alerts'], function (header, api, alerts) {
|
||||||
const AccountEditEmail = {};
|
const AccountEditEmail = {};
|
||||||
|
|
||||||
AccountEditEmail.init = function () {
|
AccountEditEmail.init = function () {
|
||||||
@@ -20,7 +20,7 @@ define('forum/account/edit/email', ['forum/account/header', 'api'], function (he
|
|||||||
|
|
||||||
if (userData.email === userData.password) {
|
if (userData.email === userData.password) {
|
||||||
curPasswordEl.parents('.control-group').toggleClass('has-error', true);
|
curPasswordEl.parents('.control-group').toggleClass('has-error', true);
|
||||||
return app.alertError('[[user:email_same_as_password]]');
|
return alerts.error('[[user:email_same_as_password]]');
|
||||||
}
|
}
|
||||||
|
|
||||||
const btn = $(this);
|
const btn = $(this);
|
||||||
@@ -32,7 +32,7 @@ define('forum/account/edit/email', ['forum/account/header', 'api'], function (he
|
|||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
btn.removeClass('disabled').find('i').addClass('hide');
|
btn.removeClass('disabled').find('i').addClass('hide');
|
||||||
app.alertError(err);
|
alerts.error(err);
|
||||||
}, 300); // for UX: this call is too fast.
|
}, 300); // for UX: this call is too fast.
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('forum/account/edit/password', [
|
define('forum/account/edit/password', [
|
||||||
'forum/account/header', 'translator', 'zxcvbn', 'api',
|
'forum/account/header', 'translator', 'zxcvbn', 'api', 'alerts',
|
||||||
], function (header, translator, zxcvbn, api) {
|
], function (header, translator, zxcvbn, api, alerts) {
|
||||||
const AccountEditPassword = {};
|
const AccountEditPassword = {};
|
||||||
|
|
||||||
AccountEditPassword.init = function () {
|
AccountEditPassword.init = function () {
|
||||||
@@ -91,11 +91,11 @@ define('forum/account/edit/password', [
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (!passwordsmatch) {
|
if (!passwordsmatch) {
|
||||||
app.alertError('[[user:change_password_error_match]]');
|
alerts.error('[[user:change_password_error_match]]');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!passwordvalid) {
|
if (!passwordvalid) {
|
||||||
app.alertError('[[user:change_password_error]]');
|
alerts.error('[[user:change_password_error]]');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('forum/account/edit/username', [
|
define('forum/account/edit/username', [
|
||||||
'forum/account/header', 'api', 'slugify',
|
'forum/account/header', 'api', 'slugify', 'alerts',
|
||||||
], function (header, api, slugify) {
|
], function (header, api, slugify, alerts) {
|
||||||
const AccountEditUsername = {};
|
const AccountEditUsername = {};
|
||||||
|
|
||||||
AccountEditUsername.init = function () {
|
AccountEditUsername.init = function () {
|
||||||
@@ -20,7 +20,7 @@ define('forum/account/edit/username', [
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (userData.username === userData.password) {
|
if (userData.username === userData.password) {
|
||||||
return app.alertError('[[user:username_same_as_password]]');
|
return alerts.error('[[user:username_same_as_password]]');
|
||||||
}
|
}
|
||||||
|
|
||||||
const btn = $(this);
|
const btn = $(this);
|
||||||
@@ -38,7 +38,7 @@ define('forum/account/edit/username', [
|
|||||||
}
|
}
|
||||||
|
|
||||||
ajaxify.go('user/' + userslug + '/edit');
|
ajaxify.go('user/' + userslug + '/edit');
|
||||||
}).catch(app.alertError)
|
}).catch(alerts.error)
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
btn.removeClass('disabled').find('i').addClass('hide');
|
btn.removeClass('disabled').find('i').addClass('hide');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ define('forum/account/header', [
|
|||||||
'accounts/delete',
|
'accounts/delete',
|
||||||
'api',
|
'api',
|
||||||
'bootbox',
|
'bootbox',
|
||||||
], function (coverPhoto, pictureCropper, components, translator, Benchpress, AccountsDelete, api, bootbox) {
|
'alerts',
|
||||||
|
], function (coverPhoto, pictureCropper, components, translator, Benchpress, AccountsDelete, api, bootbox, alerts) {
|
||||||
const AccountHeader = {};
|
const AccountHeader = {};
|
||||||
let isAdminOrSelfOrGlobalMod;
|
let isAdminOrSelfOrGlobalMod;
|
||||||
|
|
||||||
@@ -117,11 +118,11 @@ define('forum/account/header', [
|
|||||||
function toggleFollow(type) {
|
function toggleFollow(type) {
|
||||||
api[type === 'follow' ? 'put' : 'del']('/users/' + ajaxify.data.uid + '/follow', undefined, function (err) {
|
api[type === 'follow' ? 'put' : 'del']('/users/' + ajaxify.data.uid + '/follow', undefined, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
components.get('account/follow').toggleClass('hide', type === 'follow');
|
components.get('account/follow').toggleClass('hide', type === 'follow');
|
||||||
components.get('account/unfollow').toggleClass('hide', type === 'unfollow');
|
components.get('account/unfollow').toggleClass('hide', type === 'unfollow');
|
||||||
app.alertSuccess('[[global:alert.' + type + ', ' + ajaxify.data.username + ']]');
|
alerts.success('[[global:alert.' + type + ', ' + ajaxify.data.username + ']]');
|
||||||
});
|
});
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -162,7 +163,7 @@ define('forum/account/header', [
|
|||||||
}
|
}
|
||||||
|
|
||||||
ajaxify.refresh();
|
ajaxify.refresh();
|
||||||
}).catch(app.alertError);
|
}).catch(alerts.error);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -173,7 +174,7 @@ define('forum/account/header', [
|
|||||||
function unbanAccount() {
|
function unbanAccount() {
|
||||||
api.del('/users/' + ajaxify.data.theirid + '/ban').then(() => {
|
api.del('/users/' + ajaxify.data.theirid + '/ban').then(() => {
|
||||||
ajaxify.refresh();
|
ajaxify.refresh();
|
||||||
}).catch(app.alertError);
|
}).catch(alerts.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
function flagAccount() {
|
function flagAccount() {
|
||||||
@@ -192,7 +193,7 @@ define('forum/account/header', [
|
|||||||
blockerUid: app.user.uid,
|
blockerUid: app.user.uid,
|
||||||
}, function (err, blocked) {
|
}, function (err, blocked) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
translator.translate('[[user:' + (blocked ? 'unblock' : 'block') + '_user]]', function (label) {
|
translator.translate('[[user:' + (blocked ? 'unblock' : 'block') + '_user]]', function (label) {
|
||||||
@@ -217,7 +218,7 @@ define('forum/account/header', [
|
|||||||
if (!err) {
|
if (!err) {
|
||||||
ajaxify.refresh();
|
ajaxify.refresh();
|
||||||
} else {
|
} else {
|
||||||
app.alertError(err.message);
|
alerts.error(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('forum/account/info', ['forum/account/header', 'components', 'forum/account/sessions'], function (header, components, sessions) {
|
define('forum/account/info', ['forum/account/header', 'alerts', 'forum/account/sessions'], function (header, alerts, sessions) {
|
||||||
const Info = {};
|
const Info = {};
|
||||||
|
|
||||||
Info.init = function () {
|
Info.init = function () {
|
||||||
@@ -15,10 +15,10 @@ define('forum/account/info', ['forum/account/header', 'components', 'forum/accou
|
|||||||
const note = $('[component="account/moderation-note"]').val();
|
const note = $('[component="account/moderation-note"]').val();
|
||||||
socket.emit('user.setModerationNote', { uid: ajaxify.data.uid, note: note }, function (err) {
|
socket.emit('user.setModerationNote', { uid: ajaxify.data.uid, note: note }, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
$('[component="account/moderation-note"]').val('');
|
$('[component="account/moderation-note"]').val('');
|
||||||
app.alertSuccess('[[user:info.moderation-note.success]]');
|
alerts.success('[[user:info.moderation-note.success]]');
|
||||||
const timestamp = Date.now();
|
const timestamp = Date.now();
|
||||||
const data = [{
|
const data = [{
|
||||||
note: utils.escapeHTML(note),
|
note: utils.escapeHTML(note),
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('forum/account/sessions', ['forum/account/header', 'components', 'api'], function (header, components, api) {
|
define('forum/account/sessions', ['forum/account/header', 'components', 'api', 'alerts'], function (header, components, api, alerts) {
|
||||||
const Sessions = {};
|
const Sessions = {};
|
||||||
|
|
||||||
Sessions.init = function () {
|
Sessions.init = function () {
|
||||||
@@ -25,9 +25,9 @@ define('forum/account/sessions', ['forum/account/header', 'components', 'api'],
|
|||||||
if (errorObj.loggedIn === false) {
|
if (errorObj.loggedIn === false) {
|
||||||
window.location.href = config.relative_path + '/login?error=' + errorObj.title;
|
window.location.href = config.relative_path + '/login?error=' + errorObj.title;
|
||||||
}
|
}
|
||||||
app.alertError(errorObj.title);
|
alerts.error(errorObj.title);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
app.alertError('[[error:invalid-data]]');
|
alerts.error('[[error:invalid-data]]');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('forum/account/settings', ['forum/account/header', 'components', 'translator', 'api'], function (header, components, translator, api) {
|
define('forum/account/settings', [
|
||||||
|
'forum/account/header', 'components', 'translator', 'api', 'alerts',
|
||||||
|
], function (header, components, translator, api, alerts) {
|
||||||
const AccountSettings = {};
|
const AccountSettings = {};
|
||||||
|
|
||||||
// If page skin is changed but not saved, switch the skin back
|
// If page skin is changed but not saved, switch the skin back
|
||||||
@@ -21,7 +23,7 @@ define('forum/account/settings', ['forum/account/header', 'components', 'transla
|
|||||||
$.get(config.relative_path + '/' + settings.homePageCustom, function () {
|
$.get(config.relative_path + '/' + settings.homePageCustom, function () {
|
||||||
saveSettings(settings);
|
saveSettings(settings);
|
||||||
}).fail(function () {
|
}).fail(function () {
|
||||||
app.alertError('[[error:invalid-home-page-route]]');
|
alerts.error('[[error:invalid-home-page-route]]');
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
saveSettings(settings);
|
saveSettings(settings);
|
||||||
@@ -67,7 +69,7 @@ define('forum/account/settings', ['forum/account/header', 'components', 'transla
|
|||||||
|
|
||||||
function saveSettings(settings) {
|
function saveSettings(settings) {
|
||||||
api.put(`/users/${ajaxify.data.uid}/settings`, { settings }).then((newSettings) => {
|
api.put(`/users/${ajaxify.data.uid}/settings`, { settings }).then((newSettings) => {
|
||||||
app.alertSuccess('[[success:settings-saved]]');
|
alerts.success('[[success:settings-saved]]');
|
||||||
let languageChanged = false;
|
let languageChanged = false;
|
||||||
for (const key in newSettings) {
|
for (const key in newSettings) {
|
||||||
if (newSettings.hasOwnProperty(key)) {
|
if (newSettings.hasOwnProperty(key)) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('forum/account/uploads', ['forum/account/header'], function (header) {
|
define('forum/account/uploads', ['forum/account/header', 'alerts'], function (header, alerts) {
|
||||||
const AccountUploads = {};
|
const AccountUploads = {};
|
||||||
|
|
||||||
AccountUploads.init = function () {
|
AccountUploads.init = function () {
|
||||||
@@ -12,7 +12,7 @@ define('forum/account/uploads', ['forum/account/header'], function (header) {
|
|||||||
|
|
||||||
socket.emit('user.deleteUpload', { name: name, uid: ajaxify.data.uid }, function (err) {
|
socket.emit('user.deleteUpload', { name: name, uid: ajaxify.data.uid }, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
el.remove();
|
el.remove();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ define('forum/category', [
|
|||||||
'sort',
|
'sort',
|
||||||
'categorySelector',
|
'categorySelector',
|
||||||
'hooks',
|
'hooks',
|
||||||
], function (infinitescroll, share, navigator, topicList, sort, categorySelector, hooks) {
|
'alerts',
|
||||||
|
], function (infinitescroll, share, navigator, topicList, sort, categorySelector, hooks, alerts) {
|
||||||
const Category = {};
|
const Category = {};
|
||||||
|
|
||||||
$(window).on('action:ajaxify.start', function (ev, data) {
|
$(window).on('action:ajaxify.start', function (ev, data) {
|
||||||
@@ -69,7 +70,7 @@ define('forum/category', [
|
|||||||
|
|
||||||
socket.emit('categories.setWatchState', { cid: cid, state: state }, function (err) {
|
socket.emit('categories.setWatchState', { cid: cid, state: state }, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
$('[component="category/watching/menu"]').toggleClass('hidden', state !== 'watching');
|
$('[component="category/watching/menu"]').toggleClass('hidden', state !== 'watching');
|
||||||
@@ -81,7 +82,7 @@ define('forum/category', [
|
|||||||
$('[component="category/ignoring/menu"]').toggleClass('hidden', state !== 'ignoring');
|
$('[component="category/ignoring/menu"]').toggleClass('hidden', state !== 'ignoring');
|
||||||
$('[component="category/ignoring/check"]').toggleClass('fa-check', state === 'ignoring');
|
$('[component="category/ignoring/check"]').toggleClass('fa-check', state === 'ignoring');
|
||||||
|
|
||||||
app.alertSuccess('[[category:' + state + '.message]]');
|
alerts.success('[[category:' + state + '.message]]');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -94,7 +95,7 @@ define('forum/category', [
|
|||||||
start: ajaxify.data.nextSubCategoryStart,
|
start: ajaxify.data.nextSubCategoryStart,
|
||||||
}, function (err, data) {
|
}, function (err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
btn.toggleClass('hidden', !data.length || data.length < ajaxify.data.subCategoriesPerPage);
|
btn.toggleClass('hidden', !data.length || data.length < ajaxify.data.subCategoriesPerPage);
|
||||||
if (!data.length) {
|
if (!data.length) {
|
||||||
@@ -122,7 +123,7 @@ define('forum/category', [
|
|||||||
Category.toBottom = function () {
|
Category.toBottom = function () {
|
||||||
socket.emit('categories.getTopicCount', ajaxify.data.cid, function (err, count) {
|
socket.emit('categories.getTopicCount', ajaxify.data.cid, function (err, count) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
navigator.scrollBottom(count - 1);
|
navigator.scrollBottom(count - 1);
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ define('forum/category/tools', [
|
|||||||
'topicSelect',
|
'topicSelect',
|
||||||
'forum/topic/threadTools',
|
'forum/topic/threadTools',
|
||||||
'components',
|
'components',
|
||||||
'translator',
|
|
||||||
'api',
|
'api',
|
||||||
'bootbox',
|
'bootbox',
|
||||||
], function (topicSelect, threadTools, components, translator, api, bootbox) {
|
'alerts',
|
||||||
|
], function (topicSelect, threadTools, components, api, bootbox, alerts) {
|
||||||
const CategoryTools = {};
|
const CategoryTools = {};
|
||||||
|
|
||||||
CategoryTools.init = function () {
|
CategoryTools.init = function () {
|
||||||
@@ -56,13 +56,13 @@ define('forum/category/tools', [
|
|||||||
components.get('topic/mark-unread-for-all').on('click', function () {
|
components.get('topic/mark-unread-for-all').on('click', function () {
|
||||||
const tids = topicSelect.getSelectedTids();
|
const tids = topicSelect.getSelectedTids();
|
||||||
if (!tids.length) {
|
if (!tids.length) {
|
||||||
return app.alertError('[[error:no-topics-selected]]');
|
return alerts.error('[[error:no-topics-selected]]');
|
||||||
}
|
}
|
||||||
socket.emit('topics.markAsUnreadForAll', tids, function (err) {
|
socket.emit('topics.markAsUnreadForAll', tids, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
app.alertSuccess('[[topic:markAsUnreadForAll.success]]');
|
alerts.success('[[topic:markAsUnreadForAll.success]]');
|
||||||
tids.forEach(function (tid) {
|
tids.forEach(function (tid) {
|
||||||
$('[component="category/topic"][data-tid="' + tid + '"]').addClass('unread');
|
$('[component="category/topic"][data-tid="' + tid + '"]').addClass('unread');
|
||||||
});
|
});
|
||||||
@@ -76,7 +76,7 @@ define('forum/category/tools', [
|
|||||||
const tids = topicSelect.getSelectedTids();
|
const tids = topicSelect.getSelectedTids();
|
||||||
|
|
||||||
if (!tids.length) {
|
if (!tids.length) {
|
||||||
return app.alertError('[[error:no-topics-selected]]');
|
return alerts.error('[[error:no-topics-selected]]');
|
||||||
}
|
}
|
||||||
move.init(tids, null, onCommandComplete);
|
move.init(tids, null, onCommandComplete);
|
||||||
});
|
});
|
||||||
@@ -87,12 +87,12 @@ define('forum/category/tools', [
|
|||||||
components.get('topic/move-all').on('click', function () {
|
components.get('topic/move-all').on('click', function () {
|
||||||
const cid = ajaxify.data.cid;
|
const cid = ajaxify.data.cid;
|
||||||
if (!ajaxify.data.template.category) {
|
if (!ajaxify.data.template.category) {
|
||||||
return app.alertError('[[error:invalid-data]]');
|
return alerts.error('[[error:invalid-data]]');
|
||||||
}
|
}
|
||||||
require(['forum/topic/move'], function (move) {
|
require(['forum/topic/move'], function (move) {
|
||||||
move.init(null, cid, function (err) {
|
move.init(null, cid, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
ajaxify.refresh();
|
ajaxify.refresh();
|
||||||
@@ -134,12 +134,12 @@ define('forum/category/tools', [
|
|||||||
if (ok) {
|
if (ok) {
|
||||||
Promise.all(tids.map(tid => api[method](`/topics/${tid}${path}`, body)))
|
Promise.all(tids.map(tid => api[method](`/topics/${tid}${path}`, body)))
|
||||||
.then(onComplete)
|
.then(onComplete)
|
||||||
.catch(app.alertError);
|
.catch(alerts.error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!tids.length) {
|
if (!tids.length) {
|
||||||
return app.alertError('[[error:no-topics-selected]]');
|
return alerts.error('[[error:no-topics-selected]]');
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (command) {
|
switch (command) {
|
||||||
@@ -294,7 +294,7 @@ define('forum/category/tools', [
|
|||||||
order: baseIndex + ui.item.index() - 1,
|
order: baseIndex + ui.item.index() - 1,
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -11,11 +11,12 @@ define('forum/chats', [
|
|||||||
'composer/autocomplete',
|
'composer/autocomplete',
|
||||||
'hooks',
|
'hooks',
|
||||||
'bootbox',
|
'bootbox',
|
||||||
|
'alerts',
|
||||||
'chat',
|
'chat',
|
||||||
], function (
|
], function (
|
||||||
components, translator, mousetrap,
|
components, translator, mousetrap,
|
||||||
recentChats, search, messages,
|
recentChats, search, messages,
|
||||||
autocomplete, hooks, bootbox, chatModule
|
autocomplete, hooks, bootbox, alerts, chatModule
|
||||||
) {
|
) {
|
||||||
const Chats = {
|
const Chats = {
|
||||||
initialised: false,
|
initialised: false,
|
||||||
@@ -79,7 +80,7 @@ define('forum/chats', [
|
|||||||
const mid = ipEl.parents('[data-mid]').attr('data-mid');
|
const mid = ipEl.parents('[data-mid]').attr('data-mid');
|
||||||
socket.emit('modules.chats.getIP', mid, function (err, ip) {
|
socket.emit('modules.chats.getIP', mid, function (err, ip) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
ipEl.html(ip);
|
ipEl.html(ip);
|
||||||
});
|
});
|
||||||
@@ -126,7 +127,7 @@ define('forum/chats', [
|
|||||||
start: start,
|
start: start,
|
||||||
}, function (err, data) {
|
}, function (err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
if (!data) {
|
if (!data) {
|
||||||
loading = false;
|
loading = false;
|
||||||
@@ -270,7 +271,7 @@ define('forum/chats', [
|
|||||||
uid: uid,
|
uid: uid,
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
Chats.refreshParticipantsList(roomId, modal);
|
Chats.refreshParticipantsList(roomId, modal);
|
||||||
@@ -288,7 +289,7 @@ define('forum/chats', [
|
|||||||
if (ok) {
|
if (ok) {
|
||||||
socket.emit('modules.chats.leave', roomId, function (err) {
|
socket.emit('modules.chats.leave', roomId, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
app.alertError(err.message);
|
alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return user to chats page. If modal, close modal.
|
// Return user to chats page. If modal, close modal.
|
||||||
@@ -350,7 +351,7 @@ define('forum/chats', [
|
|||||||
newName: modal.find('#roomName').val(),
|
newName: modal.find('#roomName').val(),
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
alerts.error(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -399,7 +400,7 @@ define('forum/chats', [
|
|||||||
const roomId = el.attr('data-roomid');
|
const roomId = el.attr('data-roomid');
|
||||||
socket.emit('modules.chats.leave', roomId, function (err) {
|
socket.emit('modules.chats.leave', roomId, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
if (parseInt(roomId, 10) === parseInt(ajaxify.data.roomId, 10)) {
|
if (parseInt(roomId, 10) === parseInt(ajaxify.data.roomId, 10)) {
|
||||||
ajaxify.go('user/' + ajaxify.data.userslug + '/chats');
|
ajaxify.go('user/' + ajaxify.data.userslug + '/chats');
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ define('forum/chats/messages', [
|
|||||||
inputEl.val(msg);
|
inputEl.val(msg);
|
||||||
inputEl.attr('data-mid', mid);
|
inputEl.attr('data-mid', mid);
|
||||||
messages.updateRemainingLength(inputEl.parent());
|
messages.updateRemainingLength(inputEl.parent());
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -142,7 +142,7 @@ define('forum/chats/messages', [
|
|||||||
messages.prepEdit = function (inputEl, messageId, roomId) {
|
messages.prepEdit = function (inputEl, messageId, roomId) {
|
||||||
socket.emit('modules.chats.getRaw', { mid: messageId, roomId: roomId }, function (err, raw) {
|
socket.emit('modules.chats.getRaw', { mid: messageId, roomId: roomId }, function (err, raw) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
// Populate the input field with the raw message content
|
// Populate the input field with the raw message content
|
||||||
if (inputEl.val().length === 0) {
|
if (inputEl.val().length === 0) {
|
||||||
@@ -209,7 +209,7 @@ define('forum/chats/messages', [
|
|||||||
roomId: roomId,
|
roomId: roomId,
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
components.get('chat/message', messageId).toggleClass('deleted', true);
|
components.get('chat/message', messageId).toggleClass('deleted', true);
|
||||||
@@ -224,7 +224,7 @@ define('forum/chats/messages', [
|
|||||||
roomId: roomId,
|
roomId: roomId,
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
components.get('chat/message', messageId).toggleClass('deleted', false);
|
components.get('chat/message', messageId).toggleClass('deleted', false);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('forum/chats/recent', function () {
|
define('forum/chats/recent', ['alerts'], function (alerts) {
|
||||||
const recent = {};
|
const recent = {};
|
||||||
|
|
||||||
recent.init = function () {
|
recent.init = function () {
|
||||||
@@ -31,7 +31,7 @@ define('forum/chats/recent', function () {
|
|||||||
after: recentChats.attr('data-nextstart'),
|
after: recentChats.attr('data-nextstart'),
|
||||||
}, function (err, data) {
|
}, function (err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data && data.rooms.length) {
|
if (data && data.rooms.length) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('forum/chats/search', ['components', 'api'], function (components, api) {
|
define('forum/chats/search', ['components', 'api', 'alerts'], function (components, api, alerts) {
|
||||||
const search = {};
|
const search = {};
|
||||||
|
|
||||||
search.init = function () {
|
search.init = function () {
|
||||||
@@ -19,7 +19,7 @@ define('forum/chats/search', ['components', 'api'], function (components, api) {
|
|||||||
searchBy: 'username',
|
searchBy: 'username',
|
||||||
paginate: false,
|
paginate: false,
|
||||||
}).then(displayResults)
|
}).then(displayResults)
|
||||||
.catch(app.alertError);
|
.catch(alerts.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
function displayResults(data) {
|
function displayResults(data) {
|
||||||
@@ -62,7 +62,7 @@ define('forum/chats/search', ['components', 'api'], function (components, api) {
|
|||||||
chatEl.on('click', function () {
|
chatEl.on('click', function () {
|
||||||
socket.emit('modules.chats.hasPrivateChat', userObj.uid, function (err, roomId) {
|
socket.emit('modules.chats.hasPrivateChat', userObj.uid, function (err, roomId) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
if (roomId) {
|
if (roomId) {
|
||||||
require(['forum/chats'], function (chats) {
|
require(['forum/chats'], function (chats) {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('forum/flags/detail', [
|
define('forum/flags/detail', [
|
||||||
'components', 'translator', 'benchpress', 'forum/account/header', 'accounts/delete', 'api', 'bootbox',
|
'components', 'translator', 'benchpress', 'forum/account/header', 'accounts/delete', 'api', 'bootbox', 'alerts',
|
||||||
], function (components, translator, Benchpress, AccountHeader, AccountsDelete, api, bootbox) {
|
], function (components, translator, Benchpress, AccountHeader, AccountsDelete, api, bootbox, alerts) {
|
||||||
const Detail = {};
|
const Detail = {};
|
||||||
|
|
||||||
Detail.init = function () {
|
Detail.init = function () {
|
||||||
@@ -27,9 +27,9 @@ define('forum/flags/detail', [
|
|||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
api.put(`/flags/${ajaxify.data.flagId}`, data).then((history) => {
|
api.put(`/flags/${ajaxify.data.flagId}`, data).then((history) => {
|
||||||
app.alertSuccess('[[flags:updated]]');
|
alerts.success('[[flags:updated]]');
|
||||||
Detail.reloadHistory(history);
|
Detail.reloadHistory(history);
|
||||||
}).catch(app.alertError);
|
}).catch(alerts.error);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,12 +39,12 @@ define('forum/flags/detail', [
|
|||||||
note: noteEl.value,
|
note: noteEl.value,
|
||||||
datetime: parseInt(noteEl.getAttribute('data-datetime'), 10),
|
datetime: parseInt(noteEl.getAttribute('data-datetime'), 10),
|
||||||
}).then((payload) => {
|
}).then((payload) => {
|
||||||
app.alertSuccess('[[flags:note-added]]');
|
alerts.success('[[flags:note-added]]');
|
||||||
Detail.reloadNotes(payload.notes);
|
Detail.reloadNotes(payload.notes);
|
||||||
Detail.reloadHistory(payload.history);
|
Detail.reloadHistory(payload.history);
|
||||||
|
|
||||||
noteEl.removeAttribute('data-datetime');
|
noteEl.removeAttribute('data-datetime');
|
||||||
}).catch(app.alertError);
|
}).catch(alerts.error);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'delete-note': {
|
case 'delete-note': {
|
||||||
@@ -52,10 +52,10 @@ define('forum/flags/detail', [
|
|||||||
bootbox.confirm('[[flags:delete-note-confirm]]', function (ok) {
|
bootbox.confirm('[[flags:delete-note-confirm]]', function (ok) {
|
||||||
if (ok) {
|
if (ok) {
|
||||||
api.delete(`/flags/${ajaxify.data.flagId}/notes/${datetime}`, {}).then((payload) => {
|
api.delete(`/flags/${ajaxify.data.flagId}/notes/${datetime}`, {}).then((payload) => {
|
||||||
app.alertSuccess('[[flags:note-deleted]]');
|
alerts.success('[[flags:note-deleted]]');
|
||||||
Detail.reloadNotes(payload.notes);
|
Detail.reloadNotes(payload.notes);
|
||||||
Detail.reloadHistory(payload.history);
|
Detail.reloadHistory(payload.history);
|
||||||
}).catch(app.alertError);
|
}).catch(alerts.error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
@@ -127,7 +127,7 @@ define('forum/flags/detail', [
|
|||||||
tid: tid,
|
tid: tid,
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
app.alertError(err.message);
|
alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
ajaxify.refresh();
|
ajaxify.refresh();
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('forum/flags/list', ['components', 'Chart', 'categoryFilter', 'autocomplete', 'api'], function (components, Chart, categoryFilter, autocomplete, api) {
|
define('forum/flags/list', [
|
||||||
|
'components', 'Chart', 'categoryFilter', 'autocomplete', 'api', 'alerts',
|
||||||
|
], function (components, Chart, categoryFilter, autocomplete, api, alerts) {
|
||||||
const Flags = {};
|
const Flags = {};
|
||||||
|
|
||||||
let selectedCids;
|
let selectedCids;
|
||||||
@@ -171,12 +173,12 @@ define('forum/flags/list', ['components', 'Chart', 'categoryFilter', 'autocomple
|
|||||||
return res.status === 'rejected';
|
return res.status === 'rejected';
|
||||||
});
|
});
|
||||||
if (fulfilled) {
|
if (fulfilled) {
|
||||||
app.alertSuccess('[[flags:bulk-success, ' + fulfilled + ']]');
|
alerts.success('[[flags:bulk-success, ' + fulfilled + ']]');
|
||||||
ajaxify.refresh();
|
ajaxify.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
errors.forEach(function (res) {
|
errors.forEach(function (res) {
|
||||||
app.alertError(res.reason);
|
alerts.error(res.reason);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ define('forum/groups/details', [
|
|||||||
'slugify',
|
'slugify',
|
||||||
'categorySelector',
|
'categorySelector',
|
||||||
'bootbox',
|
'bootbox',
|
||||||
|
'alerts',
|
||||||
], function (
|
], function (
|
||||||
memberList,
|
memberList,
|
||||||
iconSelect,
|
iconSelect,
|
||||||
@@ -21,7 +22,8 @@ define('forum/groups/details', [
|
|||||||
api,
|
api,
|
||||||
slugify,
|
slugify,
|
||||||
categorySelector,
|
categorySelector,
|
||||||
bootbox
|
bootbox,
|
||||||
|
alerts,
|
||||||
) {
|
) {
|
||||||
const Details = {};
|
const Details = {};
|
||||||
let groupName;
|
let groupName;
|
||||||
@@ -79,7 +81,7 @@ define('forum/groups/details', [
|
|||||||
case 'toggleOwnership':
|
case 'toggleOwnership':
|
||||||
api[isOwner ? 'del' : 'put'](`/groups/${ajaxify.data.group.slug}/ownership/${uid}`, {}).then(() => {
|
api[isOwner ? 'del' : 'put'](`/groups/${ajaxify.data.group.slug}/ownership/${uid}`, {}).then(() => {
|
||||||
ownerFlagEl.toggleClass('invisible');
|
ownerFlagEl.toggleClass('invisible');
|
||||||
}).catch(app.alertError);
|
}).catch(alerts.error);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'kick':
|
case 'kick':
|
||||||
@@ -89,7 +91,7 @@ define('forum/groups/details', [
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
api.del(`/groups/${ajaxify.data.group.slug}/membership/${uid}`, undefined).then(() => userRow.slideUp().remove()).catch(app.alertError);
|
api.del(`/groups/${ajaxify.data.group.slug}/membership/${uid}`, undefined).then(() => userRow.slideUp().remove()).catch(alerts.error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
@@ -103,11 +105,11 @@ define('forum/groups/details', [
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'join': // intentional fall-throughs!
|
case 'join': // intentional fall-throughs!
|
||||||
api.put('/groups/' + ajaxify.data.group.slug + '/membership/' + (uid || app.user.uid), undefined).then(() => ajaxify.refresh()).catch(app.alertError);
|
api.put('/groups/' + ajaxify.data.group.slug + '/membership/' + (uid || app.user.uid), undefined).then(() => ajaxify.refresh()).catch(alerts.error);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'leave':
|
case 'leave':
|
||||||
api.del('/groups/' + ajaxify.data.group.slug + '/membership/' + (uid || app.user.uid), undefined).then(() => ajaxify.refresh()).catch(app.alertError);
|
api.del('/groups/' + ajaxify.data.group.slug + '/membership/' + (uid || app.user.uid), undefined).then(() => ajaxify.refresh()).catch(alerts.error);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// TODO (14/10/2020): rewrite these to use api module and merge with above 2 case blocks
|
// TODO (14/10/2020): rewrite these to use api module and merge with above 2 case blocks
|
||||||
@@ -126,7 +128,7 @@ define('forum/groups/details', [
|
|||||||
if (!err) {
|
if (!err) {
|
||||||
ajaxify.refresh();
|
ajaxify.refresh();
|
||||||
} else {
|
} else {
|
||||||
app.alertError(err.message);
|
alerts.error(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
@@ -219,8 +221,8 @@ define('forum/groups/details', [
|
|||||||
ajaxify.refresh();
|
ajaxify.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
app.alertSuccess('[[groups:event.updated]]');
|
alerts.success('[[groups:event.updated]]');
|
||||||
}).catch(app.alertError);
|
}).catch(alerts.error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -230,9 +232,9 @@ define('forum/groups/details', [
|
|||||||
bootbox.prompt('Please enter the name of this group in order to delete it:', function (response) {
|
bootbox.prompt('Please enter the name of this group in order to delete it:', function (response) {
|
||||||
if (response === groupName) {
|
if (response === groupName) {
|
||||||
api.del(`/groups/${ajaxify.data.group.slug}`, {}).then(() => {
|
api.del(`/groups/${ajaxify.data.group.slug}`, {}).then(() => {
|
||||||
app.alertSuccess('[[groups:event.deleted, ' + utils.escapeHTML(groupName) + ']]');
|
alerts.success('[[groups:event.deleted, ' + utils.escapeHTML(groupName) + ']]');
|
||||||
ajaxify.go('groups');
|
ajaxify.go('groups');
|
||||||
}).catch(app.alertError);
|
}).catch(alerts.error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -252,7 +254,7 @@ define('forum/groups/details', [
|
|||||||
groupName: ajaxify.data.group.name,
|
groupName: ajaxify.data.group.name,
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
ajaxify.refresh();
|
ajaxify.refresh();
|
||||||
});
|
});
|
||||||
@@ -269,7 +271,7 @@ define('forum/groups/details', [
|
|||||||
groupName: ajaxify.data.group.name,
|
groupName: ajaxify.data.group.name,
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
ajaxify.refresh();
|
ajaxify.refresh();
|
||||||
});
|
});
|
||||||
@@ -290,7 +292,7 @@ define('forum/groups/details', [
|
|||||||
if (!err) {
|
if (!err) {
|
||||||
ajaxify.refresh();
|
ajaxify.refresh();
|
||||||
} else {
|
} else {
|
||||||
app.alertError(err.message);
|
alerts.error(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('forum/groups/list', [
|
define('forum/groups/list', [
|
||||||
'forum/infinitescroll', 'benchpress', 'api', 'bootbox',
|
'forum/infinitescroll', 'benchpress', 'api', 'bootbox', 'alerts',
|
||||||
], function (infinitescroll, Benchpress, api, bootbox) {
|
], function (infinitescroll, Benchpress, api, bootbox, alerts) {
|
||||||
const Groups = {};
|
const Groups = {};
|
||||||
|
|
||||||
Groups.init = function () {
|
Groups.init = function () {
|
||||||
@@ -16,7 +16,7 @@ define('forum/groups/list', [
|
|||||||
name: name,
|
name: name,
|
||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
ajaxify.go('groups/' + res.slug);
|
ajaxify.go('groups/' + res.slug);
|
||||||
}).catch(app.alertError);
|
}).catch(alerts.error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -72,7 +72,7 @@ define('forum/groups/list', [
|
|||||||
},
|
},
|
||||||
}, function (err, groups) {
|
}, function (err, groups) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
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';
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('forum/groups/memberlist', ['api', 'bootbox'], function (api, bootbox) {
|
define('forum/groups/memberlist', ['api', 'bootbox', 'alerts'], function (api, bootbox, alerts) {
|
||||||
const MemberList = {};
|
const MemberList = {};
|
||||||
let searchInterval;
|
let searchInterval;
|
||||||
let groupName;
|
let groupName;
|
||||||
@@ -51,7 +51,7 @@ define('forum/groups/memberlist', ['api', 'bootbox'], function (api, bootbox) {
|
|||||||
paginate: false,
|
paginate: false,
|
||||||
}, function (err, result) {
|
}, function (err, result) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
result.users.forEach(function (user) {
|
result.users.forEach(function (user) {
|
||||||
foundUsers[user.uid] = user;
|
foundUsers[user.uid] = user;
|
||||||
@@ -79,12 +79,12 @@ define('forum/groups/memberlist', ['api', 'bootbox'], function (api, bootbox) {
|
|||||||
if (groupName === 'administrators') {
|
if (groupName === 'administrators') {
|
||||||
socket.emit('admin.user.makeAdmins', uids, function (err) {
|
socket.emit('admin.user.makeAdmins', uids, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
Promise.all(uids.map(uid => api.put('/groups/' + ajaxify.data.group.slug + '/membership/' + uid))).then(done).catch(app.alertError);
|
Promise.all(uids.map(uid => api.put('/groups/' + ajaxify.data.group.slug + '/membership/' + uid))).then(done).catch(alerts.error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ define('forum/groups/memberlist', ['api', 'bootbox'], function (api, bootbox) {
|
|||||||
searchInterval = setTimeout(function () {
|
searchInterval = setTimeout(function () {
|
||||||
socket.emit('groups.searchMembers', { groupName: groupName, query: query }, function (err, results) {
|
socket.emit('groups.searchMembers', { groupName: groupName, query: query }, function (err, results) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
parseAndTranslate(results.users, function (html) {
|
parseAndTranslate(results.users, function (html) {
|
||||||
$('[component="groups/members"] tbody').html(html);
|
$('[component="groups/members"] tbody').html(html);
|
||||||
@@ -133,7 +133,7 @@ define('forum/groups/memberlist', ['api', 'bootbox'], function (api, bootbox) {
|
|||||||
after: members.attr('data-nextstart'),
|
after: members.attr('data-nextstart'),
|
||||||
}, function (err, data) {
|
}, function (err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data && data.users.length) {
|
if (data && data.users.length) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('forum/header', ['forum/header/notifications', 'forum/header/chat'], function (notifications, chat) {
|
define('forum/header', ['forum/header/notifications', 'forum/header/chat', 'alerts'], function (notifications, chat, alerts) {
|
||||||
const module = {};
|
const module = {};
|
||||||
|
|
||||||
module.prepareDOM = function () {
|
module.prepareDOM = function () {
|
||||||
@@ -16,7 +16,7 @@ define('forum/header', ['forum/header/notifications', 'forum/header/chat'], func
|
|||||||
const status = $(this).attr('data-status');
|
const status = $(this).attr('data-status');
|
||||||
socket.emit('user.setStatus', status, function (err) {
|
socket.emit('user.setStatus', status, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
$('[data-uid="' + app.user.uid + '"] [component="user/status"], [component="header/profilelink"] [component="user/status"]')
|
$('[data-uid="' + app.user.uid + '"] [component="user/status"], [component="header/profilelink"] [component="user/status"]')
|
||||||
.removeClass('away online dnd offline')
|
.removeClass('away online dnd offline')
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('forum/infinitescroll', ['hooks'], function (hooks) {
|
define('forum/infinitescroll', ['hooks', 'alerts'], function (hooks, alerts) {
|
||||||
const scroll = {};
|
const scroll = {};
|
||||||
let callback;
|
let callback;
|
||||||
let previousScrollTop = 0;
|
let previousScrollTop = 0;
|
||||||
@@ -75,7 +75,7 @@ define('forum/infinitescroll', ['hooks'], function (hooks) {
|
|||||||
socket.emit(hookData.method, hookData.data, function (err, data) {
|
socket.emit(hookData.method, hookData.data, function (err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
loadingMore = false;
|
loadingMore = false;
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
callback(data, function () {
|
callback(data, function () {
|
||||||
loadingMore = false;
|
loadingMore = false;
|
||||||
@@ -98,7 +98,7 @@ define('forum/infinitescroll', ['hooks'], function (hooks) {
|
|||||||
});
|
});
|
||||||
}).fail(function (jqXHR) {
|
}).fail(function (jqXHR) {
|
||||||
loadingMore = false;
|
loadingMore = false;
|
||||||
app.alertError(String(jqXHR.responseJSON || jqXHR.statusText));
|
alerts.error(String(jqXHR.responseJSON || jqXHR.statusText));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('forum/notifications', ['components'], function (components) {
|
define('forum/notifications', ['components', 'alerts'], function (components, alerts) {
|
||||||
const Notifications = {};
|
const Notifications = {};
|
||||||
|
|
||||||
Notifications.init = function () {
|
Notifications.init = function () {
|
||||||
@@ -10,7 +10,7 @@ define('forum/notifications', ['components'], function (components) {
|
|||||||
const nid = $(this).parents('[data-nid]').attr('data-nid');
|
const nid = $(this).parents('[data-nid]').attr('data-nid');
|
||||||
socket.emit('notifications.markRead', nid, function (err) {
|
socket.emit('notifications.markRead', nid, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -18,7 +18,7 @@ define('forum/notifications', ['components'], function (components) {
|
|||||||
components.get('notifications/mark_all').on('click', function () {
|
components.get('notifications/mark_all').on('click', function () {
|
||||||
socket.emit('notifications.markAllRead', function (err) {
|
socket.emit('notifications.markAllRead', function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
components.get('notifications/item').removeClass('unread');
|
components.get('notifications/item').removeClass('unread');
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
|
|
||||||
define('forum/post-queue', [
|
define('forum/post-queue', [
|
||||||
'categoryFilter', 'categorySelector', 'api',
|
'categoryFilter', 'categorySelector', 'api', 'alerts',
|
||||||
], function (categoryFilter, categorySelector, api) {
|
], function (categoryFilter, categorySelector, api, alerts) {
|
||||||
const PostQueue = {};
|
const PostQueue = {};
|
||||||
|
|
||||||
PostQueue.init = function () {
|
PostQueue.init = function () {
|
||||||
@@ -27,7 +27,7 @@ define('forum/post-queue', [
|
|||||||
|
|
||||||
socket.emit('posts.' + action, { id: id }, function (err) {
|
socket.emit('posts.' + action, { id: id }, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
parent.remove();
|
parent.remove();
|
||||||
|
|
||||||
@@ -66,9 +66,7 @@ define('forum/post-queue', [
|
|||||||
$this.replaceWith(html.find('.topic-category'));
|
$this.replaceWith(html.find('.topic-category'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}).catch(function (err) {
|
}).catch(alerts.error);
|
||||||
app.alertError(err);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
@@ -99,7 +97,7 @@ define('forum/post-queue', [
|
|||||||
content: titleEdit ? undefined : textarea.val(),
|
content: titleEdit ? undefined : textarea.val(),
|
||||||
}, function (err, data) {
|
}, function (err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
if (titleEdit) {
|
if (titleEdit) {
|
||||||
if (preview.find('.title-text').length) {
|
if (preview.find('.title-text').length) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('forum/reset', function () {
|
define('forum/reset', ['alerts'], function (alerts) {
|
||||||
const ResetPassword = {};
|
const ResetPassword = {};
|
||||||
|
|
||||||
ResetPassword.init = function () {
|
ResetPassword.init = function () {
|
||||||
@@ -13,7 +13,7 @@ define('forum/reset', function () {
|
|||||||
if (inputEl.val() && inputEl.val().indexOf('@') !== -1) {
|
if (inputEl.val() && inputEl.val().indexOf('@') !== -1) {
|
||||||
socket.emit('user.reset.send', inputEl.val(), function (err) {
|
socket.emit('user.reset.send', inputEl.val(), function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
errorEl.addClass('hide');
|
errorEl.addClass('hide');
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('forum/reset_code', ['zxcvbn'], function (zxcvbn) {
|
define('forum/reset_code', ['zxcvbn', 'alerts'], function (zxcvbn, alerts) {
|
||||||
const ResetCode = {};
|
const ResetCode = {};
|
||||||
|
|
||||||
ResetCode.init = function () {
|
ResetCode.init = function () {
|
||||||
@@ -33,7 +33,7 @@ define('forum/reset_code', ['zxcvbn'], function (zxcvbn) {
|
|||||||
}, function (err) {
|
}, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
ajaxify.refresh();
|
ajaxify.refresh();
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.location.href = config.relative_path + '/login';
|
window.location.href = config.relative_path + '/login';
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ define('forum/search', [
|
|||||||
'autocomplete',
|
'autocomplete',
|
||||||
'storage',
|
'storage',
|
||||||
'hooks',
|
'hooks',
|
||||||
], function (searchModule, autocomplete, storage, hooks) {
|
'alerts',
|
||||||
|
], function (searchModule, autocomplete, storage, hooks, alerts) {
|
||||||
const Search = {};
|
const Search = {};
|
||||||
|
|
||||||
Search.init = function () {
|
Search.init = function () {
|
||||||
@@ -142,7 +143,7 @@ define('forum/search', [
|
|||||||
function handleSavePreferences() {
|
function handleSavePreferences() {
|
||||||
$('#save-preferences').on('click', function () {
|
$('#save-preferences').on('click', function () {
|
||||||
storage.setItem('search-preferences', JSON.stringify(getSearchDataFromDOM()));
|
storage.setItem('search-preferences', JSON.stringify(getSearchDataFromDOM()));
|
||||||
app.alertSuccess('[[search:search-preferences-saved]]');
|
alerts.success('[[search:search-preferences-saved]]');
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -151,7 +152,7 @@ define('forum/search', [
|
|||||||
const query = $('#search-input').val();
|
const query = $('#search-input').val();
|
||||||
$('#advanced-search')[0].reset();
|
$('#advanced-search')[0].reset();
|
||||||
$('#search-input').val(query);
|
$('#search-input').val(query);
|
||||||
app.alertSuccess('[[search:search-preferences-cleared]]');
|
alerts.success('[[search:search-preferences-cleared]]');
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('forum/tags', ['forum/infinitescroll'], function (infinitescroll) {
|
define('forum/tags', ['forum/infinitescroll', 'alerts'], function (infinitescroll, alerts) {
|
||||||
const Tags = {};
|
const Tags = {};
|
||||||
|
|
||||||
Tags.init = function () {
|
Tags.init = function () {
|
||||||
@@ -14,7 +14,7 @@ define('forum/tags', ['forum/infinitescroll'], function (infinitescroll) {
|
|||||||
|
|
||||||
socket.emit('topics.searchAndLoadTags', { query: $('#tag-search').val() }, function (err, results) {
|
socket.emit('topics.searchAndLoadTags', { query: $('#tag-search').val() }, function (err, results) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
onTagsLoaded(results.tags, true);
|
onTagsLoaded(results.tags, true);
|
||||||
});
|
});
|
||||||
@@ -45,7 +45,7 @@ define('forum/tags', ['forum/infinitescroll'], function (infinitescroll) {
|
|||||||
after: 0,
|
after: 0,
|
||||||
}, function (err, data) {
|
}, function (err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
onTagsLoaded(data.tags, true);
|
onTagsLoaded(data.tags, true);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ define('forum/topic', [
|
|||||||
if (!String(data.url).startsWith('topic/')) {
|
if (!String(data.url).startsWith('topic/')) {
|
||||||
navigator.disable();
|
navigator.disable();
|
||||||
components.get('navbar/title').find('span').text('').hide();
|
components.get('navbar/title').find('span').text('').hide();
|
||||||
app.removeAlert('bookmark');
|
alerts.remove('bookmark');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ define('forum/topic', [
|
|||||||
Topic.toBottom = function () {
|
Topic.toBottom = function () {
|
||||||
socket.emit('topics.postcount', ajaxify.data.tid, function (err, postCount) {
|
socket.emit('topics.postcount', ajaxify.data.tid, function (err, postCount) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
navigator.scrollBottom(postCount - 1);
|
navigator.scrollBottom(postCount - 1);
|
||||||
@@ -297,7 +297,7 @@ define('forum/topic', [
|
|||||||
index: index,
|
index: index,
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
ajaxify.data.bookmark = index + 1;
|
ajaxify.data.bookmark = index + 1;
|
||||||
});
|
});
|
||||||
@@ -308,7 +308,7 @@ define('forum/topic', [
|
|||||||
|
|
||||||
// removes the bookmark alert when we get to / past the bookmark
|
// removes the bookmark alert when we get to / past the bookmark
|
||||||
if (!currentBookmark || parseInt(index, 10) >= parseInt(currentBookmark, 10)) {
|
if (!currentBookmark || parseInt(index, 10) >= parseInt(currentBookmark, 10)) {
|
||||||
app.removeAlert('bookmark');
|
alerts.remove('bookmark');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
|
|
||||||
define('forum/topic/change-owner', [
|
define('forum/topic/change-owner', [
|
||||||
'components',
|
|
||||||
'postSelect',
|
'postSelect',
|
||||||
'autocomplete',
|
'autocomplete',
|
||||||
], function (components, postSelect, autocomplete) {
|
'alerts',
|
||||||
|
], function (postSelect, autocomplete, alerts) {
|
||||||
const ChangeOwner = {};
|
const ChangeOwner = {};
|
||||||
|
|
||||||
let modal;
|
let modal;
|
||||||
@@ -71,7 +71,7 @@ define('forum/topic/change-owner', [
|
|||||||
}
|
}
|
||||||
socket.emit('posts.changeOwner', { pids: postSelect.pids, toUid: toUid }, function (err) {
|
socket.emit('posts.changeOwner', { pids: postSelect.pids, toUid: toUid }, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
ajaxify.refresh();
|
ajaxify.refresh();
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('forum/topic/delete-posts', ['components', 'postSelect'], function (components, postSelect) {
|
define('forum/topic/delete-posts', ['postSelect', 'alerts'], function (postSelect, alerts) {
|
||||||
const DeletePosts = {};
|
const DeletePosts = {};
|
||||||
let modal;
|
let modal;
|
||||||
let deleteBtn;
|
let deleteBtn;
|
||||||
@@ -56,7 +56,7 @@ define('forum/topic/delete-posts', ['components', 'postSelect'], function (compo
|
|||||||
}, function (err) {
|
}, function (err) {
|
||||||
btn.removeAttr('disabled');
|
btn.removeAttr('disabled');
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
closeModal();
|
closeModal();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('forum/topic/diffs', ['api', 'bootbox', 'forum/topic/images'], function (api, bootbox) {
|
define('forum/topic/diffs', ['api', 'bootbox', 'alerts', 'forum/topic/images'], function (api, bootbox, alerts) {
|
||||||
const Diffs = {};
|
const Diffs = {};
|
||||||
const localeStringOpts = { year: 'numeric', month: 'short', day: 'numeric', hour: 'numeric', minute: 'numeric' };
|
const localeStringOpts = { year: 'numeric', month: 'short', day: 'numeric', hour: 'numeric', minute: 'numeric' };
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ define('forum/topic/diffs', ['api', 'bootbox', 'forum/topic/images'], function (
|
|||||||
$deleteEl.prop('disabled', true);
|
$deleteEl.prop('disabled', true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}).catch(app.alertError);
|
}).catch(alerts.error);
|
||||||
};
|
};
|
||||||
|
|
||||||
Diffs.load = function (pid, since, $postContainer) {
|
Diffs.load = function (pid, since, $postContainer) {
|
||||||
@@ -59,7 +59,7 @@ define('forum/topic/diffs', ['api', 'bootbox', 'forum/topic/images'], function (
|
|||||||
}, function ($html) {
|
}, function ($html) {
|
||||||
$postContainer.empty().append($html);
|
$postContainer.empty().append($html);
|
||||||
});
|
});
|
||||||
}).catch(app.alertError);
|
}).catch(alerts.error);
|
||||||
};
|
};
|
||||||
|
|
||||||
Diffs.restore = function (pid, since, $modal) {
|
Diffs.restore = function (pid, since, $modal) {
|
||||||
@@ -69,8 +69,8 @@ define('forum/topic/diffs', ['api', 'bootbox', 'forum/topic/images'], function (
|
|||||||
|
|
||||||
api.put(`/posts/${pid}/diffs/${since}`, {}).then(() => {
|
api.put(`/posts/${pid}/diffs/${since}`, {}).then(() => {
|
||||||
$modal.modal('hide');
|
$modal.modal('hide');
|
||||||
app.alertSuccess('[[topic:diffs.post-restored]]');
|
alerts.success('[[topic:diffs.post-restored]]');
|
||||||
}).catch(app.alertError);
|
}).catch(alerts.error);
|
||||||
};
|
};
|
||||||
|
|
||||||
Diffs.delete = function (pid, timestamp, $selectEl, $numberOfDiffCon) {
|
Diffs.delete = function (pid, timestamp, $selectEl, $numberOfDiffCon) {
|
||||||
@@ -80,9 +80,9 @@ define('forum/topic/diffs', ['api', 'bootbox', 'forum/topic/images'], function (
|
|||||||
$selectEl.trigger('change');
|
$selectEl.trigger('change');
|
||||||
const numberOfDiffs = $selectEl.find('option').length;
|
const numberOfDiffs = $selectEl.find('option').length;
|
||||||
$numberOfDiffCon.text(numberOfDiffs);
|
$numberOfDiffCon.text(numberOfDiffs);
|
||||||
app.alertSuccess('[[topic:diffs.deleted]]');
|
alerts.success('[[topic:diffs.deleted]]');
|
||||||
});
|
});
|
||||||
}).catch(app.alertError);
|
}).catch(alerts.error);
|
||||||
};
|
};
|
||||||
|
|
||||||
function parsePostHistory(data, blockName) {
|
function parsePostHistory(data, blockName) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('forum/topic/merge', ['search'], function (search) {
|
define('forum/topic/merge', ['search', 'alerts'], function (search, alerts) {
|
||||||
const Merge = {};
|
const Merge = {};
|
||||||
let modal;
|
let modal;
|
||||||
let mergeBtn;
|
let mergeBtn;
|
||||||
@@ -54,7 +54,7 @@ define('forum/topic/merge', ['search'], function (search) {
|
|||||||
callback = callback || function () {};
|
callback = callback || function () {};
|
||||||
socket.emit('topics.getTopic', tid, function (err, topicData) {
|
socket.emit('topics.getTopic', tid, function (err, topicData) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
const title = topicData ? topicData.title : 'No title';
|
const title = topicData ? topicData.title : 'No title';
|
||||||
if (selectedTids[tid]) {
|
if (selectedTids[tid]) {
|
||||||
@@ -93,7 +93,7 @@ define('forum/topic/merge', ['search'], function (search) {
|
|||||||
socket.emit('topics.merge', { tids: tids, options: options }, function (err, tid) {
|
socket.emit('topics.merge', { tids: tids, options: options }, function (err, tid) {
|
||||||
btn.removeAttr('disabled');
|
btn.removeAttr('disabled');
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
ajaxify.go('/topic/' + tid);
|
ajaxify.go('/topic/' + tid);
|
||||||
closeModal();
|
closeModal();
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ define('forum/topic/move-post', [
|
|||||||
},
|
},
|
||||||
clickfn: function (alert, params) {
|
clickfn: function (alert, params) {
|
||||||
delete params.timeoutfn;
|
delete params.timeoutfn;
|
||||||
app.alertSuccess('[[topic:topic_move_posts_undone]]');
|
alerts.success('[[topic:topic_move_posts_undone]]');
|
||||||
moveCommit.removeAttr('disabled');
|
moveCommit.removeAttr('disabled');
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -101,10 +101,10 @@ define('forum/topic/move-post', [
|
|||||||
if (targetTid && parseInt(targetTid, 10) !== parseInt(fromTid, 10)) {
|
if (targetTid && parseInt(targetTid, 10) !== parseInt(fromTid, 10)) {
|
||||||
api.get('/topics/' + targetTid, {}).then(function (data) {
|
api.get('/topics/' + targetTid, {}).then(function (data) {
|
||||||
if (!data || !data.tid) {
|
if (!data || !data.tid) {
|
||||||
return app.alertError('[[error:no-topic]]');
|
return alerts.error('[[error:no-topic]]');
|
||||||
}
|
}
|
||||||
if (data.scheduled) {
|
if (data.scheduled) {
|
||||||
return app.alertError('[[error:cant-move-posts-to-scheduled]]');
|
return alerts.error('[[error:cant-move-posts-to-scheduled]]');
|
||||||
}
|
}
|
||||||
const translateStr = translator.compile('topic:x-posts-will-be-moved-to-y', postSelect.pids.length, data.title);
|
const translateStr = translator.compile('topic:x-posts-will-be-moved-to-y', postSelect.pids.length, data.title);
|
||||||
moveModal.find('#pids').translateHtml(translateStr);
|
moveModal.find('#pids').translateHtml(translateStr);
|
||||||
@@ -151,7 +151,7 @@ define('forum/topic/move-post', [
|
|||||||
});
|
});
|
||||||
|
|
||||||
closeMoveModal();
|
closeMoveModal();
|
||||||
}).catch(app.alertError);
|
}).catch(alerts.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeMoveModal() {
|
function closeMoveModal() {
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ define('forum/topic/move', ['categorySelector', 'alerts', 'hooks'], function (ca
|
|||||||
},
|
},
|
||||||
clickfn: function (alert, params) {
|
clickfn: function (alert, params) {
|
||||||
delete params.timeoutfn;
|
delete params.timeoutfn;
|
||||||
app.alertSuccess('[[topic:topic_move_undone]]');
|
alerts.success('[[topic:topic_move_undone]]');
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -89,7 +89,7 @@ define('forum/topic/move', ['categorySelector', 'alerts', 'hooks'], function (ca
|
|||||||
|
|
||||||
socket.emit(!data.tids ? 'topics.moveAll' : 'topics.move', data, function (err) {
|
socket.emit(!data.tids ? 'topics.moveAll' : 'topics.move', data, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof data.onComplete === 'function') {
|
if (typeof data.onComplete === 'function') {
|
||||||
|
|||||||
@@ -9,8 +9,9 @@ define('forum/topic/postTools', [
|
|||||||
'forum/topic/votes',
|
'forum/topic/votes',
|
||||||
'api',
|
'api',
|
||||||
'bootbox',
|
'bootbox',
|
||||||
|
'alerts',
|
||||||
'hooks',
|
'hooks',
|
||||||
], function (share, navigator, components, translator, votes, api, bootbox, hooks) {
|
], function (share, navigator, components, translator, votes, api, bootbox, alerts, hooks) {
|
||||||
const PostTools = {};
|
const PostTools = {};
|
||||||
|
|
||||||
let staleReplyAnyway = false;
|
let staleReplyAnyway = false;
|
||||||
@@ -42,7 +43,7 @@ define('forum/topic/postTools', [
|
|||||||
|
|
||||||
socket.emit('posts.loadPostTools', { pid: pid, cid: ajaxify.data.cid }, function (err, data) {
|
socket.emit('posts.loadPostTools', { pid: pid, cid: ajaxify.data.cid }, function (err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
data.posts.display_move_tools = data.posts.display_move_tools && index !== 0;
|
data.posts.display_move_tools = data.posts.display_move_tools && index !== 0;
|
||||||
|
|
||||||
@@ -208,7 +209,7 @@ define('forum/topic/postTools', [
|
|||||||
msg = '[[error:' + languageKey + '-minutes, ' + numMinutes + ']]';
|
msg = '[[error:' + languageKey + '-minutes, ' + numMinutes + ']]';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
app.alertError(msg);
|
alerts.error(msg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -240,9 +241,9 @@ define('forum/topic/postTools', [
|
|||||||
const ip = $(this).attr('data-ip');
|
const ip = $(this).attr('data-ip');
|
||||||
socket.emit('blacklist.addRule', ip, function (err) {
|
socket.emit('blacklist.addRule', ip, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
app.alertSuccess('[[admin/manage/blacklist:ban-ip]]');
|
alerts.success('[[admin/manage/blacklist:ban-ip]]');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -306,7 +307,7 @@ define('forum/topic/postTools', [
|
|||||||
}
|
}
|
||||||
socket.emit('posts.getRawPost', toPid, function (err, post) {
|
socket.emit('posts.getRawPost', toPid, function (err, post) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
quote(post);
|
quote(post);
|
||||||
@@ -352,7 +353,7 @@ define('forum/topic/postTools', [
|
|||||||
|
|
||||||
api[method](`/posts/${pid}/bookmark`, undefined, function (err) {
|
api[method](`/posts/${pid}/bookmark`, undefined, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
const type = method === 'put' ? 'bookmark' : 'unbookmark';
|
const type = method === 'put' ? 'bookmark' : 'unbookmark';
|
||||||
hooks.fire(`action:post.${type}`, { pid: pid });
|
hooks.fire(`action:post.${type}`, { pid: pid });
|
||||||
@@ -414,7 +415,7 @@ define('forum/topic/postTools', [
|
|||||||
|
|
||||||
const route = action === 'purge' ? '' : '/state';
|
const route = action === 'purge' ? '' : '/state';
|
||||||
const method = action === 'restore' ? 'put' : 'del';
|
const method = action === 'restore' ? 'put' : 'del';
|
||||||
api[method](`/posts/${pid}${route}`).catch(app.alertError);
|
api[method](`/posts/${pid}${route}`).catch(alerts.error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('forum/topic/replies', ['navigator', 'components', 'forum/topic/posts', 'hooks'], function (navigator, components, posts, hooks) {
|
define('forum/topic/replies', ['forum/topic/posts', 'hooks', 'alerts'], function (posts, hooks, alerts) {
|
||||||
const Replies = {};
|
const Replies = {};
|
||||||
|
|
||||||
Replies.init = function (button) {
|
Replies.init = function (button) {
|
||||||
@@ -19,7 +19,7 @@ define('forum/topic/replies', ['navigator', 'components', 'forum/topic/posts', '
|
|||||||
loading.addClass('hidden');
|
loading.addClass('hidden');
|
||||||
if (err) {
|
if (err) {
|
||||||
open.removeClass('hidden');
|
open.removeClass('hidden');
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
close.removeClass('hidden');
|
close.removeClass('hidden');
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ define('forum/topic/threadTools', [
|
|||||||
.then(function () {
|
.then(function () {
|
||||||
eventEl.remove();
|
eventEl.remove();
|
||||||
})
|
})
|
||||||
.catch(app.alertError);
|
.catch(alerts.error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -70,7 +70,7 @@ define('forum/topic/threadTools', [
|
|||||||
topicContainer.on('click', '[component="topic/mark-unread"]', function () {
|
topicContainer.on('click', '[component="topic/mark-unread"]', function () {
|
||||||
socket.emit('topics.markUnread', tid, function (err) {
|
socket.emit('topics.markUnread', tid, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (app.previousUrl && !app.previousUrl.match('^/topic')) {
|
if (app.previousUrl && !app.previousUrl.match('^/topic')) {
|
||||||
@@ -81,7 +81,7 @@ define('forum/topic/threadTools', [
|
|||||||
ajaxify.go('category/' + ajaxify.data.category.slug, handleBack.onBackClicked);
|
ajaxify.go('category/' + ajaxify.data.category.slug, handleBack.onBackClicked);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.alertSuccess('[[topic:mark_unread.success]]');
|
alerts.success('[[topic:mark_unread.success]]');
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
@@ -90,9 +90,9 @@ define('forum/topic/threadTools', [
|
|||||||
const btn = $(this);
|
const btn = $(this);
|
||||||
socket.emit('topics.markAsUnreadForAll', [tid], function (err) {
|
socket.emit('topics.markAsUnreadForAll', [tid], function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
app.alertSuccess('[[topic:markAsUnreadForAll.success]]');
|
alerts.success('[[topic:markAsUnreadForAll.success]]');
|
||||||
btn.parents('.thread-tools.open').find('.dropdown-toggle').trigger('click');
|
btn.parents('.thread-tools.open').find('.dropdown-toggle').trigger('click');
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
@@ -182,7 +182,7 @@ define('forum/topic/threadTools', [
|
|||||||
|
|
||||||
socket.emit('topics.loadTopicTools', { tid: ajaxify.data.tid, cid: ajaxify.data.cid }, function (err, data) {
|
socket.emit('topics.loadTopicTools', { tid: ajaxify.data.tid, cid: ajaxify.data.cid }, function (err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
app.parseAndTranslate('partials/topic/topic-menu-list', data, function (html) {
|
app.parseAndTranslate('partials/topic/topic-menu-list', data, function (html) {
|
||||||
dropdownMenu.html(html);
|
dropdownMenu.html(html);
|
||||||
@@ -204,7 +204,7 @@ define('forum/topic/threadTools', [
|
|||||||
if (ok) {
|
if (ok) {
|
||||||
api[method](`/topics/${tid}${path}`, body)
|
api[method](`/topics/${tid}${path}`, body)
|
||||||
.then(onComplete)
|
.then(onComplete)
|
||||||
.catch(app.alertError);
|
.catch(alerts.error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -256,7 +256,7 @@ define('forum/topic/threadTools', [
|
|||||||
body.expiry = expiry.getTime();
|
body.expiry = expiry.getTime();
|
||||||
onSuccess();
|
onSuccess();
|
||||||
} else {
|
} else {
|
||||||
app.alertError('[[error:invalid-date]]');
|
alerts.error('[[error:invalid-date]]');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
|
|
||||||
define('forum/topic/votes', [
|
define('forum/topic/votes', [
|
||||||
'components', 'translator', 'benchpress', 'api', 'hooks', 'bootbox',
|
'components', 'translator', 'api', 'hooks', 'bootbox', 'alerts',
|
||||||
], function (components, translator, Benchpress, api, hooks, bootbox) {
|
], function (components, translator, api, hooks, bootbox, alerts) {
|
||||||
const Votes = {};
|
const Votes = {};
|
||||||
|
|
||||||
Votes.addVoteHandler = function () {
|
Votes.addVoteHandler = function () {
|
||||||
@@ -20,7 +20,7 @@ define('forum/topic/votes', [
|
|||||||
|
|
||||||
socket.emit('posts.getUpvoters', [pid], function (err, data) {
|
socket.emit('posts.getUpvoters', [pid], function (err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.length) {
|
if (data.length) {
|
||||||
@@ -68,7 +68,7 @@ define('forum/topic/votes', [
|
|||||||
ajaxify.go('login');
|
ajaxify.go('login');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
hooks.fire('action:post.toggleVote', {
|
hooks.fire('action:post.toggleVote', {
|
||||||
pid: pid,
|
pid: pid,
|
||||||
@@ -88,7 +88,7 @@ define('forum/topic/votes', [
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Only show error if it's an unexpected error.
|
// Only show error if it's an unexpected error.
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.parseAndTranslate('partials/modals/votes_modal', data, function (html) {
|
app.parseAndTranslate('partials/modals/votes_modal', data, function (html) {
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
|
|
||||||
define('forum/unread', [
|
define('forum/unread', [
|
||||||
'topicSelect', 'components', 'topicList', 'categorySelector',
|
'topicSelect', 'components', 'topicList', 'categorySelector', 'alerts',
|
||||||
], function (topicSelect, components, topicList, categorySelector) {
|
], function (topicSelect, components, topicList, categorySelector, alerts) {
|
||||||
const Unread = {};
|
const Unread = {};
|
||||||
|
|
||||||
const watchStates = {
|
const watchStates = {
|
||||||
@@ -26,10 +26,10 @@ define('forum/unread', [
|
|||||||
function markAllRead() {
|
function markAllRead() {
|
||||||
socket.emit('topics.markAllRead', function (err) {
|
socket.emit('topics.markAllRead', function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
app.alertSuccess('[[unread:topics_marked_as_read.success]]');
|
alerts.success('[[unread:topics_marked_as_read.success]]');
|
||||||
|
|
||||||
$('[component="category"]').empty();
|
$('[component="category"]').empty();
|
||||||
$('[component="pagination"]').addClass('hidden');
|
$('[component="pagination"]').addClass('hidden');
|
||||||
@@ -45,7 +45,7 @@ define('forum/unread', [
|
|||||||
}
|
}
|
||||||
socket.emit('topics.markAsRead', tids, function (err) {
|
socket.emit('topics.markAsRead', tids, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
doneRemovingTids(tids);
|
doneRemovingTids(tids);
|
||||||
@@ -64,7 +64,7 @@ define('forum/unread', [
|
|||||||
|
|
||||||
socket.emit('topics.markCategoryTopicsRead', cid, function (err) {
|
socket.emit('topics.markCategoryTopicsRead', cid, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
doneRemovingTids(tids);
|
doneRemovingTids(tids);
|
||||||
@@ -101,7 +101,7 @@ define('forum/unread', [
|
|||||||
function doneRemovingTids(tids) {
|
function doneRemovingTids(tids) {
|
||||||
removeTids(tids);
|
removeTids(tids);
|
||||||
|
|
||||||
app.alertSuccess('[[unread:topics_marked_as_read.success]]');
|
alerts.success('[[unread:topics_marked_as_read.success]]');
|
||||||
|
|
||||||
if (!$('[component="category"]').children().length) {
|
if (!$('[component="category"]').children().length) {
|
||||||
$('#category-no-topics').removeClass('hidden');
|
$('#category-no-topics').removeClass('hidden');
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
|
|
||||||
define('forum/users', [
|
define('forum/users', [
|
||||||
'translator', 'benchpress', 'api', 'accounts/invite',
|
'translator', 'benchpress', 'api', 'alerts', 'accounts/invite',
|
||||||
], function (translator, Benchpress, api, AccountInvite) {
|
], function (translator, Benchpress, api, alerts, AccountInvite) {
|
||||||
const Users = {};
|
const Users = {};
|
||||||
|
|
||||||
let searchResultCount = 0;
|
let searchResultCount = 0;
|
||||||
@@ -82,7 +82,7 @@ define('forum/users', [
|
|||||||
function loadPage(query) {
|
function loadPage(query) {
|
||||||
api.get('/api/users', query)
|
api.get('/api/users', query)
|
||||||
.then(renderSearchResults)
|
.then(renderSearchResults)
|
||||||
.catch(app.alertError);
|
.catch(alerts.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderSearchResults(data) {
|
function renderSearchResults(data) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('accounts/delete', ['api', 'bootbox'], function (api, bootbox) {
|
define('accounts/delete', ['api', 'bootbox', 'alerts'], function (api, bootbox, alerts) {
|
||||||
const Delete = {};
|
const Delete = {};
|
||||||
|
|
||||||
Delete.account = function (uid, callback) {
|
Delete.account = function (uid, callback) {
|
||||||
@@ -40,14 +40,12 @@ define('accounts/delete', ['api', 'bootbox'], function (api, bootbox) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
api.del(`/users/${uid}${path}`, {}).then(() => {
|
api.del(`/users/${uid}${path}`, {}).then(() => {
|
||||||
app.alertSuccess(successText);
|
alerts.success(successText);
|
||||||
|
|
||||||
if (typeof callback === 'function') {
|
if (typeof callback === 'function') {
|
||||||
return callback();
|
return callback();
|
||||||
}
|
}
|
||||||
}).catch(function (err) {
|
}).catch(alerts.error);
|
||||||
app.alertError(err);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('accounts/invite', ['api', 'benchpress', 'bootbox'], function (api, Benchpress, bootbox) {
|
define('accounts/invite', ['api', 'benchpress', 'bootbox', 'alerts'], function (api, Benchpress, bootbox, alerts) {
|
||||||
const Invite = {};
|
const Invite = {};
|
||||||
|
|
||||||
function isACP() {
|
function isACP() {
|
||||||
@@ -29,9 +29,7 @@ define('accounts/invite', ['api', 'benchpress', 'bootbox'], function (api, Bench
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}).catch((err) => {
|
}).catch(alerts.error);
|
||||||
app.alertError(err.message);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -54,10 +52,8 @@ define('accounts/invite', ['api', 'benchpress', 'bootbox'], function (api, Bench
|
|||||||
}
|
}
|
||||||
|
|
||||||
api.post(`/users/${app.user.uid}/invites`, data).then(() => {
|
api.post(`/users/${app.user.uid}/invites`, data).then(() => {
|
||||||
app.alertSuccess(`[[${isACP() ? 'admin/manage/users:alerts.email-sent-to' : 'users:invitation-email-sent'}, ${data.emails.replace(/,/g, ', ')}]]`);
|
alerts.success(`[[${isACP() ? 'admin/manage/users:alerts.email-sent-to' : 'users:invitation-email-sent'}, ${data.emails.replace(/,/g, ', ')}]]`);
|
||||||
}).catch((err) => {
|
}).catch(alerts.error);
|
||||||
app.alertError(err.message);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return Invite;
|
return Invite;
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ define('accounts/picture', [
|
|||||||
'pictureCropper',
|
'pictureCropper',
|
||||||
'api',
|
'api',
|
||||||
'bootbox',
|
'bootbox',
|
||||||
], (pictureCropper, api, bootbox) => {
|
'alerts',
|
||||||
|
], (pictureCropper, api, bootbox, alerts) => {
|
||||||
const Picture = {};
|
const Picture = {};
|
||||||
|
|
||||||
Picture.openChangeModal = () => {
|
Picture.openChangeModal = () => {
|
||||||
@@ -12,7 +13,7 @@ define('accounts/picture', [
|
|||||||
uid: ajaxify.data.uid,
|
uid: ajaxify.data.uid,
|
||||||
}, function (err, pictures) {
|
}, function (err, pictures) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
// boolean to signify whether an uploaded picture is present in the pictures list
|
// boolean to signify whether an uploaded picture is present in the pictures list
|
||||||
@@ -94,7 +95,7 @@ define('accounts/picture', [
|
|||||||
changeUserPicture(type, iconBgColor).then(() => {
|
changeUserPicture(type, iconBgColor).then(() => {
|
||||||
Picture.updateHeader(type === 'default' ? '' : modal.find('.list-group-item.active img').attr('src'), iconBgColor);
|
Picture.updateHeader(type === 'default' ? '' : modal.find('.list-group-item.active img').attr('src'), iconBgColor);
|
||||||
ajaxify.refresh();
|
ajaxify.refresh();
|
||||||
}).catch(app.alertError);
|
}).catch(alerts.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onCloseModal() {
|
function onCloseModal() {
|
||||||
@@ -203,7 +204,7 @@ define('accounts/picture', [
|
|||||||
}, function (err) {
|
}, function (err) {
|
||||||
modal.modal('hide');
|
modal.modal('hide');
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
onRemoveComplete();
|
onRemoveComplete();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('autocomplete', ['api'], function (api) {
|
define('autocomplete', ['api', 'alerts'], function (api, alerts) {
|
||||||
const module = {};
|
const module = {};
|
||||||
|
|
||||||
module.user = function (input, params, onselect) {
|
module.user = function (input, params, onselect) {
|
||||||
@@ -25,7 +25,7 @@ define('autocomplete', ['api'], function (api) {
|
|||||||
|
|
||||||
api.get('/api/users', params, function (err, result) {
|
api.get('/api/users', params, function (err, result) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result && result.users) {
|
if (result && result.users) {
|
||||||
@@ -72,7 +72,7 @@ define('autocomplete', ['api'], function (api) {
|
|||||||
query: request.term,
|
query: request.term,
|
||||||
}, function (err, results) {
|
}, function (err, results) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
if (results && results.length) {
|
if (results && results.length) {
|
||||||
const names = results.map(function (group) {
|
const names = results.map(function (group) {
|
||||||
@@ -107,7 +107,7 @@ define('autocomplete', ['api'], function (api) {
|
|||||||
cid: ajaxify.data.cid || 0,
|
cid: ajaxify.data.cid || 0,
|
||||||
}, function (err, tags) {
|
}, function (err, tags) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
if (tags) {
|
if (tags) {
|
||||||
response(tags);
|
response(tags);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('categorySearch', function () {
|
define('categorySearch', ['alerts'], function (alerts) {
|
||||||
const categorySearch = {};
|
const categorySearch = {};
|
||||||
|
|
||||||
categorySearch.init = function (el, options) {
|
categorySearch.init = function (el, options) {
|
||||||
@@ -77,7 +77,7 @@ define('categorySearch', function () {
|
|||||||
showLinks: options.showLinks,
|
showLinks: options.showLinks,
|
||||||
}, function (err, categories) {
|
}, function (err, categories) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
callback(localCategories.concat(categories));
|
callback(localCategories.concat(categories));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('chat', [
|
define('chat', [
|
||||||
'components', 'taskbar', 'translator', 'hooks', 'bootbox',
|
'components', 'taskbar', 'translator', 'hooks', 'bootbox', 'alerts'
|
||||||
], function (components, taskbar, translator, hooks, bootbox) {
|
], function (components, taskbar, translator, hooks, bootbox, alerts) {
|
||||||
const module = {};
|
const module = {};
|
||||||
let newMessage = false;
|
let newMessage = false;
|
||||||
|
|
||||||
module.openChat = function (roomId, uid) {
|
module.openChat = function (roomId, uid) {
|
||||||
if (!app.user.uid) {
|
if (!app.user.uid) {
|
||||||
return app.alertError('[[error:not-logged-in]]');
|
return alerts.error('[[error:not-logged-in]]');
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadAndCenter(chatModal) {
|
function loadAndCenter(chatModal) {
|
||||||
@@ -22,7 +22,7 @@ define('chat', [
|
|||||||
} else {
|
} else {
|
||||||
socket.emit('modules.chats.loadRoom', { roomId: roomId, uid: uid || app.user.uid }, function (err, roomData) {
|
socket.emit('modules.chats.loadRoom', { roomId: roomId, uid: uid || app.user.uid }, function (err, roomData) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
roomData.users = roomData.users.filter(function (user) {
|
roomData.users = roomData.users.filter(function (user) {
|
||||||
return user && parseInt(user.uid, 10) !== parseInt(app.user.uid, 10);
|
return user && parseInt(user.uid, 10) !== parseInt(app.user.uid, 10);
|
||||||
@@ -38,7 +38,7 @@ define('chat', [
|
|||||||
function createChat() {
|
function createChat() {
|
||||||
socket.emit('modules.chats.newRoom', { touid: touid }, function (err, roomId) {
|
socket.emit('modules.chats.newRoom', { touid: touid }, function (err, roomId) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ajaxify.data.template.chats) {
|
if (!ajaxify.data.template.chats) {
|
||||||
@@ -53,15 +53,15 @@ define('chat', [
|
|||||||
|
|
||||||
callback = callback || function () { };
|
callback = callback || function () { };
|
||||||
if (!app.user.uid) {
|
if (!app.user.uid) {
|
||||||
return app.alertError('[[error:not-logged-in]]');
|
return alerts.error('[[error:not-logged-in]]');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parseInt(touid, 10) === parseInt(app.user.uid, 10)) {
|
if (parseInt(touid, 10) === parseInt(app.user.uid, 10)) {
|
||||||
return app.alertError('[[error:cant-chat-with-yourself]]');
|
return alerts.error('[[error:cant-chat-with-yourself]]');
|
||||||
}
|
}
|
||||||
socket.emit('modules.chats.isDnD', touid, function (err, isDnD) {
|
socket.emit('modules.chats.isDnD', touid, function (err, isDnD) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
if (!isDnD) {
|
if (!isDnD) {
|
||||||
return createChat();
|
return createChat();
|
||||||
@@ -81,7 +81,7 @@ define('chat', [
|
|||||||
after: 0,
|
after: 0,
|
||||||
}, function (err, data) {
|
}, function (err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
const rooms = data.rooms.filter(function (room) {
|
const rooms = data.rooms.filter(function (room) {
|
||||||
@@ -112,7 +112,7 @@ define('chat', [
|
|||||||
$('[component="chats/mark-all-read"]').off('click').on('click', function () {
|
$('[component="chats/mark-all-read"]').off('click').on('click', function () {
|
||||||
socket.emit('modules.chats.markAllRead', function (err) {
|
socket.emit('modules.chats.markAllRead', function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -134,7 +134,7 @@ define('chat', [
|
|||||||
roomId: data.roomId,
|
roomId: data.roomId,
|
||||||
}, function (err, roomData) {
|
}, function (err, roomData) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
roomData.users = roomData.users.filter(function (user) {
|
roomData.users = roomData.users.filter(function (user) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
define('flags', ['hooks', 'components', 'api'], function (hooks, components, api) {
|
define('flags', ['hooks', 'components', 'api', 'alerts'], function (hooks, components, api, alerts) {
|
||||||
const Flag = {};
|
const Flag = {};
|
||||||
let flagModal;
|
let flagModal;
|
||||||
let flagCommit;
|
let flagCommit;
|
||||||
@@ -57,9 +57,9 @@ define('flags', ['hooks', 'components', 'api'], function (hooks, components, api
|
|||||||
api.put(`/flags/${flagId}`, {
|
api.put(`/flags/${flagId}`, {
|
||||||
state: 'resolved',
|
state: 'resolved',
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
app.alertSuccess('[[flags:resolved]]');
|
alerts.success('[[flags:resolved]]');
|
||||||
hooks.fire('action:flag.resolved', { flagId: flagId });
|
hooks.fire('action:flag.resolved', { flagId: flagId });
|
||||||
}).catch(app.alertError);
|
}).catch(alerts.error);
|
||||||
};
|
};
|
||||||
|
|
||||||
function createFlag(type, id, reason) {
|
function createFlag(type, id, reason) {
|
||||||
@@ -69,11 +69,11 @@ define('flags', ['hooks', 'components', 'api'], function (hooks, components, api
|
|||||||
const data = { type: type, id: id, reason: reason };
|
const data = { type: type, id: id, reason: reason };
|
||||||
api.post('/flags', data, function (err, flagId) {
|
api.post('/flags', data, function (err, flagId) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
flagModal.modal('hide');
|
flagModal.modal('hide');
|
||||||
app.alertSuccess('[[flags:modal-submit-success]]');
|
alerts.success('[[flags:modal-submit-success]]');
|
||||||
if (type === 'post') {
|
if (type === 'post') {
|
||||||
const postEl = components.get('post', 'pid', id);
|
const postEl = components.get('post', 'pid', id);
|
||||||
postEl.find('[component="post/flag"]').addClass('hidden').parent().attr('hidden', '');
|
postEl.find('[component="post/flag"]').addClass('hidden').parent().attr('hidden', '');
|
||||||
|
|||||||
@@ -38,9 +38,9 @@ define('messages', ['bootbox', 'translator', 'storage', 'alerts'], function (boo
|
|||||||
app.removeAlert('email_confirm');
|
app.removeAlert('email_confirm');
|
||||||
socket.emit('user.emailConfirm', {}, function (err) {
|
socket.emit('user.emailConfirm', {}, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
app.alertSuccess('[[notifications:email-confirm-sent]]');
|
alerts.success('[[notifications:email-confirm-sent]]');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
alerts.alert(msg);
|
alerts.alert(msg);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('navigator', ['forum/pagination', 'components', 'hooks'], function (pagination, components, hooks) {
|
define('navigator', ['forum/pagination', 'components', 'hooks', 'alerts'], function (pagination, components, hooks, alerts) {
|
||||||
const navigator = {};
|
const navigator = {};
|
||||||
let index = 0;
|
let index = 0;
|
||||||
let count = 0;
|
let count = 0;
|
||||||
@@ -251,7 +251,7 @@ define('navigator', ['forum/pagination', 'components', 'hooks'], function (pagin
|
|||||||
|
|
||||||
socket.emit('posts.getPostSummaryByIndex', { tid: ajaxify.data.tid, index: index - 1 }, function (err, postData) {
|
socket.emit('posts.getPostSummaryByIndex', { tid: ajaxify.data.tid, index: index - 1 }, function (err, postData) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
app.parseAndTranslate('partials/topic/navigation-post', { post: postData }, function (html) {
|
app.parseAndTranslate('partials/topic/navigation-post', { post: postData }, function (html) {
|
||||||
paginationBlockEl
|
paginationBlockEl
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ define('notifications', [
|
|||||||
'translator',
|
'translator',
|
||||||
'components',
|
'components',
|
||||||
'navigator',
|
'navigator',
|
||||||
'benchpress',
|
|
||||||
'tinycon',
|
'tinycon',
|
||||||
'hooks',
|
'hooks',
|
||||||
], function (translator, components, navigator, Benchpress, Tinycon, hooks) {
|
'alerts',
|
||||||
|
], function (translator, components, navigator, Tinycon, hooks, alerts) {
|
||||||
const Notifications = {};
|
const Notifications = {};
|
||||||
|
|
||||||
let unreadNotifs = {};
|
let unreadNotifs = {};
|
||||||
@@ -28,7 +28,7 @@ define('notifications', [
|
|||||||
callback = callback || function () {};
|
callback = callback || function () {};
|
||||||
socket.emit('notifications.get', null, function (err, data) {
|
socket.emit('notifications.get', null, function (err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
const notifs = data.unread.concat(data.read).sort(function (a, b) {
|
const notifs = data.unread.concat(data.read).sort(function (a, b) {
|
||||||
@@ -82,7 +82,7 @@ define('notifications', [
|
|||||||
|
|
||||||
socket.emit('notifications.getCount', function (err, count) {
|
socket.emit('notifications.getCount', function (err, count) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
Notifications.updateNotifCount(count);
|
Notifications.updateNotifCount(count);
|
||||||
@@ -96,7 +96,7 @@ define('notifications', [
|
|||||||
function markNotification(nid, read, callback) {
|
function markNotification(nid, read, callback) {
|
||||||
socket.emit('notifications.mark' + (read ? 'Read' : 'Unread'), nid, function (err) {
|
socket.emit('notifications.mark' + (read ? 'Read' : 'Unread'), nid, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (read && unreadNotifs[nid]) {
|
if (read && unreadNotifs[nid]) {
|
||||||
@@ -150,7 +150,7 @@ define('notifications', [
|
|||||||
Notifications.markAllRead = function () {
|
Notifications.markAllRead = function () {
|
||||||
socket.emit('notifications.markAllRead', function (err) {
|
socket.emit('notifications.markAllRead', function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
app.alertError(err.message);
|
alerts.error(err);
|
||||||
}
|
}
|
||||||
unreadNotifs = {};
|
unreadNotifs = {};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('pictureCropper', ['cropper'], function (Cropper) {
|
define('pictureCropper', ['cropper', 'alerts'], function (Cropper, alerts) {
|
||||||
const module = {};
|
const module = {};
|
||||||
|
|
||||||
module.show = function (data, callback) {
|
module.show = function (data, callback) {
|
||||||
@@ -118,7 +118,7 @@ define('pictureCropper', ['cropper'], function (Cropper) {
|
|||||||
cropperModal.find('#upload-progress-box').hide();
|
cropperModal.find('#upload-progress-box').hide();
|
||||||
cropperModal.find('.upload-btn').removeClass('disabled');
|
cropperModal.find('.upload-btn').removeClass('disabled');
|
||||||
cropperModal.find('.crop-btn').removeClass('disabled');
|
cropperModal.find('.crop-btn').removeClass('disabled');
|
||||||
return app.alertError(err.message);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(result.url);
|
callback(result.url);
|
||||||
@@ -158,7 +158,7 @@ define('pictureCropper', ['cropper'], function (Cropper) {
|
|||||||
params: socketData,
|
params: socketData,
|
||||||
}, function (err, result) {
|
}, function (err, result) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return app.alertError(err);
|
return alerts.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (socketData.progress + chunkSize < socketData.size) {
|
if (socketData.progress + chunkSize < socketData.size) {
|
||||||
@@ -185,9 +185,9 @@ define('pictureCropper', ['cropper'], function (Cropper) {
|
|||||||
'Failed to execute \'toDataURL\' on \'HTMLCanvasElement\': Tainted canvases may not be exported.',
|
'Failed to execute \'toDataURL\' on \'HTMLCanvasElement\': Tainted canvases may not be exported.',
|
||||||
];
|
];
|
||||||
if (corsErrors.indexOf(err.message) !== -1) {
|
if (corsErrors.indexOf(err.message) !== -1) {
|
||||||
app.alertError('[[error:cors-error]]');
|
alerts.error('[[error:cors-error]]');
|
||||||
} else {
|
} else {
|
||||||
app.alertError(err.message);
|
alerts.error(err.message);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ define('search', ['translator', 'storage', 'hooks', 'alerts'], function (transla
|
|||||||
try {
|
try {
|
||||||
term = encodeURIComponent(term);
|
term = encodeURIComponent(term);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return app.alertError('[[error:invalid-search-term]]');
|
return alerts.error('[[error:invalid-search-term]]');
|
||||||
}
|
}
|
||||||
|
|
||||||
const query = {
|
const query = {
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define('topicThumbs', ['api', 'bootbox', 'uploader', 'benchpress', 'translator', 'jquery-ui/widgets/sortable'], function (api, bootbox, uploader, Benchpress, translator) {
|
define('topicThumbs', [
|
||||||
|
'api', 'bootbox', 'alerts', 'uploader', 'benchpress', 'translator', 'jquery-ui/widgets/sortable',
|
||||||
|
], function (api, bootbox, alerts, uploader, Benchpress, translator) {
|
||||||
const Thumbs = {};
|
const Thumbs = {};
|
||||||
|
|
||||||
Thumbs.get = id => api.get(`/topics/${id}/thumbs`, {});
|
Thumbs.get = id => api.get(`/topics/${id}/thumbs`, {});
|
||||||
@@ -97,7 +99,7 @@ define('topicThumbs', ['api', 'bootbox', 'uploader', 'benchpress', 'translator',
|
|||||||
path: path,
|
path: path,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
Thumbs.modal.open(payload);
|
Thumbs.modal.open(payload);
|
||||||
}).catch(app.alertError);
|
}).catch(alerts.error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -120,7 +122,7 @@ define('topicThumbs', ['api', 'bootbox', 'uploader', 'benchpress', 'translator',
|
|||||||
let path = el.getAttribute('data-path');
|
let path = el.getAttribute('data-path');
|
||||||
path = path.replace(new RegExp(`^${config.upload_url}`), '');
|
path = path.replace(new RegExp(`^${config.upload_url}`), '');
|
||||||
|
|
||||||
api.put(`/topics/${id}/thumbs/order`, { path, order }).catch(app.alertError);
|
api.put(`/topics/${id}/thumbs/order`, { path, order }).catch(alerts.error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user