UNPKG

uikit

Version:

UIkit is a lightweight and modular front-end framework for developing fast and powerful web interfaces.

690 lines (586 loc) • 34.5 kB
<!DOCTYPE html> <html lang="en-gb" dir="ltr"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Lightbox - UIkit tests</title> <script src="js/test.js"></script> </head> <body> <div class="uk-container"> <h1>Lightbox</h1> <div class="uk-margin"> <select id="js-animation-switcher" class="uk-select uk-form-width-small" aria-label="Animation switcher"> <option value="slide">Slide</option> <option value="fade">Fade</option> <option value="scale">Scale</option> </select> <select id="js-bg-close-switcher" class="uk-select uk-form-width-small" aria-label="Bg close switcher"> <option value="1">Close bg</option> <option value="0">Don't close bg</option> </select> <select id="js-delay-controls-switcher" class="uk-select uk-form-width-small" aria-label="Delay controls switcher"> <option value="3000">Delay controls</option> <option value="0">Always controls</option> </select> <select id="js-counter-switcher" class="uk-select uk-form-width-small" aria-label="Counter switcher"> <option value="0">Hide counter</option> <option value="1">Show Counter</option> </select> <select id="js-video-autoplay-switcher" class="uk-select uk-form-width-small" aria-label="Video autoplay switcher"> <option value="0">No video autoplay</option> <option value="1">Video autoplay</option> <option value="inline">Video inline (Autoplay, Mute, Loop, No Controls)</option> </select> </div> <h2>Sizes</h2> <div class="uk-grid-small uk-child-width-1-6@m" uk-grid uk-lightbox> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="images/size1.jpg" caption="900x600" data-alt="The value for the image alt attribute" attrs="class: uk-inverse-light"> <figure> <img src="images/size1.jpg" width="400" height="267" alt="" class="uk-object-cover" style="aspect-ratio: 400 / 267;"> <figcaption class="uk-margin-small-top">900x600</figcaption> </figure> </a> </div> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="images/size2.jpg" caption="700x500" attrs="class: uk-inverse-dark"> <figure> <img src="images/size2.jpg" width="400" height="267" alt="" class="uk-object-cover" style="aspect-ratio: 400 / 267;"> <figcaption class="uk-margin-small-top">700x500</figcaption> </figure> </a> </div> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="images/photo.jpg" caption="1800x1200" attrs="class: uk-inverse-light"> <figure> <img src="images/photo.jpg" width="400" height="267" alt="" class="uk-object-cover" style="aspect-ratio: 400 / 267;"> <figcaption class="uk-margin-small-top">1800x1200</figcaption> </figure> </a> </div> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="images/size-v.jpg" caption="1000x2000" attrs="class: uk-inverse-light"> <figure> <img src="images/size-v.jpg" width="400" height="267" alt="" class="uk-object-cover" style="aspect-ratio: 400 / 267;"> <figcaption class="uk-margin-small-top">1000x2000</figcaption> </figure> </a> </div> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="images/size-h.jpg" caption="2000x500" attrs="class: uk-inverse-dark"> <figure> <img src="images/size-h.jpg" width="400" height="267" alt="" class="uk-object-cover" style="aspect-ratio: 400 / 267;"> <figcaption class="uk-margin-small-top">2000x500</figcaption> </figure> </a> </div> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="https://yootheme.com/site/images/media/yootheme-pro.mp4" caption="Video" poster="images/photo.jpg" attrs="class: uk-inverse-light"> <figure> <video src="https://yootheme.com/site/images/media/yootheme-pro.mp4" width="400" height="267" class="uk-object-cover" style="aspect-ratio: 400 / 267;" playsinline loop uk-video="automute: true"></video> <figcaption class="uk-margin-small-top">Video</figcaption> </figure> </a> </div> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="https://www.youtube-nocookie.com/watch?v=c2pz2mlSfXA" caption="YouTube" attrs="class: uk-inverse-light"> <figure> <img src="images/photo.jpg" width="400" height="267" alt=""> <figcaption class="uk-margin-small-top">YouTube</figcaption> </figure> </a> </div> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="https://vimeo.com/1084537" caption="Vimeo" attrs="class: uk-inverse-light"> <figure> <img src="images/photo.jpg" width="400" height="267" alt=""> <figcaption class="uk-margin-small-top">Vimeo</figcaption> </figure> </a> </div> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="https://google.com/maps/embed?pb=!1m18!1m12!1m3!1d4740.819266853735!2d9.99008871708242!3d53.550454675412404!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x0%3A0x3f9d24afe84a0263!2sRathaus!5e0!3m2!1sde!2sde!4v1499675200938" caption="Iframe" type="iframe" attrs="class: uk-inverse-light"> <figure> <img src="images/photo.jpg" width="400" height="267" alt=""> <figcaption class="uk-margin-small-top">Iframe</figcaption> </figure> </a> </div> </div> <h2>Thumbnav</h2> <div class="uk-grid-small uk-child-width-1-6@m" uk-grid uk-lightbox="nav: thumbnav; slidenav: false"> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="images/size1.jpg" caption="900x600" data-alt="The value for the image alt attribute" attrs="class: uk-inverse-light"> <figure> <img src="images/size1.jpg" width="400" height="267" alt="" class="uk-object-cover" style="aspect-ratio: 400 / 267;"> <figcaption class="uk-margin-small-top">900x600</figcaption> </figure> </a> </div> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="images/size2.jpg" caption="700x500" attrs="class: uk-inverse-dark"> <figure> <img src="images/size2.jpg" width="400" height="267" alt="" class="uk-object-cover" style="aspect-ratio: 400 / 267;"> <figcaption class="uk-margin-small-top">700x500</figcaption> </figure> </a> </div> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="images/photo.jpg" caption="1800x1200" attrs="class: uk-inverse-light"> <figure> <img src="images/photo.jpg" width="400" height="267" alt="" class="uk-object-cover" style="aspect-ratio: 400 / 267;"> <figcaption class="uk-margin-small-top">1800x1200</figcaption> </figure> </a> </div> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="images/size-v.jpg" caption="1000x2000" attrs="class: uk-inverse-light"> <figure> <img src="images/size-v.jpg" width="400" height="267" alt="" class="uk-object-cover" style="aspect-ratio: 400 / 267;"> <figcaption class="uk-margin-small-top">1000x2000</figcaption> </figure> </a> </div> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="images/size-h.jpg" caption="2000x500" attrs="class: uk-inverse-dark"> <figure> <img src="images/size-h.jpg" width="400" height="267" alt="" class="uk-object-cover" style="aspect-ratio: 400 / 267;"> <figcaption class="uk-margin-small-top">2000x500</figcaption> </figure> </a> </div> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="https://yootheme.com/site/images/media/yootheme-pro.mp4" caption="Video" poster="images/photo.jpg" attrs="class: uk-inverse-light"> <figure> <video src="https://yootheme.com/site/images/media/yootheme-pro.mp4" width="400" height="267" class="uk-object-cover" style="aspect-ratio: 400 / 267;" playsinline loop uk-video="automute: true"></video> <figcaption class="uk-margin-small-top">Video</figcaption> </figure> </a> </div> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="https://www.youtube-nocookie.com/watch?v=c2pz2mlSfXA" caption="YouTube" attrs="class: uk-inverse-light"> <figure> <img src="images/photo.jpg" width="400" height="267" alt=""> <figcaption class="uk-margin-small-top">YouTube</figcaption> </figure> </a> </div> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="https://vimeo.com/1084537" caption="Vimeo" attrs="class: uk-inverse-light"> <figure> <img src="images/photo.jpg" width="400" height="267" alt=""> <figcaption class="uk-margin-small-top">Vimeo</figcaption> </figure> </a> </div> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="https://google.com/maps/embed?pb=!1m18!1m12!1m3!1d4740.819266853735!2d9.99008871708242!3d53.550454675412404!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x0%3A0x3f9d24afe84a0263!2sRathaus!5e0!3m2!1sde!2sde!4v1499675200938" caption="Iframe" type="iframe" attrs="class: uk-inverse-light"> <figure> <img src="images/photo.jpg" width="400" height="267" alt=""> <figcaption class="uk-margin-small-top">Iframe</figcaption> </figure> </a> </div> </div> <h2>Dotnav</h2> <div class="uk-grid-small uk-child-width-1-6@m" uk-grid uk-lightbox="nav: dotnav; slidenav: false"> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="images/size1.jpg" caption="900x600" data-alt="The value for the image alt attribute" attrs="class: uk-inverse-light"> <figure> <img src="images/size1.jpg" width="400" height="267" alt="" class="uk-object-cover" style="aspect-ratio: 400 / 267;"> <figcaption class="uk-margin-small-top">900x600</figcaption> </figure> </a> </div> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="images/size2.jpg" caption="700x500" attrs="class: uk-inverse-dark"> <figure> <img src="images/size2.jpg" width="400" height="267" alt="" class="uk-object-cover" style="aspect-ratio: 400 / 267;"> <figcaption class="uk-margin-small-top">700x500</figcaption> </figure> </a> </div> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="images/photo.jpg" caption="1800x1200" attrs="class: uk-inverse-light"> <figure> <img src="images/photo.jpg" width="400" height="267" alt="" class="uk-object-cover" style="aspect-ratio: 400 / 267;"> <figcaption class="uk-margin-small-top">1800x1200</figcaption> </figure> </a> </div> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="images/size-v.jpg" caption="1000x2000" attrs="class: uk-inverse-light"> <figure> <img src="images/size-v.jpg" width="400" height="267" alt="" class="uk-object-cover" style="aspect-ratio: 400 / 267;"> <figcaption class="uk-margin-small-top">1000x2000</figcaption> </figure> </a> </div> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="images/size-h.jpg" caption="2000x500" attrs="class: uk-inverse-dark"> <figure> <img src="images/size-h.jpg" width="400" height="267" alt="" class="uk-object-cover" style="aspect-ratio: 400 / 267;"> <figcaption class="uk-margin-small-top">2000x500</figcaption> </figure> </a> </div> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="https://yootheme.com/site/images/media/yootheme-pro.mp4" caption="Video" poster="images/photo.jpg" attrs="class: uk-inverse-light"> <figure> <video src="https://yootheme.com/site/images/media/yootheme-pro.mp4" width="400" height="267" class="uk-object-cover" style="aspect-ratio: 400 / 267;" playsinline loop uk-video="automute: true"></video> <figcaption class="uk-margin-small-top">Video</figcaption> </figure> </a> </div> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="https://www.youtube-nocookie.com/watch?v=c2pz2mlSfXA" caption="YouTube" attrs="class: uk-inverse-light"> <figure> <img src="images/photo.jpg" width="400" height="267" alt=""> <figcaption class="uk-margin-small-top">YouTube</figcaption> </figure> </a> </div> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="https://vimeo.com/1084537" caption="Vimeo" attrs="class: uk-inverse-light"> <figure> <img src="images/photo.jpg" width="400" height="267" alt=""> <figcaption class="uk-margin-small-top">Vimeo</figcaption> </figure> </a> </div> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="https://google.com/maps/embed?pb=!1m18!1m12!1m3!1d4740.819266853735!2d9.99008871708242!3d53.550454675412404!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x0%3A0x3f9d24afe84a0263!2sRathaus!5e0!3m2!1sde!2sde!4v1499675200938" caption="Iframe" type="iframe" attrs="class: uk-inverse-light"> <figure> <img src="images/photo.jpg" width="400" height="267" alt=""> <figcaption class="uk-margin-small-top">Iframe</figcaption> </figure> </a> </div> </div> <h2>Template</h2> <template id="js-lightbox-template"> <div class="uk-lightbox uk-overflow-hidden"> <div class="uk-lightbox-items"></div> <div class="uk-position-top-right uk-position-small uk-transition-fade" uk-inverse> <button class="uk-lightbox-close uk-close-large" type="button" uk-close></button> </div> <div class="uk-position-bottom uk-position-medium uk-text-center uk-transition-fade" uk-inverse> <div class="uk-grid-small uk-width-auto uk-flex-inline uk-flex-middle" uk-grid> <div><a class="uk-lightbox-slidenav" href uk-slidenav-previous uk-lightbox-item="previous"></a></div> <div><div class="uk-lightbox-counter"></div></div> <div><a class="uk-lightbox-slidenav" href uk-slidenav-next uk-lightbox-item="next"></a></div> </div> </div> </div> </template> <div class="uk-grid-small uk-child-width-1-6@m" uk-grid uk-lightbox="counter: true; template: #js-lightbox-template"> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="images/size1.jpg" caption="900x600" data-alt="The value for the image alt attribute" attrs="class: uk-inverse-light"> <figure> <img src="images/size1.jpg" width="400" height="267" alt="" class="uk-object-cover" style="aspect-ratio: 400 / 267;"> <figcaption class="uk-margin-small-top">900x600</figcaption> </figure> </a> </div> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="images/size2.jpg" caption="700x500" attrs="class: uk-inverse-dark"> <figure> <img src="images/size2.jpg" width="400" height="267" alt="" class="uk-object-cover" style="aspect-ratio: 400 / 267;"> <figcaption class="uk-margin-small-top">700x500</figcaption> </figure> </a> </div> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="images/photo.jpg" caption="1800x1200" attrs="class: uk-inverse-light"> <figure> <img src="images/photo.jpg" width="400" height="267" alt="" class="uk-object-cover" style="aspect-ratio: 400 / 267;"> <figcaption class="uk-margin-small-top">1800x1200</figcaption> </figure> </a> </div> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="images/size-v.jpg" caption="1000x2000" attrs="class: uk-inverse-light"> <figure> <img src="images/size-v.jpg" width="400" height="267" alt="" class="uk-object-cover" style="aspect-ratio: 400 / 267;"> <figcaption class="uk-margin-small-top">1000x2000</figcaption> </figure> </a> </div> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="images/size-h.jpg" caption="2000x500" attrs="class: uk-inverse-dark"> <figure> <img src="images/size-h.jpg" width="400" height="267" alt="" class="uk-object-cover" style="aspect-ratio: 400 / 267;"> <figcaption class="uk-margin-small-top">2000x500</figcaption> </figure> </a> </div> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="https://yootheme.com/site/images/media/yootheme-pro.mp4" caption="Video" poster="images/photo.jpg" attrs="class: uk-inverse-light"> <figure> <video src="https://yootheme.com/site/images/media/yootheme-pro.mp4" width="400" height="267" class="uk-object-cover" style="aspect-ratio: 400 / 267;" playsinline loop uk-video="automute: true"></video> <figcaption class="uk-margin-small-top">Video</figcaption> </figure> </a> </div> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="https://www.youtube-nocookie.com/watch?v=c2pz2mlSfXA" caption="YouTube" attrs="class: uk-inverse-light"> <figure> <img src="images/photo.jpg" width="400" height="267" alt=""> <figcaption class="uk-margin-small-top">YouTube</figcaption> </figure> </a> </div> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="https://vimeo.com/1084537" caption="Vimeo" attrs="class: uk-inverse-light"> <figure> <img src="images/photo.jpg" width="400" height="267" alt=""> <figcaption class="uk-margin-small-top">Vimeo</figcaption> </figure> </a> </div> <div> <a class="uk-inline uk-panel uk-link-muted uk-text-center" href="https://google.com/maps/embed?pb=!1m18!1m12!1m3!1d4740.819266853735!2d9.99008871708242!3d53.550454675412404!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x0%3A0x3f9d24afe84a0263!2sRathaus!5e0!3m2!1sde!2sde!4v1499675200938" caption="Iframe" type="iframe" attrs="class: uk-inverse-light"> <figure> <img src="images/photo.jpg" width="400" height="267" alt=""> <figcaption class="uk-margin-small-top">Iframe</figcaption> </figure> </a> </div> </div> <h2>Dynamic lightbox</h2> <button id="js-lightbox" class="uk-button uk-button-default" type="button">Dynamic lightbox</button> <h2>JavaScript Options</h2> <h3>Lightbox</h3> <div class="uk-overflow-auto"> <table class="uk-table uk-table-striped"> <thead> <tr> <th>Option</th> <th>Value</th> <th>Default</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><code>animation</code></td> <td>String</td> <td>slide</td> <td>The animation to use. (fade, slide, scale)</td> </tr> <tr> <td><code>autoplay</code></td> <td>Boolean</td> <td>0</td> <td>Starts autoplaying the lightbox.</td> </tr> <tr> <td><code>autoplay-interval</code></td> <td>Number</td> <td>0</td> <td>The delay between switching slides in autoplay mode.</td> </tr> <tr> <td><code>pause-on-hover</code></td> <td>Boolean</td> <td>0</td> <td>Pause autoplay mode on hover.</td> </tr> <tr> <td><code>video-autoplay</code></td> <td>Boolean, String</td> <td>false</td> <td>Lightbox videos autoplay. A value of `inline` will autoplay the video, muted and without controls.</td> </tr> <tr> <td><code>counter</code></td> <td>Boolean</td> <td>false</td> <td>Show counter.</td> </tr> <tr> <td><code>nav</code></td> <td>Boolean, String</td> <td>false</td> <td>The nav to use. (dotnav, thumbnav)</td> </tr> <tr> <td><code>slidenav</code></td> <td>Boolean</td> <td>true</td> <td>Show slidenav.</td> </tr> <tr> <td><code>delay-controls</code></td> <td>Number</td> <td>3000</td> <td>Delay time before controls fade out in ms. Setting `0` will prevent hiding controls.</td> </tr> <tr> <td><code>toggle</code></td> <td>CSS selector</td> <td>a</td> <td>Toggle selector - triggers the lightbox.</td> </tr> </tbody> </table> </div> <h3>Lightbox Panel</h3> <div class="uk-overflow-auto"> <table class="uk-table uk-table-striped"> <thead> <tr> <th>Option</th> <th>Value</th> <th>Default</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><code>animation</code></td> <td>String</td> <td>slide</td> <td>The animation to use. (slide, fade, scale)</td> </tr> <tr> <td><code>autoplay</code></td> <td>Boolean</td> <td>false</td> <td>Starts autoplaying the lightbox.</td> </tr> <tr> <td><code>autoplay-interval</code></td> <td>Number</td> <td>7000</td> <td>The delay between switching slides in autoplay mode.</td> </tr> <tr> <td><code>video-autoplay</code></td> <td>Boolean, String</td> <td>false</td> <td>Lightbox videos autoplay. A value of `inline` will autoplay the video, muted and without controls.</td> </tr> <tr> <td><code>counter</code></td> <td>Boolean</td> <td>false</td> <td>Show counter.</td> </tr> <tr> <td><code>nav</code></td> <td>Boolean, String</td> <td>false</td> <td>The nav to use. (dotnav, thumbnav)</td> </tr> <tr> <td><code>slidenav</code></td> <td>Boolean</td> <td>true</td> <td>Show slidenav.</td> </tr> <tr> <td><code>velocity</code></td> <td>Number</td> <td>2</td> <td>The animation velocity (pixel/ms).</td> </tr> <tr> <td><code>index</code></td> <td>Number</td> <td>0</td> <td>The initial item to show. (zero based)</td> </tr> <tr> <td><code>preload</code></td> <td>Number</td> <td>1</td> <td>The number of items to preload. (left and right of the currently active item)</td> </tr> <tr> <td><code>items</code></td> <td>Array</td> <td>[]</td> <td>An array of items to display. ([{source: 'images/size1.jpg', caption: '900x600'}])</td> </tr> <tr> <td><code>template</code></td> <td>String</td> <td></td> <td>The template string.</td> </tr> <tr> <td><code>delay-controls</code></td> <td>Number</td> <td>3000</td> <td>Delay time before controls fade out in ms. Setting `0` will prevent hiding controls.</td> </tr> <tr> <td><code>i18n</code></td> <td>Object</td> <td>null</td> <td>Override default translation texts.</td> </tr> </tbody> </table> </div> <h2>i18n</h2> <div class="uk-overflow-auto"> <table class="uk-table uk-table-striped"> <thead> <tr> <th>Key</th> <th>Default</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><code>counter</code></td> <td>%s / %s</td> <td>Counter indicator for current slide.</td> </tr> <tr> <td><code>next</code></td> <td>Next Slide</td> <td><code>aria-label</code> for next slide button.</td> </tr> <tr> <td><code>previous</code></td> <td>Previous Slide</td> <td><code>aria-label</code> for previous slide button.</td> </tr> <tr> <td><code>slideLabel</code></td> <td>%s of %s</td> <td><code>aria-label</code> for slide.</td> </tr> <tr> <td><code>close</code></td> <td>Close</td> <td><code>aria-label</code> for close button.</td> </tr> </tbody> </table> </div> </div> <script> const {attr, $$, on} = UIkit.util; for (const attribute of ['animation', 'bg-close', 'delay-controls', 'counter', 'video-autoplay']) { on(`#js-${attribute}-switcher`, 'change', e => attr($$('[uk-lightbox]'), attribute, e.target.value) ); } on('#js-lightbox', 'click', (e) => { e.preventDefault(); UIkit.lightboxPanel({ items: [ {source: 'images/size1.jpg', caption: '900x600'}, {source: 'images/size2.jpg', caption: '700x500'}, ] }).show(); }); </script> </body> </html>