-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
99 lines (81 loc) · 2.9 KB
/
script.js
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
// Portfolio Filtering
const filterButtons = document.querySelectorAll('.portfolio-filter button');
const portfolioItems = document.querySelectorAll('.portfolio-item');
filterButtons.forEach(button => {
button.addEventListener('click', () => {
filterButtons.forEach(btn => btn.classList.remove('active'));
button.classList.add('active');
const filterValue = button.dataset.filter;
portfolioItems.forEach(item => {
if (filterValue === 'all' || item.dataset.category === filterValue) {
item.style.display = 'block';
} else {
item.style.display = 'none';
}
});
});
});
// Portfolio Modal
const portfolioModal = document.querySelector('.portfolio-modal');
const portfolioModalClose = document.querySelector('.portfolio-modal-close');
const portfolioModalImg = document.querySelector('.portfolio-modal-img');
const portfolioModalTitle = document.querySelector('.portfolio-modal-title');
const portfolioModalDesc = document.querySelector('.portfolio-modal-desc');
portfolioItems.forEach(item => {
item.addEventListener('click', () => {
portfolioModal.style.display = 'block';
portfolioModalImg.src = item.querySelector('img').src;
portfolioModalTitle.textContent = item.dataset.title;
portfolioModalDesc.textContent = item.dataset.description;
});
});
portfolioModalClose.addEventListener('click', () => {
portfolioModal.style.display = 'none';
});
// Navbar Toggle
const navbarToggle = document.querySelector('.navbar-toggle');
const navbarMenu = document.querySelector('.navbar-menu');
navbarToggle.addEventListener('click', () => {
navbarMenu.classList.toggle('open');
});
// Skills Progress Bars
const skillsBars = document.querySelectorAll('.skills-bar');
skillsBars.forEach(bar => {
const value = bar.dataset.value;
const progress = bar.querySelector('.progress');
progress.style.width = `${value}%`;
});
// Testimonials Slider
const testimonialsSlider = new Swiper('.testimonials-slider', {
slidesPerView: 1,
spaceBetween: 30,
loop: true,
autoplay: {
delay: 5000,
},
pagination: {
el: '.testimonials-pagination',
clickable: true,
},
});
// Contact Form
const contactForm = document.querySelector('.contact-form');
const contactName = document.querySelector('.contact-name');
const contactEmail = document.querySelector('.contact-email');
const contactMessage = document.querySelector('.contact-message');
const contactSubmit = document.querySelector('.contact-submit');
contactForm.addEventListener('submit', (e) => {
e.preventDefault();
if (!contactName.value || !contactEmail.value || !contactMessage.value) {
alert('Please fill in all fields.');
return;
}
const formData = new FormData(contactForm);
const xhr = new XMLHttpRequest();
xhr.open('POST', '/contact');
xhr.send(formData);
contactName.value = '';
contactEmail.value = '';
contactMessage.value = '';
alert('Message sent successfully.');
});