tagliatelle

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

admin-tabs.js (1334B)


      1 function activateTab(contentPrefix, btnSelector, tabPrefix, tabName) {
      2     document.querySelectorAll(btnSelector).forEach(btn => {
      3         btn.style.borderBottomColor = 'transparent';
      4         btn.style.fontWeight = 'normal';
      5     });
      6 
      7     document.querySelectorAll(`[id^="${contentPrefix}"]`).forEach(el => {
      8         el.style.display = 'none';
      9     });
     10 
     11     const selectedContent = document.getElementById(contentPrefix + tabName);
     12     if (selectedContent) selectedContent.style.display = 'block';
     13 
     14     const selectedBtn = document.getElementById(tabPrefix + tabName);
     15     if (selectedBtn) {
     16         selectedBtn.style.borderBottomColor = '#007bff';
     17         selectedBtn.style.fontWeight = 'bold';
     18     }
     19 }
     20 
     21 function showAdminTab(tabName) {
     22     activateTab('admin-content-', '.admin-tab-btn', 'admin-tab-', tabName);
     23 }
     24 
     25 function showThumbnailSubTab(subTabName) {
     26     activateTab('thumb-content-', '.thumb-subtab-btn', 'thumb-subtab-', subTabName);
     27 }
     28 
     29 document.addEventListener('DOMContentLoaded', function() {
     30     showAdminTab('settings');
     31     showThumbnailSubTab('missing');
     32 
     33     document.querySelectorAll('.auto-hide-success').forEach(div => {
     34         setTimeout(() => {
     35             div.style.transition = 'opacity 0.5s';
     36             div.style.opacity = '0';
     37             setTimeout(() => div.remove(), 500);
     38         }, 5000);
     39     });
     40 });