-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
52 lines (44 loc) · 1.83 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
// the share button div
const shareButtonLight = document.querySelector('.share-button');
// the dark and white share icons
const shareIconDark = document.querySelector('.dark');
const shareIconWhite = document.querySelector('.white');
// the pop-up windows (small and big screen)
const sharePopupSmall = document.querySelector('.share-popup-small');
const sharePopupBig = document.querySelector('.share-popup-big');
// the body selector for mouseup()
const body = document.querySelector('body');
// hiding pop-up windows
sharePopupSmall.classList.add('hidden-small')
sharePopupBig.classList.add('hidden-big')
// default button: light bg and dark icon
// removing classes for the dark button
shareIconDark.classList.remove('icon-hidden');
shareButtonLight.classList.remove('dark-bg');
// click function for the button
shareButtonLight.addEventListener('click', function(){
// mobile screens
if (window.innerWidth > 900 ) {
// showing the pop-up window
sharePopupBig.classList.remove('hidden-big')
// changing the colors of the button when clicked
shareIconDark.classList.add('icon-hidden');
shareIconWhite.classList.remove('icon-hidden');
shareButtonLight.classList.add('dark-bg')
// when clicked outsite of the button
// changing the colors back to light
body.addEventListener('mouseup', function () {
sharePopupBig.classList.add('hidden-big')
shareButtonLight.classList.remove('dark-bg')
shareIconWhite.classList.add('icon-hidden');
shareIconDark.classList.remove('icon-hidden');
});
}
// desktop screens
if (window.innerWidth <= 900 ) {
sharePopupSmall.classList.remove('hidden-small')
body.addEventListener('mouseup', function () {
sharePopupSmall.classList.add('hidden-small')
});
}
});