frayerjj-frontend 0.7.7 → 0.7.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/init.js +25 -0
package/package.json
CHANGED
package/src/init.js
CHANGED
|
@@ -152,6 +152,31 @@ export const init = (args) => {
|
|
|
152
152
|
});
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
+
// Tab Session Persistence
|
|
156
|
+
const PERSIST_CLASS = 'tab-session-persist';
|
|
157
|
+
document.querySelectorAll(`.${PERSIST_CLASS}`).forEach(container => {
|
|
158
|
+
const storageKey = `activeTab_${window.location.pathname}_${container.id}`;
|
|
159
|
+
const savedTarget = session.getStrVar(storageKey);
|
|
160
|
+
msg.verbose(`Restoring tab for container #${container.id} with key ${storageKey}:`, savedTarget);
|
|
161
|
+
if (savedTarget) {
|
|
162
|
+
const tabEl = container.querySelector(`[data-bs-target="${savedTarget}"], [href="${savedTarget}"]`);
|
|
163
|
+
if (tabEl) {
|
|
164
|
+
const tab = new bootstrap.Tab(tabEl);
|
|
165
|
+
tab.show();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
document.addEventListener('shown.bs.tab', event => {
|
|
170
|
+
const tabButton = event.target;
|
|
171
|
+
const container = tabButton.closest(`.${PERSIST_CLASS}`);
|
|
172
|
+
if (container) {
|
|
173
|
+
const storageKey = `activeTab_${window.location.pathname}_${container.id}`;
|
|
174
|
+
const target = tabButton.getAttribute('data-bs-target') || tabButton.getAttribute('href');
|
|
175
|
+
session.set(storageKey, target);
|
|
176
|
+
msg.verbose(`Saved active tab for container #${container.id} with key ${storageKey}:`, target);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
|
|
155
180
|
});
|
|
156
181
|
|
|
157
182
|
}
|