-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
494 lines (402 loc) · 16.4 KB
/
demo.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
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
<!DOCTYPE html>
<html lang="en-us" dir="ltr">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta charset="utf-8">
<title>Lightbox JS Example</title>
<!-- Remove Tap Highlight on Windows Phone IE -->
<meta name="msapplication-tap-highlight" content="no">
<!--[if IEMobile]><meta http-equiv="cleartype" content="on"><![endif]-->
<!--[if IE]><meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible"><meta http-equiv="imagetoolbar" content="no"><![endif]-->
<style>
html {
/* killing 300ms touch delay in IE */
-ms-touch-action: manipulation;
touch-action: manipulation
}
html,
body {
height: 100%;
margin: 0;
padding: 0
}
body {
text-align: center;
font: normal normal normal 16px/1 serif
}
.wrapper {
width: 90%;
margin: 0 5% 2em;
padding: 1em 0 0;
text-align: left
}
.gallery {
position: relative;
/*
overflow: auto;
*/
clear: both;
width: auto /* 60% */;
margin: 0 auto 1em
}
.gallery:after {
content: "";
display: table;
clear: both
}
.photo-link {
overflow: hidden;
position: relative;
display: block;
float: left;
width: 23%;
height: 200px;
margin: 1%;
text-decoration: none;
border: none;
outline: none;
cursor: zoom-in
}
.thumb-image {
display: block;
max-width: 100%;
max-height: 200px;
width: auto;
height: auto;
margin: 0 auto;
vertical-align: middle;
border: none;
border-style: none;
-ms-interpolation-mode: bicubic;
-o-object-fit: cover;
object-fit: cover;
-webkit-transform: translate(0%,0%);
-ms-transform: translate(0%,0%);
transform: translate(0%,0%)
}
/*
* For consistency with recent browsers only
*/
@media screen and (min-width: 771px) {
.thumb-image {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
max-width: 100%;
width: 100%;
height: 100%
}
}
@media screen and (max-width: 770px) {
.gallery{overflow: hidden;width: 100%}
.photo-link{display: block;float: none;width: 100%}
.thumb-image {width: 100%;margin: 0 auto}
}
.gutter {
width: 100%;
height: 1px;
clear: both
}
.footer {
float: left;
clear: both;
width: 100%
}
/*! Start: Lightbox rules */
@-webkit-keyframes bounce {
0% {
-webkit-transform: scale3d(0.1, 0.1, 1);
transform: scale3d(.1, .1, 1)
}
55% {
-webkit-transform: scale3d(1, 1, 1);
transform: scale3d(1, 1, 1)
}
75% {
-webkit-transform: scale3d(0.95, 0.95, 1);
transform: scale3d(.95, .95, 1)
}
100% {
-webkit-transform: scale3d(1, 1, 1);
transform: scale3d(1, 1, 1)
}
}
@-moz-keyframes bounce {
0% {
-webkit-transform: scale3d(0.1, 0.1, 1);
-moz-transform: scale3d(.1, .1, 1);
transform: scale3d(.1, .1, 1)
}
55% {
-webkit-transform: scale3d(1, 1, 1);
-moz-transform: scale3d(1, 1, 1);
transform: scale3d(1, 1, 1)
}
75% {
-webkit-transform: scale3d(0.95, 0.95, 1);
-moz-transform: scale3d(.95, .95, 1);
transform: scale3d(.95, .95, 1)
}
100% {
-webkit-transform: scale3d(1, 1, 1);
-moz-transform: scale3d(1, 1, 1);
transform: scale3d(1, 1, 1)
}
}
@-o-keyframes bounce {
0% {
-webkit-transform: scale3d(0.1, 0.1, 1);
transform: scale3d(.1, .1, 1)
}
55% {
-webkit-transform: scale3d(1, 1, 1);
transform: scale3d(1, 1, 1)
}
75% {
-webkit-transform: scale3d(0.95, 0.95, 1);
transform: scale3d(.95, .95, 1)
}
100% {
-webkit-transform: scale3d(1, 1, 1);
transform: scale3d(1, 1, 1)
}
}
@keyframes bounce {
0% {
-webkit-transform: scale3d(0.1, 0.1, 1);
transform: scale3d(.1, .1, 1)
}
55% {
-webkit-transform: scale3d(1, 1, 1);
transform: scale3d(1, 1, 1)
}
75% {
-webkit-transform: scale3d(0.95, 0.95, 1);
transform: scale3d(.95, .95, 1)
}
100% {
-webkit-transform: scale3d(1, 1, 1);
transform: scale3d(1, 1, 1)
}
}
@-webkit-keyframes fade {
0% {opacity: 0}
50% {opacity: 0.80}
}
@-moz-keyframes fade {
0% {opacity: 0}
50% {opacity: .80}
}
@keyframes fade {
0% {opacity: 0}
50% {opacity: .80}
}
#overlay {
position: fixed !important;
right: 0;
bottom: 0;
background-color: #333;
background-color: rgba(0, 0, 0, 0.8);
-webkit-opacity: 0.8;
-moz-opacity: 0.8;
opacity: .80;
filter: alpha(opacity=80);
will-change: opacity;
-webkit-animation: fade 700ms linear;
-moz-animation: fade 700ms linear;
-o-animation: fade 700ms linear;
animation: fade 700ms linear
}
* html #overlay {
position: absolute !important;
background-color: #333;
back\ground-color: transparent;
background-image: url(./img/overlay.png);
filter:progid: DXImageTransform.Microsoft.AlphaImageLoader(src="./img/000000-0.8.png", sizingMethod="scale")
}
html #overlay > a {
display: block;
height: 100%
}
html #lightbox {
max-width: 99%;
max-width: calc(100% - 6px);
height: auto;
margin: 0 auto;
padding: 0 0 5px;
/* If you want to add a border:
border: 3px solid #fff;
*/
background-color: #000;
background-color: rgba(0, 0, 0, 0.5);
border-radius: 4px;
-webkit-transform-origin: center center;
transform-origin: center center;
-webkit-animation: bounce 800ms ease-in-out;
-moz-animation-name: bounce 800ms ease-in-out;
-o-animation-name: bounce 800ms ease-in-out;
animation: bounce 800ms cubic-bezier(.65, .05, .36, 1);
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
will-change: transform;
-ms-touch-action: none;
touch-action: none
}
* html #lightbox {position: absolute !important}
#lightbox a {
text-decoration: none;
cursor: zoom-out
}
#lightbox > a {display: block}
#closeButton {
position: absolute;
z-index: 2000;
top: 0;
right: 0;
display: block;
width: 1em;
width: 1.5rem;
background: #333;
vertical-align: middle;
color: #fff;
text-align: center;
font: normal normal normal 1.55em/0.85 Arial,sans-serif;
line-height: 1.4rem;
border: 1px solid #808080;
/* If you want a rounding close button:
border-radius: 50%;
*/
cursor: pointer
}
@supports (display: grid) {
html body #lightbox {position: fixed!important;top: 0!important}
#closeButton {height: auto;border: none;box-shadow: inset 0 0 1px #b3b3b3}
}
html #loadingImage {
position: absolute;
top: 25% !important;
top: calc(50vh - 38px) !important;
left: 50%;
width: 38px;
height: 38px;
background: url("data:image/svg+xml,%3Csvg enable-background='new 0 0 38 38' version='1.1' viewBox='0 0 38 38' xml:space='preserve' xmlns='http://www.w3.org/2000/svg'%3E%3Cg transform='translate(1 1)' fill='none' stroke='%23F7F7F7' stroke-width='3'%3E%3Cpath d='m18 7.747c5.521 0 10 4.591 10 10.251 0 5.666-4.479 10.256-10 10.256-5.522 0-10-4.59-10-10.256 0-5.66 4.478-10.251 10-10.251z' stroke-opacity='.5'/%3E%3Cpath d='m28 17.998c0-5.66-4.479-10.251-10-10.251'%3E%3CanimateTransform fill='remove' accumulate='none' additive='replace' attributeName='transform' calcMode='linear' dur='1s' from='0 18 18' repeatCount='indefinite' restart='always' to='360 18 18' type='rotate'%3E%3C/animateTransform%3E%3C/path%3E%3C/g%3E%3C/svg%3E") center center no-repeat
}
#lightbox img {
clear: both;
width: auto;
max-width: 100%;
height: auto;
max-height: 100%;
max-height: 94vh;
margin: 0 auto;
border: none;
border-style: none;
object-fit: contain;
object-position: center
}
#overlay img {border: none}
#lightboxImage {
display: block;
width: 100%;
*width: auto;
height: auto;
vertical-align: top
}
#lightboxDetails {
float: left;
width: 100%;
margin: 0 0 -5px 0;
padding: 0;
background: #000;
background: rgba(0, 0, 0, 0.7);
color: #ccc;
font: normal normal normal 0.8em/1 sans-serif
}
#lightboxCaption {
max-width: 50%;
float: left;
padding: 10px 0 10px 10px;
text-align: left
}
#keyboardMsg {
float: right;
padding: 10px 10px 10px 0;
color: #6e6e6e
}
#keyboardMsg span {
vertical-align: baseline;
color: #aaa
}
@media screen and (max-width: 770px) {
html #lightbox {position: fixed!important;top: 0!important;max-width: 90%}
#lightboxDetails {width: 100% !important}
}
/* If you want to apply a bluring effect over the entire document, uncomment:
.lightboxOn .wrapper,.lightboxOn .footer {
filter: url("data:image/svg+xml;utf9,<svg%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'><filter%20id='blur'><feGaussianBlur%20stdDeviation='3'%20/></filter></svg>#blur");
-webkit-filter: blur(3px);
-moz-filter: blur(3px);
filter: blur(3px);
filter: progid:DXImageTransform.Microsoft.Blur(PixelRadius='3')
}
*/
/*! End: Lightbox rules */
</style>
<!-- Best practice: use external link instead
<link rel="stylesheet" href="//cdn.jsdelivr.net/gh/cara-tm/lightbox_js/css/lightbox.min.css" media="screen" />
-->
<!--[if lte IE 6]>
<style>
/*! IE5 just because LightBox JS seems to work with it 😋 */
body {overflow-x: hidden}
#overlay{background:#000!important}
html #lightbox{position:absolute!important}
.gallery {width: 97.5%}
.thumb-image {width: 300px;height: 200px}
</style>
<![endif]-->
</head>
<body>
<div class="wrapper">
<div class="gallery">
<a href="images/unplash.jpg" title="Click to display" data-box="lightbox" data-title="Arche" class="photo-link" target="_blank">
<img class="thumb-image" src="images/unplash.jpg" alt="Arche" />
</a>
<a href="images/grayscale.jpg" title="Click to display" data-box="lightbox" data-title="Grayscale. A long caption for this picture here in order to test the position of this item." class="photo-link" target="_blank">
<img class="thumb-image" src="images/grayscale.jpg" alt="Grayscale" />
</a>
<a href="images/480x270.png" title="Click to display" data-box="lightbox" data-title="Placeholder" class="photo-link" target="_blank">
<img class="thumb-image" src="images/480x270.png" alt="Grayscale" />
</a>
<a href="images/karla-villaizan-408309.jpg" title="Click to display" data-box="lightbox" data-title="Bilbao Museum (large)" class="photo-link" target="_blank"><img class="thumb-image" src="images/karla-villaizan-408309.jpg" alt="Bilbao Museum (large)" /></a>
</div> <!-- /gallery -->
<p style="line-height:1.5">The 20 years old but well known javascript LightBox v.1 with no dependencies (very light: 4.5 Ko only) that helped us in the '2000s to create simple but effective photo galleries. This is a version adapted and corrected for a better cross-browser support, Cross-Site Scripting (XSS) attacks safe, data attributes support, responsive and with capacities for multilanguage. Minified within Babel JS to follow the new generation of coding.</p>
<div class="gutter"></div>
</div> <!-- /wrapper -->
<div class="footer">
<div class="footer-inner">
<p>LightBox, original script by Lokesh Dhakar with some enhancements by cara-tm.com</p>
</div>
</div>
<!-- You can externalize the script:
<script src="//cdn.jsdelivr.net/gh/cara-tm/lightbox_js/lightbox_js.min.js"></script>
-->
<script>
/*!
* Lightbox JS: Fullsize Image Overlays
* by Lokesh Dhakar - http://www.huddletogether.com
* Adaptations by cara-tm.com
*
* For more information on this script, visit:
* http://huddletogether.com/projects/lightbox/
* http://lokeshdhakar.com/projects/lightbox/
* https://github.com/cara-tm/lightbox_js
*
* Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
* (basically, do anything you want, just leave my name and link)
*/
'use strict';var close_string='press x key or tap to close',close_tooltip='Click to close',pageHeight=window.innerHeight||document.documentElement.clientHeight||document.getElementsByTagName('body')[0].clientHeight,pageWidth=window.innerWidth||document.documentElement.clientWidth||document.getElementsByTagName('body')[0].clientWidth,arrayPageSize='',arrayPageScroll='',imgPreload='',selects='',i='',objOverlay='',objLightbox='',keycode='',key='';var setText=function(){return'innerText'in document.createElement('span')?function(c,d){c.innerText=d}:function(c,d){c.textContent=d}}();function getPageScroll(){var a;return self.pageYOffset?a=self.pageYOffset:document.documentElement&&document.documentElement.scrollTop?a=document.documentElement.scrollTop:document.body&&(a=document.body.scrollTop),arrayPageScroll=['',a],arrayPageScroll}function getPageSize(){var a,b;window.innerHeight&&window.scrollMaxY?(a=document.body.scrollWidth,b=window.innerHeight+window.scrollMaxY):document.body.scrollHeight>document.body.offsetHeight?(a=document.body.scrollWidth,b=document.body.scrollHeight):(a=document.body.offsetWidth,b=document.body.offsetHeight);var c,d;return self.innerHeight?(c=self.innerWidth,d=self.innerHeight):document.documentElement&&document.documentElement.clientHeight?(c=document.documentElement.clientWidth,d=document.documentElement.clientHeight):document.body&&(c=document.body.clientWidth,d=document.body.clientHeight),pageHeight=b<d?d:b,pageWidth=a<c?c:a,arrayPageSize=[pageWidth,pageHeight,c,d],arrayPageSize}function pause(a){for(var b=new Date,c=b.getTime()+a;;)if(b=new Date,b.getTime()>c)return}function getKey(a){keycode=null==a?event.keyCode:a.which,key=String.fromCharCode(keycode).toLowerCase(),'x'==key&&hideLightbox()}function listenKey(){document.onkeypress=getKey}function showLightbox(a){var b=document.getElementById('overlay'),c=document.getElementById('lightbox'),d=document.getElementById('lightboxCaption'),f=document.getElementById('lightboxImage'),g=document.getElementById('loadingImage'),h=document.getElementById('lightboxDetails'),j=getPageSize(),k=getPageScroll();g&&(g.style.top=k[1]+(j[3]-35-g.height)/2+'px',g.style.left=(j[0]-20-g.width)/2+'px',g.style.display='block'),b.style.height=j[1]+'px',b.style.display='block',imgPreload=new Image,imgPreload.onload=function(){f.src=a.href;var l=k[1]+(j[3]-35-imgPreload.height)/2,m=(j[0]-20-imgPreload.width)/2,n=m;for(c.style.top=0>l?'0px':l+'px',c.style.left=0>m?'0px':m+'px',c.style.right=0>n?'0px':n+'px',f.setAttribute('alt',(a.getAttribute('data-title')?a.getAttribute('data-title'):'')),a.getAttribute('data-title')?(setText(d,a.getAttribute('data-title'))):'',-1!=navigator.appVersion.indexOf('MSIE')&&pause(250),g&&(g.style.display='none'),selects=document.getElementsByTagName('select'),i=0;i!=selects.length;i++)selects[i].style.visibility='hidden';return c.style.display='block',j=getPageSize(),b.style.height=j[1]+'px',listenKey(),!1},imgPreload.src=a.href}function removeClass(a,b){var c=new RegExp('(\\s|^)'+b+'(\\s|$)');a.className=a.className.replace(c,' ')}function hideLightbox(){for(objOverlay=document.getElementById('overlay'),objLightbox=document.getElementById('lightbox'),objOverlay.style.display='none',objLightbox.style.display='none',selects=document.getElementsByTagName('select'),i=0;i!=selects.length;i++)selects[i].style.visibility='visible';document.onkeypress='';removeClass(document.getElementsByTagName('html')[0],'lightboxOn')}function initLightbox(){if(document.getElementsByTagName){for(var c,a=document.getElementsByTagName('a'),b=0;b<a.length;b++)c=a[b],c.getAttribute('href')&&'lightbox'==c.getAttribute('data-box')&&(c.onclick=function(){document.getElementsByTagName('html')[0].className+=' lightboxOn';return showLightbox(this),!1});var d=document.getElementsByTagName('body').item(0),f=document.createElement('div');f.setAttribute('id','overlay'),f.onclick=function(){return hideLightbox(),!1},f.style.display='none',f.style.position='absolute',f.style.top='0',f.style.left='0',f.style.zIndex='90',f.style.width='100%',d.insertBefore(f,d.firstChild);var g=getPageSize(),h=getPageScroll(),j=new Image;j.onload=function(){var r=document.createElement('a');r.setAttribute('href','#'),r.onclick=function(){return hideLightbox(),!1},f.appendChild(r);var s=document.createElement('div');return s.setAttribute('id','loadingImage'),s.style.position='absolute',s.style.zIndex='150',r.appendChild(s),j.onload=function(){},!1},j.src='data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=';var k=document.createElement('div');k.setAttribute('id','lightbox'),k.style.display='none',k.style.position='absolute',k.style.position='absolute',k.style.zIndex='100',d.insertBefore(k,f.nextSibling);var l=document.createElement('a'),r=document.createElement('span');l.setAttribute('href','#'),l.setAttribute('title',close_tooltip),setText(r,'×'),r.setAttribute('id','closeButton'),l.appendChild(r);l.onclick=function(){return hideLightbox(),!1},k.appendChild(l);var n=document.createElement('img');n.setAttribute('id','lightboxImage'),l.appendChild(n);var o=document.createElement('div');o.setAttribute('id','lightboxDetails'),k.appendChild(o);var p=document.createElement('div');p.setAttribute('id','lightboxCaption'),o.appendChild(p);var q=document.createElement('div');q.setAttribute('id','keyboardMsg'),setText(q,close_string),o.appendChild(q)}}function addLoadEvent(a){var b=window.onload;window.onload='function'==typeof window.onload?function(){b(),a()}:a}addLoadEvent(initLightbox);
</script>
</body></html>