demonsom's picture
<!DOCTYPE html>
5bef5b3 verified
// Mobile Navigation Toggle
const navToggle = document.querySelector('.nav-toggle');
const navMenu = document.querySelector('.nav-menu');
if (navToggle && navMenu) {
navToggle.addEventListener('click', () => {
navMenu.classList.toggle('active');
navToggle.classList.toggle('is-active');
});
}
// Tracking Form Example
const trackingExamples = document.querySelectorAll('.tracking-example');
const trackingInput = document.getElementById('tracking-number');
if (trackingExamples.length > 0 && trackingInput) {
trackingExamples.forEach(button => {
button.addEventListener('click', () => {
trackingInput.value = button.getAttribute('data-tracking');
});
});
}
// Form Submission
const forms = document.querySelectorAll('form');
forms.forEach(form => {
form.addEventListener('submit', (e) => {
e.preventDefault();
// In a real app, you would submit the form data here
alert('Form submitted successfully!');
});
});
// Dashboard Stats Animation
const statCards = document.querySelectorAll('.stat-card');
statCards.forEach((card, index) => {
setTimeout(() => {
card.style.opacity = '1';
card.style.transform = 'translateY(0)';
}, 300 * index);
});
// Shipment Actions
const actionButtons = document.querySelectorAll('.table-actions button');
actionButtons.forEach(button => {
button.addEventListener('click', (e) => {
e.stopPropagation();
const action = e.currentTarget.querySelector('i').getAttribute('data-feather');
const row = e.currentTarget.closest('tr');
const trackingId = row.cells[1].textContent;
switch(action) {
case 'eye':
alert(`Viewing details for shipment ${trackingId}`);
break;
case 'edit':
alert(`Editing shipment ${trackingId}`);
break;
case 'trash':
if (confirm(`Are you sure you want to delete shipment ${trackingId}?`)) {
row.remove();
}
break;
}
});
});