-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
235 lines (215 loc) · 11.1 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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
/* this module You use an array to store all of the information for all projects */
/* each project has: name, ShortDescrip, featured image, technologies,
link to live version, link to source */
const arrCardsInfo = [
{
id: 'card-0',
name: 'Tonic',
name2: 'Canopy',
ShortDescrip: "A daily selection of privately personalized reads; no accounts or sign-ups required. has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a standard dummy text.",
LongDescrip: "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.",
cardImage: './assets/images/image1.svg',
alternateTextImage: 'header-main-project image.',
technologies: ['HTML', 'CSS', 'Javascript'],
liveVersion: 'https://jlcarrascof.github.io/card-portfolio/',
source: 'https://github.com/jlcarrascof/card-portfolio/',
},
{
id: 'card-1',
name: 'Multi-Post Stories',
name2: 'Canopy',
ShortDescrip: "A daily selection of privately personalized reads; no accounts or sign-ups required. has been the industry's standard.",
LongDescrip: "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.",
cardImage: './assets/images/image2.svg',
alternateTextImage: 'secondary project ShortDescrip image.',
technologies: ['CSS', 'Boostrap', 'Ruby'],
liveVersion: 'https://jlcarrascof.github.io/card-portfolio/',
source: 'https://github.com/jlcarrascof/card-portfolio/',
},
{
id: 'card-2',
name: 'Profesional Art 2',
name2: 'Printing Data',
ShortDescrip: "A daily selection of privately personalized reads; no accounts or sign-ups required. has been the industry's standard.",
LongDescrip: "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.",
cardImage: './assets/images/image3.svg',
alternateTextImage: 'secondary project ShortDescrip image.',
technologies: ['CSS', 'Boostrap', 'Ruby'],
liveVersion: 'https://jlcarrascof.github.io/card-portfolio/',
source: 'https://github.com/jlcarrascof/card-portfolio/',
},
{
id: 'card-3',
name: 'Profesional Art 3',
name2: 'Printing Data',
ShortDescrip: "A daily selection of privately personalized reads; no accounts or sign-ups required. has been the industry's standard.",
LongDescrip: "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.",
cardImage: './assets/images/image4.svg',
alternateTextImage: 'secondary project ShortDescrip image.',
technologies: ['CSS', 'Boostrap', 'Ruby'],
liveVersion: 'https://jlcarrascof.github.io/card-portfolio/',
source: 'https://github.com/jlcarrascof/card-portfolio/',
},
];
const gridWorks = document.getElementById('grid_works');
let winPopup = null;
let div = null;
let loadBody = null;
let card = null;
for (let i = 0; i < arrCardsInfo.length; i += 1) {
card = arrCardsInfo[i];
div = document.createElement('div');
div.id = card.id;
div.innerHTML = `
<div class="cards card-1">
<div>
<img src="${card.cardImage}" alt="${card.alternateTextImage}" class="screenshot">
</div>
<div class="card-description">
<div>
<h3 class="card-title mobile">${card.name}</h3>
<h3 class="card-title desktop">${card.name}</h3>
<div class="card-bg-info">
<p class="mobile">${card.name2}</p>
<p class="desktop">${card.name2}</p>
<ul>
<li>Full Stack Dev</li>
<li>2015</li>
</ul>
</div>
</div>
<div class="card-text mobile">
<p>
A daily selection of privately personalized reads; no accounts or sign-ups required. A daily selection of privately personalized reads; no accounts or sign-ups required A daily selection of privately personalized reads; no accounts or sign-ups required
</p>
</div>
<div class="card-text desktop">
<p>
Exploring the future of media in Facebook's first Virtual Reality app; a place to discover and enjoy 360 photos and videos on Gear VR. A daily selection of privately personalized reads; no accounts or sign-ups required. A daily selection of privately personalized reads; no accounts or sign-ups required A daily selection of privately personalized reads; no accounts or sign-ups required7
</p>
</div>
<div class="card-skills mobile">
<ul>
${card.technologies.map((tech) => `
<li class="li_btn_2">${tech}</li>`).join(' ')
}
</ul>
</div>
<div class="card-skills desktop">
<ul>
${card.technologies.map((tech) => `
<li class="li_btn_2">${tech}</li>`).join(' ')
}
</ul>
</div>
<div>
<button id="btn-${card.id}" type="button" class="btn btnCard">See Project</button>
</div>
</div>
</div>
`;
gridWorks.appendChild(div);
}
// functions realted with popup window
function closeWinPopup() {
loadBody.removeChild(winPopup);
/* re-activate the scrollbar for the body */
loadBody.style.overflow = 'auto';
}
function openLink(url) {
window.open(url);
closeWinPopup();
}
// create popup window
function openPopup(card) {
loadBody = document.getElementById('loadBody');
/* Hide scrollbar for the body */
loadBody.style.overflow = 'hidden';
loadBody.appendChild(document.createElement('div')).setAttribute('id', 'winPopup');
winPopup = document.getElementById('winPopup');
winPopup.classList = 'winPopup';
/* *********************************** */
div = document.createElement('div');
div.classList = 'InfoPopup';
div.id = card.id;
div.innerHTML = `
<div class="card-description-popup">
<h3 class="card-title mobile">${card.name}</h3>
<h3 class="card-title desktop">${card.name}</h3>
<a id="btnClosePopup" class="btnClosePopup">
<img class="btn-close-icon" src="./assets/images/icon-close-popup.png" alt="Close menu icon.">
</a>
</div>
<div class="bodyPopup">
<div class="card-bg-info-popup">
<div class="line1-popup">
<h2 class="mobile">${card.name2}</h2>
<h2 class="desktop">${card.name2}</h2>
<ul class="ul-popup">
<li>Full Stack Dev</li>
<li>2015</li>
</ul>
</div>
<div class="screenshot-popup">
<img class="screenshot-popup" src="${card.cardImage}" alt="${card.alternateTextImage}" >
</div>
</div>
<div class="lowsection">
<div class="col1">
<div class="card-text ">
<p>
exampple XXX A daily selection of privately personalized reads; no accounts or sign-ups required. A daily selection of privately personalized reads; no accounts or sign-ups required. A daily selection of privately personalized reads; no accounts or sign-ups required A daily selection of privately personalized reads; no accounts or sign-ups required
</p>
</div>
</div>
<div class="col2">
<div class="card-skills mobile">
<ul>
${card.technologies.map((tech) => `
<li class="li_btn_2">${tech}</li>`).join(' ')
}
</ul>
</div>
<div class="card-skills desktop">
<ul>
${card.technologies.map((tech) => `
<li class="li_btn_2">${tech}</li>`).join(' ')
}
</ul>
</div>
<div class="btnlinks">
<div>
<button id="btnLive" type="button" class="btn btnCard">See Live <img class="icon-live-git" src="./assets/images/icon-export-blue.png">
</button>
</div>
<div>
<button id="btnGit" type="button" class="btn btnCard">See Source <img class="icon-live-git" src="./assets/images/icon-git-blue.png">
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
`;
winPopup.appendChild(div).setAttribute('id', 'modal');
const btnClose = document.getElementById('btnClosePopup');
const btnLive = document.getElementById('btnLive');
const btnSrc = document.getElementById('btnGit');
btnClose.addEventListener('click', closeWinPopup);
btnLive.addEventListener('click', () => { openLink(card.liveVersion); });
btnSrc.addEventListener('click', () => { openLink(card.source); });
}
/* ********************************************** */
function clickBtn(event) {
const btn = event.srcElement;
event.preventDefault();
const numCard = parseInt(btn.id.slice(-1), 10);
openPopup(arrCardsInfo[numCard]);
}
/* ***** add click event to button */
const btn = document.getElementsByClassName('btnCard');
for (let i = 0; i < btn.length; i += 1) {
btn[i].addEventListener('click', clickBtn);
}