-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
133 lines (118 loc) · 5.95 KB
/
index.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
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
const hamburger = document.querySelector('.hamburger');
const navMenu = document.querySelector('.nav-menu');
hamburger.addEventListener('click', () => {
hamburger.classList.toggle('active');
navMenu.classList.toggle('show-menu');
});
// <=============== Function for the target effect ==============>
const navLinks = document.querySelectorAll('.nav-link');
navLinks.forEach((navLink) => {
navLink.addEventListener('click', () => {
hamburger.classList.remove('active');
navMenu.classList.remove('show-menu');
});
});
const projects = [{
name: 'Tonic',
description: 'A daily selection of privately personalized reads; no accounts or sign-ups required.',
image: 'images/portoflio-card/Snapshoot-Portfolio1.png',
technologies: ['html', 'css', 'javascript', 'github'],
link: 'https://ridwanullahi-code.github.io/professional-portfolio/',
demo: 'https://github.com/Ridwanullahi-code/professional-portfolio',
},
{
name: 'Tonic',
description: 'A daily selection of privately personalized reads; no accounts or sign-ups required.',
image: 'images/portoflio-card/Snapshoot-Portfolio1.png',
technologies: ['html', 'css', 'javascript', 'github'],
link: 'https://ridwanullahi-code.github.io/professional-portfolio/',
demo: 'https://github.com/Ridwanullahi-code/professional-portfolio',
},
{
name: 'Multi-Post<br>Stories',
description: 'A daily selection of privately personalized reads; no accounts or sign-ups required.',
image: 'images/portoflio-card/Snapshoot-Portfolio1.png',
technologies: ['html', 'css', 'javascript', 'github'],
link: 'https://ridwanullahi-code.github.io/professional-portfolio/',
demo: 'https://github.com/Ridwanullahi-code/professional-portfolio',
},
{
name: 'Multi-Post<br>Stories',
description: 'A daily selection of privately personalized reads; no accounts or sign-ups required.',
image: 'images/portoflio-card/Snapshoot-Portfolio1.png',
technologies: ['html', 'css', 'javascript', 'github'],
link: 'https://ridwanullahi-code.github.io/professional-portfolio/',
demo: 'https://github.com/Ridwanullahi-code/professional-portfolio',
},
];
// <=============== modal popup information ====================>
const projectTitle = document.querySelectorAll('.project-title');
const projectImage = document.querySelectorAll('.project-image');
const projectDescpt = document.querySelectorAll('.description');
const techList = document.querySelectorAll('.tools');
const cardTitle = document.querySelector('.card-title');
const cardImage = document.querySelector('.card-image');
const modalTech = document.querySelector('.tech');
const description = document.querySelector('.card-description');
const modalButton = document.querySelectorAll('.modal-button');
const cards = {
description: "MLorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it 1960s with the releaLorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it 1960s with the releorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum han printer took a galley of type and scrambled it 1960s with the releawn printer took galley of type and scrambled it 1960s with the releaLorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it 1960s with therelea",
technologies: ['ruby', 'bootstrap'],
};
// store each project's information into object
for (let i = 0; i < projects.length; i += 1) {
projectTitle[i].innerHTML = projects[i].name;
projectImage[i].src = projects[i].image;
projectDescpt[i].innerHTML = projects[i].description;
techList[0].children[i].innerHTML = projects[i].technologies[i];
techList[1].children[i].innerHTML = projects[i].technologies[i];
techList[2].children[i].innerHTML = projects[i].technologies[i];
techList[3].children[i].innerHTML = projects[i].technologies[i];
modalTech.children[i].innerHTML = projects[i].technologies[i];
}
for (let i = 0; i < 2; i += 1) {
const list = document.createElement('li');
list.innerHTML = cards.technologies[i];
modalTech.appendChild(list);
}
// get the modal popup initial elements
const buttons = document.querySelectorAll('.see-project-btn');
const modal = document.querySelector('.card');
const closeButton = document.querySelector('.close-button');
const backdrop = document.querySelector('#backdrop');
// <=============== Function to show modal ======================>
for (let i = 0; i < buttons.length; i += 1) {
buttons[i].addEventListener('click', () => {
modal.classList.toggle('active');
backdrop.classList.toggle('show');
cardTitle.innerHTML = projects[i].name;
description.innerHTML = cards.description;
cardImage.src = projects[i].image;
modalButton[0].href = projects[i].demo;
modalButton[1].href = projects[i].link;
});
}
// <=============== Function to close modal ===============>
closeButton.addEventListener('click', () => {
modal.classList.remove('active');
backdrop.classList.remove('show');
});
// <=============== Function to close the modal with backdrop =================
backdrop.addEventListener('click', () => {
modal.classList.remove('active');
backdrop.classList.remove('show');
});
// <======== form validation ======>
const form = document.querySelector('.form');
const email = document.querySelector('form [type=email]');
const error = document.createElement('p');
error.innerHTML = 'email must be in lowercase, example([email protected])';
error.setAttribute('class', 'error');
form.addEventListener('submit', (event) => {
if (email.value === email.value.toLowerCase()) {
form.send();
} else {
event.preventDefault();
email.parentElement.appendChild(error);
}
});