-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
121 lines (99 loc) · 3.96 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
window.addEventListener("load" , () => {
document.querySelector(".main").classList.remove("hidden");
document.querySelector(".home-section").classList.add("active");
// Page Loader
document.querySelector(".page-loader").classList.add("fade-out");
setTimeout(() => {
document.querySelector(".page-loader").style.display = "none";
},600);
});
// Toggle Navbar
const navToggler = document.querySelector(".nav-toggler");
navToggler.addEventListener("click", () => {
hideSection();
toggleNavbar();
document.body.classList.toggle("hide-scrolling");
});
function hideSection() {
document.querySelector("section.active").classList.toggle("fade-out");
}
function toggleNavbar() {
document.querySelector(".header").classList.toggle("active");
}
// Active Section
document.addEventListener("click", (e) => {
if(e.target.classList.contains("link-item") && e.target.hash !== "") {
// Activate the overlay to prevent multiple clicks
document.querySelector(".overlay").classList.add("active");
navToggler.classList.add("hide")
if(e.target.classList.contains("nav-item")) {
toggleNavbar();
} else {
hideSection();
document.body.classList.add("hide-scrolling");
}
setTimeout(() => {
document.querySelector("section.active").classList.remove("active", "fade-out");
document.querySelector(e.target.hash).classList.add("active");
window.scrollTo(0, 0);
document.body.classList.remove("hide-scrolling");
navToggler.classList.remove("hide");
document.querySelector(".overlay").classList.remove("active");
}, 500);
}
});
// About Tabs
const tabsContainer = document.querySelector(".about-tabs"),
aboutSection = document.querySelector(".about-section");
tabsContainer.addEventListener("click", (e) => {
if(e.target.classList.contains("tab-item") && !e.target.classList.contains("active")){
tabsContainer.querySelector(".active").classList.remove("active");
e.target.classList.add("active");
const target = e.target.getAttribute("data-target");
aboutSection.querySelector(".tab-content.active").classList.remove("active");
aboutSection.querySelector(target).classList.add("active");
}
});
// Portfolio Item Details Popup
document.addEventListener("click", (e) => {
if(e.target.classList.contains("view-project-btn")) {
togglePortfolioPopup();
document.querySelector(".portfolio-popup").scrollTo(0,0);
portfolioItemDetails(e.target.parentElement);
}
});
// hide popup when clicking outside of it
document.addEventListener("click", (e) => {
if(e.target.classList.contains("pp-inner")){
togglePortfolioPopup();
}
});
function togglePortfolioPopup() {
document.querySelector(".portfolio-popup").classList.toggle("open");
document.body.classList.toggle("hide-scrolling");
document.querySelector(".main").classList.toggle("fade-out");
}
document.querySelector(".pp-close").addEventListener("click", togglePortfolioPopup);
function portfolioItemDetails(portfolioItem) {
document.querySelector(".pp-thumbnail img").src =
portfolioItem.querySelector(".portfolio-item-thumbnail img").src;
document.querySelector(".pp-header h3").innerHTML =
portfolioItem.querySelector(".portfolio-item-title").innerHTML;
document.querySelector(".pp-body").innerHTML =
portfolioItem.querySelector(".portfolio-item-details").innerHTML;
}
// Listen For Send Message
// document.querySelector(".contact-form").addEventListener("submit", sendEmail);
// function sendEmail() {
// Email.send({
// Host : "smtp.yourisp.com",
// Username : "username",
// Password : "password",
// To : 'them@website.com',
// From : "you@isp.com",
// Subject : "This is the subject",
// Body : "And this is the body"
// }).then(
// message => alert(message)
// );
// }