diff --git a/__pycache__/models.cpython-313.pyc b/__pycache__/models.cpython-313.pyc index ba276ec..9f733d1 100644 Binary files a/__pycache__/models.cpython-313.pyc and b/__pycache__/models.cpython-313.pyc differ diff --git a/routes/__pycache__/main.cpython-313.pyc b/routes/__pycache__/main.cpython-313.pyc index 0b8cc23..ffb86a1 100644 Binary files a/routes/__pycache__/main.cpython-313.pyc and b/routes/__pycache__/main.cpython-313.pyc differ diff --git a/routes/main.py b/routes/main.py index d7773bb..42d4fa2 100644 --- a/routes/main.py +++ b/routes/main.py @@ -331,9 +331,11 @@ def init_routes(main_bp): return redirect(url_for('main.dashboard')) site_settings = SiteSettings.get_settings() + active_tab = request.args.get('tab', 'colors') return render_template('settings/settings.html', primary_color=site_settings.primary_color, - secondary_color=site_settings.secondary_color) + secondary_color=site_settings.secondary_color, + active_tab=active_tab) @main_bp.route('/settings/colors', methods=['POST']) @login_required diff --git a/static/js/settings.js b/static/js/settings.js index c748ad5..81c3e83 100644 --- a/static/js/settings.js +++ b/static/js/settings.js @@ -2,6 +2,45 @@ document.addEventListener('DOMContentLoaded', function() { const primaryColorInput = document.getElementById('primaryColor'); const secondaryColorInput = document.getElementById('secondaryColor'); + // Tab persistence + const settingsTabs = document.querySelectorAll('#settingsTabs button[data-bs-toggle="tab"]'); + const tabContent = document.querySelectorAll('.tab-pane'); + + // Function to activate a specific tab + function activateTab(tabId) { + // Remove active class from all tabs and content + settingsTabs.forEach(tab => { + tab.classList.remove('active'); + tab.setAttribute('aria-selected', 'false'); + }); + tabContent.forEach(content => { + content.classList.remove('show', 'active'); + }); + + // Activate the selected tab + const selectedTab = document.querySelector(`#${tabId}-tab`); + const selectedContent = document.getElementById(tabId); + if (selectedTab && selectedContent) { + selectedTab.classList.add('active'); + selectedTab.setAttribute('aria-selected', 'true'); + selectedContent.classList.add('show', 'active'); + // Save to localStorage + localStorage.setItem('settingsActiveTab', tabId); + } + } + + // Add click event listeners to tabs + settingsTabs.forEach(tab => { + tab.addEventListener('click', (e) => { + const tabId = e.target.getAttribute('data-bs-target').substring(1); + activateTab(tabId); + }); + }); + + // Restore active tab from localStorage or URL hash + const savedTab = localStorage.getItem('settingsActiveTab') || window.location.hash.substring(1) || 'colors'; + activateTab(savedTab); + // Color manipulation functions function hexToRgb(hex) { const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); diff --git a/templates/settings/settings.html b/templates/settings/settings.html index 96b11df..a27b262 100644 --- a/templates/settings/settings.html +++ b/templates/settings/settings.html @@ -23,42 +23,40 @@