2026-02-20 12:27:52 +01:00
|
|
|
/**
|
|
|
|
|
* OxiCloud - View navigation actions
|
|
|
|
|
* Extracted from main.js to keep navigation concerns isolated.
|
|
|
|
|
*/
|
|
|
|
|
|
2026-02-22 20:20:00 -08:00
|
|
|
// Mapping of section names to their corresponding view flags
|
|
|
|
|
const VIEW_FLAGS = {
|
|
|
|
|
'files': 'isFilesView',
|
|
|
|
|
'shared': 'isSharedView',
|
|
|
|
|
'recent': 'isRecentView',
|
|
|
|
|
'favorites': 'isFavoritesView',
|
|
|
|
|
'trash': 'isTrashView'
|
|
|
|
|
};
|
2026-02-20 12:27:52 +01:00
|
|
|
|
2026-02-22 20:20:00 -08:00
|
|
|
/**
|
|
|
|
|
* Derive section name from nav item's data-i18n attribute.
|
|
|
|
|
* @param {HTMLElement} navItem - The nav item element
|
|
|
|
|
* @returns {string|null} - Section name or null if not found
|
|
|
|
|
*/
|
|
|
|
|
function getSectionFromNavItem(navItem) {
|
|
|
|
|
const i18nKey = navItem.querySelector('span[data-i18n]')?.getAttribute('data-i18n');
|
|
|
|
|
return i18nKey ? i18nKey.replace('nav.', '') : null;
|
|
|
|
|
}
|
2026-02-20 12:27:52 +01:00
|
|
|
|
2026-02-22 20:20:00 -08:00
|
|
|
/**
|
|
|
|
|
* Set the current active section, updating all view flags and nav UI.
|
|
|
|
|
* @param {string} section - The section to activate ('files', 'shared', 'recent', 'favorites', 'trash')
|
|
|
|
|
*/
|
|
|
|
|
function setCurrentSection(section) {
|
|
|
|
|
// Set all view flags - true for active section, false for others
|
|
|
|
|
Object.entries(VIEW_FLAGS).forEach(([key, flag]) => {
|
|
|
|
|
window.app[flag] = (key === section);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
window.app.currentSection = section;
|
|
|
|
|
|
|
|
|
|
// Update nav item active classes by finding matching item from DOM
|
|
|
|
|
window.appElements.navItems.forEach(item => {
|
|
|
|
|
const itemSection = getSectionFromNavItem(item);
|
|
|
|
|
item.classList.toggle('active', itemSection === section);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Update page title
|
|
|
|
|
const titleKey = `nav.${section}`;
|
|
|
|
|
const defaultTitle = section.charAt(0).toUpperCase() + section.slice(1);
|
|
|
|
|
window.appElements.pageTitle.textContent = window.i18n ? window.i18n.t(titleKey) : defaultTitle;
|
|
|
|
|
window.appElements.pageTitle.setAttribute('data-i18n', titleKey);
|
|
|
|
|
|
|
|
|
|
// Hide sharedView when switching to any other section
|
|
|
|
|
if (section !== 'shared' && window.sharedView) {
|
|
|
|
|
window.sharedView.hide();
|
2026-02-20 12:27:52 +01:00
|
|
|
}
|
2026-02-22 20:20:00 -08:00
|
|
|
}
|
2026-02-20 12:27:52 +01:00
|
|
|
|
2026-02-22 20:20:00 -08:00
|
|
|
function switchToSharedView() {
|
|
|
|
|
setCurrentSection('shared');
|
2026-02-20 12:27:52 +01:00
|
|
|
|
2026-02-22 20:20:00 -08:00
|
|
|
// Hide breadcrumb (only shown in Files view)
|
2026-02-20 12:27:52 +01:00
|
|
|
const breadcrumb = document.querySelector('.breadcrumb');
|
|
|
|
|
if (breadcrumb) breadcrumb.style.display = 'none';
|
|
|
|
|
|
2026-02-22 20:20:00 -08:00
|
|
|
// Hide actions-bar for shared view
|
|
|
|
|
window.setActionsBarMode('hidden');
|
2026-02-20 12:27:52 +01:00
|
|
|
|
|
|
|
|
const filesGrid = document.getElementById('files-grid');
|
|
|
|
|
const filesListView = document.getElementById('files-list-view');
|
|
|
|
|
if (filesGrid) filesGrid.style.display = 'none';
|
|
|
|
|
if (filesListView) filesListView.style.display = 'none';
|
|
|
|
|
|
2026-02-22 20:20:00 -08:00
|
|
|
// Show shared view
|
2026-02-20 12:27:52 +01:00
|
|
|
if (window.sharedView) {
|
|
|
|
|
window.sharedView.init();
|
|
|
|
|
window.sharedView.show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function switchToFilesView() {
|
2026-02-22 20:20:00 -08:00
|
|
|
setCurrentSection('files');
|
2026-02-20 12:27:52 +01:00
|
|
|
|
2026-02-22 20:20:00 -08:00
|
|
|
// Set actions bar mode
|
|
|
|
|
window.setActionsBarMode('files', true);
|
2026-02-20 12:27:52 +01:00
|
|
|
|
2026-02-22 20:20:00 -08:00
|
|
|
// Show breadcrumb (only in Files view)
|
2026-02-20 12:27:52 +01:00
|
|
|
const breadcrumb = document.querySelector('.breadcrumb');
|
|
|
|
|
if (breadcrumb) breadcrumb.style.display = '';
|
|
|
|
|
|
|
|
|
|
const filesGrid = document.getElementById('files-grid');
|
|
|
|
|
const filesListView = document.getElementById('files-list-view');
|
2026-02-22 20:20:00 -08:00
|
|
|
if (filesGrid) filesGrid.style.display = window.app.currentView === 'grid' ? 'grid' : 'none';
|
|
|
|
|
if (filesListView) filesListView.style.display = window.app.currentView === 'list' ? 'block' : 'none';
|
|
|
|
|
|
|
|
|
|
// Reset to home folder and update breadcrumb
|
|
|
|
|
window.app.currentPath = window.app.userHomeFolderId || '';
|
|
|
|
|
window.app.breadcrumbPath = [];
|
|
|
|
|
window.ui.updateBreadcrumb();
|
2026-02-20 12:27:52 +01:00
|
|
|
|
|
|
|
|
window.loadFiles();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function switchToFavoritesView() {
|
2026-02-22 20:20:00 -08:00
|
|
|
setCurrentSection('favorites');
|
2026-02-20 12:27:52 +01:00
|
|
|
|
2026-02-22 20:20:00 -08:00
|
|
|
// Set actions bar mode
|
2026-02-20 12:27:52 +01:00
|
|
|
window.setActionsBarMode('favorites');
|
|
|
|
|
|
2026-02-22 20:20:00 -08:00
|
|
|
// Hide breadcrumb (only shown in Files view)
|
|
|
|
|
const breadcrumb = document.querySelector('.breadcrumb');
|
|
|
|
|
if (breadcrumb) breadcrumb.style.display = 'none';
|
|
|
|
|
|
2026-02-20 12:27:52 +01:00
|
|
|
const filesGrid = document.getElementById('files-grid');
|
|
|
|
|
const filesListView = document.getElementById('files-list-view');
|
2026-02-22 20:20:00 -08:00
|
|
|
if (filesGrid) filesGrid.style.display = window.app.currentView === 'grid' ? 'grid' : 'none';
|
|
|
|
|
if (filesListView) filesListView.style.display = window.app.currentView === 'list' ? 'block' : 'none';
|
2026-02-20 12:27:52 +01:00
|
|
|
|
|
|
|
|
if (window.favorites) {
|
|
|
|
|
window.favorites.displayFavorites();
|
|
|
|
|
} else {
|
|
|
|
|
console.error('Favorites module not loaded or initialized');
|
|
|
|
|
const filesGridError = document.getElementById('files-grid');
|
|
|
|
|
if (filesGridError) {
|
|
|
|
|
filesGridError.innerHTML = `
|
|
|
|
|
<div class="empty-state">
|
|
|
|
|
<i class="fas fa-exclamation-circle" style="font-size: 48px; color: #f44336; margin-bottom: 16px;"></i>
|
|
|
|
|
<p>Error loading the favorites module</p>
|
|
|
|
|
</div>
|
|
|
|
|
`;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function switchToRecentFilesView() {
|
2026-02-22 20:20:00 -08:00
|
|
|
setCurrentSection('recent');
|
2026-02-20 12:27:52 +01:00
|
|
|
|
2026-02-22 20:20:00 -08:00
|
|
|
// Set actions bar mode
|
2026-02-20 12:27:52 +01:00
|
|
|
window.setActionsBarMode('recent');
|
|
|
|
|
|
2026-02-22 20:20:00 -08:00
|
|
|
// Hide breadcrumb (only shown in Files view)
|
|
|
|
|
const breadcrumb = document.querySelector('.breadcrumb');
|
|
|
|
|
if (breadcrumb) breadcrumb.style.display = 'none';
|
|
|
|
|
|
2026-02-20 12:27:52 +01:00
|
|
|
const filesGrid = document.getElementById('files-grid');
|
|
|
|
|
const filesListView = document.getElementById('files-list-view');
|
2026-02-22 20:20:00 -08:00
|
|
|
if (filesGrid) filesGrid.style.display = window.app.currentView === 'grid' ? 'grid' : 'none';
|
|
|
|
|
if (filesListView) filesListView.style.display = window.app.currentView === 'list' ? 'block' : 'none';
|
2026-02-20 12:27:52 +01:00
|
|
|
|
|
|
|
|
if (window.recent) {
|
|
|
|
|
window.recent.displayRecentFiles();
|
|
|
|
|
} else {
|
|
|
|
|
console.error('Recent files module not loaded or initialized');
|
|
|
|
|
const filesGridError = document.getElementById('files-grid');
|
|
|
|
|
if (filesGridError) {
|
|
|
|
|
filesGridError.innerHTML = `
|
|
|
|
|
<div class="empty-state">
|
|
|
|
|
<i class="fas fa-exclamation-circle" style="font-size: 48px; color: #f44336; margin-bottom: 16px;"></i>
|
|
|
|
|
<p>Error loading the recent files module</p>
|
|
|
|
|
</div>
|
|
|
|
|
`;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
window.switchToFilesView = switchToFilesView;
|
|
|
|
|
window.switchToSharedView = switchToSharedView;
|
|
|
|
|
window.switchToFavoritesView = switchToFavoritesView;
|
|
|
|
|
window.switchToRecentFilesView = switchToRecentFilesView;
|