mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-28 01:21:13 +01:00
fix: alert on page load
This commit is contained in:
committed by
Julian Lam
parent
3bd9a87154
commit
8cf4a6f62e
@@ -9,15 +9,23 @@ define('admin/settings/email', ['ace/ace', 'alerts', 'admin/settings'], function
|
|||||||
configureEmailTester();
|
configureEmailTester();
|
||||||
configureEmailEditor();
|
configureEmailEditor();
|
||||||
handleDigestHourChange();
|
handleDigestHourChange();
|
||||||
handleSmtpServiceChange();
|
|
||||||
|
|
||||||
$(window).on('action:admin.settingsLoaded action:admin.settingsSaved', handleDigestHourChange);
|
$(window).off('action:admin.settingsLoaded', onSettingsLoaded)
|
||||||
$(window).on('action:admin.settingsSaved', function () {
|
.on('action:admin.settingsLoaded', onSettingsLoaded);
|
||||||
socket.emit('admin.user.restartJobs');
|
$(window).off('action:admin.settingsSaved', onSettingsSaved)
|
||||||
});
|
.on('action:admin.settingsSaved', onSettingsSaved);
|
||||||
$('[id="email:smtpTransport:service"]').change(handleSmtpServiceChange);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function onSettingsLoaded() {
|
||||||
|
handleDigestHourChange();
|
||||||
|
handleSmtpServiceChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSettingsSaved() {
|
||||||
|
handleDigestHourChange();
|
||||||
|
socket.emit('admin.user.restartJobs');
|
||||||
|
}
|
||||||
|
|
||||||
function configureEmailTester() {
|
function configureEmailTester() {
|
||||||
$('button[data-action="email.test"]').off('click').on('click', function () {
|
$('button[data-action="email.test"]').off('click').on('click', function () {
|
||||||
socket.emit('admin.email.test', { template: $('#test-email').val() }, function (err) {
|
socket.emit('admin.email.test', { template: $('#test-email').val() }, function (err) {
|
||||||
@@ -106,20 +114,26 @@ define('admin/settings/email', ['ace/ace', 'alerts', 'admin/settings'], function
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleSmtpServiceChange() {
|
function handleSmtpServiceChange() {
|
||||||
const isCustom = $('[id="email:smtpTransport:service"]').val() === 'nodebb-custom-smtp';
|
function toggleCustomService() {
|
||||||
$('[id="email:smtpTransport:custom-service"]')[isCustom ? 'slideDown' : 'slideUp'](isCustom);
|
const isCustom = $('[id="email:smtpTransport:service"]').val() === 'nodebb-custom-smtp';
|
||||||
|
$('[id="email:smtpTransport:custom-service"]')[isCustom ? 'slideDown' : 'slideUp'](isCustom);
|
||||||
const enabledEl = document.getElementById('email:smtpTransport:enabled');
|
|
||||||
if (enabledEl) {
|
|
||||||
if (!enabledEl.checked) {
|
|
||||||
enabledEl.closest('label').classList.toggle('is-checked', true);
|
|
||||||
enabledEl.checked = true;
|
|
||||||
alerts.alert({
|
|
||||||
message: '[[admin/settings/email:smtp-transport.auto-enable-toast]]',
|
|
||||||
timeout: 5000,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
toggleCustomService();
|
||||||
|
$('[id="email:smtpTransport:service"]').change(function () {
|
||||||
|
toggleCustomService();
|
||||||
|
|
||||||
|
const enabledEl = document.getElementById('email:smtpTransport:enabled');
|
||||||
|
if (enabledEl) {
|
||||||
|
if (!enabledEl.checked) {
|
||||||
|
$('label[for="email:smtpTransport:enabled"]').toggleClass('is-checked', true);
|
||||||
|
enabledEl.checked = true;
|
||||||
|
alerts.alert({
|
||||||
|
message: '[[admin/settings/email:smtp-transport.auto-enable-toast]]',
|
||||||
|
timeout: 5000,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return module;
|
return module;
|
||||||
|
|||||||
@@ -150,7 +150,7 @@
|
|||||||
[[admin/settings/email:smtp-transport.gmail-warning2]]
|
[[admin/settings/email:smtp-transport.gmail-warning2]]
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group well" id="email:smtpTransport:custom-service" style="display: none">
|
<div class="form-group well" id="email:smtpTransport:custom-service">
|
||||||
<h5>Custom Service</h5>
|
<h5>Custom Service</h5>
|
||||||
|
|
||||||
<label for="email:smtpTransport:host">[[admin/settings/email:smtp-transport.host]]</label>
|
<label for="email:smtpTransport:host">[[admin/settings/email:smtp-transport.host]]</label>
|
||||||
|
|||||||
Reference in New Issue
Block a user