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

View file

@ -472,29 +472,40 @@ document.addEventListener('DOMContentLoaded', function () {
}
// File upload functionality
const uploadBtn = document.querySelector('.btn.primary [class*="fa-upload"]');
const fileInput = document.getElementById('file-upload');
const uploadButton = document.getElementById('upload-button');
const uploadModal = document.querySelector('.upload-modal');
// Check if we're on upload page or have upload elements
if (uploadBtn && fileInput) {
uploadBtn.addEventListener('click', function (e) {
// Trigger the hidden file input
// Hide upload modal by default if it exists
if (uploadModal) {
uploadModal.style.display = 'none';
uploadModal.style.opacity = '0';
uploadModal.style.visibility = 'hidden';
}
// Setup upload button
if (uploadButton && fileInput) {
uploadButton.addEventListener('click', function () {
fileInput.click();
});
fileInput.addEventListener('change', function () {
if (this.files.length) {
if (this.files.length > 0) {
// Handle file upload
handleFileUpload(this.files);
}
});
// Setup drag and drop zone if exists
const dropzone = document.getElementById('dropzone');
if (dropzone) {
setupDragAndDrop(dropzone);
}
}
// Close upload modal when close button is clicked
const closeButtons = document.querySelectorAll('.upload-modal .close-btn, .upload-modal .modal-close');
closeButtons.forEach(btn => {
btn.addEventListener('click', function () {
if (uploadModal) {
uploadModal.classList.remove('active');
}
});
});
// Handle file upload process
function handleFileUpload(files) {
// Show progress indicator