Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
EmulatorOS
GitHub Repository: EmulatorOS/attaeht.github.io
Path: blob/main/assets/js/main.js
2251 views
1
/*=============== FILTERS TABS ===============*/
2
const tabs = document.querySelectorAll('[data-target]'),
3
tabContents = document.querySelectorAll('[data-content]')
4
5
tabs.forEach(tab =>{
6
tab.addEventListener('click', () =>{
7
const target = document.querySelector(tab.dataset.target)
8
9
tabContents.forEach(tc =>{
10
tc.classList.remove('filters__active')
11
})
12
target.classList.add('filters__active')
13
14
tabs.forEach(t =>{
15
t.classList.remove('filter-tab-active')
16
})
17
tab.classList.add('filter-tab-active')
18
})
19
})
20
21
/*=============== DARK LIGHT THEME ===============*/
22
const themeButton = document.getElementById('theme-button')
23
const darkTheme = 'dark-theme'
24
const iconTheme = 'ri-sun-line'
25
26
// Previously selected topic (if user selected)
27
const selectedTheme = localStorage.getItem('selected-theme')
28
const selectedIcon = localStorage.getItem('selected-icon')
29
30
// We obtain the current theme that the interface has by validating the dark-theme class
31
const getCurrentTheme = () => document.body.classList.contains(darkTheme) ? 'dark' : 'light'
32
const getCurrentIcon = () => themeButton.classList.contains(iconTheme) ? 'ri-moon-line' : 'ri-sun-line'
33
34
// We validate if the user previously chose a topic
35
if (selectedTheme) {
36
// If the validation is fulfilled, we ask what the issue was to know if we activated or deactivated the dark
37
document.body.classList[selectedTheme === 'dark' ? 'add' : 'remove'](darkTheme)
38
themeButton.classList[selectedIcon === 'ri-moon-line' ? 'add' : 'remove'](iconTheme)
39
}
40
41
// Activate / deactivate the theme manually with the button
42
themeButton.addEventListener('click', () => {
43
// Add or remove the dark / icon theme
44
document.body.classList.toggle(darkTheme)
45
themeButton.classList.toggle(iconTheme)
46
// We save the theme and the current icon that the user chose
47
localStorage.setItem('selected-theme', getCurrentTheme())
48
localStorage.setItem('selected-icon', getCurrentIcon())
49
})
50
51
/*=============== SCROLL REVEAL ANIMATION ===============*/
52
const sr = ScrollReveal({
53
origin: 'top',
54
distance: '60px',
55
duration: 2500,
56
delay: 400,
57
})
58
59
sr.reveal(`.profile__border`)
60
sr.reveal(`.profile__name`, {delay: 500})
61
sr.reveal(`.profile__profession`, {delay: 600})
62
sr.reveal(`.profile__social`, {delay: 700})
63
sr.reveal(`.profile__info-group`, {interval: 100, delay: 700})
64
sr.reveal(`.profile__buttons`, {delay: 800})
65
sr.reveal(`.filters__content`, {delay: 900})
66
sr.reveal(`.filters`, {delay: 1000})
67