-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
435 lines (394 loc) · 21.2 KB
/
main.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
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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
/* Mobile Menu */
const body = document.querySelector('body');
const menuIcon = document.querySelector('.fa-bars');
const menuContainer = document.querySelector('#menu-mobile-container');
const closeIcon = document.querySelector('#close-mobile-menu');
const menuLinks = document.querySelectorAll('.menu-link-mb');
function display() {
menuContainer.style.transform = 'translate(0%)';
body.style.overflow = 'hidden';
}
function disapear() {
menuContainer.style.transform = 'translate(-100%)';
body.style.overflow = 'initial';
}
function disapearEcsResizeClickout(event) {
if (
(window.innerWidth > 991)
|| (event.key === 'Escape')
|| (event.target === menuContainer)
) {
disapear();
}
}
menuIcon.addEventListener('click', display);
closeIcon.addEventListener('click', disapear);
body.addEventListener('keyup', disapearEcsResizeClickout);
window.addEventListener('resize', disapearEcsResizeClickout);
window.addEventListener('click', disapearEcsResizeClickout);
menuLinks.forEach((link) => {
link.addEventListener('click', disapear);
});
// Section 2 & PopUp Window
const cardsContent = [
{ // 1
header: 'Multi-Post Stories',
description: 'A daily selection of privately personalized reads; no accounts or sign-ups required. has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a standard dummy text.',
image: 'images/cards/card1.svg',
technologies: ['css', 'html', 'bootstrap', 'Ruby'],
button: 'See Project',
link: 'https://github.com/Jord4N-AC/portfolio',
// Popup Window
headerPopup: ['Multi Post Stories', 'Keeping track of hundreds of components website'],
descriptionPopup: [
'Lorem 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 to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essent',
'Lorem 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 releax map lapora verita.',
],
imagePopup: 'images/cards/card_1_popup.svg',
technologiesPopup: ['html', 'bootstrap', 'Ruby on rails'],
buttonsPopup: ['See Live', 'See Source'],
iconButtonsPopup: ['images/Icons/see_live_icon.svg', 'images/Icons/see_source_icon.svg'],
},
{ // 2
header: 'Profesional Art Printing Data',
description: 'A daily selection of privately personalized reads; no accounts or sign-ups required. has been the industry\'s standard',
technologies: ['html', 'bootstrap', 'Ruby'],
button: 'See Project',
link: 'https://github.com/Jord4N-AC/portfolio',
// Popup Window
headerPopup: ['Profesional Art Printing Data', 'Profesional Art Printing Data More'],
descriptionPopup: [
'Lorem 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 to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essent',
'Lorem 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 releax map lapora verita.',
],
imagePopup: 'images/cards/card_2&5_desktop_light.svg',
technologiesPopup: ['html', 'bootstrap', 'Ruby on rails'],
buttonsPopup: ['See Live', 'See Source'],
iconButtonsPopup: ['images/Icons/see_live_icon.svg', 'images/Icons/see_source_icon.svg'],
},
{ // 3
header: 'Profesional Art Printing Data',
description: 'A daily selection of privately personalized reads; no accounts or sign-ups required. has been the industry\'s standard',
technologies: ['html', 'bootstrap', 'Ruby'],
button: 'See Project',
link: 'https://github.com/Jord4N-AC/portfolio',
// Popup Window
headerPopup: ['Profesional Art Printing Data', 'Data Dashboard Healthcare'],
descriptionPopup: [
'Lorem 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 to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essent',
'Lorem 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 releax map lapora verita.',
],
imagePopup: 'images/cards/card_3&6_desktop_light.svg',
technologiesPopup: ['html', 'bootstrap', 'Ruby on rails'],
buttonsPopup: ['See Live', 'See Source'],
iconButtonsPopup: ['images/Icons/see_live_icon.svg', 'images/Icons/see_source_icon.svg'],
},
{ // 4
header: 'Profesional Art Printing Data',
description: 'A daily selection of privately personalized reads; no accounts or sign-ups required. has been the industry\'s standard',
technologies: ['html', 'bootstrap', 'Ruby'],
button: 'See Project',
link: 'https://github.com/Jord4N-AC/portfolio',
// Popup Window
headerPopup: ['Profesional Art Printing Data', 'Website Protfolio'],
descriptionPopup: [
'Lorem 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 to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essent',
'Lorem 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 releax map lapora verita.',
],
imagePopup: 'images/cards/card_4&7_desktop_light.svg',
technologiesPopup: ['html', 'bootstrap', 'Ruby on rails'],
buttonsPopup: ['See Live', 'See Source'],
iconButtonsPopup: ['images/Icons/see_live_icon.svg', 'images/Icons/see_source_icon.svg'],
},
{ // 5
header: 'Profesional Art Printing Data',
description: 'A daily selection of privately personalized reads; no accounts or sign-ups required. has been the industry\'s standard',
technologies: ['html', 'bootstrap', 'Ruby'],
button: 'See Project',
link: 'https://github.com/Jord4N-AC/portfolio',
// Popup Window
headerPopup: ['Profesional Art Printing Data', 'Profesional Art Printing Data More'],
descriptionPopup: [
'Lorem 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 to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essent',
'Lorem 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 releax map lapora verita.',
],
imagePopup: 'images/cards/card_2&5_desktop_light.svg',
technologiesPopup: ['html', 'bootstrap', 'Ruby on rails'],
buttonsPopup: ['See Live', 'See Source'],
iconButtonsPopup: ['images/Icons/see_live_icon.svg', 'images/Icons/see_source_icon.svg'],
},
{ // 6
header: 'Profesional Art Printing Data',
description: 'A daily selection of privately personalized reads; no accounts or sign-ups required. has been the industry\'s standard',
technologies: ['html', 'bootstrap', 'Ruby'],
button: 'See Project',
link: 'https://github.com/Jord4N-AC/portfolio',
// Popup Window
headerPopup: ['Profesional Art Printing Data', 'Data Dashboard Healthcare'],
descriptionPopup: [
'Lorem 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 to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essent',
'Lorem 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 releax map lapora verita.',
],
imagePopup: 'images/cards/card_3&6_desktop_light.svg',
technologiesPopup: ['html', 'bootstrap', 'Ruby on rails'],
buttonsPopup: ['See Live', 'See Source'],
iconButtonsPopup: ['images/Icons/see_live_icon.svg', 'images/Icons/see_source_icon.svg'],
},
{ // 7
header: 'Profesional Art Printing Data',
description: 'A daily selection of privately personalized reads; no accounts or sign-ups required. has been the industry\'s standard',
technologies: ['html', 'bootstrap', 'Ruby'],
button: 'See Project',
link: 'https://github.com/Jord4N-AC/portfolio',
// Popup Window
headerPopup: ['Profesional Art Printing Data', 'Website Protfolio'],
descriptionPopup: [
'Lorem 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 to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essent',
'Lorem 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 releax map lapora verita.',
],
imagePopup: 'images/cards/card_4&7_desktop_light.svg',
technologiesPopup: ['html', 'bootstrap', 'Ruby on rails'],
buttonsPopup: ['See Live', 'See Source'],
iconButtonsPopup: ['images/Icons/see_live_icon.svg', 'images/Icons/see_source_icon.svg'],
},
];
const [mobile, desktop] = [0, 1];
function createCard() {
const worksSection = document.querySelector('#works-section');
const headerSection = `
<header id="works-header">
<h2>My Recent Works</h2>
<div id="header-line"></div>
</header>
`;
for (let i = cardsContent.length; i >= 1; i -= 1) {
if (i === 1) {
const card = `
<div id="main-card" class="card${i}">
<img src="${cardsContent[i - 1].image}" alt="project${i} screenshot">
<div class="content">
<h3>${cardsContent[i - 1].header}</h3>
<p class="p-format card${i}-p">
${cardsContent[i - 1].description}
</p>
<ul class="tag-group">
<li class="tag">${cardsContent[i - 1].technologies[0]}</li>
<li class="tag">${cardsContent[i - 1].technologies[1]}</li>
<li class="tag">${cardsContent[i - 1].technologies[2]}</li>
<li class="tag">${cardsContent[i - 1].technologies[3]}</li>
</ul>
<a class="btn see-project-btn main-btn" href="#modal-window">
${cardsContent[i - 1].button}
</a>
</div>
</div>
`;
worksSection.insertAdjacentHTML('afterbegin', card);
break;
}
const card = `
<div id="c${i}" class="card${i} card">
<div class="content">
<h3>${cardsContent[i - 1].header}</h3>
<p class="p-format">
${cardsContent[i - 1].description}
</p>
<ul class="tag-group">
<li class="tag">${cardsContent[i - 1].technologies[0]}</li>
<li class="tag">${cardsContent[i - 1].technologies[1]}</li>
<li class="tag">${cardsContent[i - 1].technologies[2]}</li>
</ul>
</div>
<a class="btn btn-2 see-project-btn" href="#modal-window">
${cardsContent[i - 1].button}
</a>
</div>
`;
worksSection.insertAdjacentHTML('afterbegin', card);
}
worksSection.insertAdjacentHTML('afterbegin', headerSection);
}
createCard();
// PopUp Window
const buttons = document.querySelectorAll('.see-project-btn');
// For changing content
let modalHeaders;
let modalParagraphs;
let popupInd;
function showModalWindow(ind) {
const cards = document.querySelectorAll('#main-card, .card');
const modalHtmlContent = `
<div class="modal-container">
<div id="modal" class="card1 modal-window">
<div class="hearder-container">
<div class="modal-header">
<h3>${cardsContent[0].headerPopup[0]}</h3>
<a class="close-btn close-modal-btn" href="#modal-${ind + 1}">×</a>
</div>
<ul class="tag-group">
<li class="tag">${cardsContent[ind].technologiesPopup[0]}</li>
<li class="tag">${cardsContent[ind].technologiesPopup[1]}</li>
<li class="tag">${cardsContent[ind].technologiesPopup[2]}</li>
</ul>
</div>
<div class="modal-content" class="content">
<img id="modal-img" src="${cardsContent[ind].imagePopup}" alt="project${ind + 1} screenshot">
<div class="modal-description">
<p id="modal-p" class="p-format">
${cardsContent[ind].descriptionPopup[0]}
</p>
<div class="modal-btn-container">
<a class="btn modal-btn main-btn modal-btn-1" href="${cardsContent[ind].link}">
${cardsContent[ind].buttonsPopup[0]}
<img src="${cardsContent[ind].iconButtonsPopup[0]}" alt="${cardsContent[ind].buttonsPopup[0]} Icon">
</a>
<a class="btn modal-btn main-btn modal-btn-2" href="${cardsContent[ind].link}">
${cardsContent[ind].buttonsPopup[1]}
<img src="${cardsContent[ind].iconButtonsPopup[1]}" alt="${cardsContent[ind].buttonsPopup[1]} Icon">
</a>
</div>
</div>
</div>
</div>
</div>`;
cards[ind].insertAdjacentHTML('afterbegin', modalHtmlContent);
// For changing content
modalHeaders = document.querySelector('.modal-header h3');
modalParagraphs = document.querySelector('#modal-p');
const modalWindow = document.querySelector('.modal-container');
const closeModaIcon = document.querySelector('.close-modal-btn');
body.style.overflow = 'hidden';
function closeModal() {
modalWindow.remove();
body.style.overflow = 'initial';
}
closeModaIcon.addEventListener('click', closeModal);
body.addEventListener('keydown', (event) => {
if (event.key === 'Escape') {
closeModal();
}
});
window.addEventListener('click', (event) => {
if (event.target === modalWindow) {
closeModal();
}
});
}
buttons.forEach((btn, ind) => {
btn.addEventListener('click', () => {
popupInd = ind;
showModalWindow(ind);
if (window.innerWidth > 991) {
modalHeaders.innerHTML = cardsContent[ind].headerPopup[desktop];
modalParagraphs.innerHTML = cardsContent[ind].descriptionPopup[desktop];
} else {
modalHeaders.innerHTML = cardsContent[ind].headerPopup[mobile];
modalParagraphs.innerHTML = cardsContent[ind].descriptionPopup[mobile];
}
});
});
// Change Content When Resize, Changing content
const cardHeaders = document.querySelectorAll('.card h3');
function updateText() {
if (window.innerWidth > 991) {
cardHeaders.forEach((c, ind) => {
c.innerHTML = cardsContent[ind + 1].headerPopup[desktop];
});
modalHeaders.innerHTML = cardsContent[popupInd].headerPopup[desktop];
modalParagraphs.innerHTML = cardsContent[popupInd].descriptionPopup[desktop];
} else {
cardHeaders.forEach((c, ind) => {
c.innerHTML = cardsContent[ind + 1].headerPopup[mobile];
});
modalHeaders.innerHTML = cardsContent[popupInd].headerPopup[mobile];
modalParagraphs.innerHTML = cardsContent[popupInd].descriptionPopup[mobile];
}
}
window.addEventListener('resize', updateText);
window.addEventListener('load', updateText);
// Contact Form
const form = document.forms[0];
const { fullName, email, message } = form.elements;
const msg = document.querySelector('#form-message');
const submitBtn = document.querySelector('#get-in-touch-btn');
// To Highlight Form Message
function highlightMessage() {
if (
// Message just heighlight when all inputs have text and email is UpperCase
fullName.value !== ''
&& email.value !== ''
&& message.value !== ''
) {
msg.style.boxShadow = '0 0 20px #fa1f1f';
msg.style.transform = 'scale(1.04)';
submitBtn.addEventListener('mouseup', () => {
msg.style.boxShadow = '0 0 14px #517ad3';
msg.style.transform = 'scale(1)';
});
}
}
submitBtn.addEventListener('mousedown', highlightMessage);
// This checks if e-mail has valid format and shows message before inmediately
function checkInput() {
if (email.value.toLowerCase() !== email.value) {
msg.textContent = 'E-mail should be in LOWER CASE, Form NOT submitted';
msg.style.display = 'inline-block';
} else {
msg.style.display = 'none';
}
}
function showMsg(event) {
event.preventDefault();
if (email.value.toLowerCase() !== email.value) {
msg.textContent = 'E-mail should be in LOWER CASE, Form NOT submitted';
msg.style.display = 'inline-block';
} else {
form.submit();
}
}
form.addEventListener('submit', showMsg);
form.addEventListener('input', checkInput);
// window.addEventListener('load', () => {
// form.reset();
// });
// Local Storage
function storageAvailable(type) {
let storage;
try {
storage = window[type];
const x = '__storage_test__';
storage.setItem(x, x);
storage.removeItem(x);
return true;
} catch (e) {
return e instanceof DOMException && (
// everything except Firefox
e.code === 22
// Firefox
|| e.code === 1014
// test name field too, because code might not be present
// everything except Firefox
|| e.name === 'QuotaExceededError'
// Firefox
|| e.name === 'NS_ERROR_DOM_QUOTA_REACHED')
// acknowledge QuotaExceededError only if there's something already stored
&& (storage && storage.length !== 0);
}
}
if (storageAvailable('localStorage')) {
const inputs = [form.fullName, form.email, form.message];
inputs.forEach((input) => {
input.addEventListener('input', () => {
const inputValues = {
fullName: form.fullName.value,
email: form.email.value,
message: form.message.value,
};
localStorage.setItem('formData', JSON.stringify(inputValues));
});
});
const getFormData = JSON.parse(localStorage.getItem('formData'));
form.fullName.value = getFormData.fullName;
form.email.value = getFormData.email;
form.message.value = getFormData.message;
}