Update index.html
Browse files- index.html +151 -51
index.html
CHANGED
|
@@ -451,7 +451,7 @@
|
|
| 451 |
|
| 452 |
<label class="font-medium text-xs pt-2 block">Bonus Icons</label>
|
| 453 |
<div class="flex items-center space-x-2"><input type="checkbox" id="lms-el-refresh" class="h-4 w-4 rounded"><label for="lms-el-refresh" class="text-sm">Refresh Icon 🔁</label></div>
|
| 454 |
-
<div class="flex items-center space-x-2"><input type="checkbox" id="lms-el-theme" class="h-4 w-4 rounded" checked><label for="lms-el-theme" class="text-sm">Theme Toggle 🌙</label></div>
|
| 455 |
<div class="flex items-center space-x-2"><input type="checkbox" id="lms-el-calendar" class="h-4 w-4 rounded"><label for="lms-el-calendar" class="text-sm">Calendar Icon 📅</label></div>
|
| 456 |
<div class="flex items-center space-x-2"><input type="checkbox" id="lms-el-share" class="h-4 w-4 rounded"><label for="lms-el-share" class="text-sm">Share Icon 📤</label></div>
|
| 457 |
</div>
|
|
@@ -507,6 +507,13 @@
|
|
| 507 |
<div id="sidebar-categories-builder" class="space-y-3 border-b pb-4"></div>
|
| 508 |
<div id="sidebar-user-section-builder" class="space-y-3 border-b pb-4"></div>
|
| 509 |
<div id="sidebar-shortcuts-builder" class="space-y-3 border-b pb-4"></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 510 |
<div id="sidebar-footer-builder" class="space-y-3 border-b pb-4"></div>
|
| 511 |
</div>
|
| 512 |
</div>
|
|
@@ -817,7 +824,7 @@
|
|
| 817 |
links: [ { icon: 'fas fa-leaf', text: 'Agriculture', url: '#', enabled: true }, ]
|
| 818 |
},
|
| 819 |
userSection: { enabled: true, title: 'User Account', links: [ { icon: 'fas fa-user-circle', text: 'Profile', url: '#', enabled: true }, ] },
|
| 820 |
-
shortcuts: { enabled: true, title: 'Shortcuts & CTA', links: [ { icon: 'fas fa-bell', text: 'Notifications', url: '#', badge: '3', enabled: true }, ] },
|
| 821 |
footer: { enabled: true, title: 'Support', links: [ { icon: 'fas fa-headset', text: 'Contact / Support', url: '#', enabled: true }, ] }
|
| 822 |
},
|
| 823 |
topBar: {
|
|
@@ -933,6 +940,7 @@
|
|
| 933 |
categoriesBuilder: document.getElementById('sidebar-categories-builder'),
|
| 934 |
userSectionBuilder: document.getElementById('sidebar-user-section-builder'),
|
| 935 |
shortcutsBuilder: document.getElementById('sidebar-shortcuts-builder'),
|
|
|
|
| 936 |
footerBuilder: document.getElementById('sidebar-footer-builder'),
|
| 937 |
},
|
| 938 |
topBar: {
|
|
@@ -1081,6 +1089,7 @@
|
|
| 1081 |
sidebarUI.brand.sitenameToggle.addEventListener('change', e => { sidebarConfig.branding.showSitename = e.target.checked; renderAll(); });
|
| 1082 |
sidebarUI.brand.sitename.addEventListener('input', e => { sidebarConfig.branding.sitename = e.target.value; renderAll(); });
|
| 1083 |
sidebarUI.brand.tagline.addEventListener('input', e => { sidebarConfig.branding.tagline = e.target.value; renderAll(); });
|
|
|
|
| 1084 |
|
| 1085 |
// Top Bar Listeners
|
| 1086 |
const topBarUI = ui.topBar;
|
|
@@ -1325,6 +1334,21 @@
|
|
| 1325 |
builderUI.addEventListener('change', handleChange);
|
| 1326 |
renderControls();
|
| 1327 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1328 |
function renderLmsTabsControls() {
|
| 1329 |
ui.learningAppHeader.tabs.container.innerHTML = config.learningAppHeader.tabs.items.map((tab, index) => `
|
| 1330 |
<div class="flex items-center gap-1 p-2 border rounded bg-white">
|
|
@@ -1579,13 +1603,13 @@
|
|
| 1579 |
sidebar: () => {
|
| 1580 |
if (!config.sidebar.enabled) return '';
|
| 1581 |
const s = config.sidebar;
|
| 1582 |
-
const brandHtml = `<div class="lms-sidebar-brand">${s.branding.showLogo ? `<img src="${config.learningAppHeader.primaryBar.brand.imageUrl}" alt="Logo" class="lms-sidebar-logo">` : ''}${s.branding.showSitename ? `<div class="lms-sidebar-sitename"><strong>${s.branding.sitename}</strong><small>${s.branding.tagline}</small></div>` : ''}<button class="lms-sidebar-toggle" id="lms-sidebar-collapse-btn"></button></div>`;
|
| 1583 |
const createLinkSection = (sec) => {
|
| 1584 |
if (!sec.enabled) return '';
|
| 1585 |
const links = sec.links.filter(l => l.enabled).map(l => {
|
| 1586 |
const badge = l.badge ? `<span class="sidebar-badge">${l.badge}</span>` : '';
|
| 1587 |
-
const
|
| 1588 |
-
return `<li><a href="${l.url}" ${
|
| 1589 |
}).join('');
|
| 1590 |
return `<nav class="lms-sidebar-nav"><ul>${links}</ul></nav>`;
|
| 1591 |
};
|
|
@@ -1620,7 +1644,6 @@
|
|
| 1620 |
};
|
| 1621 |
|
| 1622 |
function getAllHtml() {
|
| 1623 |
-
// Refactored to separate sidebar from main content
|
| 1624 |
const allComponents = {
|
| 1625 |
sidebar: componentGenerators.sidebar(),
|
| 1626 |
mobileFooter: componentGenerators.mobileFooter(),
|
|
@@ -1642,21 +1665,46 @@
|
|
| 1642 |
const css = {};
|
| 1643 |
|
| 1644 |
css.global = `
|
| 1645 |
-
:root {
|
| 1646 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1647 |
h1,h2,h3,h4,h5,h6 { color: var(--heading-color); }
|
| 1648 |
.container { max-width: 1280px; margin: 0 auto; width: 90%; } a { color: var(--primary-color); text-decoration: none; }
|
| 1649 |
.main-content-pusher { transition: margin-left 0.3s ease-in-out; }
|
| 1650 |
@keyframes gift-bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
|
| 1651 |
@keyframes button-pulse { 0% { box-shadow: 0 0 0 0 rgba(255, 152, 0, 0.7); } 70% { box-shadow: 0 0 0 10px rgba(255, 152, 0, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 152, 0, 0); } }
|
| 1652 |
-
@media(min-width: 1024px) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1653 |
`;
|
| 1654 |
|
| 1655 |
if(config.customHtml.enabled) css.customHtml = `.custom-html-section { padding: 2rem 0; }`;
|
| 1656 |
css.topBar = config.topBar.enabled ? `.site-topbar { background: linear-gradient(90deg, var(--bg-start), var(--bg-end)); color: var(--text-color); font-size: var(--font-size); padding: var(--padding) 0; font-weight: 500; } .site-topbar .container { display: flex; align-items: center; justify-content: center; gap: 15px; flex-wrap: wrap; } .site-topbar a { color: inherit; text-decoration: none; } .offer-icon { margin-right: 12px; font-size: 1.2em; animation: gift-bounce 1.5s ease-in-out infinite; } .cta-button { margin-left: 20px; background-color: #ff9800; color: #fff; padding: 0.5em 1.2em; border-radius: 50px; font-weight: 700; animation: button-pulse 2s infinite; } @media (max-width: 768px) { .site-topbar .container { flex-direction: column; gap: 8px; text-align: center; } .cta-button { margin-left: 0; } }` : '';
|
| 1657 |
css.ticker = config.ticker.enabled ? `.product-ticker { background-color: #f8f9fa; padding: 10px 0; overflow: hidden; white-space: nowrap; border-bottom: 1px solid #e5e7eb; } .ticker-track { display: inline-block; animation: scroll-ticker 40s linear infinite; } .ticker-item { display: inline-flex; align-items: center; margin: 0 25px; color: #343a40; font-size: 0.9rem; } .ticker-item img { height: 30px; margin-right: 10px; } @keyframes scroll-ticker { 0% { transform: translateX(0); } 100% { transform: translateX(-50%); } }` : '';
|
| 1658 |
css.lmsHeader = `
|
| 1659 |
-
.learning-app-header-container { background-color: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.05); z-index: 100; position: relative; }
|
| 1660 |
.learning-app-header-container.sticky-header { position: sticky; top: 0; z-index: 1010; }
|
| 1661 |
.lms-primary-bar { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 1rem; height: 60px; border-bottom: 1px solid #e5e7eb; }
|
| 1662 |
.lms-brand { display: flex; align-items: center; gap: 1rem; }
|
|
@@ -1667,10 +1715,10 @@ h1,h2,h3,h4,h5,h6 { color: var(--heading-color); }
|
|
| 1667 |
.icon-btn { display: inline-flex; align-items: center; justify-content: center; background: none; border: none; color: #4b5563; font-size: 1.2rem; cursor: pointer; position: relative; width: 40px; height: 40px; border-radius: 50%; transition: background-color 0.2s, color 0.2s; }
|
| 1668 |
.icon-btn:hover { background-color: #f3f4f6; color: var(--primary-color); }
|
| 1669 |
.notification-bell .badge { position: absolute; top: 5px; right: 5px; background-color: #ef4444; color: #fff; font-size: 0.65rem; width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 500; }
|
| 1670 |
-
.lms-page-title { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1rem; background-color: #fafafa; border-bottom: 1px solid #e5e7eb;}
|
| 1671 |
.back-btn { background: none; border: 1px solid #d1d5db; border-radius: 50%; width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
|
| 1672 |
.lms-page-title h2 { font-size: 1.125rem; font-weight: 600; margin: 0; }
|
| 1673 |
-
.lms-tabs-nav { display: flex; overflow-x: auto; padding: 0 1rem; border-bottom: 1px solid #e5e7eb; background: #fff;}
|
| 1674 |
.lms-tab-item { padding: 0.75rem 1rem; font-size: 0.9rem; color: #6b7280; white-space: nowrap; border-bottom: 2px solid transparent; transition: all 0.2s; }
|
| 1675 |
.lms-tab-item.active, .lms-tab-item:hover { color: var(--primary-color); font-weight: 600; border-bottom-color: var(--primary-color); }
|
| 1676 |
.lms-search-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(243, 244, 246, 0.8); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); z-index: 2000; display: flex; align-items: center; justify-content: center; opacity: 0; visibility: hidden; transition: opacity 0.3s ease-in-out; }
|
|
@@ -1690,30 +1738,51 @@ body.search-active .lms-search-overlay { opacity: 1; visibility: visible; }
|
|
| 1690 |
@media (max-width: 1023px) { .hamburger-menu { display: block; } }
|
| 1691 |
@media (max-width: 768px) { .lms-bonus-icon, .lms-custom-icon { display: none; } .lms-brand .app-name { display: none; } }`;
|
| 1692 |
css.sidebar = config.sidebar.enabled ? `
|
| 1693 |
-
.lms-sidebar {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1694 |
.lms-sidebar-overlay { position: fixed; inset: 0; background-color: rgba(0,0,0,0.5); z-index: 1999; opacity: 0; visibility: hidden; transition: opacity 0.3s, visibility 0.3s; }
|
| 1695 |
-
body.sidebar-open .lms-sidebar { transform: translateX(0); }
|
| 1696 |
-
@media (max-width: 1023px) { body.sidebar-open .lms-sidebar-overlay { opacity: 1; visibility: visible; } }
|
| 1697 |
.lms-sidebar-brand { display: flex; align-items: center; padding: 1rem; height: 60px; border-bottom: 1px solid #e5e7eb; flex-shrink: 0; }
|
| 1698 |
-
.lms-sidebar-logo { height: 40px; object-fit: contain; }
|
| 1699 |
-
.lms-sidebar-
|
|
|
|
| 1700 |
.lms-sidebar-content { flex-grow: 1; overflow-y: auto; padding: 0.5rem; }
|
| 1701 |
.lms-sidebar-nav, .lms-sidebar-nav-accordion { border-bottom: 1px solid #e5e7eb; padding: 0.5rem 0; margin-bottom: 0.5rem; }
|
| 1702 |
.lms-sidebar-nav:last-child, .lms-sidebar-nav-accordion:last-child { border: none; }
|
| 1703 |
.lms-sidebar-nav ul { list-style: none; padding: 0; margin: 0; }
|
| 1704 |
-
.lms-sidebar-nav ul li a { display: flex; align-items: center; gap: 0.85rem; padding: 0.65rem; border-radius: 6px; font-weight: 500; color: #374151;
|
| 1705 |
-
.lms-sidebar-nav ul li a
|
|
|
|
|
|
|
| 1706 |
.sidebar-badge { margin-left: auto; background-color: var(--primary-color); color: white; font-size: 0.7rem; padding: 2px 6px; border-radius: 10px; }
|
| 1707 |
.accordion-trigger { display: flex; justify-content: space-between; align-items: center; width: 100%; background: none; border: none; cursor: pointer; padding: 0.65rem; font-weight: 500; color: #374151; }
|
| 1708 |
-
.accordion-trigger div { display: flex; align-items: center; gap: 0.85rem; }
|
| 1709 |
.accordion-trigger i { width: 20px; text-align: center; color: #9ca3af; } .accordion-trigger .arrow { transition: transform 0.3s ease; }
|
| 1710 |
.accordion-trigger.active .arrow { transform: rotate(180deg); }
|
| 1711 |
.accordion-panel { max-height: 0; overflow: hidden; transition: max-height 0.3s ease-out; }
|
| 1712 |
.accordion-panel .lms-sidebar-nav { border: none; padding: 0; margin: 0; }
|
| 1713 |
.accordion-panel .lms-sidebar-nav ul { padding-left: 1.5rem; }
|
| 1714 |
-
.lms-sidebar-footer { padding: 0.5rem; border-top: 1px solid #e5e7eb; flex-shrink: 0; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1715 |
css.footer = `
|
| 1716 |
-
.site-footer { background-color: #1f2937; color: #d1d5db; padding: 60px 0 20px; font-size: 14px; }
|
| 1717 |
.footer-main { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 40px; padding-bottom: 40px; border-bottom: 1px solid #374151; }
|
| 1718 |
.footer-widget .widget-title { font-weight: 700; color: #fff; margin-bottom: 20px; }
|
| 1719 |
.footer-widget ul { list-style: none; padding: 0; } .footer-widget ul li { margin-bottom: 12px; }
|
|
@@ -1753,30 +1822,65 @@ body.sidebar-open .lms-sidebar { transform: translateX(0); }
|
|
| 1753 |
|
| 1754 |
function getFullCSS() {
|
| 1755 |
const cssObject = generateComponentCSS();
|
| 1756 |
-
// The order here doesn't matter as much due to specificity, but it's good practice.
|
| 1757 |
return [cssObject.global, cssObject.sidebar, cssObject.topBar, cssObject.ticker, cssObject.lmsHeader, cssObject.customHtml, cssObject.footer, cssObject.mobileFooter].filter(Boolean).join('\n\n');
|
| 1758 |
}
|
| 1759 |
|
| 1760 |
function generateComponentJavaScript(targetKey = null) {
|
| 1761 |
const js = {};
|
| 1762 |
const fullInteractiveScript = `
|
|
|
|
|
|
|
|
|
|
| 1763 |
const backToTopButton = document.getElementById('back-to-top');
|
| 1764 |
if(backToTopButton) {
|
| 1765 |
window.addEventListener('scroll', () => backToTopButton.classList.toggle('visible', window.scrollY > 300));
|
| 1766 |
backToTopButton.addEventListener('click', () => window.scrollTo({ top: 0, behavior: 'smooth' }));
|
| 1767 |
}
|
| 1768 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1769 |
document.getElementById('header-theme-toggle')?.addEventListener('click', toggleTheme);
|
| 1770 |
-
document.getElementById('sidebar-theme-toggle')?.addEventListener('click',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1771 |
|
| 1772 |
-
const
|
| 1773 |
-
|
| 1774 |
-
|
| 1775 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1776 |
|
|
|
|
|
|
|
| 1777 |
document.querySelectorAll('.lms-sidebar-nav-accordion .accordion-trigger').forEach(trigger => {
|
| 1778 |
trigger.addEventListener('click', (e) => {
|
| 1779 |
e.preventDefault();
|
|
|
|
| 1780 |
const panel = trigger.nextElementSibling;
|
| 1781 |
trigger.classList.toggle('active');
|
| 1782 |
if (panel.style.maxHeight) {
|
|
@@ -1787,21 +1891,29 @@ body.sidebar-open .lms-sidebar { transform: translateX(0); }
|
|
| 1787 |
});
|
| 1788 |
});
|
| 1789 |
|
|
|
|
| 1790 |
const searchBtn = document.getElementById('lms-search-btn');
|
| 1791 |
const searchOverlay = document.getElementById('lms-search-overlay');
|
| 1792 |
const searchCloseBtn = document.getElementById('lms-search-close-btn');
|
| 1793 |
const searchInput = document.getElementById('lms-search-input');
|
| 1794 |
if (searchBtn && searchOverlay && searchCloseBtn) {
|
| 1795 |
-
|
| 1796 |
e.preventDefault();
|
| 1797 |
-
|
| 1798 |
-
searchInput.focus();
|
| 1799 |
-
}
|
| 1800 |
-
const closeSearch = () =>
|
|
|
|
|
|
|
| 1801 |
searchCloseBtn.addEventListener('click', closeSearch);
|
| 1802 |
searchOverlay.addEventListener('click', (e) => {
|
| 1803 |
if (e.target === searchOverlay) closeSearch();
|
| 1804 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1805 |
}
|
| 1806 |
`;
|
| 1807 |
// Bundle all interactive JS under one key since they are interdependent.
|
|
@@ -1900,28 +2012,22 @@ body.sidebar-open .lms-sidebar { transform: translateX(0); }
|
|
| 1900 |
|
| 1901 |
const importedConfig = JSON.parse(configScript.textContent);
|
| 1902 |
|
| 1903 |
-
// Basic validation to ensure it's a valid config file
|
| 1904 |
if (!importedConfig || typeof importedConfig !== 'object' || !importedConfig.componentOrder || !importedConfig.globalSettings) {
|
| 1905 |
showToast('Error: Invalid or corrupted configuration file.');
|
| 1906 |
return;
|
| 1907 |
}
|
| 1908 |
|
| 1909 |
-
// SUCCESS: Update the main config object
|
| 1910 |
-
// Clear the existing config properties
|
| 1911 |
Object.keys(config).forEach(key => delete config[key]);
|
| 1912 |
-
// Assign the new properties from the imported config
|
| 1913 |
Object.assign(config, importedConfig);
|
| 1914 |
|
| 1915 |
showToast('Configuration imported successfully!');
|
| 1916 |
|
| 1917 |
-
// Re-initialize the entire UI to reflect the newly loaded config
|
| 1918 |
init();
|
| 1919 |
|
| 1920 |
} catch (error) {
|
| 1921 |
console.error("Import failed:", error);
|
| 1922 |
showToast(`Import failed: ${error.message}`);
|
| 1923 |
} finally {
|
| 1924 |
-
// Reset file input to allow importing the same file again if needed
|
| 1925 |
event.target.value = null;
|
| 1926 |
}
|
| 1927 |
};
|
|
@@ -1935,7 +2041,7 @@ body.sidebar-open .lms-sidebar { transform: translateX(0); }
|
|
| 1935 |
|
| 1936 |
const html = componentGenerators[key] ? componentGenerators[key]() : 'N/A';
|
| 1937 |
const { global, component: css } = generateComponentCSS(key);
|
| 1938 |
-
const js =
|
| 1939 |
|
| 1940 |
ui.codeModal.title.textContent = `${componentNames[key]} Component Code`;
|
| 1941 |
ui.codeModal.htmlCode.textContent = html;
|
|
@@ -1952,7 +2058,7 @@ body.sidebar-open .lms-sidebar { transform: translateX(0); }
|
|
| 1952 |
function generateComponentZip(key) {
|
| 1953 |
const zip = new JSZip();
|
| 1954 |
const { global, component: css } = generateComponentCSS(key);
|
| 1955 |
-
const js =
|
| 1956 |
const htmlBody = componentGenerators[key] ? componentGenerators[key]() : '';
|
| 1957 |
const html = `<!DOCTYPE html><html><head><title>${componentNames[key]}</title><link rel="stylesheet" href="style.css"></head><body>${htmlBody}${js.trim() ? '<script src="script.js"><\/script>' : ''}</body></html>`;
|
| 1958 |
zip.file("index.html", html);
|
|
@@ -1970,11 +2076,9 @@ body.sidebar-open .lms-sidebar { transform: translateX(0); }
|
|
| 1970 |
ui.globalSettings.headingColor.value = config.globalSettings.colors.heading;
|
| 1971 |
ui.globalSettings.fontFamily.value = config.globalSettings.typography.fontFamily;
|
| 1972 |
|
| 1973 |
-
// Init Custom HTML
|
| 1974 |
ui.customHtml.toggle.checked = config.customHtml.enabled;
|
| 1975 |
ui.customHtml.content.value = config.customHtml.content;
|
| 1976 |
|
| 1977 |
-
// Init LMS Header
|
| 1978 |
const lmsUI = ui.learningAppHeader; const lmsConfig = config.learningAppHeader;
|
| 1979 |
lmsUI.stickyToggle.checked = lmsConfig.sticky;
|
| 1980 |
lmsUI.primaryBarToggle.checked = lmsConfig.primaryBar.enabled;
|
|
@@ -1987,12 +2091,10 @@ body.sidebar-open .lms-sidebar { transform: translateX(0); }
|
|
| 1987 |
lmsUI.pageTitleText.value = lmsConfig.pageTitle.text;
|
| 1988 |
lmsUI.tabs.toggle.checked = lmsConfig.tabs.enabled;
|
| 1989 |
|
| 1990 |
-
// Init Sidebar
|
| 1991 |
ui.sidebar.enableToggle.checked = config.sidebar.enabled;
|
| 1992 |
ui.sidebar.brand.sitename.value = config.sidebar.branding.sitename;
|
| 1993 |
ui.sidebar.brand.tagline.value = config.sidebar.branding.tagline;
|
| 1994 |
|
| 1995 |
-
// Init Top Bar
|
| 1996 |
const topBarUI = ui.topBar;
|
| 1997 |
topBarUI.toggle.checked = config.topBar.enabled;
|
| 1998 |
topBarUI.text.value = config.topBar.text;
|
|
@@ -2006,7 +2108,6 @@ body.sidebar-open .lms-sidebar { transform: translateX(0); }
|
|
| 2006 |
topBarUI.paddingVal.textContent = config.topBar.styles.padding;
|
| 2007 |
topBarUI.mainControls.style.display = config.topBar.enabled ? 'block' : 'none';
|
| 2008 |
|
| 2009 |
-
|
| 2010 |
ui.ticker.toggle.checked = config.ticker.enabled;
|
| 2011 |
|
| 2012 |
ui.footer.aboutDesc.value = config.footer.about.description;
|
|
@@ -2017,15 +2118,14 @@ body.sidebar-open .lms-sidebar { transform: translateX(0); }
|
|
| 2017 |
ui.mobileFooter.cta.text.value = config.mobileFooter.cta.text;
|
| 2018 |
ui.mobileFooter.support.toggle.checked = config.mobileFooter.support.enabled;
|
| 2019 |
|
| 2020 |
-
// This is the first time running, so attach all event listeners.
|
| 2021 |
-
// On import, this function is called again, but the listeners are already attached.
|
| 2022 |
-
// Re-attaching them is harmless in this setup.
|
| 2023 |
if (!document.body.classList.contains('initialized')) {
|
| 2024 |
setupEventListeners();
|
| 2025 |
document.body.classList.add('initialized');
|
| 2026 |
}
|
| 2027 |
|
| 2028 |
-
|
|
|
|
|
|
|
| 2029 |
toggleLmsBrandControls();
|
| 2030 |
createSidebarLinkBuilder('primary-nav', 'Primary Navigation', ui.sidebar.primaryNavBuilder, config.sidebar.primaryNav);
|
| 2031 |
createSidebarLinkBuilder('categories', 'Course Categories', ui.sidebar.categoriesBuilder, config.sidebar.categories);
|
|
|
|
| 451 |
|
| 452 |
<label class="font-medium text-xs pt-2 block">Bonus Icons</label>
|
| 453 |
<div class="flex items-center space-x-2"><input type="checkbox" id="lms-el-refresh" class="h-4 w-4 rounded"><label for="lms-el-refresh" class="text-sm">Refresh Icon 🔁</label></div>
|
| 454 |
+
<div class="flex items-center space-x-2"><input type="checkbox" id="lms-el-theme" class="h-4 w-4 rounded" checked><label for="lms-el-theme" class="text-sm">Theme Toggle (Header) 🌙</label></div>
|
| 455 |
<div class="flex items-center space-x-2"><input type="checkbox" id="lms-el-calendar" class="h-4 w-4 rounded"><label for="lms-el-calendar" class="text-sm">Calendar Icon 📅</label></div>
|
| 456 |
<div class="flex items-center space-x-2"><input type="checkbox" id="lms-el-share" class="h-4 w-4 rounded"><label for="lms-el-share" class="text-sm">Share Icon 📤</label></div>
|
| 457 |
</div>
|
|
|
|
| 507 |
<div id="sidebar-categories-builder" class="space-y-3 border-b pb-4"></div>
|
| 508 |
<div id="sidebar-user-section-builder" class="space-y-3 border-b pb-4"></div>
|
| 509 |
<div id="sidebar-shortcuts-builder" class="space-y-3 border-b pb-4"></div>
|
| 510 |
+
<div class="space-y-2 border-b pb-4 pl-4">
|
| 511 |
+
<label class="font-medium text-sm">Special Toggles</label>
|
| 512 |
+
<div class="flex items-center space-x-2">
|
| 513 |
+
<input type="checkbox" id="sidebar-theme-toggle-cb" class="h-4 w-4 rounded">
|
| 514 |
+
<label for="sidebar-theme-toggle-cb" class="text-sm">Add Dark/Light Mode Toggle</label>
|
| 515 |
+
</div>
|
| 516 |
+
</div>
|
| 517 |
<div id="sidebar-footer-builder" class="space-y-3 border-b pb-4"></div>
|
| 518 |
</div>
|
| 519 |
</div>
|
|
|
|
| 824 |
links: [ { icon: 'fas fa-leaf', text: 'Agriculture', url: '#', enabled: true }, ]
|
| 825 |
},
|
| 826 |
userSection: { enabled: true, title: 'User Account', links: [ { icon: 'fas fa-user-circle', text: 'Profile', url: '#', enabled: true }, ] },
|
| 827 |
+
shortcuts: { enabled: true, title: 'Shortcuts & CTA', links: [ { icon: 'fas fa-bell', text: 'Notifications', url: '#', badge: '3', enabled: true }, { icon: 'fas fa-moon', text: 'Theme Toggle', url: '#', enabled: true, isThemeToggle: true } ] },
|
| 828 |
footer: { enabled: true, title: 'Support', links: [ { icon: 'fas fa-headset', text: 'Contact / Support', url: '#', enabled: true }, ] }
|
| 829 |
},
|
| 830 |
topBar: {
|
|
|
|
| 940 |
categoriesBuilder: document.getElementById('sidebar-categories-builder'),
|
| 941 |
userSectionBuilder: document.getElementById('sidebar-user-section-builder'),
|
| 942 |
shortcutsBuilder: document.getElementById('sidebar-shortcuts-builder'),
|
| 943 |
+
themeToggleCheckbox: document.getElementById('sidebar-theme-toggle-cb'),
|
| 944 |
footerBuilder: document.getElementById('sidebar-footer-builder'),
|
| 945 |
},
|
| 946 |
topBar: {
|
|
|
|
| 1089 |
sidebarUI.brand.sitenameToggle.addEventListener('change', e => { sidebarConfig.branding.showSitename = e.target.checked; renderAll(); });
|
| 1090 |
sidebarUI.brand.sitename.addEventListener('input', e => { sidebarConfig.branding.sitename = e.target.value; renderAll(); });
|
| 1091 |
sidebarUI.brand.tagline.addEventListener('input', e => { sidebarConfig.branding.tagline = e.target.value; renderAll(); });
|
| 1092 |
+
sidebarUI.themeToggleCheckbox.addEventListener('change', handleThemeToggleCheckboxChange);
|
| 1093 |
|
| 1094 |
// Top Bar Listeners
|
| 1095 |
const topBarUI = ui.topBar;
|
|
|
|
| 1334 |
builderUI.addEventListener('change', handleChange);
|
| 1335 |
renderControls();
|
| 1336 |
}
|
| 1337 |
+
function handleThemeToggleCheckboxChange(e) {
|
| 1338 |
+
const shortcuts = config.sidebar.shortcuts;
|
| 1339 |
+
const themeToggleLink = { icon: 'fas fa-moon', text: 'Theme Toggle', url: '#', enabled: true, isThemeToggle: true };
|
| 1340 |
+
|
| 1341 |
+
// Remove any existing theme toggle to avoid duplicates
|
| 1342 |
+
shortcuts.links = shortcuts.links.filter(link => !link.isThemeToggle);
|
| 1343 |
+
|
| 1344 |
+
if (e.target.checked) {
|
| 1345 |
+
shortcuts.links.push(themeToggleLink);
|
| 1346 |
+
}
|
| 1347 |
+
|
| 1348 |
+
// Re-render the controls for that section and the preview
|
| 1349 |
+
createSidebarLinkBuilder('shortcuts', 'Shortcuts & CTA', ui.sidebar.shortcutsBuilder, config.sidebar.shortcuts);
|
| 1350 |
+
renderAll();
|
| 1351 |
+
}
|
| 1352 |
function renderLmsTabsControls() {
|
| 1353 |
ui.learningAppHeader.tabs.container.innerHTML = config.learningAppHeader.tabs.items.map((tab, index) => `
|
| 1354 |
<div class="flex items-center gap-1 p-2 border rounded bg-white">
|
|
|
|
| 1603 |
sidebar: () => {
|
| 1604 |
if (!config.sidebar.enabled) return '';
|
| 1605 |
const s = config.sidebar;
|
| 1606 |
+
const brandHtml = `<div class="lms-sidebar-brand">${s.branding.showLogo ? `<img src="${config.learningAppHeader.primaryBar.brand.imageUrl}" alt="Logo" class="lms-sidebar-logo">` : ''}${s.branding.showSitename ? `<div class="lms-sidebar-sitename"><strong>${s.branding.sitename}</strong><small>${s.branding.tagline}</small></div>` : ''}<button class="lms-sidebar-toggle" id="lms-sidebar-collapse-btn"><i class="fas fa-chevron-left"></i></button></div>`;
|
| 1607 |
const createLinkSection = (sec) => {
|
| 1608 |
if (!sec.enabled) return '';
|
| 1609 |
const links = sec.links.filter(l => l.enabled).map(l => {
|
| 1610 |
const badge = l.badge ? `<span class="sidebar-badge">${l.badge}</span>` : '';
|
| 1611 |
+
const themeToggleId = l.isThemeToggle ? 'id="sidebar-theme-toggle"' : '';
|
| 1612 |
+
return `<li><a href="${l.url}" ${themeToggleId}><i class="${l.icon}"></i><span>${l.text}</span>${badge}</a></li>`;
|
| 1613 |
}).join('');
|
| 1614 |
return `<nav class="lms-sidebar-nav"><ul>${links}</ul></nav>`;
|
| 1615 |
};
|
|
|
|
| 1644 |
};
|
| 1645 |
|
| 1646 |
function getAllHtml() {
|
|
|
|
| 1647 |
const allComponents = {
|
| 1648 |
sidebar: componentGenerators.sidebar(),
|
| 1649 |
mobileFooter: componentGenerators.mobileFooter(),
|
|
|
|
| 1665 |
const css = {};
|
| 1666 |
|
| 1667 |
css.global = `
|
| 1668 |
+
:root {
|
| 1669 |
+
--sidebar-width: 260px;
|
| 1670 |
+
--sidebar-width-collapsed: 80px;
|
| 1671 |
+
--primary-color: ${colors.primary};
|
| 1672 |
+
--secondary-color: ${colors.secondary};
|
| 1673 |
+
--text-color: ${colors.text};
|
| 1674 |
+
--heading-color: ${colors.heading};
|
| 1675 |
+
--font-family: ${typography.fontFamily};
|
| 1676 |
+
}
|
| 1677 |
+
body { font-family: var(--font-family); color: var(--text-color); margin: 0; background-color: #f0f2f5; transition: background-color 0.3s, color 0.3s; }
|
| 1678 |
h1,h2,h3,h4,h5,h6 { color: var(--heading-color); }
|
| 1679 |
.container { max-width: 1280px; margin: 0 auto; width: 90%; } a { color: var(--primary-color); text-decoration: none; }
|
| 1680 |
.main-content-pusher { transition: margin-left 0.3s ease-in-out; }
|
| 1681 |
@keyframes gift-bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
|
| 1682 |
@keyframes button-pulse { 0% { box-shadow: 0 0 0 0 rgba(255, 152, 0, 0.7); } 70% { box-shadow: 0 0 0 10px rgba(255, 152, 0, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 152, 0, 0); } }
|
| 1683 |
+
@media(min-width: 1024px) {
|
| 1684 |
+
body:not(.sidebar-collapsed) .main-content-pusher { margin-left: var(--sidebar-width); }
|
| 1685 |
+
body.sidebar-collapsed .main-content-pusher { margin-left: var(--sidebar-width-collapsed); }
|
| 1686 |
+
}
|
| 1687 |
+
|
| 1688 |
+
/* --- Dark Mode Styles --- */
|
| 1689 |
+
body.dark-mode { background-color: #1f2937; color: #d1d5db; }
|
| 1690 |
+
body.dark-mode h1, body.dark-mode h2, body.dark-mode h3, body.dark-mode h4 { color: #f9fafb; }
|
| 1691 |
+
body.dark-mode .lms-sidebar,
|
| 1692 |
+
body.dark-mode .learning-app-header-container,
|
| 1693 |
+
body.dark-mode .lms-page-title,
|
| 1694 |
+
body.dark-mode .lms-tabs-nav,
|
| 1695 |
+
body.dark-mode .site-footer { background-color: #111827; border-color: #374151; }
|
| 1696 |
+
body.dark-mode .lms-sidebar-nav ul li a, body.dark-mode .icon-btn, body.dark-mode .back-btn { color: #f9fafb; }
|
| 1697 |
+
body.dark-mode .lms-sidebar-nav ul li a:hover, body.dark-mode .icon-btn:hover { background-color: #374151; }
|
| 1698 |
+
body.dark-mode .site-footer { color: #9ca3af; }
|
| 1699 |
+
body.dark-mode .footer-widget a { color: #9ca3af; } body.dark-mode .footer-widget a:hover { color: #fff; }
|
| 1700 |
+
body.dark-mode .widget-title { color: #fff; }
|
| 1701 |
`;
|
| 1702 |
|
| 1703 |
if(config.customHtml.enabled) css.customHtml = `.custom-html-section { padding: 2rem 0; }`;
|
| 1704 |
css.topBar = config.topBar.enabled ? `.site-topbar { background: linear-gradient(90deg, var(--bg-start), var(--bg-end)); color: var(--text-color); font-size: var(--font-size); padding: var(--padding) 0; font-weight: 500; } .site-topbar .container { display: flex; align-items: center; justify-content: center; gap: 15px; flex-wrap: wrap; } .site-topbar a { color: inherit; text-decoration: none; } .offer-icon { margin-right: 12px; font-size: 1.2em; animation: gift-bounce 1.5s ease-in-out infinite; } .cta-button { margin-left: 20px; background-color: #ff9800; color: #fff; padding: 0.5em 1.2em; border-radius: 50px; font-weight: 700; animation: button-pulse 2s infinite; } @media (max-width: 768px) { .site-topbar .container { flex-direction: column; gap: 8px; text-align: center; } .cta-button { margin-left: 0; } }` : '';
|
| 1705 |
css.ticker = config.ticker.enabled ? `.product-ticker { background-color: #f8f9fa; padding: 10px 0; overflow: hidden; white-space: nowrap; border-bottom: 1px solid #e5e7eb; } .ticker-track { display: inline-block; animation: scroll-ticker 40s linear infinite; } .ticker-item { display: inline-flex; align-items: center; margin: 0 25px; color: #343a40; font-size: 0.9rem; } .ticker-item img { height: 30px; margin-right: 10px; } @keyframes scroll-ticker { 0% { transform: translateX(0); } 100% { transform: translateX(-50%); } }` : '';
|
| 1706 |
css.lmsHeader = `
|
| 1707 |
+
.learning-app-header-container { background-color: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.05); z-index: 100; position: relative; transition: background-color 0.3s; }
|
| 1708 |
.learning-app-header-container.sticky-header { position: sticky; top: 0; z-index: 1010; }
|
| 1709 |
.lms-primary-bar { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 1rem; height: 60px; border-bottom: 1px solid #e5e7eb; }
|
| 1710 |
.lms-brand { display: flex; align-items: center; gap: 1rem; }
|
|
|
|
| 1715 |
.icon-btn { display: inline-flex; align-items: center; justify-content: center; background: none; border: none; color: #4b5563; font-size: 1.2rem; cursor: pointer; position: relative; width: 40px; height: 40px; border-radius: 50%; transition: background-color 0.2s, color 0.2s; }
|
| 1716 |
.icon-btn:hover { background-color: #f3f4f6; color: var(--primary-color); }
|
| 1717 |
.notification-bell .badge { position: absolute; top: 5px; right: 5px; background-color: #ef4444; color: #fff; font-size: 0.65rem; width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 500; }
|
| 1718 |
+
.lms-page-title { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1rem; background-color: #fafafa; border-bottom: 1px solid #e5e7eb; transition: background-color 0.3s; }
|
| 1719 |
.back-btn { background: none; border: 1px solid #d1d5db; border-radius: 50%; width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
|
| 1720 |
.lms-page-title h2 { font-size: 1.125rem; font-weight: 600; margin: 0; }
|
| 1721 |
+
.lms-tabs-nav { display: flex; overflow-x: auto; padding: 0 1rem; border-bottom: 1px solid #e5e7eb; background: #fff; transition: background-color 0.3s;}
|
| 1722 |
.lms-tab-item { padding: 0.75rem 1rem; font-size: 0.9rem; color: #6b7280; white-space: nowrap; border-bottom: 2px solid transparent; transition: all 0.2s; }
|
| 1723 |
.lms-tab-item.active, .lms-tab-item:hover { color: var(--primary-color); font-weight: 600; border-bottom-color: var(--primary-color); }
|
| 1724 |
.lms-search-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(243, 244, 246, 0.8); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); z-index: 2000; display: flex; align-items: center; justify-content: center; opacity: 0; visibility: hidden; transition: opacity 0.3s ease-in-out; }
|
|
|
|
| 1738 |
@media (max-width: 1023px) { .hamburger-menu { display: block; } }
|
| 1739 |
@media (max-width: 768px) { .lms-bonus-icon, .lms-custom-icon { display: none; } .lms-brand .app-name { display: none; } }`;
|
| 1740 |
css.sidebar = config.sidebar.enabled ? `
|
| 1741 |
+
.lms-sidebar {
|
| 1742 |
+
position: fixed; top: 0; left: 0; height: 100vh; width: var(--sidebar-width);
|
| 1743 |
+
background-color: #fff; z-index: 2000; display: flex; flex-direction: column;
|
| 1744 |
+
border-right: 1px solid #e5e7eb; transition: transform 0.3s ease-in-out, width 0.3s ease-in-out, background-color 0.3s;
|
| 1745 |
+
}
|
| 1746 |
.lms-sidebar-overlay { position: fixed; inset: 0; background-color: rgba(0,0,0,0.5); z-index: 1999; opacity: 0; visibility: hidden; transition: opacity 0.3s, visibility 0.3s; }
|
|
|
|
|
|
|
| 1747 |
.lms-sidebar-brand { display: flex; align-items: center; padding: 1rem; height: 60px; border-bottom: 1px solid #e5e7eb; flex-shrink: 0; }
|
| 1748 |
+
.lms-sidebar-logo { height: 40px; object-fit: contain; }
|
| 1749 |
+
.lms-sidebar-sitename { margin-left: 0.75rem; line-height: 1.2; } .lms-sidebar-sitename strong { font-weight: 600; } .lms-sidebar-sitename small { font-size: 0.8rem; color: #6b7280; }
|
| 1750 |
+
.lms-sidebar-toggle { background: none; border: 1px solid #d1d5db; font-size: 1rem; cursor: pointer; margin-left: auto; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items:center; transition: transform 0.3s ease-in-out; }
|
| 1751 |
.lms-sidebar-content { flex-grow: 1; overflow-y: auto; padding: 0.5rem; }
|
| 1752 |
.lms-sidebar-nav, .lms-sidebar-nav-accordion { border-bottom: 1px solid #e5e7eb; padding: 0.5rem 0; margin-bottom: 0.5rem; }
|
| 1753 |
.lms-sidebar-nav:last-child, .lms-sidebar-nav-accordion:last-child { border: none; }
|
| 1754 |
.lms-sidebar-nav ul { list-style: none; padding: 0; margin: 0; }
|
| 1755 |
+
.lms-sidebar-nav ul li a { display: flex; align-items: center; gap: 0.85rem; padding: 0.65rem; border-radius: 6px; font-weight: 500; color: #374151; overflow: hidden; white-space: nowrap; }
|
| 1756 |
+
.lms-sidebar-nav ul li a:hover { background-color: #f3f4f6; }
|
| 1757 |
+
.lms-sidebar-nav ul li a i { width: 20px; text-align: center; color: #9ca3af; flex-shrink: 0; }
|
| 1758 |
+
.lms-sidebar-nav ul li a span, .accordion-trigger div span { transition: opacity 0.2s; }
|
| 1759 |
.sidebar-badge { margin-left: auto; background-color: var(--primary-color); color: white; font-size: 0.7rem; padding: 2px 6px; border-radius: 10px; }
|
| 1760 |
.accordion-trigger { display: flex; justify-content: space-between; align-items: center; width: 100%; background: none; border: none; cursor: pointer; padding: 0.65rem; font-weight: 500; color: #374151; }
|
| 1761 |
+
.accordion-trigger div { display: flex; align-items: center; gap: 0.85rem; overflow: hidden; }
|
| 1762 |
.accordion-trigger i { width: 20px; text-align: center; color: #9ca3af; } .accordion-trigger .arrow { transition: transform 0.3s ease; }
|
| 1763 |
.accordion-trigger.active .arrow { transform: rotate(180deg); }
|
| 1764 |
.accordion-panel { max-height: 0; overflow: hidden; transition: max-height 0.3s ease-out; }
|
| 1765 |
.accordion-panel .lms-sidebar-nav { border: none; padding: 0; margin: 0; }
|
| 1766 |
.accordion-panel .lms-sidebar-nav ul { padding-left: 1.5rem; }
|
| 1767 |
+
.lms-sidebar-footer { padding: 0.5rem; border-top: 1px solid #e5e7eb; flex-shrink: 0; }
|
| 1768 |
+
|
| 1769 |
+
@media(max-width: 1023px) {
|
| 1770 |
+
.lms-sidebar { transform: translateX(-100%); }
|
| 1771 |
+
body.sidebar-open .lms-sidebar { transform: translateX(0); }
|
| 1772 |
+
body.sidebar-open .lms-sidebar-overlay { opacity: 1; visibility: visible; }
|
| 1773 |
+
}
|
| 1774 |
+
|
| 1775 |
+
@media(min-width: 1024px) {
|
| 1776 |
+
body.sidebar-collapsed .lms-sidebar { width: var(--sidebar-width-collapsed); }
|
| 1777 |
+
body.sidebar-collapsed .lms-sidebar-toggle { transform: rotate(180deg); }
|
| 1778 |
+
body.sidebar-collapsed .lms-sidebar-sitename, body.sidebar-collapsed .lms-sidebar-nav ul li a span, body.sidebar-collapsed .accordion-trigger div span, body.sidebar-collapsed .accordion-trigger .arrow, body.sidebar-collapsed .sidebar-badge { opacity: 0; visibility: hidden; width: 0; }
|
| 1779 |
+
body.sidebar-collapsed .lms-sidebar-nav ul li a { justify-content: center; }
|
| 1780 |
+
body.sidebar-collapsed .accordion-panel { display: none; }
|
| 1781 |
+
body.sidebar-collapsed .lms-sidebar-logo { margin: 0 auto; }
|
| 1782 |
+
}
|
| 1783 |
+
` : '';
|
| 1784 |
css.footer = `
|
| 1785 |
+
.site-footer { background-color: #1f2937; color: #d1d5db; padding: 60px 0 20px; font-size: 14px; transition: background-color 0.3s; }
|
| 1786 |
.footer-main { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 40px; padding-bottom: 40px; border-bottom: 1px solid #374151; }
|
| 1787 |
.footer-widget .widget-title { font-weight: 700; color: #fff; margin-bottom: 20px; }
|
| 1788 |
.footer-widget ul { list-style: none; padding: 0; } .footer-widget ul li { margin-bottom: 12px; }
|
|
|
|
| 1822 |
|
| 1823 |
function getFullCSS() {
|
| 1824 |
const cssObject = generateComponentCSS();
|
|
|
|
| 1825 |
return [cssObject.global, cssObject.sidebar, cssObject.topBar, cssObject.ticker, cssObject.lmsHeader, cssObject.customHtml, cssObject.footer, cssObject.mobileFooter].filter(Boolean).join('\n\n');
|
| 1826 |
}
|
| 1827 |
|
| 1828 |
function generateComponentJavaScript(targetKey = null) {
|
| 1829 |
const js = {};
|
| 1830 |
const fullInteractiveScript = `
|
| 1831 |
+
const body = document.body;
|
| 1832 |
+
|
| 1833 |
+
// Back to top button
|
| 1834 |
const backToTopButton = document.getElementById('back-to-top');
|
| 1835 |
if(backToTopButton) {
|
| 1836 |
window.addEventListener('scroll', () => backToTopButton.classList.toggle('visible', window.scrollY > 300));
|
| 1837 |
backToTopButton.addEventListener('click', () => window.scrollTo({ top: 0, behavior: 'smooth' }));
|
| 1838 |
}
|
| 1839 |
+
|
| 1840 |
+
// Theme Toggling
|
| 1841 |
+
const toggleTheme = () => {
|
| 1842 |
+
body.classList.toggle('dark-mode');
|
| 1843 |
+
const icon = document.querySelector('#sidebar-theme-toggle i') || document.querySelector('#header-theme-toggle i');
|
| 1844 |
+
if (icon) {
|
| 1845 |
+
icon.classList.toggle('fa-moon');
|
| 1846 |
+
icon.classList.toggle('fa-sun');
|
| 1847 |
+
}
|
| 1848 |
+
};
|
| 1849 |
document.getElementById('header-theme-toggle')?.addEventListener('click', toggleTheme);
|
| 1850 |
+
document.getElementById('sidebar-theme-toggle')?.addEventListener('click', (e) => {
|
| 1851 |
+
e.preventDefault();
|
| 1852 |
+
toggleTheme();
|
| 1853 |
+
});
|
| 1854 |
+
|
| 1855 |
+
// Sidebar Toggling Logic
|
| 1856 |
+
const lmsSidebarToggle = document.getElementById('lms-sidebar-toggle'); // Hamburger in header
|
| 1857 |
+
const lmsSidebarCollapseBtn = document.getElementById('lms-sidebar-collapse-btn'); // Toggle in sidebar
|
| 1858 |
+
const lmsSidebarOverlay = document.querySelector('.lms-sidebar-overlay');
|
| 1859 |
|
| 1860 |
+
const handleSidebarToggle = () => {
|
| 1861 |
+
if (window.innerWidth < 1024) {
|
| 1862 |
+
body.classList.toggle('sidebar-open'); // Mobile: slide in/out
|
| 1863 |
+
} else {
|
| 1864 |
+
body.classList.toggle('sidebar-collapsed'); // Desktop: expand/collapse
|
| 1865 |
+
}
|
| 1866 |
+
};
|
| 1867 |
+
|
| 1868 |
+
const closeMobileSidebar = () => {
|
| 1869 |
+
if (window.innerWidth < 1024) {
|
| 1870 |
+
body.classList.remove('sidebar-open');
|
| 1871 |
+
}
|
| 1872 |
+
}
|
| 1873 |
+
|
| 1874 |
+
lmsSidebarToggle?.addEventListener('click', handleSidebarToggle);
|
| 1875 |
+
lmsSidebarCollapseBtn?.addEventListener('click', handleSidebarToggle);
|
| 1876 |
+
lmsSidebarOverlay?.addEventListener('click', closeMobileSidebar);
|
| 1877 |
|
| 1878 |
+
|
| 1879 |
+
// Accordion Logic
|
| 1880 |
document.querySelectorAll('.lms-sidebar-nav-accordion .accordion-trigger').forEach(trigger => {
|
| 1881 |
trigger.addEventListener('click', (e) => {
|
| 1882 |
e.preventDefault();
|
| 1883 |
+
if (body.classList.contains('sidebar-collapsed')) return; // Don't open accordion when collapsed
|
| 1884 |
const panel = trigger.nextElementSibling;
|
| 1885 |
trigger.classList.toggle('active');
|
| 1886 |
if (panel.style.maxHeight) {
|
|
|
|
| 1891 |
});
|
| 1892 |
});
|
| 1893 |
|
| 1894 |
+
// Search Overlay Logic
|
| 1895 |
const searchBtn = document.getElementById('lms-search-btn');
|
| 1896 |
const searchOverlay = document.getElementById('lms-search-overlay');
|
| 1897 |
const searchCloseBtn = document.getElementById('lms-search-close-btn');
|
| 1898 |
const searchInput = document.getElementById('lms-search-input');
|
| 1899 |
if (searchBtn && searchOverlay && searchCloseBtn) {
|
| 1900 |
+
const openSearch = (e) => {
|
| 1901 |
e.preventDefault();
|
| 1902 |
+
body.classList.add('search-active');
|
| 1903 |
+
setTimeout(() => searchInput.focus(), 50);
|
| 1904 |
+
};
|
| 1905 |
+
const closeSearch = () => body.classList.remove('search-active');
|
| 1906 |
+
|
| 1907 |
+
searchBtn.addEventListener('click', openSearch);
|
| 1908 |
searchCloseBtn.addEventListener('click', closeSearch);
|
| 1909 |
searchOverlay.addEventListener('click', (e) => {
|
| 1910 |
if (e.target === searchOverlay) closeSearch();
|
| 1911 |
});
|
| 1912 |
+
document.addEventListener('keydown', (e) => {
|
| 1913 |
+
if (e.key === 'Escape' && body.classList.contains('search-active')) {
|
| 1914 |
+
closeSearch();
|
| 1915 |
+
}
|
| 1916 |
+
});
|
| 1917 |
}
|
| 1918 |
`;
|
| 1919 |
// Bundle all interactive JS under one key since they are interdependent.
|
|
|
|
| 2012 |
|
| 2013 |
const importedConfig = JSON.parse(configScript.textContent);
|
| 2014 |
|
|
|
|
| 2015 |
if (!importedConfig || typeof importedConfig !== 'object' || !importedConfig.componentOrder || !importedConfig.globalSettings) {
|
| 2016 |
showToast('Error: Invalid or corrupted configuration file.');
|
| 2017 |
return;
|
| 2018 |
}
|
| 2019 |
|
|
|
|
|
|
|
| 2020 |
Object.keys(config).forEach(key => delete config[key]);
|
|
|
|
| 2021 |
Object.assign(config, importedConfig);
|
| 2022 |
|
| 2023 |
showToast('Configuration imported successfully!');
|
| 2024 |
|
|
|
|
| 2025 |
init();
|
| 2026 |
|
| 2027 |
} catch (error) {
|
| 2028 |
console.error("Import failed:", error);
|
| 2029 |
showToast(`Import failed: ${error.message}`);
|
| 2030 |
} finally {
|
|
|
|
| 2031 |
event.target.value = null;
|
| 2032 |
}
|
| 2033 |
};
|
|
|
|
| 2041 |
|
| 2042 |
const html = componentGenerators[key] ? componentGenerators[key]() : 'N/A';
|
| 2043 |
const { global, component: css } = generateComponentCSS(key);
|
| 2044 |
+
const js = getFullJS();
|
| 2045 |
|
| 2046 |
ui.codeModal.title.textContent = `${componentNames[key]} Component Code`;
|
| 2047 |
ui.codeModal.htmlCode.textContent = html;
|
|
|
|
| 2058 |
function generateComponentZip(key) {
|
| 2059 |
const zip = new JSZip();
|
| 2060 |
const { global, component: css } = generateComponentCSS(key);
|
| 2061 |
+
const js = getFullJS();
|
| 2062 |
const htmlBody = componentGenerators[key] ? componentGenerators[key]() : '';
|
| 2063 |
const html = `<!DOCTYPE html><html><head><title>${componentNames[key]}</title><link rel="stylesheet" href="style.css"></head><body>${htmlBody}${js.trim() ? '<script src="script.js"><\/script>' : ''}</body></html>`;
|
| 2064 |
zip.file("index.html", html);
|
|
|
|
| 2076 |
ui.globalSettings.headingColor.value = config.globalSettings.colors.heading;
|
| 2077 |
ui.globalSettings.fontFamily.value = config.globalSettings.typography.fontFamily;
|
| 2078 |
|
|
|
|
| 2079 |
ui.customHtml.toggle.checked = config.customHtml.enabled;
|
| 2080 |
ui.customHtml.content.value = config.customHtml.content;
|
| 2081 |
|
|
|
|
| 2082 |
const lmsUI = ui.learningAppHeader; const lmsConfig = config.learningAppHeader;
|
| 2083 |
lmsUI.stickyToggle.checked = lmsConfig.sticky;
|
| 2084 |
lmsUI.primaryBarToggle.checked = lmsConfig.primaryBar.enabled;
|
|
|
|
| 2091 |
lmsUI.pageTitleText.value = lmsConfig.pageTitle.text;
|
| 2092 |
lmsUI.tabs.toggle.checked = lmsConfig.tabs.enabled;
|
| 2093 |
|
|
|
|
| 2094 |
ui.sidebar.enableToggle.checked = config.sidebar.enabled;
|
| 2095 |
ui.sidebar.brand.sitename.value = config.sidebar.branding.sitename;
|
| 2096 |
ui.sidebar.brand.tagline.value = config.sidebar.branding.tagline;
|
| 2097 |
|
|
|
|
| 2098 |
const topBarUI = ui.topBar;
|
| 2099 |
topBarUI.toggle.checked = config.topBar.enabled;
|
| 2100 |
topBarUI.text.value = config.topBar.text;
|
|
|
|
| 2108 |
topBarUI.paddingVal.textContent = config.topBar.styles.padding;
|
| 2109 |
topBarUI.mainControls.style.display = config.topBar.enabled ? 'block' : 'none';
|
| 2110 |
|
|
|
|
| 2111 |
ui.ticker.toggle.checked = config.ticker.enabled;
|
| 2112 |
|
| 2113 |
ui.footer.aboutDesc.value = config.footer.about.description;
|
|
|
|
| 2118 |
ui.mobileFooter.cta.text.value = config.mobileFooter.cta.text;
|
| 2119 |
ui.mobileFooter.support.toggle.checked = config.mobileFooter.support.enabled;
|
| 2120 |
|
|
|
|
|
|
|
|
|
|
| 2121 |
if (!document.body.classList.contains('initialized')) {
|
| 2122 |
setupEventListeners();
|
| 2123 |
document.body.classList.add('initialized');
|
| 2124 |
}
|
| 2125 |
|
| 2126 |
+
const hasThemeToggle = config.sidebar.shortcuts.links.some(link => link.isThemeToggle);
|
| 2127 |
+
ui.sidebar.themeToggleCheckbox.checked = hasThemeToggle;
|
| 2128 |
+
|
| 2129 |
toggleLmsBrandControls();
|
| 2130 |
createSidebarLinkBuilder('primary-nav', 'Primary Navigation', ui.sidebar.primaryNavBuilder, config.sidebar.primaryNav);
|
| 2131 |
createSidebarLinkBuilder('categories', 'Course Categories', ui.sidebar.categoriesBuilder, config.sidebar.categories);
|