-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscrip.js
130 lines (110 loc) · 3.71 KB
/
scrip.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
/*========================= ATR ======================= */
const nav = document.querySelector(".nav"),
navList = nav.querySelectorAll("li"),
totalNavList = navList.length,
allSection = document.querySelectorAll(".section"),
totalSection = allSection.length;
for(let i=0; i<totalNavList; i++)
{
const a = navList[i].querySelector("a");
a.addEventListener("click",function()
{
for(let i=0; i<totalSection; i++)
{
allSection[i].classList.remove("back-section");
}
for(let j=0; j<totalNavList; j++)
{
if(navList[j].querySelector("a").classList.contains("active"))
{
allSection[j].classList.add("back-section");
}
navList[j].querySelector("a").classList.remove("active");
}
this.classList.add("active")
showSection(this);
if(window.innerWidth < 1200)
{
ATRSectionTogglerBtn();
}
})
}
function showSection(element)
{
for(let i=0; i<totalSection; i++)
{
allSection[i].classList.remove("active");
}
const target = element.getAttribute("href").split("#")[1];
document.querySelector("#" + target ).classList.add("active")
}
document.querySelector(".hire-me").addEventListener("click", function()
{
showSection(this);
updateNav(this);
})
const navTogglerBtn = document.querySelector(".nav-toggler"),
ATR = document.querySelector(".ATR");
navTogglerBtn.addEventListener("click", () =>
{
ATRSectionTogglerBtn();
})
function ATRSectionTogglerBtn()
{
ATR.classList.toggle("open");
navTogglerBtn.classList.toggle("open")
for(let i=0; i<totalSection; i++)
{
allSection[i].classList.toggle("open")
}
}
/*======== toggle style switcher ========= */
const styleSwitcherToggle = document.querySelector(".style-switcher-toggler");
styleSwitcherToggle.addEventListener("click", () => {
document.querySelector(".style-switcher").classList.toggle("open");
})
// hide style - switcher on scroll
window.addEventListener("scroll", () => {
if(document.querySelector(".style-switcher").classList.contains("open"))
{
document.querySelector(".style-switcher").classList.remove("open");
}
})
/* ================== theme colors ================= */
const alternateStyle = document.querySelectorAll(".alternate-style");
function setActiveStyle(color)
{
alternateStyle.forEach((style) => {
if(color === style.getAttribute("title"))
{
style.removeAttribute("disabled");
}
else
{
style.setAttribute("disabled","true");
}
})
}
/* ================ theme colors and dark mode ================= */
const dayNight = document.querySelector(".day-night");
dayNight.addEventListener("click", () =>{
dayNight.querySelector("i").classList.toggle("fa-sun");
dayNight.querySelector("i").classList.toggle("fa-moon");
document.body.classList.toggle("dark");
})
window.addEventListener("load" , () =>{
if(document.body.classList.contains("dark"))
{
dayNight.querySelector("i").classList.add("fa-sun");
}
else
{
dayNight.querySelector("i").classList.add("fa-moon");
}
})
var typed = new Typed(".typing",{
strings:["","FullStack Developer.","Software Engineer.","Backend Developer."],
typeSpeed:100,
BackSpeed:60,
loop:true
})