fix: restore and stabilize tab navigation with Alpine.js
- Fixed navigation blockage by moving Alpine state to body scope - Resolved CSS display conflicts between legacy .active class and x-show - Synchronized legacy auth logic with Alpine global state - Redirected legacy switchTab calls to Alpine events - Removed obsolete tabs.js and updated home section initialization - Added E2E navigation test placeholder
This commit is contained in:
+3
-55
@@ -195,63 +195,11 @@ async function handleDownloadProviderEpisode(providerId) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch between tabs
|
||||
* Switch between tabs (Modernized to Alpine.js)
|
||||
*/
|
||||
function switchTab(tabName) {
|
||||
// Hide all tabs
|
||||
document.querySelectorAll('.tab-content').forEach(tab => {
|
||||
tab.classList.remove('active');
|
||||
});
|
||||
document.querySelectorAll('.tab').forEach(btn => {
|
||||
btn.classList.remove('active');
|
||||
});
|
||||
|
||||
// Show selected tab
|
||||
const tabElement = document.getElementById(`tab-${tabName}`);
|
||||
if (tabElement) {
|
||||
tabElement.classList.add('active');
|
||||
}
|
||||
|
||||
// Find and activate the button
|
||||
const buttons = document.querySelectorAll('.tab');
|
||||
buttons.forEach(btn => {
|
||||
const tabType = btn.getAttribute('data-tab-type');
|
||||
|
||||
if (tabType === 'home' && tabName === 'home') {
|
||||
btn.classList.add('active');
|
||||
} else if (tabType === 'anime' && tabName === 'anime') {
|
||||
// Static anime tab
|
||||
btn.classList.add('active');
|
||||
} else if (tabType === 'series' && tabName === 'series') {
|
||||
// Static series tab
|
||||
btn.classList.add('active');
|
||||
} else if (tabType === 'providers' && tabName === 'providers') {
|
||||
// Static providers tab
|
||||
btn.classList.add('active');
|
||||
} else if (tabType === 'anime' && btn.getAttribute('data-provider') === tabName.replace('anime-', '')) {
|
||||
btn.classList.add('active');
|
||||
} else if (tabType === 'series' && btn.getAttribute('data-provider') === tabName.replace('series-', '')) {
|
||||
btn.classList.add('active');
|
||||
}
|
||||
});
|
||||
|
||||
// Load home content when switching to home tab
|
||||
if (tabName === 'home') {
|
||||
// Content is already loaded on init, but you can reload if needed
|
||||
if (typeof loadHomeContent === 'function' && !document.getElementById('recommendationsList').hasChildNodes()) {
|
||||
loadHomeContent();
|
||||
}
|
||||
}
|
||||
|
||||
// Load watchlist content when switching to watchlist tab
|
||||
if (tabName === 'watchlist') {
|
||||
if (typeof loadSchedulerStatus === 'function') {
|
||||
loadSchedulerStatus();
|
||||
}
|
||||
if (typeof displayWatchlist === 'function') {
|
||||
displayWatchlist();
|
||||
}
|
||||
}
|
||||
console.log('Switching tab to:', tabName);
|
||||
window.dispatchEvent(new CustomEvent('set-tab', { detail: { tab: tabName } }));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user