-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
184 lines (159 loc) · 5.95 KB
/
Copy pathscript.js
File metadata and controls
184 lines (159 loc) · 5.95 KB
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
// DOM Elements
const hamburger = document.querySelector('.hamburger');
const navLinks = document.querySelector('.nav-links');
const inquiryBtns = document.querySelectorAll('.inquiry-btn');
const modal = document.getElementById('inquiryModal');
const closeModal = document.querySelector('.close-modal');
const inquiryForm = document.getElementById('inquiryForm');
const houseTypeInput = document.getElementById('houseType');
const contactForm = document.getElementById('contactForm');
const slider = document.querySelector('.slider');
const images = slider.querySelectorAll('img');
// Mobile Navigation
hamburger.addEventListener('click', () => {
navLinks.classList.toggle('active');
hamburger.innerHTML = navLinks.classList.contains('active')
? '<i class="fas fa-times"></i>'
: '<i class="fas fa-bars"></i>';
});
// Close mobile menu when clicking outside
document.addEventListener('click', (e) => {
if (!hamburger.contains(e.target) && !navLinks.contains(e.target)) {
navLinks.classList.remove('active');
hamburger.innerHTML = '<i class="fas fa-bars"></i>';
}
});
// Image Slider
let currentImage = 0;
function changeSlide() {
images[currentImage].style.opacity = 0;
currentImage = (currentImage + 1) % images.length;
images[currentImage].style.opacity = 1;
}
setInterval(changeSlide, 4000);
// Initialize Map
function initMap() {
// Miritini, Mombasa coordinates
const miritini = [-4.0333, 39.6333];
const map = L.map('map').setView(miritini, 14);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors'
}).addTo(map);
// Add marker for CANA COURT
const canaCourt = L.marker([-4.0333, 39.6333]).addTo(map);
canaCourt.bindPopup('<b>CANA COURT</b><br>Premium Rental Apartments<br>Miritini, Mombasa');
// Add some points of interest
const points = [
{name: "Moi International Airport", coords: [-4.0348, 39.5945], icon: "✈️"},
{name: "SGR Station", coords: [-4.025, 39.618], icon: "🚆"},
{name: "Miritini Market", coords: [-4.03, 39.64], icon: "🛒"},
{name: "Local Park", coords: [-4.028, 39.628], icon: "🌳"}
];
points.forEach(point => {
L.marker(point.coords)
.addTo(map)
.bindPopup(`<b>${point.icon} ${point.name}</b>`);
});
}
// Inquiry Modal
inquiryBtns.forEach(btn => {
btn.addEventListener('click', () => {
modal.style.display = 'flex';
houseTypeInput.value = btn.dataset.house + ' Apartment';
});
});
closeModal.addEventListener('click', () => {
modal.style.display = 'none';
});
window.addEventListener('click', (e) => {
if (e.target === modal) {
modal.style.display = 'none';
}
});
// Form Submissions
inquiryForm.addEventListener('submit', (e) => {
e.preventDefault();
const anonymousId = document.getElementById('anonymousId').value;
const message = document.getElementById('inquiryMessage').value;
// In a real application, this would send data to a backend
alert(`Thank you! Your inquiry for ${houseTypeInput.value} has been received. Admin will contact you soon.`);
modal.style.display = 'none';
inquiryForm.reset();
});
contactForm.addEventListener('submit', (e) => {
e.preventDefault();
alert('Message sent to admin! You will receive a response within 24 hours.');
contactForm.reset();
});
// Smooth Scrolling
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'
});
// Close mobile menu after clicking
navLinks.classList.remove('active');
hamburger.innerHTML = '<i class="fas fa-bars"></i>';
}
});
});
// Initialize map when page loads
document.addEventListener('DOMContentLoaded', initMap);
// Gallery lightbox functionality
const galleryItems = document.querySelectorAll('.gallery-item');
galleryItems.forEach(item => {
item.addEventListener('click', () => {
const imgSrc = item.querySelector('img').src;
const lightbox = document.createElement('div');
lightbox.style.cssText = `
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.9);
display: flex;
justify-content: center;
align-items: center;
z-index: 2000;
cursor: pointer;
`;
const img = document.createElement('img');
img.src = imgSrc;
img.style.cssText = `
max-width: 90%;
max-height: 90%;
object-fit: contain;
border-radius: 10px;
`;
lightbox.appendChild(img);
document.body.appendChild(lightbox);
lightbox.addEventListener('click', () => {
lightbox.remove();
});
});
});
// Animate elements on scroll
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
}
});
}, observerOptions);
// Observe animated elements
document.querySelectorAll('.property-card, .rules-card, .gallery-item').forEach(el => {
el.style.opacity = '0';
el.style.transform = 'translateY(20px)';
el.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
observer.observe(el);
});