|
252 | 252 | } |
253 | 253 |
|
254 | 254 | /* ── RENDER LISTS ─────────────────────────────────────────────── */ |
| 255 | + function renderNavLinks() { |
| 256 | + var el = document.getElementById('navLinksList'); |
| 257 | + if (!el || !cfg) return; |
| 258 | + el.innerHTML = (cfg.navLinks || []).map(function (lnk, i) { |
| 259 | + return '<div class="list-item"><div class="li-row">' + |
| 260 | + '<input type="text" value="' + esc(lnk.label) + '" data-nll="' + i + '" placeholder="Label">' + |
| 261 | + '<input type="text" value="' + esc(lnk.href) + '" data-nlh="' + i + '" placeholder="#section">' + |
| 262 | + '<button class="btn-rm" data-rnl="' + i + '" title="Remove"><i class="fas fa-times"></i></button>' + |
| 263 | + '</div></div>'; |
| 264 | + }).join(''); |
| 265 | + el.querySelectorAll('[data-nll]').forEach(function (inp) { |
| 266 | + inp.addEventListener('input', function () { cfg.navLinks[+inp.dataset.nll].label = inp.value; schedulePreview(); }); |
| 267 | + }); |
| 268 | + el.querySelectorAll('[data-nlh]').forEach(function (inp) { |
| 269 | + inp.addEventListener('input', function () { cfg.navLinks[+inp.dataset.nlh].href = inp.value; schedulePreview(); }); |
| 270 | + }); |
| 271 | + el.querySelectorAll('[data-rnl]').forEach(function (btn) { |
| 272 | + btn.addEventListener('click', function () { cfg.navLinks.splice(+btn.dataset.rnl, 1); renderNavLinks(); schedulePreview(); }); |
| 273 | + }); |
| 274 | +} |
| 275 | + |
| 276 | + document.getElementById('addNavLinkBtn').addEventListener('click', function () { |
| 277 | + if (!cfg) return; |
| 278 | + cfg.navLinks.push({ label: 'New link', href: '#' }); |
| 279 | + renderNavLinks(); |
| 280 | + schedulePreview(); |
| 281 | +}); |
| 282 | + |
255 | 283 | function renderBrands() { |
256 | 284 | var el = document.getElementById('brandsList'); |
257 | 285 | if (!el || !cfg) return; |
|
273 | 301 | '<div class="li-row"><input type="text" value="' + esc(f.icon) + '" data-fi="' + i + '" placeholder="Icon HTML"></div>' + |
274 | 302 | '</div>'; |
275 | 303 | }).join(''); |
| 304 | + |
276 | 305 | el.querySelectorAll('[data-ft]').forEach(function (inp) { inp.addEventListener('input', function () { cfg.features[+inp.dataset.ft].title = inp.value; schedulePreview(); }); }); |
277 | 306 | el.querySelectorAll('[data-fd]').forEach(function (inp) { inp.addEventListener('input', function () { cfg.features[+inp.dataset.fd].desc = inp.value; schedulePreview(); }); }); |
278 | 307 | el.querySelectorAll('[data-fi]').forEach(function (inp) { inp.addEventListener('input', function () { cfg.features[+inp.dataset.fi].icon = inp.value; schedulePreview(); }); }); |
|
351 | 380 | el.querySelectorAll('[data-rl]').forEach(function (btn) { btn.addEventListener('click', function () { cfg.footer.legal.splice(+btn.dataset.rl,1); renderLegal(); schedulePreview(); }); }); |
352 | 381 | } |
353 | 382 |
|
354 | | - function renderAllLists() { renderBrands(); renderFeatures(); renderPanels(); renderFooterCols(); renderSocial(); renderLegal(); } |
| 383 | + |
| 384 | + |
| 385 | + function renderAllLists() { |
| 386 | + renderNavLinks(); // added |
| 387 | + renderBrands(); |
| 388 | + renderFeatures(); |
| 389 | + renderPanels(); |
| 390 | + renderFooterCols(); |
| 391 | + renderSocial(); |
| 392 | + renderLegal(); |
| 393 | +} |
355 | 394 |
|
356 | 395 | /* ── ADD BUTTONS ──────────────────────────────────────────────── */ |
357 | 396 | document.getElementById('addBrandBtn').addEventListener('click', function () { if (!cfg) return; cfg.brands.push('New Brand'); renderBrands(); schedulePreview(); }); |
|
0 commit comments