Files
ETPlot/assets/js/folder-metadata.js
T

70 lines
2.4 KiB
JavaScript

/**
* Folder Metadata functionality for Gallery
*
* Handles interactions with folder-level metadata display
*/
// Function to toggle expansion of long metadata text
function toggleMetadataText(button) {
const longText = button.previousElementSibling;
const fullText = button.nextElementSibling;
if (fullText.style.display === 'none') {
// Show full text
longText.style.display = 'none';
fullText.style.display = 'inline';
fullText.classList.add('show');
button.textContent = 'Show less';
} else {
// Show truncated text
longText.style.display = 'inline';
fullText.style.display = 'none';
fullText.classList.remove('show');
button.textContent = 'Show more';
}
}
// Function to handle folder metadata editing (placeholder for future implementation)
function editFolderMetadata() {
// For now, just show an alert that this feature is coming soon
alert('Folder metadata editing functionality is coming soon!');
// Future implementation will:
// 1. Open an edit modal with form fields for each metadata key
// 2. Allow adding/removing metadata fields
// 3. Validate the input
// 4. Send updates to the server
// 5. Refresh the page or update the display dynamically
}
// Initialize folder metadata functionality when DOM is loaded
document.addEventListener('DOMContentLoaded', function() {
console.log('Folder metadata functionality initialized');
// Add keyboard shortcuts for metadata editing (future feature)
document.addEventListener('keydown', function(e) {
// Ctrl+M for metadata editing
if (e.ctrlKey && e.key === 'm') {
e.preventDefault();
const editBtn = document.querySelector('.folder-metadata-edit-btn');
if (editBtn) {
editFolderMetadata();
}
}
});
// Add accessibility improvements
const metadataItems = document.querySelectorAll('.folder-metadata-item');
metadataItems.forEach(item => {
item.setAttribute('tabindex', '0');
item.setAttribute('role', 'listitem');
});
// Add ARIA labels for better accessibility
const metadataContainer = document.querySelector('.folder-metadata-container');
if (metadataContainer) {
metadataContainer.setAttribute('role', 'region');
metadataContainer.setAttribute('aria-label', 'Folder metadata information');
}
});