-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
172 lines (163 loc) · 7.51 KB
/
popup.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
const btnPopup = document.querySelectorAll('.btnpop');
const closeBtn = document.createElement('button');
const windowShadow = document.createElement('div');
windowShadow.className = 'window';
const popUp = document.createElement('div');
const title = document.createElement('h2');
const divHead = document.createElement('div');
const divTitle = document.createElement('div');
const divMiddle = document.createElement('div');
const divFooter = document.createElement('div');
const imagePortrait = document.createElement('img');
const pLoret = document.createElement('p');
const buttonContainer = document.createElement('div');
const btnLive = document.createElement('a');
const btnSee = document.createElement('a');
const body = document.querySelector('body');
// works
const works = [
{
item: 0,
title: 'Multi Post Stories',
apps: ['html', 'Bootstrap', 'Ruby on Rails'],
image: 'images/Snapshoot Portfolio.png',
desktopImage: 'images/first-place.png',
p: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essent',
btnText: '#',
btnText1: '#',
},
{
item: 1,
title: 'Profesional Art Printing Data',
apps: ['html', 'Bootstrap', 'Ruby on Rails'],
image: 'images/second-place.png',
desktopImage: 'images/Img Placeholder.png',
p: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essent',
btnText: '#',
btnText1: '#',
},
{
item: 2,
title: 'Profesional Art Printing Data',
apps: ['html', 'Bootstrap', 'Ruby on Rails'],
image: 'images/second-place.png',
desktopImage: 'images/placeholder1.png',
p: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essent',
btnText: '#',
btnText1: '#',
},
{
item: 3,
title: 'Profesional Art Printing Data',
apps: ['html', 'Bootstrap', 'Ruby on Rails'],
image: 'images/second-place.png',
desktopImage: 'images/placeholder2.png',
p: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essent',
btnText: '#',
btnText1: '#',
},
{
item: 4,
title: 'Profesional Art Printing Data',
apps: ['html', 'Bootstrap', 'Ruby on Rails'],
image: 'images/second-place.png',
desktopImage: 'images/Img Placeholder.png',
p: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essent',
btnText: '#',
btnText1: '#',
},
{
item: 5,
title: 'Profesional Art Printing Data',
apps: ['html', 'Bootstrap', 'Ruby on Rails'],
image: 'images/second-place.png',
desktopImage: 'images/placeholder1.png',
p: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essent',
btnText: '#',
btnText1: '#',
},
{
item: 6,
title: 'Profesional Art Printing Data',
apps: ['html', 'Bootstrap', 'Ruby on Rails'],
image: 'images/second-place.png',
desktopImage: 'images/placeholder2.png',
p: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essent',
btnText: '#',
btnText1: '#',
},
];
divHead.appendChild(divTitle);
let i = 0;
works.forEach((element) => {
i += 1;
const ulElement = document.createElement('ul');
const nombre = `ul-list${String(i)}`;
ulElement.id = 'ul-list';
ulElement.className = nombre;
ulElement.className = 'ul-list';
element.apps.forEach((app, iddex) => {
const liElement = document.createElement('li');
liElement.classList.add('tags-popup');
liElement.textContent = element.apps[iddex];
ulElement.appendChild(liElement);
});
divHead.appendChild(ulElement);
});
let posicionActualDelDesplazamiento;
btnPopup.forEach((button, id) => {
button.addEventListener('click', () => {
const nId = works.findIndex((work) => work.item === id);
body.appendChild(windowShadow);
body.appendChild(popUp);
popUp.appendChild(divHead);
const numList = document.querySelectorAll('.ul-list');
numList.forEach((list, idd) => {
if (idd === id) {
list.style.display = 'flex';
list.classList.add('apps-popup');
} else {
list.style.display = 'none';
}
});
posicionActualDelDesplazamiento = window.scrollY;
divTitle.appendChild(title);
divTitle.appendChild(closeBtn);
popUp.appendChild(divMiddle);
divMiddle.appendChild(imagePortrait);
divMiddle.appendChild(divFooter);
divFooter.appendChild(pLoret);
divFooter.appendChild(buttonContainer);
buttonContainer.appendChild(btnLive);
buttonContainer.appendChild(btnSee);
const windowScreen = document.querySelector('.window');
windowScreen.style.display = 'flex';
popUp.style.display = 'flex';
windowShadow.classList.add('window');
popUp.classList.add('pop-up');
divHead.classList.add('div-head');
title.textContent = works[nId].title;
imagePortrait.src = window.innerWidth < 768 ? works[nId].image : works[nId].desktopImage;
imagePortrait.classList.add('image-portrait');
divFooter.classList.add('footer-container');
pLoret.textContent = works[nId].p;
divTitle.classList.add('div-title');
title.classList.add('title-popup');
closeBtn.classList.add('close-button');
divMiddle.classList.add('middle');
pLoret.classList.add('ploret');
buttonContainer.classList.add('buttons-container');
btnLive.classList.add('button1');
btnSee.classList.add('button2');
btnLive.href = works[nId].btnText;
btnSee.href = works[nId].btnText1;
});
});
function closePopup() {
const windowScreen = document.querySelector('.window');
windowScreen.style.display = 'none';
popUp.style.display = 'none';
document.body.style.overflow = 'auto';
window.scrollTo(0, posicionActualDelDesplazamiento);
}
closeBtn.addEventListener('click', closePopup);