-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin-js.js
More file actions
41 lines (33 loc) · 1.28 KB
/
admin-js.js
File metadata and controls
41 lines (33 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
document.addEventListener('DOMContentLoaded', function () {
const sidebarLinks = document.querySelectorAll('.swrt-settings-sidebar a');
const sections = document.querySelectorAll('.swrt-settings-content section');
const storageKey = 'swrt_theme_settings_active_tab';
if (!sidebarLinks.length || !sections.length) return;
// Function to switch tabs
function switchTab(targetID) {
// Remove active class from all links
sidebarLinks.forEach(l => l.classList.remove('active'));
// Hide all sections
sections.forEach(sec => sec.style.display = 'none');
// Find and activate the target link
const targetLink = document.querySelector(`.swrt-settings-sidebar a[href="#${targetID}"]`);
if (targetLink) {
targetLink.classList.add('active');
}
// Show the selected section
const activeSection = document.getElementById(targetID);
if (activeSection) {
activeSection.style.display = 'block';
}
// Save to localStorage
localStorage.setItem(storageKey, targetID);
// Update hidden input field
const activeTabInput = document.getElementById('swrt-active-tab-input');
if (activeTabInput) {
activeTabInput.value = targetID;
}
}
// Add click event listeners to tabs
sidebarLinks.forEach(link => {
link.addEventListener('click', function (e) {
e.preventDefault();