settings site changes
This commit is contained in:
52
settings-site/public/js/router.js.bak-20260421
Normal file
52
settings-site/public/js/router.js.bak-20260421
Normal file
@@ -0,0 +1,52 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
const ROUTES = {
|
||||
'/': 's-core',
|
||||
'/channels': 's-channels',
|
||||
'/categories': 's-categories',
|
||||
'/gmail': 's-gmail',
|
||||
'/behavior': 's-behavior',
|
||||
'/threads': 's-threads',
|
||||
'/pins': 's-pins',
|
||||
'/notifications': 's-notifications',
|
||||
'/logging': 's-logging',
|
||||
'/automation': 's-automation',
|
||||
'/appearance': 's-appearance',
|
||||
'/staff': 's-staff',
|
||||
'/advanced': 's-advanced'
|
||||
};
|
||||
|
||||
function navigate(path, updateHistory = true) {
|
||||
const sectionId = ROUTES[path] || ROUTES['/'];
|
||||
const normalizedPath = ROUTES[path] ? path : '/';
|
||||
if (updateHistory) history.pushState({}, '', normalizedPath);
|
||||
|
||||
document.querySelectorAll('.section').forEach(section => {
|
||||
section.classList.toggle('hidden', section.id !== sectionId);
|
||||
});
|
||||
|
||||
document.querySelectorAll('.sidebar a').forEach(link => {
|
||||
link.classList.toggle('active', link.getAttribute('href') === normalizedPath);
|
||||
});
|
||||
}
|
||||
|
||||
function setupSidebarRouting() {
|
||||
const sidebar = document.querySelector('.sidebar');
|
||||
if (!sidebar) return;
|
||||
|
||||
sidebar.addEventListener('click', e => {
|
||||
const a = e.target.closest('a');
|
||||
if (!a) return;
|
||||
e.preventDefault();
|
||||
navigate(a.getAttribute('href'));
|
||||
if (Util.isMobileViewport()) Util.setSidebarOpen(false);
|
||||
});
|
||||
|
||||
window.addEventListener('popstate', () => {
|
||||
navigate(location.pathname, false);
|
||||
});
|
||||
}
|
||||
|
||||
window.Router = { ROUTES, navigate, setupSidebarRouting };
|
||||
})();
|
||||
Reference in New Issue
Block a user