feat: bring back noskin option

if forum sets a default skin there was no way for the user to go back to the no skin version
This commit is contained in:
Barış Soner Uşaklı
2023-06-10 11:55:59 -04:00
parent 33a6b3e1da
commit 2edfe0ef3e
7 changed files with 51 additions and 19 deletions

View File

@@ -155,6 +155,8 @@
"no-group-title": "No group title",
"select-skin": "Select a Skin",
"default": "Default (%1)",
"no-skin": "No Skin",
"select-homepage": "Select a Homepage",
"homepage": "Homepage",

View File

@@ -108,6 +108,8 @@ get:
type: boolean
bootswatchSkin:
type: string
defaultBootswatchSkin:
type: string
composer:showHelpTab:
type: boolean
enablePostHistory:

View File

@@ -5,15 +5,19 @@ define('forum/account/settings', [
'forum/account/header', 'components', 'api', 'alerts', 'hooks',
], function (header, components, api, alerts, hooks) {
const AccountSettings = {};
let savedSkin = '';
// If page skin is changed but not saved, switch the skin back
$(window).on('action:ajaxify.start', function () {
if (ajaxify.data.template.name === 'account/settings' && $('#bootswatchSkin').length && $('#bootswatchSkin').val() !== config.bootswatchSkin) {
reskin(config.bootswatchSkin);
const skinEl = $('#bootswatchSkin');
if (
ajaxify.data.template.name === 'account/settings' &&
skinEl.length && skinEl.val() !== savedSkin) {
reskin(savedSkin);
}
});
AccountSettings.init = function () {
savedSkin = $('#bootswatchSkin').length && $('#bootswatchSkin').val();
header.init();
$('#submitBtn').on('click', function () {
@@ -76,7 +80,10 @@ define('forum/account/settings', [
if (key === 'userLang' && config.userLang !== newSettings.userLang) {
languageChanged = true;
}
if (config.hasOwnProperty(key)) {
if (key === 'bootswatchSkin') {
savedSkin = newSettings.bootswatchSkin;
config.bootswatchSkin = savedSkin === 'noskin' ? '' : savedSkin;
} else if (config.hasOwnProperty(key)) {
config[key] = newSettings[key];
}
}
@@ -105,6 +112,12 @@ define('forum/account/settings', [
return;
}
if (skinName === '') {
skinName = config.defaultBootswatchSkin || '';
} else if (skinName === 'noskin') {
skinName = '';
}
const currentSkinClassName = $('body').attr('class').split(/\s+/).filter(function (className) {
return className.startsWith('skin-');
});
@@ -143,7 +156,8 @@ define('forum/account/settings', [
if (app.user.uid) {
await api.put(`/users/${app.user.uid}/settings`, { settings: { bootswatchSkin: skin } });
}
config.bootswatchSkin = skin;
config.bootswatchSkin = skin === 'noskin' ? '' : skin;
savedSkin = skin;
reskin(skin);
};