-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
60 lines (51 loc) · 1.91 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
import handleModal from "./functions/handleModal.js";
import changeTheme from "./functions/handleTheme.js"
import { moveSlider } from "./functions/slider.js";
import handleSubmit from "./functions/handleSubmit.js";
import responsiveMedia from "./functions/responsiveMedia.js";
// setTime
import timeSlider from "./timeSlider.js";
const d = document,
$btnMode = d.getElementById("btnMode"),
$menu = d.getElementById("menu"),
$form = d.getElementById("contactForm");
let mediaSlider = window.matchMedia("(max-width: 567px)");
// Code...
d.addEventListener("DOMContentLoaded", () => {
changeTheme($btnMode);
responsiveMedia(mediaSlider);
});
d.addEventListener("click", (event) => {
let $target = event.target,
theme = $target.dataset.mode;
if ($target.matches("#btnMode")) {
changeTheme($target, theme);
$target.classList.toggle("actived");
} else if ($target.matches(".menuBtn *") || $target.matches(".menuBtn")) {
$menu.classList.toggle("actived");
} else if ($target.matches(".index")) {
// clearInterval(timeSlider);
timeSlider.deleteTime()
let $indexs = $target.parentElement.children,
dataIndex = $target.dataset.index,
$sliderFirstItem =
$target.parentElement.previousElementSibling.firstElementChild;
for (const $i of $indexs)
$i.classList.item(1) && $i.classList.remove("actived");
$target.classList.add("actived");
moveSlider($sliderFirstItem, dataIndex, !0);
} else if (
$target.matches("#close-subpage") ||
$target.matches("#open-subpage") ||
$target.matches("#modal") ||
$target.matches("#link-contact") ||
$target.matches("#see-readme") ||
$target.matches("#close-readme")
) {
handleModal($target);
} else if (!$target.matches("#menu") && $menu.classList.contains("actived")) {
$menu.classList.remove("actived");
}
})
$form.addEventListener("submit", handleSubmit)
mediaSlider.addListener(responsiveMedia);