Skip to content

Commit

Permalink
Readded reskin function.
Browse files Browse the repository at this point in the history
  • Loading branch information
jullia andrei committed Sep 5, 2024
1 parent 2768a0e commit ff59a39
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 5 deletions.
Binary file modified dump.rdb
Binary file not shown.
54 changes: 49 additions & 5 deletions public/src/client/account/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

define('forum/account/settings', [
'forum/account/header', 'components', 'api', 'alerts',
], function (header, components, api, alerts) {
], function (header, components, api, alerts, hooks) {
const AccountSettings = {};
let savedSkin = '';

Expand Down Expand Up @@ -62,10 +62,12 @@ define('forum/account/settings', [
}

function saveSettings(settings) {
console.log('Logging Jullia ');
api.put(`/users/${ajaxify.data.uid}/settings`, { settings }).then(handleNewSettings);
}

function handleNewSettings(newSettings) {
console.log('Logging Jullia');
alerts.success('[[success:settings-saved]]');
processNewSettings(newSettings);
}
Expand Down Expand Up @@ -93,10 +95,52 @@ define('forum/account/settings', [
config.bootswatchSkin = skin === 'noskin' ? '' : skin;
}

function reskin(skin) {
// Implement the logic to reskin the application
// This is a placeholder function and should be implemented as needed
console.log(`Reskinning to: ${skin}`);
function reskin(skinName) {
const clientEl = Array.prototype.filter.call(document.querySelectorAll('link[rel="stylesheet"]'), function (el) {
return el.href.indexOf(config.relative_path + '/assets/client') !== -1;
})[0] || null;
if (!clientEl) {
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-');
});
if (!currentSkinClassName[0]) {
return;
}
let currentSkin = currentSkinClassName[0].slice(5);
currentSkin = currentSkin !== 'noskin' ? currentSkin : '';

// Stop execution if skin didn't change
if (skinName === currentSkin) {
hooks.fire('action:skin.change', { skin: skinName, currentSkin });
return;
}
const langDir = $('html').attr('data-dir');
const linkEl = document.createElement('link');
linkEl.rel = 'stylesheet';
linkEl.type = 'text/css';
linkEl.href = config.relative_path +
'/assets/client' + (skinName ? '-' + skinName : '') +
(langDir === 'rtl' ? '-rtl' : '') +
'.css?' + config['cache-buster'];
linkEl.onload = function () {
clientEl.parentNode.removeChild(clientEl);

// Update body class with proper skin name
$('body').removeClass(currentSkinClassName.join(' '));
$('body').addClass('skin-' + (skinName || 'noskin'));
hooks.fire('action:skin.change', { skin: skinName, currentSkin });
};

document.head.appendChild(linkEl);
}

function toggleCustomRoute() {
Expand Down

0 comments on commit ff59a39

Please sign in to comment.