-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
48 lines (42 loc) · 1.2 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
// Header
class Header extends HTMLElement {
constructor() {
super();
}
connectedCallback() {
this.innerHTML = `
<header>
<div id="logo">
<h1 role="heading" alt="home"><a href="/">Ming Yang</a></h1>
</div>
<div id="nav">
<nav>
<a href="../../about.html">about <span>→</span></a>
<a href="../../works.html">works <span>→</span></a>
<a href="../../research.html">research <span>→</span></a>
</nav>
</div>
</header>
`;
}
}
customElements.define("header-component", Header);
// pdf modal
let modalBtns = document.querySelectorAll(".modal-btn");
let modal = document.getElementById("pdf-modal");
var span = document.getElementsByClassName("close")[0];
modalBtns.forEach(function(btn) {
btn.onclick = function() {
modal.style.display = "block";
let pdfUrl = btn.getAttribute("data-pdf-url");
document.getElementById("pdf-frame").src = pdfUrl;
}
});
span.onclick = function() {
modal.style.display = "none";
}
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}