-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
75 lines (66 loc) · 2.61 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, height=device-height" />
<title>Paspartou</title>
<link type="text/css" rel="stylesheet" href="paspartou.css" media="all" />
<script type="text/javascript" src="paspartou.js"></script>
<style>
body {
max-width: 50em;
margin: 0 auto;
padding: 1.5em 1em;
}
img {
max-width: 100%;
height: auto;
}
#gallery {
text-align: center;
}
</style>
</head>
<body>
<h1>Paspartou</h1>
<p id="gallery">
<a href="http://lorempixel.com/1200/800/people/1"><img src="http://lorempixel.com/320/240/people/1" alt="" /></a>
<a href="http://lorempixel.com/1200/800/people/2" data-title="Nice bike, I want one of these!"><img src="http://lorempixel.com/320/240/people/2" alt="" /></a>
<a href="http://lorempixel.com/1200/800/people/4" data-title="Beautiful women."><img src="http://lorempixel.com/320/240/people/4" alt="" /></a>
<a href="http://lorempixel.com/1200/800/people/3"><img src="http://lorempixel.com/320/240/people/3" alt="" /></a>
</p>
<h2>How it works</h2>
<p>
This lightbox script uses only plain JavaScript and DOM methods.
It looks for a element with <code>id="gallery"</code>, walks all the links in it and attaches event handler to load them in a predefined DOM element.
I've avoided using modern methods like <code>querySelector</code> and <code>querySelectorAll</code> so that the script
works in old IE. The script will use <a href="https://github.com/ded/domready">Dustin Diaz' <code>domready()</code> method</a> if available and fallback to a simple replacement function
that uses either the standard <code>DOMCOntentLoaded</code> event or <code>window.onload</code>.
</p>
<h2>How to use</h2>
<p>Add the JavaScript and CSS files to the <code>head</code> of your document:</p>
<pre>
<link type="text/css" rel="stylesheet" href="paspartou.css" media="all" />
<script type="text/javascript" src="paspartou.js"></script>
</pre>
<p>Add this markup at the bottom of your document (I hate creating markup with JavaScript):</p>
<pre>
<div id="paspartou">
<button id="prev">&#10094;</button>
<button id="next">&#10095;</button>
<div>
<div></div>
</div>
<button id="close">&#10005;</button>
</div>
</pre>
<div id="paspartou">
<button id="prev">❮</button>
<button id="next">❯</button>
<div>
<div></div>
</div>
<button id="close">✕</button>
</div>
</body>
</html>