-
Notifications
You must be signed in to change notification settings - Fork 77
/
Copy pathindex.html
403 lines (295 loc) · 14.5 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
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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>SimpleLightbox</title>
<meta name="description" content="SimpleLightbox is lightweight and responsive lightbox library based on jQuery.">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href='https://fonts.googleapis.com/css?family=Lato:400,300,700,900&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="https://rawgit.com/dbrekalo/attire/master/dist/css/build.min.css">
<script src="https://rawgit.com/dbrekalo/attire/master/dist/js/build.min.js"></script>
<link rel="stylesheet" href="dist/simpleLightbox.min.css">
<script src="dist/simpleLightbox.min.js"></script>
</head>
<body>
<section id="section-about" class="attireBlock">
<div class="inner">
<h1 data-nav-title="About" class="attireTitleType1">Simple lightbox</h1>
<p class="attireTextType1">
SimpleLightbox is lightweight and responsive lightbox library with no dependencies.
Display images, galleries, videos or custom content and control your lightbox with
easy to use api. It weighs less than 3KB.
</p>
<nav class="attireAuthor">
<a class="imageElement" href="https://github.com/dbrekalo">
<img src="https://s.gravatar.com/avatar/32754a476fb3db1c5a1f9ad80c65d89d?s=80" alt="Damir Brekalo">
</a>
<a class="name" href="https://github.com/dbrekalo">Damir Brekalo</a>
<p class="socialBox">
<a href="mailto:[email protected]" class="iconMail" title="Contact me by email">Contact me by email</a>
<a href="https://github.com/dbrekalo" class="iconGithub" title="Find me on Github">Find me on Github</a>
<a href="https://twitter.com/damirbr" class="iconTwitter" title="Reach me on Twitter">Reach me on Twitter</a>
</p>
</nav>
<p class="attireTextType2">
SimpleLightbox tries to delegate most of heavy work to browser
native mechanisms. Almost everything regarding layout (positioning and
resizing) and animations is CSS. Letting browser do it's own thing when
possible is oftentimes a good idea.
<br><br>
From version 2.0 library has no external dependencies (was dependenant on jQuery in version 1).
Adapter for jQuery plugin usage still comes included.
Evergreen browsers and IE9+ are supported.
</p>
</div>
</section>
<section id="section-examples" class="attireBlock mod1">
<div class="inner">
<h2 class="attireTitleType2">Examples</h2>
<div class="imageGallery1">
<a href="demo/images/4big.jpg" title="Caption for gallery item 1"><img src="demo/images/4small.jpg" alt="Gallery image 1" /></a>
<a href="demo/images/5big.jpg" title="Caption for gallery item 2"><img src="demo/images/5small.jpg" alt="Gallery image 2" /></a>
<a href="demo/images/6big.jpg" title="Caption for gallery item 3"><img src="demo/images/6small.jpg" alt="Gallery image 3" /></a>
</div>
<h3 class="attireTitleType3">Thumbs gallery</h3>
<p class="attireTextType2">
Lets start with one of most common use cases - a gallery of thumbs where each thumb should be enlarged when clicked.
Once light-box is up you should be able to traverse images in collection either via arrows on screen or keyboard controls
(gamers might appreciate that "a" and "d" will work as arrow keys do).
</p>
<style>
.imageGallery1 {
overflow: hidden; margin: 30px -20px;
}
.imageGallery1 > a {
float: left; width: 33.3333%; padding: 1px; box-sizing: border-box; position: relative;
}
.imageGallery1 > a:first-child { left: -1px; }
.imageGallery1 > a:last-child { right: -1px; }
.imageGallery1 > a > img {
display: block; width: 100%;
}
</style>
<script>
new SimpleLightbox({elements: '.imageGallery1 a'});
// or if using jQuery
// $('.imageGallery1 a').simpleLightbox();
</script>
<pre class="attireCodeHighlight"><code class="language-markup">
<script type="prism-html-markup"><div class="imageGallery1">
<a href="demo/images/4big.jpg" title="Caption for gallery item 1"><img src="demo/images/4small.jpg" alt="Gallery image 1" /></a>
<a href="demo/images/5big.jpg" title="Caption for gallery item 2"><img src="demo/images/5small.jpg" alt="Gallery image 2" /></a>
<a href="demo/images/6big.jpg" title="Caption for gallery item 3"><img src="demo/images/6small.jpg" alt="Gallery image 3" /></a>
</div>
</script>
</code></pre>
<pre class="attireCodeHighlight"><code class="language-javascript">
// using plain js
new SimpleLightbox({elements: '.imageGallery1 a'});
// or if using jQuery
$('.imageGallery1 a').simpleLightbox();
</code></pre>
<hr class="attireSeparator mod1">
<h3 class="attireTitleType3">Gallery from array of images</h3>
<p class="attireTextType2">
Often it is required to show image or gallery of images directly from code.
<a class="showGalleryFromArray" role="button">Clicking here</a> will display images like so.
</p>
<script>
$('.showGalleryFromArray').on('click', function() {
SimpleLightbox.open({
items: ['demo/images/1big.jpg', 'demo/images/2big.jpg', 'demo/images/3big.jpg']
});
});
</script>
<pre class="attireCodeHighlight"><code class="language-javascript">
SimpleLightbox.open({
items: ['demo/images/1big.jpg', 'demo/images/2big.jpg', 'demo/images/3big.jpg']
});
</code></pre>
<hr class="attireSeparator mod1">
<h3 class="attireTitleType3">Custom content</h3>
<p class="attireTextType2">
There are times when you need to show some other type of content in lightbox beside images.
SimpleLightbox can be used to display forms, teasers or any custom html content.
<a class="customContentLink" role="button">Clicking here</a> will display the text above in lightbox form.
</p>
<style>
.contentInPopup {
padding: 2em; max-width: 40em;
}
</style>
<script>
$('.customContentLink').on('click', function() {
SimpleLightbox.open({
content: '<div class="contentInPopup">' +
'<h3 class="attireTitleType3">Custom content</h3>' +
'<p class="attireTextType2">' +
'There are times when you need to show some other type of content in lightbox beside images.' +
'SimpleLightbox can be used to display forms, teasers or any custom html content.' +
'</p>' +
'</div>',
elementClass: 'slbContentEl'
});
});
</script>
<pre class="attireCodeHighlight"><code class="language-javascript">
SimpleLightbox.open({
content: '<div class="contentInPopup"><h3 class="attireTitleType3">Custom content</h3>...',
elementClass: 'slbContentEl'
});
</code></pre>
<hr class="attireSeparator mod1">
<h3 class="attireTitleType3">Displaying video</h3>
<p class="attireTextType2">
Sometimes you need to <a class="lightBoxVideoLink" href="https://www.youtube.com/embed/qtQgbdmIO30?autoplay=true">show a video</a> in light-box
(Video can be placed somewhere in gallery as well).
</p>
<script>
$('.lightBoxVideoLink').simpleLightbox();
</script>
<pre class="attireCodeHighlight"><code class="language-markup">
<script type="prism-html-markup">Sometimes you need to <a class="lightBoxVideoLink" href="https://www.youtube.com/embed/qtQgbdmIO30?autoplay=true">show a video</a> in light-box (Video can be placed somewhere in gallery as well).</script>
</code></pre>
<pre class="attireCodeHighlight"><code class="language-javascript">
$('.lightBoxVideoLink').simpleLightbox();
</code></pre>
<hr class="attireSeparator mod1">
<h3 class="attireTitleType3">Curious case of library lazy loading</h3>
<p class="attireTextType2">
Lets say that you have a performance budget and you have a thumb gallery on your web app.
You want light-box library resources to be lazy loaded (JS and CSS) after user clicked on thumb.
If we assume that you have an implementation of resource loader your application code might end up looking like this:
</p>
<pre class="attireCodeHighlight"><code class="language-javascript">
var $items = $('.gallery a');
$items.on('click', function(e) {
resourceLoader.makeSureIsLoaded('$.SimpleLightbox', function() {
SimpleLightbox.open({
$items: $items,
startAt: $items.index($(e.target)),
bindToItems: false
});
});
});
</code></pre>
</div>
</section>
<section id="section-api-and-options" class="attireBlock">
<div class="inner">
<h2 class="attireTitleType2">Api and options</h2>
<p class="attireTextType2">
SimpleLightbox can be instantiated via standard constructor interface.
If using jQuery lightbox can be instantiated via plugin facade.
If there is a need to obtain lightbox object instance you can do so via jQuery data utility.
</p>
<pre class="attireCodeHighlight"><code class="language-javascript">
// intance via constructor and selector
var lightbox = new SimpleLightbox({elements: '.gallery a'});
// intance via constructor and elements
var lightbox = new SimpleLightbox({
elements: document.querySelectorAll('.gallery a')
});
// Using jQuery plugin interface
$('.gallery a').simpleLightbox();
// Run via plugin facade and get instance
var lightbox = $('.gallery a').simpleLightbox(options).data('simpleLightbox');
// run directly
var lightbox = new SimpleLightbox({
$items: $('.gallery a')
});
// when images are in code
var lightbox = SimpleLightbox.open({
items: ['img1-large.jpg', 'img2-large.jpg', 'img3-large.jpg']
});
</code></pre>
<p class="attireTextType2">
Once you have a reference to SimpleLightbox instance following methods are available:
</p>
<pre class="attireCodeHighlight"><code class="language-javascript">
// Go to next image
lightbox.next();
// Go to previous image
lightbox.prev();
// Close lightbox
lightbox.close();
// Destroy lightbox (does close and removes all $items click handlers)
lightbox.destroy();
// Open lightbox
lightbox.show();
// Open lightbox at certain position
lightbox.showPosition(1);
// Set custom content
lightbox.setContent('<div>My content</div>');
</code></pre>
<p class="attireTextType2">
Plugin options / defaults are exposed in SimpleLightbox.defaults namespace so you can easily adjust them globally.
Full list of options is bellow.
</p>
<pre class="attireCodeHighlight"><code class="language-javascript">
SimpleLightbox.defaults = {
// add custom classes to lightbox elements
elementClass: '',
elementLoadingClass: 'slbLoading',
htmlClass: 'slbActive',
closeBtnClass: '',
nextBtnClass: '',
prevBtnClass: '',
loadingTextClass: '',
// customize / localize controls captions
closeBtnCaption: 'Close',
nextBtnCaption: 'Next',
prevBtnCaption: 'Previous',
loadingCaption: 'Loading...',
bindToItems: true, // set click event handler to trigger lightbox on provided $items
closeOnOverlayClick: true,
closeOnEscapeKey: true,
nextOnImageClick: true,
showCaptions: true,
captionAttribute: 'title', // choose data source for library to glean image caption from
urlAttribute: 'href', // where to expect large image
startAt: 0, // start gallery at custom index
loadingTimeout: 100, // time after loading element will appear
appendTarget: 'body', // append elsewhere if needed
beforeSetContent: null, // convenient hooks for extending library behavoiur
beforeClose: null,
beforeDestroy: null,
videoRegex: new RegExp(/youtube.com|vimeo.com/) // regex which tests load url for iframe content
};
</code></pre>
</div>
</section>
<section id="section-installation" class="attireBlock">
<div class="inner">
<h2 class="attireTitleType2">Installation</h2>
<p class="attireTextType2">
SimpleLightbox is packaged as UMD library so you can use it in CommonJS and AMD environment or with browser globals.
</p>
<pre class="attireCodeHighlight"><code class="language-javascript">
// install via npm
npm install simple-lightbox --save
// if you use bundler
var SimpleLightbox = require('simple-lightbox');
// or just using browser globals
var SimpleLightbox = window.SimpleLightbox;
// if using bundler with jQuery
var $ = require('jquery');
var SimpleLightbox = require('simple-lightbox');
SimpleLightbox.registerAsJqueryPlugin($);
</code></pre>
<p class="attireTextType2">
For browser usage browse dist folder - if working with build tools go with src folder.
Download library files from <a href="https://github.com/dbrekalo/simpleLightbox">github repo</a>,
get them via npm (npm install simple-lightbox)
</p>
</div>
</section>
<a class="githubRibbon" href="https://github.com/dbrekalo/simpleLightbox">
<img src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png">
</a>
<footer class="attireFooter">
<p>This page is built with <a href="http://dbrekalo.github.io/attire/">Attire</a>.</p>
</footer>
</body>
</html>