-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
132 lines (119 loc) · 4.66 KB
/
app.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
122
123
124
125
126
127
128
129
130
131
132
document.addEventListener("DOMContentLoaded", function() {
const toggler = document.getElementById("menu-toggler-link");
const links = document.querySelector(".wrapper .navbar .navlinks");
const link1 = document.querySelector("#link1");
const link2 = document.querySelector("#link2");
const link3 = document.querySelector("#link3");
const h1 = document.querySelector('h1');
const proyects = document.querySelector('#proyect-titel');
const contact = document.querySelector('#contact');
const hire = document.getElementsByClassName('hireButton')[0];
const span = document.getElementById('copied');
const phoneNumber = document.getElementById('phone-number');
const submit = document.getElementsByClassName('send')[0];
const nav = document.getElementsByClassName('navbar')[0];
const container = document.getElementsByClassName('container')[0];
let text = '+49(176)61256323';
window.addEventListener('resize', function() {
if(window.innerWidth < 500) {
links.style.display = "none";
toggler.style.display = "flex";
} else {
links.style.display = "flex";
toggler.style.display = "none";
}
});
window.addEventListener('DOMContentLoaded', function() {
fadeIn(nav, 250, 'flex');
fadeIn(container, 400, 'block');
if(window.innerWidth < 500) {
links.style.display = "none";
toggler.style.display = "flex";
} else {
links.style.display = "flex";
toggler.style.display = "none";
}
});
toggler.addEventListener("click", function() {
if(links.style.display === "none") {
links.style.display = "flex";
links.setAttribute("id", "navegation-links");
} else if(links.style.display === "flex") {
links.removeAttribute("id");
links.style.display = "none";
}
});
link1.addEventListener('click', function(e) {
e.preventDefault();
h1.scrollIntoView({
block: 'end',
behavior: 'smooth'
});
});
link2.addEventListener('click', function(e) {
e.preventDefault();
proyects.scrollIntoView({
block: 'start',
behavior: 'smooth'
})
});
link3.addEventListener('click', function(e) {
e.preventDefault();
contact.scrollIntoView({
block: 'start',
behavior: 'smooth'
})
});
hire.addEventListener('click', function(e) {
e.preventDefault();
contact.scrollIntoView({
block: 'start',
behavior: 'smooth'
})
});
function fadeOut(el) {
var op = 1;
var timer = setInterval(function () {
if (op <= 0.1){
clearInterval(timer);
el.style.display = 'none';
}
el.style.opacity = op;
op -= op * 0.1;
}, 70);
}
function fadeIn(el, time, display) {
var op = 0;
el.style.opacity = op;
var timer = setInterval(function () {
if (op >= 1.0){
clearInterval(timer);
}
el.style.opacity = op;
op = op + 0.1;
}, time);
el.style.display = display;
}
phoneNumber.addEventListener('click', function(e) {
e.stopPropagation();
e.preventDefault();
// Create the textarea input to hold our text.
const element = document.createElement('input');
// element.style.display = 'none';
element.value = text;
// Add it to the document so that it can be focused.
document.body.appendChild(element);
// Focus on the element so that it can be copied.
element.focus();
element.setSelectionRange(0, element.value.length);
// Execute the copy command.
document.execCommand('copy');
// Remove the element to keep the document clear.
document.body.removeChild(element);
phoneNumber.scrollIntoView({
block: 'center'
});
fadeIn(span, 100, 'inline-block');
fadeOut(span);
});
});