-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
252 lines (217 loc) · 10.3 KB
/
script.js
File metadata and controls
252 lines (217 loc) · 10.3 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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
document.addEventListener('DOMContentLoaded', function() {
// Mobile Menu Toggle
const mobileMenuBtn = document.querySelector('.mobile-menu');
const navbar = document.querySelector('.navbar');
mobileMenuBtn.addEventListener('click', function() {
navbar.classList.toggle('active');
this.classList.toggle('fa-times');
});
// Close mobile menu when clicking on a link
document.querySelectorAll('.navbar ul li a').forEach(link => {
link.addEventListener('click', function() {
navbar.classList.remove('active');
mobileMenuBtn.classList.remove('fa-times');
});
});
// Sticky Header
window.addEventListener('scroll', function() {
const header = document.querySelector('.header');
header.classList.toggle('scrolled', window.scrollY > 100);
});
// Back to Top Button
const backToTopBtn = document.querySelector('.back-to-top');
window.addEventListener('scroll', function() {
if (window.scrollY > 300) {
backToTopBtn.classList.add('active');
} else {
backToTopBtn.classList.remove('active');
}
});
// Smooth Scrolling for Anchor Links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const targetId = this.getAttribute('href');
if (targetId === '#') return;
const targetElement = document.querySelector(targetId);
if (targetElement) {
window.scrollTo({
top: targetElement.offsetTop - 80,
behavior: 'smooth'
});
}
});
});
// Project Filter
const filterButtons = document.querySelectorAll('.filter-btn');
const projectCards = document.querySelectorAll('.project-card');
filterButtons.forEach(button => {
button.addEventListener('click', function() {
// Remove active class from all buttons
filterButtons.forEach(btn => btn.classList.remove('active'));
// Add active class to clicked button
this.classList.add('active');
const filterValue = this.getAttribute('data-filter');
projectCards.forEach(card => {
if (filterValue === 'all' || card.getAttribute('data-category') === filterValue) {
card.style.display = 'block';
} else {
card.style.display = 'none';
}
});
});
});
// Testimonial Slider (Simple Version)
let currentTestimonial = 0;
const testimonials = document.querySelectorAll('.testimonial-card');
function showTestimonial(index) {
testimonials.forEach(testimonial => {
testimonial.style.display = 'none';
});
testimonials[index].style.display = 'block';
}
// Initialize first testimonial
showTestimonial(currentTestimonial);
// Auto-rotate testimonials
setInterval(() => {
currentTestimonial = (currentTestimonial + 1) % testimonials.length;
showTestimonial(currentTestimonial);
}, 5000);
// Form Submission
const contactForm = document.querySelector('.contact-form form');
if (contactForm) {
contactForm.addEventListener('submit', function(e) {
e.preventDefault();
// Here you would typically send the form data to a server
// For demonstration, we'll just show an alert
alert('Thank you for your message! We will get back to you soon.');
this.reset();
});
}
// Newsletter Form
const newsletterForm = document.querySelector('.newsletter-form');
if (newsletterForm) {
newsletterForm.addEventListener('submit', function(e) {
e.preventDefault();
const emailInput = this.querySelector('input[type="email"]');
alert(`Thank you for subscribing with ${emailInput.value}!`);
emailInput.value = '';
});
}
// Animation on Scroll
function animateOnScroll() {
const elements = document.querySelectorAll('.about-content, .service-card, .project-card, .testimonial-card, .contact-content');
elements.forEach(element => {
const elementPosition = element.getBoundingClientRect().top;
const screenPosition = window.innerHeight / 1.3;
if (elementPosition < screenPosition) {
element.style.opacity = '1';
element.style.transform = 'translateY(0)';
}
});
}
// Set initial state for animated elements
const animatedElements = document.querySelectorAll('.about-content, .service-card, .project-card, .testimonial-card, .contact-content');
animatedElements.forEach(element => {
element.style.opacity = '0';
element.style.transform = 'translateY(50px)';
element.style.transition = 'opacity 0.5s ease, transform 0.5s ease';
});
// Run on load and scroll
window.addEventListener('load', animateOnScroll);
window.addEventListener('scroll', animateOnScroll);
});
// Service Popup Functionality
const serviceCards = document.querySelectorAll('.service-card');
const servicePopup = document.getElementById('servicePopup');
const closePopup = document.querySelector('.close-popup');
const popupTitle = document.getElementById('popupServiceTitle');
const popupDescription = document.getElementById('popupServiceDescription');
const serviceImagesContainer = document.getElementById('serviceImages');
// Service data with images and descriptions
const servicesData = {
'RCC WORK': {
description: 'From office towers to retail spaces, we deliver commercial projects that combine functionality with aesthetic appeal. Our team specializes in creating modern, efficient spaces that meet the highest industry standards.',
images: [
'https://images.unsplash.com/photo-1487958449943-2429e8be8625',
'https://images.unsplash.com/photo-1499793983690-e29da59ef1c2',
'https://images.unsplash.com/photo-1502672260266-1c1ef2d93688'
]
},
'EXTENSION WORK': {
description: 'Quality homes built with precision and care, designed to meet your lifestyle needs and exceed expectations. We offer custom home building and development services with attention to every detail.',
images: [
'https://images.unsplash.com/photo-1605276374104-dee2a0ed3cd6',
'https://images.unsplash.com/photo-1600607687920-4e2a09cf159d',
'https://images.unsplash.com/photo-1600585152220-90363fe7e115'
]
},
// Add other services following the same pattern
'CIVIL WORK': {
description: 'Robust industrial facilities designed for efficiency, safety, and long-term operational success. We build warehouses, factories, and specialized industrial spaces with durable materials.',
images: [
'https://images.unsplash.com/photo-1477959858617-67f85cf4f1df',
'https://images.unsplash.com/photo-1513828583688-c52646db42da',
'https://images.unsplash.com/photo-1519501025264-65ba15a82390'
]
},
'INTERIORS': {
description: 'Bridges, roads, and public works that connect communities and drive economic growth. Our infrastructure projects are built to last with innovative engineering solutions.',
images: [
'https://images.unsplash.com/photo-1476231682828-37e571bc172f',
'https://images.unsplash.com/photo-1541625602330-2277a4c46182',
'https://images.unsplash.com/photo-1477959858617-67f85cf4f1df'
]
},
'RESTORATION & REPAIRS': {
description: 'Green building solutions that reduce environmental impact while maintaining structural integrity. We use eco-friendly materials and energy-efficient designs for sustainable development.',
images: [
'https://images.unsplash.com/photo-1486406146926-c627a92ad1ab',
'https://images.unsplash.com/photo-1487958449943-2429e8be8625',
'https://images.unsplash.com/photo-1486406146926-c627a92ad1ab'
]
},
'PAINTING WORK': {
description: 'Transforming existing spaces to meet modern standards and functional requirements. Our renovation services breathe new life into old structures while preserving their character.',
images: [
'https://images.unsplash.com/photo-1556911220-bff31c812dba',
'https://images.unsplash.com/photo-1600121848594-d8644e57abab',
'https://images.unsplash.com/photo-1600566752225-3f2fe98059b1'
]
}
};
// Open popup when service card is clicked
serviceCards.forEach(card => {
card.addEventListener('click', function() {
const serviceName = this.querySelector('h3').textContent;
const serviceData = servicesData[serviceName];
if (serviceData) {
popupTitle.textContent = serviceName;
popupDescription.textContent = serviceData.description;
// Clear previous images
serviceImagesContainer.innerHTML = '';
// Add new images
serviceData.images.forEach(imageUrl => {
const img = document.createElement('img');
img.src = imageUrl;
img.alt = serviceName;
serviceImagesContainer.appendChild(img);
});
// Show popup
servicePopup.classList.add('active');
document.body.style.overflow = 'hidden'; // Prevent scrolling
}
});
});
// Close popup
closePopup.addEventListener('click', function() {
servicePopup.classList.remove('active');
document.body.style.overflow = 'auto'; // Enable scrolling
});
// Close when clicking outside content
servicePopup.addEventListener('click', function(e) {
if (e.target === this) {
servicePopup.classList.remove('active');
document.body.style.overflow = 'auto';
}
});