Jake Vanderwerf
2025-12-21 3aada9949d51024a92a8b5c6cb70d12f9c3cac16
assets/js/concise/Tabs.js
File was renamed from assets/js/dash/Tabs.js
@@ -63,7 +63,7 @@
            if(hasChildren && hasChildren.querySelector('.tabs')){
                let container = this.container.querySelector(`.tab-content[data-tab="${tab.dataset['tab']}"]`);
                let tabs = new window.jvbTabs(container, {}, this);
            let tabs = new window.jvbTabs(container, {updateURL: false}, this);
                this.childTabs.set(tab.dataset.tab, tabs);
            }
        });
@@ -157,11 +157,8 @@
     * @param {boolean} updateHistory - Whether to push the state to the url
     */
    switchTab(tab, updateHistory = false) {
      document.activeElement?.blur();
      // if (typeof this.callbacks['onSwitch'] === 'function') {
      //    this.callbacks.onSwitch(tab)
      // }
        // Update tab buttons
        this.tabs.querySelectorAll('[data-tab]').forEach(tabBtn => {
            tabBtn.classList.toggle('active', tabBtn.dataset.tab === tab);
@@ -181,19 +178,19 @@
            this.callbacks[tab]();
        }
      // Activate first child tab if this tab has children
      const childContainer = this.childTabs.get(tab);
      if (childContainer) {
         const firstTab = childContainer.container.querySelector('button.tab')?.dataset.tab;
         if (firstTab) {
            childContainer.switchTab(firstTab, false);
         }
      }
        // Update URL hash with full path (only from root container)
        if (updateHistory) {
            if (!this.parent) {
                // This is a root container, build full path including child tabs
                let fullPath = tab;
                // Add active child tab paths if they exist
                const childContainer = this.childTabs.get(tab);
                if (childContainer && childContainer.activeTab) {
                    fullPath = childContainer.getFullTabPath(childContainer.activeTab);
                }
                window.history.pushState({ tab: fullPath }, '', `#${fullPath}`);
            window.history.pushState({ tab: tab }, '', `#${tab}`);
            } else {
                // This is a child container, notify parent to update URL
                this.parent.updateUrlFromChild();