-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
94 lines (93 loc) · 2.78 KB
/
index.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
window.onload = () => {
$(() => {
$("#main-frame").css({ display: "block" });
$("#loading").css({ display: "none" });
disableAll();
animateCSS("left", "slideInLeft");
animateCSS("right", "slideInRight");
});
//
var frames = [
"#contact-frame",
"#profile-frame",
"#about-frame",
"#askus-frame",
];
var clickables = ["#contact", "#profile", "#about", "#askus"];
clickables.forEach((item) => {
$(item).on("click", (event) => {
event.preventDefault();
enableFrame(item.concat("-frame"));
});
});
const disableAll = () => {
frames.forEach((item) => {
$(item).css({ display: "none", "z-index": "-1" });
$(item.concat("-exit")).on("click", (event) => {
event.preventDefault();
closeDoors().then(() => {
$(item).css({ display: "none", "z-index": "-1" });
});
});
});
};
const enableFrame = (frame) => {
$(frame).css({ display: "block" });
openDoors().then((resolve) => {
$("#main-frame").css({ display: "none" });
$(frame).css({ "z-index": "1", display: "block" });
});
};
const openDoors = () => {
return new Promise((resolve, reject) => {
animateCSS("left", "slideOutLeft");
animateCSS("right", "slideOutRight");
$("#left").on("animationend", (event) => {
event.stopPropagation();
resolve(true);
});
});
};
const closeDoors = () => {
return new Promise((resolve, reject) => {
$("#main-frame").css({ display: "block" });
animateCSS("left", "slideInLeft");
animateCSS("right", "slideInRight");
$("#left").on("animationend", (event) => {
event.stopPropagation();
resolve(true);
});
});
};
const animateCSS = (element, animation, prefix = "animate__") =>
new Promise((resolve, reject) => {
const animationName = `${prefix}${animation}`;
const node = document.getElementById(element);
node.classList.add(`${prefix}animated`, animationName);
function handleAnimationEnd(event) {
event.stopPropagation();
node.classList.remove(`${prefix}animated`, animationName);
resolve("Animation ended");
}
node.addEventListener("animationend", handleAnimationEnd, { once: false });
});
function copyEmail() {
console.log("Here");
var copyText = document.querySelector("#email-address");
updateClipboard(copyText.innerHTML);
}
function updateClipboard(newClip) {
navigator.clipboard.writeText(newClip).then(
function () {
console.log(newClip);
document
.querySelector("#copy-icon")
.classList.replace("bi-clipboard", "bi-clipboard-check");
},
function () {}
);
}
$("#clicked").on("click", () => {
console.log("jquery works.");
});
}