This commit is contained in:
pika 2025-03-24 14:38:18 +01:00
parent e99b2745bd
commit 16e8490b30
6 changed files with 330 additions and 90 deletions

View file

@ -88,38 +88,38 @@ function initializeFolderNavigation() {
// Modal handling
function initializeModals() {
// New folder modal
const newFolderBtn = document.getElementById('new-folder-btn');
const newFolderModal = document.getElementById('new-folder-modal');
const emptyNewFolderBtn = document.getElementById('empty-new-folder-btn');
// Hide all modals by default
document.querySelectorAll('.modal, .upload-modal, [class*="-modal"]').forEach(modal => {
modal.style.display = 'none';
modal.style.opacity = '0';
modal.style.visibility = 'hidden';
if (newFolderBtn && newFolderModal) {
newFolderBtn.addEventListener('click', function () {
newFolderModal.style.display = 'flex';
document.getElementById('folder-name').focus();
});
if (emptyNewFolderBtn) {
emptyNewFolderBtn.addEventListener('click', function () {
newFolderModal.style.display = 'flex';
document.getElementById('folder-name').focus();
});
}
// Close modal
document.querySelectorAll('.modal-close, .modal-cancel').forEach(btn => {
// Get close buttons
const closeButtons = modal.querySelectorAll('.modal-close, .close-btn, .modal-cancel');
closeButtons.forEach(btn => {
btn.addEventListener('click', function () {
newFolderModal.style.display = 'none';
modal.classList.remove('active');
});
});
// Close on click outside
window.addEventListener('click', function (event) {
if (event.target === newFolderModal) {
newFolderModal.style.display = 'none';
// Close when clicking outside
modal.addEventListener('click', function (e) {
if (e.target === modal) {
modal.classList.remove('active');
}
});
}
});
// Setup modal triggers
document.querySelectorAll('[data-modal]').forEach(trigger => {
trigger.addEventListener('click', function () {
const modalId = this.dataset.modal;
const modal = document.getElementById(modalId);
if (modal) {
modal.classList.add('active');
}
});
});
}
// Context menu for right-click on files/folders