Spaces:
Running
Running
File size: 4,689 Bytes
9f07ae2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
// Tab functionality for itineraries
document.addEventListener('DOMContentLoaded', function() {
// Tab switching
const tabButtons = document.querySelectorAll('.tab-button');
const tabPanes = document.querySelectorAll('.tab-pane');
tabButtons.forEach(button => {
button.addEventListener('click', () => {
// Remove active class from all buttons and panes
tabButtons.forEach(btn => btn.classList.remove('active'));
tabPanes.forEach(pane => pane.classList.remove('active'));
// Add active class to clicked button
button.classList.add('active');
// Show corresponding pane
const tabIndex = Array.from(tabButtons).indexOf(button);
tabPanes[tabIndex].classList.add('active');
});
});
// Mobile menu toggle
const menuButton = document.querySelector('.md\\:hidden');
if (menuButton) {
menuButton.addEventListener('click', function() {
const nav = document.querySelector('nav');
nav.classList.toggle('hidden');
});
}
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
// Animation on scroll
const observerOptions = {
root: null,
rootMargin: '0px',
threshold: 0.1
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('animate-fadeInUp');
}
});
}, observerOptions);
document.querySelectorAll('.animate-on-scroll').forEach(el => {
observer.observe(el);
});
});
// Animation utilities
const animateOnScroll = {
init() {
const elements = document.querySelectorAll('[data-animate]');
const observer = new IntersectionObserver(entries => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('animated', entry.target.dataset.animate);
observer.unobserve(entry.target);
}
});
}, {
threshold: 0.1
});
elements.forEach(element => {
observer.observe(element);
});
}
};
// Initialize when DOM is loaded
document.addEventListener('DOMContentLoaded', () => {
animateOnScroll.init();
});
// Helper functions
function toggleElement(elementId) {
const element = document.getElementById(elementId);
if (element) {
element.classList.toggle('hidden');
}
}
function showNotification(message, type = 'info') {
// Create notification element
const notification = document.createElement('div');
notification.className = `fixed top-4 right-4 px-6 py-4 rounded-lg shadow-lg z-50 transform transition-all duration-300 ${
type === 'success' ? 'bg-green-500' :
type === 'error' ? 'bg-red-500' :
'bg-blue-500'
} text-white`;
notification.innerHTML = `
<div class="flex items-center">
<i data-feather="${type === 'success' ? 'check-circle' : type === 'error' ? 'x-circle' : 'info'}" class="mr-2"></i>
<span>${message}</span>
</div>
`;
document.body.appendChild(notification);
feather.replace();
// Auto remove after 3 seconds
setTimeout(() => {
notification.classList.add('opacity-0', 'translate-x-full');
setTimeout(() => {
document.body.removeChild(notification);
}, 300);
}, 3000);
}
// Form validation example
function validateSearchForm() {
const input = document.querySelector('input[type="text"]');
if (input && input.value.trim() === '') {
showNotification('Please describe your dream vacation', 'error');
return false;
}
return true;
}
// Add event listener to search form
document.addEventListener('DOMContentLoaded', () => {
const searchForm = document.querySelector('input[type="text"]').closest('div').nextElementSibling;
if (searchForm) {
searchForm.addEventListener('click', function(e) {
if (!validateSearchForm()) {
e.preventDefault();
}
});
}
}); |