-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
199 lines (167 loc) · 6.46 KB
/
Copy pathscript.js
File metadata and controls
199 lines (167 loc) · 6.46 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
// FAQ Accordion
document.addEventListener('DOMContentLoaded', function() {
const faqItems = document.querySelectorAll('.faq-item');
faqItems.forEach(item => {
const question = item.querySelector('.faq-question');
question.addEventListener('click', () => {
const isActive = item.classList.contains('active');
// Close all FAQ items
faqItems.forEach(faqItem => {
faqItem.classList.remove('active');
});
// Open clicked item if it wasn't active
if (!isActive) {
item.classList.add('active');
}
});
});
});
// Smooth scroll for navigation 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'
});
}
});
});
// Contact form handling
const contactForm = document.querySelector('.contact-form');
if (contactForm) {
contactForm.addEventListener('submit', function(e) {
e.preventDefault();
// Get form data
const formData = new FormData(this);
const data = {
name: this.querySelector('input[type="text"]').value,
contact: this.querySelector('input[type="tel"]').value,
comment: this.querySelector('textarea').value
};
// Here you would typically send the data to a server
console.log('Form submitted:', data);
// Show success message
alert('Спасибо! Ваша заявка отправлена. Мы свяжемся с вами в ближайшее время.');
// Reset form
this.reset();
});
}
// Footer email form handling
const footerInput = document.querySelector('.footer-input');
const footerButton = document.querySelector('.footer-cta .btn-primary');
if (footerInput && footerButton) {
footerButton.addEventListener('click', function(e) {
e.preventDefault();
const email = footerInput.value;
if (email && email.includes('@')) {
console.log('Email submitted:', email);
alert('Спасибо! Мы отправим вам информацию о тестировании.');
footerInput.value = '';
} else {
alert('Пожалуйста, введите корректный email адрес.');
}
});
}
// Header scroll effect
let lastScroll = 0;
const header = document.querySelector('.header');
window.addEventListener('scroll', () => {
const currentScroll = window.pageYOffset;
if (currentScroll > 100) {
header.style.boxShadow = '0 2px 10px rgba(0,0,0,0.1)';
} else {
header.style.boxShadow = 'none';
}
lastScroll = currentScroll;
});
// Partners carousel auto-scroll (optional)
const partnersCarousel = document.querySelector('.partners-carousel');
if (partnersCarousel) {
let scrollPosition = 0;
const scrollSpeed = 1;
function autoScroll() {
scrollPosition += scrollSpeed;
partnersCarousel.scrollLeft = scrollPosition;
// Reset scroll position when reaching the end
if (scrollPosition >= partnersCarousel.scrollWidth - partnersCarousel.clientWidth) {
scrollPosition = 0;
}
}
// Pause auto-scroll on hover
partnersCarousel.addEventListener('mouseenter', () => {
clearInterval(autoScrollInterval);
});
partnersCarousel.addEventListener('mouseleave', () => {
autoScrollInterval = setInterval(autoScroll, 20);
});
// Start auto-scroll (uncomment if needed)
// const autoScrollInterval = setInterval(autoScroll, 20);
}
// Intersection Observer for fade-in animations
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 sections for animation
document.querySelectorAll('section').forEach(section => {
section.style.opacity = '0';
section.style.transform = 'translateY(20px)';
section.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
observer.observe(section);
});
// Mobile menu toggle
const navMenu = document.querySelector('.nav-menu');
const nav = document.querySelector('.nav');
// Add mobile menu button if screen is small
function addMobileMenu() {
if (window.innerWidth <= 768 && !document.querySelector('.mobile-menu-toggle')) {
const menuToggle = document.createElement('button');
menuToggle.className = 'mobile-menu-toggle';
menuToggle.innerHTML = '☰';
menuToggle.setAttribute('aria-label', 'Toggle menu');
menuToggle.style.cssText = 'display: block; background: none; border: none; font-size: 24px; cursor: pointer; padding: 5px;';
nav.appendChild(menuToggle);
menuToggle.addEventListener('click', () => {
navMenu.classList.toggle('active');
menuToggle.innerHTML = navMenu.classList.contains('active') ? '✕' : '☰';
});
} else if (window.innerWidth > 768) {
const menuToggle = document.querySelector('.mobile-menu-toggle');
if (menuToggle) {
menuToggle.remove();
}
if (navMenu) {
navMenu.classList.remove('active');
navMenu.style.display = 'flex';
}
}
}
window.addEventListener('resize', addMobileMenu);
addMobileMenu();
// Button click handlers
document.querySelectorAll('.btn-primary, .btn-contact').forEach(button => {
if (button.textContent.includes('Протестировать') || button.textContent.includes('Связаться')) {
button.addEventListener('click', function(e) {
// Scroll to contact form
const contactSection = document.querySelector('.contact-form-section');
if (contactSection) {
e.preventDefault();
contactSection.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
}
});