foldbox 0.0.0-stage → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 WPGenius
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,147 @@
1
- # Temporary Holding Version
1
+ # Foldbox
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![npm](https://img.shields.io/npm/v/foldbox)](https://www.npmjs.com/package/foldbox)
4
+ [![Latest release](https://img.shields.io/github/v/release/wpgenius/foldbox)](https://github.com/wpgenius/foldbox/releases/latest)
5
+ [![CI](https://github.com/wpgenius/foldbox/actions/workflows/ci.yml/badge.svg)](https://github.com/wpgenius/foldbox/actions/workflows/ci.yml)
6
+ [![MIT licence](https://img.shields.io/github/license/wpgenius/foldbox)](LICENSE)
7
+
8
+ A small, dependency-free **lightbox** and **filterable grid** for photos and videos. The gallery unfolds from the thumbnail you click; the grid animates between category filters.
9
+
10
+ **[Live demos](https://wpgenius.github.io/foldbox/)** · **[Documentation](https://wpgenius.github.io/foldbox/docs.html)** · **[Releases](https://github.com/wpgenius/foldbox/releases)**
11
+
12
+ ## Features
13
+
14
+ - **Images and video in one gallery:** JPG, PNG and WebP (with `srcset`), MP4 and WebM, YouTube and Vimeo.
15
+ - **Thumbnail strip**, captions and a counter.
16
+ - **Zoom:** double-click, pinch, trackpad pinch or the zoom button; drag to pan.
17
+ - **Fullscreen**, **slideshow** with a progress bar, and an optional **download** button.
18
+ - **Touch:** swipe between slides, swipe down to close.
19
+ - **Themes:** dark, light or automatic, plus CSS custom properties for your own look.
20
+ - **Accessible:** dialog semantics, focus trap, keyboard (arrows, Home, End, Esc), respects reduced motion.
21
+ - **Privacy friendly:** YouTube and Vimeo players load only when the visitor presses play; YouTube uses `youtube-nocookie.com`.
22
+ - **Filterable grid:** cards glide, fade and scale between filters, with any CSS layout.
23
+ - **Translatable** and works on right-to-left pages.
24
+
25
+ No dependencies, about 11 KB minified and gzipped (JS + CSS).
26
+
27
+ ## Install
28
+
29
+ From npm:
30
+
31
+ ```bash
32
+ npm install foldbox
33
+ ```
34
+
35
+ ```js
36
+ import Foldbox from 'foldbox';
37
+ import 'foldbox/dist/foldbox.min.css';
38
+ ```
39
+
40
+ Or from the jsDelivr CDN:
41
+
42
+ ```html
43
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/wpgenius/foldbox@1/dist/foldbox.min.css">
44
+ <script src="https://cdn.jsdelivr.net/gh/wpgenius/foldbox@1/dist/foldbox.min.js"></script>
45
+ ```
46
+
47
+ `@1` follows the latest 1.x release; pin an exact version (such as `@1.2.0`) in production. Or download `foldbox.min.js` and `foldbox.min.css` from the [latest release](https://github.com/wpgenius/foldbox/releases/latest). Foldbox is a UMD module, so `require( 'foldbox' )` and AMD loaders work too.
48
+
49
+ ## Quick start
50
+
51
+ ### Open a gallery from JavaScript
52
+
53
+ ```js
54
+ const items = [
55
+ { src: 'beach.jpg', thumb: 'beach-thumb.jpg', alt: 'Beach', caption: 'Summer 2026' },
56
+ { src: 'clip.mp4', poster: 'clip.jpg' },
57
+ { src: 'https://www.youtube.com/watch?v=aqz-KE-bpKQ' },
58
+ { src: 'https://vimeo.com/76979871', thumb: 'vimeo-thumb.jpg' },
59
+ ];
60
+
61
+ button.addEventListener( 'click', () => {
62
+ Foldbox.open( items, { origin: button, theme: 'auto' } );
63
+ } );
64
+ ```
65
+
66
+ ### Turn links into a gallery
67
+
68
+ ```html
69
+ <div id="gallery">
70
+ <a href="large-1.jpg" data-caption="First"><img src="small-1.jpg" alt=""></a>
71
+ <a href="large-2.jpg" data-caption="Second"><img src="small-2.jpg" alt=""></a>
72
+ <a href="https://youtu.be/aqz-KE-bpKQ">Video</a>
73
+ </div>
74
+ <script>
75
+ Foldbox.bind( '#gallery', { download: true } );
76
+ </script>
77
+ ```
78
+
79
+ ### Filter a grid
80
+
81
+ ```js
82
+ const grid = Foldbox.grid( document.querySelector( '.grid' ), { itemSelector: ':scope > .card' } );
83
+
84
+ grid.filter( '.weddings' ); // CSS selector
85
+ grid.filter( '*' ); // everything
86
+ grid.filter( ( item ) => item.dataset.year === '2026' );
87
+ ```
88
+
89
+ Hidden items get the `hidden` attribute, so hide them in your CSS: `.card[hidden] { display: none; }`.
90
+
91
+ ## API at a glance
92
+
93
+ | | |
94
+ |---|---|
95
+ | `Foldbox.open( items, options )` | Open a gallery. Returns an object with `next()`, `prev()`, `goTo( i )`, `play()`, `pause()`, `toggleZoom()`, `toggleFullscreen()` and `close()`. |
96
+ | `Foldbox.bind( container, options )` | Open the links inside a container in a gallery. Returns an unbind function. |
97
+ | `Foldbox.grid( element, options )` | Make a filterable grid with `filter( selector \| fn, instant )`. |
98
+ | `Foldbox.close()` | Close the open gallery. |
99
+ | `Foldbox.defaults` | Default options for every gallery. |
100
+
101
+ Commonly used options: `index`, `loop`, `animation` (`'slide'` / `'fade'`), `theme` (`'dark'` / `'light'` / `'auto'`), `thumbnails`, `zoom`, `fullscreen`, `slideshow`, `download`, `captions`, `labels` and the `onOpen` / `onChange` / `onClose` callbacks.
102
+
103
+ The [documentation](https://wpgenius.github.io/foldbox/docs.html) covers every item field, option, CSS property and translation label.
104
+
105
+ ## Styling
106
+
107
+ ```css
108
+ .foldbox {
109
+ --foldbox-bg: rgba(0, 0, 0, 0.9);
110
+ --foldbox-accent: #ffcc00;
111
+ --foldbox-top: 32px; /* leave room for a fixed header */
112
+ }
113
+ ```
114
+
115
+ See [Themes and styling](https://wpgenius.github.io/foldbox/docs.html#themes) for all properties and how to make your own theme.
116
+
117
+ ## Captions and security
118
+
119
+ `Foldbox.open()` inserts captions as HTML, so escape anything that comes from users (or pass `htmlCaptions: false`). `Foldbox.bind()` shows captions as plain text by default, because they come from page markup.
120
+
121
+ ## Browser support
122
+
123
+ Current versions of Chrome, Edge, Firefox and Safari, on desktop and mobile.
124
+
125
+ ## Contributing
126
+
127
+ Issues and pull requests are welcome.
128
+
129
+ ```bash
130
+ npm install
131
+ npm run build # dist/foldbox.min.js and dist/foldbox.min.css
132
+ npm run site # assemble the website into _site/
133
+ ```
134
+
135
+ Open `demo/index.html` (development demo, uses `src/`) or `_site/index.html` (the website) through a local web server.
136
+
137
+ - **In a PR, change `src/`, `site/` and docs only.** Don't commit `dist/` or `CHANGELOG.md`, and don't change version numbers; the release workflow does that. CI fails if a PR touches `dist/` or `CHANGELOG.md`.
138
+ - **Link your PR to its issue** (`Fixes #12`): the changelog lists one line per issue closed since the previous release.
139
+ - **Version:** patch by default. Label the PR `release: minor` or `release: major` for a bigger bump.
140
+
141
+ ### Releases and website
142
+
143
+ Releases are automatic. When a change to `src/` is merged into `main`, the release workflow bumps the version, rebuilds `dist/`, writes the `CHANGELOG.md` entry, publishes a GitHub release with the minified files and publishes the package to npm. To publish an existing release to npm again, run the **Publish to npm** workflow with its tag. The website in `site/` is published to GitHub Pages when it changes and after every release, so the demos always use the latest version.
144
+
145
+ ## Licence
146
+
147
+ [MIT](LICENSE) © WPGenius
@@ -0,0 +1,4 @@
1
+ /*!
2
+ * Foldbox 1.2.1 – https://github.com/wpgenius/foldbox
3
+ * (c) WPGenius. Released under the MIT License.
4
+ */.foldbox{--foldbox-bg: rgba(10, 10, 12, .96);--foldbox-color: #fff;--foldbox-muted: rgba(255, 255, 255, .7);--foldbox-accent: #fff;--foldbox-btn-bg: rgba(255, 255, 255, .08);--foldbox-btn-hover: rgba(255, 255, 255, .18);--foldbox-thumb-bg: rgba(255, 255, 255, .1);--foldbox-spinner-track: rgba(255, 255, 255, .25);--foldbox-top: 0px;--foldbox-z: 100000;--foldbox-thumb-size: 64px;--foldbox-speed: .4s;--foldbox-ease: cubic-bezier(.2, .8, .2, 1);position:fixed;inset:var(--foldbox-top) 0 0;z-index:var(--foldbox-z);display:flex;flex-direction:column;color:var(--foldbox-color);font-family:inherit;font-size:15px;line-height:1.5;opacity:0;outline:none;transition:opacity var(--foldbox-speed) var(--foldbox-ease);-webkit-tap-highlight-color:transparent}.foldbox--light{--foldbox-bg: rgba(250, 250, 248, .97);--foldbox-color: #111;--foldbox-muted: rgba(0, 0, 0, .65);--foldbox-accent: #111;--foldbox-btn-bg: rgba(0, 0, 0, .06);--foldbox-btn-hover: rgba(0, 0, 0, .12);--foldbox-thumb-bg: rgba(0, 0, 0, .08);--foldbox-spinner-track: rgba(0, 0, 0, .15)}@media (prefers-color-scheme: light){.foldbox--auto{--foldbox-bg: rgba(250, 250, 248, .97);--foldbox-color: #111;--foldbox-muted: rgba(0, 0, 0, .65);--foldbox-accent: #111;--foldbox-btn-bg: rgba(0, 0, 0, .06);--foldbox-btn-hover: rgba(0, 0, 0, .12);--foldbox-thumb-bg: rgba(0, 0, 0, .08);--foldbox-spinner-track: rgba(0, 0, 0, .15)}}.foldbox *,.foldbox *:before,.foldbox *:after{box-sizing:border-box}.foldbox.is-open{opacity:1}.foldbox.is-closing{pointer-events:none}.foldbox__backdrop{position:absolute;inset:0;background:var(--foldbox-bg);transition:opacity .2s}.foldbox__toolbar{position:relative;z-index:3;display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 12px;transform:translateY(-12px);transition:transform var(--foldbox-speed) var(--foldbox-ease)}.foldbox.is-open .foldbox__toolbar{transform:none}.foldbox__counter{padding-left:6px;color:var(--foldbox-muted);font-variant-numeric:tabular-nums}.foldbox__actions{display:flex;gap:6px;margin-left:auto}.foldbox__btn{display:inline-flex;align-items:center;justify-content:center;width:40px;height:40px;margin:0;padding:0;color:var(--foldbox-color);background:var(--foldbox-btn-bg);border:0;border-radius:50%;cursor:pointer;text-decoration:none;transition:background-color .2s,transform .2s,opacity .2s}.foldbox__btn:hover,.foldbox__btn:focus-visible{color:var(--foldbox-color);background:var(--foldbox-btn-hover)}.foldbox__btn:focus-visible,.foldbox__thumb:focus-visible,.foldbox__play:focus-visible{outline:2px solid var(--foldbox-accent);outline-offset:2px}.foldbox__btn:active{transform:scale(.92)}.foldbox__btn[hidden]{display:none}.foldbox__btn svg{width:22px;height:22px;fill:none;stroke:currentcolor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}.foldbox__btn--play svg,.foldbox__btn--pause svg{fill:currentcolor}.foldbox__btn[aria-pressed=true] svg{fill:none}.foldbox__progress{position:absolute;top:0;left:0;right:0;z-index:4;height:3px;pointer-events:none}.foldbox__progress span{display:block;height:100%;background:var(--foldbox-accent);transform:scaleX(0);transform-origin:left center}.foldbox__stage{position:relative;z-index:1;flex:1 1 auto;min-height:0;overflow:hidden;touch-action:none;transition:transform .3s var(--foldbox-ease)}.foldbox__track,.foldbox__thumbs{direction:ltr}.foldbox__track{display:flex;height:100%;transition:transform var(--foldbox-speed) var(--foldbox-ease);will-change:transform}.foldbox__slide{position:relative;display:flex;flex:0 0 100%;align-items:center;justify-content:center;width:100%;height:100%;padding:8px 64px;overflow:hidden;user-select:none}.foldbox--fade .foldbox__track{position:relative;transform:none!important}.foldbox--fade .foldbox__slide{position:absolute;inset:0;opacity:0;visibility:hidden;transition:opacity var(--foldbox-speed) var(--foldbox-ease),visibility 0s linear var(--foldbox-speed)}.foldbox--fade .foldbox__slide.is-active{opacity:1;visibility:visible;transition:opacity var(--foldbox-speed) var(--foldbox-ease),visibility 0s}.foldbox__zoom{display:flex;align-items:center;justify-content:center;max-width:100%;max-height:100%;transition:transform .3s var(--foldbox-ease);will-change:transform}.foldbox__img{display:block;max-width:100%;max-height:calc(100vh - var(--foldbox-top) - 200px);width:auto;height:auto;margin:0;object-fit:contain;cursor:zoom-in;-webkit-user-drag:none}.foldbox--single .foldbox__img,.foldbox:not(:has(.foldbox__thumbs)) .foldbox__img{max-height:calc(100vh - var(--foldbox-top) - 120px)}.foldbox.is-fullscreen .foldbox__img{max-height:calc(100vh - 140px)}@supports (height: 1cqh){.foldbox__slide{container-type:size}.foldbox .foldbox__slide .foldbox__img{max-height:100cqh}.foldbox .foldbox__slide .foldbox__video,.foldbox .foldbox__slide .foldbox__embed,.foldbox .foldbox__slide .foldbox__play{width:min(100%,100cqh * 16 / 9)}}.foldbox.is-zoomed .foldbox__img{cursor:grab}.foldbox.is-zoomed .foldbox__img:active{cursor:grabbing}.foldbox__video,.foldbox__embed{width:min(100%,calc((100vh - var(--foldbox-top) - 200px) * 16 / 9));max-height:100%;aspect-ratio:16 / 9;background:#000}.foldbox__video{display:block;height:auto}.foldbox__embed iframe{display:block;width:100%;height:100%;border:0}.foldbox__play{position:relative;display:block;width:min(100%,calc((100vh - var(--foldbox-top) - 200px) * 16 / 9));aspect-ratio:16 / 9;margin:0;padding:0;overflow:hidden;background:#000;border:0;cursor:pointer}.foldbox__play img{display:block;width:100%;height:100%;object-fit:cover;opacity:.85;transition:opacity .2s,transform .4s var(--foldbox-ease)}.foldbox__play:hover img{opacity:1;transform:scale(1.03)}.foldbox__play-icon{position:absolute;top:50%;left:50%;width:72px;height:72px;background:#0009;border:2px solid rgba(255,255,255,.9);border-radius:50%;transform:translate(-50%,-50%);transition:transform .2s,background-color .2s}.foldbox__play-icon:after{content:"";position:absolute;top:50%;left:54%;border-style:solid;border-width:12px 0 12px 20px;border-color:transparent transparent transparent #fff;transform:translate(-50%,-50%)}.foldbox__play:hover .foldbox__play-icon{background:#000c;transform:translate(-50%,-50%) scale(1.08)}.foldbox__slide.is-loading:before{content:"";position:absolute;top:50%;left:50%;width:36px;height:36px;margin:-18px 0 0 -18px;border:3px solid var(--foldbox-spinner-track);border-top-color:var(--foldbox-accent);border-radius:50%;animation:foldbox-spin .8s linear infinite}.foldbox__slide.has-error .foldbox__zoom{color:var(--foldbox-muted)}@keyframes foldbox-spin{to{transform:rotate(360deg)}}.foldbox__nav{position:absolute;top:50%;z-index:3;width:48px;height:48px;margin-top:-24px}.foldbox__nav--prev{left:10px}.foldbox__nav--next{right:10px}.foldbox__nav:disabled{opacity:.3;cursor:default}.foldbox.is-zoomed .foldbox__nav{opacity:0;pointer-events:none}.foldbox__footer{position:relative;z-index:2;transform:translateY(12px);transition:transform var(--foldbox-speed) var(--foldbox-ease)}.foldbox.is-open .foldbox__footer{transform:none}.foldbox__caption{max-width:900px;margin:0 auto;padding:6px 16px 10px;text-align:center;color:var(--foldbox-muted)}.foldbox__caption h4{margin:0 0 2px;color:var(--foldbox-color);font-size:1.05em}.foldbox__caption p{margin:0}.foldbox__caption[hidden]{display:none}.foldbox__thumbs{display:flex;gap:6px;padding:4px 12px 12px;overflow-x:auto;scrollbar-width:none;justify-content:safe center}.foldbox__thumbs::-webkit-scrollbar{display:none}.foldbox__thumb{position:relative;flex:0 0 auto;width:var(--foldbox-thumb-size);height:var(--foldbox-thumb-size);margin:0;padding:0;overflow:hidden;background:var(--foldbox-thumb-bg);border:0;border-radius:6px;cursor:pointer;opacity:.5;transition:opacity .2s,transform .2s}.foldbox__thumb:hover{opacity:.85}.foldbox__thumb.is-active{opacity:1;box-shadow:inset 0 0 0 2px var(--foldbox-accent)}.foldbox__thumb img{display:block;width:100%;height:100%;object-fit:cover}.foldbox__thumb.is-active img{padding:2px;border-radius:6px}.foldbox__thumb--video:after,.foldbox__thumb--youtube:after,.foldbox__thumb--vimeo:after{content:"";position:absolute;top:50%;left:50%;border-style:solid;border-width:7px 0 7px 12px;border-color:transparent transparent transparent #fff;transform:translate(-40%,-50%);filter:drop-shadow(0 0 3px rgba(0,0,0,.6))}.foldbox--hide-thumbs-fs.is-fullscreen .foldbox__thumbs{display:none}@media (max-width: 640px){.foldbox__slide{padding:4px 0}.foldbox__nav{display:none}.foldbox{--foldbox-thumb-size: 52px}}@media (prefers-reduced-motion: reduce){.foldbox,.foldbox__toolbar,.foldbox__footer,.foldbox__track,.foldbox__zoom,.foldbox__slide{transition:none!important}}.foldbox-ghost{pointer-events:none}
@@ -0,0 +1,5 @@
1
+ /*!
2
+ * Foldbox 1.2.1 – lightbox and filterable grid for photos and videos.
3
+ * https://github.com/wpgenius/foldbox
4
+ * (c) WPGenius. Released under the MIT License.
5
+ */(function(M,y){typeof define=="function"&&define.amd?define([],y):typeof module=="object"&&module.exports?module.exports=y():M.Foldbox=y()})(typeof self!="undefined"?self:this,function(){"use strict";const M="1.2.1",y={dialog:"Gallery",close:"Close",prev:"Previous",next:"Next",zoomIn:"Zoom in",zoomOut:"Zoom out",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",play:"Start slideshow",pause:"Pause slideshow",download:"Download",playVideo:"Play video",counter:"%1 / %2",error:"This item could not be loaded."},C={index:0,loop:!0,animation:"slide",speed:400,origin:null,theme:"dark",className:"",counter:!0,captions:!0,htmlCaptions:!0,thumbnails:!0,hideThumbsInFullscreen:!1,zoom:!0,maxZoom:3,fullscreen:!0,slideshow:!0,slideshowAutostart:!1,slideshowInterval:5e3,download:!1,keyboard:!0,swipe:!0,swipeToClose:!0,closeOnBackdrop:!0,youtubeNoCookie:!0,youtubeThumbnails:!0,youtubeParams:{rel:0},vimeoParams:{},labels:Object.assign({},y),onOpen:null,onChange:null,onClose:null},O={close:'<path d="M6 6l12 12M18 6L6 18"/>',prev:'<path d="M15 5l-7 7 7 7"/>',next:'<path d="M9 5l7 7-7 7"/>',zoomIn:'<circle cx="11" cy="11" r="6"/><path d="M20 20l-4.5-4.5M11 8v6M8 11h6"/>',zoomOut:'<circle cx="11" cy="11" r="6"/><path d="M20 20l-4.5-4.5M8 11h6"/>',fullscreen:'<path d="M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5"/>',exitFullscreen:'<path d="M9 4v5H4M15 4v5h5M9 20v-5H4M15 20v-5h5"/>',play:'<path d="M8 5l11 7-11 7z"/>',pause:'<path d="M8 5v14M16 5v14"/>',download:'<path d="M12 4v11M7 10l5 5 5-5M5 20h14"/>'},w=function(){return typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches};function d(t,e,s){const o=document.createElement(t);return e&&(o.className=e),s&&Object.keys(s).forEach(function(i){o.setAttribute(i,s[i])}),o}function v(t){return'<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">'+O[t]+"</svg>"}function x(t,e){const s=d("button","foldbox__btn foldbox__btn--"+t,{type:"button","aria-label":e,title:e});return s.innerHTML=v(t),s}function I(t){return Object.keys(t||{}).map(function(e){return encodeURIComponent(e)+"="+encodeURIComponent(t[e])}).join("&")}function Z(t){if(!t)return"";try{const e=new URL(t,document.baseURI).protocol;return e==="http:"||e==="https:"||e==="blob:"?t:""}catch(e){return""}}const k=/(?:youtube(?:-nocookie)?\.com\/(?:watch\?(?:.*&)?v=|embed\/|shorts\/|live\/|v\/)|youtu\.be\/)([A-Za-z0-9_-]{11})/,S=/vimeo\.com\/(?:.*\/)?(?:video\/)?(\d{5,})(?:\/([A-Za-z0-9]+))?/,R=/\.(mp4|webm|ogv|mov|m4v)(?:[?#]|$)/i;function D(t){const e=/^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s?)?$/.exec(t);return e?(Number(e[1])||0)*3600+(Number(e[2])||0)*60+(Number(e[3])||0):0}function P(t,e){const s=Object.assign({},typeof t=="string"?{src:t}:t);s.src&&(s.src=String(s.src));const o=s.src||"";let i;if((s.type&&["image","video","youtube","vimeo"].indexOf(s.type)===-1||s.type==="youtube"&&!s.videoId&&!k.test(o)||s.type==="vimeo"&&!s.videoId&&!S.test(o))&&delete s.type,!s.type)if(s.sources&&s.sources.length)s.type="video";else if(i=o.match(k))s.type="youtube",s.videoId=i[1];else if(i=o.match(S)){s.type="vimeo",s.videoId=i[1];const n=o.match(/[?&]h=([A-Za-z0-9]+)/);s.hash=i[2]||(n?n[1]:"")}else R.test(o)?s.type="video":s.type="image";return s.type==="video"&&!(s.sources&&s.sources.length)&&(s.sources=[{src:o}]),s.type==="youtube"&&!s.videoId&&(i=o.match(k))&&(s.videoId=i[1]),s.type==="vimeo"&&!s.videoId&&(i=o.match(S))&&(s.videoId=i[1],s.hash=i[2]||""),(s.type==="youtube"||s.type==="vimeo")&&(!s.start&&(i=o.match(/[?&#](?:t|start)=([\dhms]+)/))&&(s.start=D(i[1])),s.start=Math.max(0,Math.floor(Number(s.start)||0))),!s.thumb&&s.poster&&(s.thumb=s.poster),!s.thumb&&s.type==="youtube"&&s.videoId&&e.youtubeThumbnails&&(s.thumb="https://i.ytimg.com/vi/"+s.videoId+"/hqdefault.jpg"),!s.thumb&&s.type==="image"&&(s.thumb=o),s}let b=null;function L(t,e){this.options=Object.assign({},C,e||{}),this.options.labels=Object.assign({},y,C.labels,e&&e.labels||{});const s=this;this.items=(t||[]).map(function(o){return P(o,s.options)}),this.index=0,this.slides=[],this.zoomState={scale:1,x:0,y:0},this.pointers=new Map,this.timer=null,this.isOpen=!1,this.handlers={}}L.prototype={open(){if(!this.items.length||this.isOpen)return this;b&&b.close(!0),this.lastFocus=document.activeElement;let t=!1;try{this.build(),this.lockScroll(),t=!0,this.bind();const s=Math.min(Math.max(parseInt(this.options.index,10)||0,0),this.items.length-1);this.goTo(s,!0)}catch(s){throw this.unbind(),t&&this.unlockScroll(),this.root&&this.root.parentNode&&this.root.parentNode.removeChild(this.root),s}b=this,this.isOpen=!0;const e=this;return window.requestAnimationFrame(function(){e.root.classList.add("is-open"),e.zoomFromOrigin()}),this.buttons.close.focus({preventScroll:!0}),this.options.slideshow&&this.options.slideshowAutostart&&this.play(),this.emit("onOpen"),this},build(){const t=this.options,e=t.labels,s=d("div","foldbox foldbox--"+(t.animation==="fade"?"fade":"slide"),{role:"dialog","aria-modal":"true","aria-label":e.dialog,tabindex:"-1"});(t.theme==="light"||t.theme==="auto")&&s.classList.add("foldbox--"+t.theme),t.className&&(s.className+=" "+t.className),t.hideThumbsInFullscreen&&s.classList.add("foldbox--hide-thumbs-fs"),this.items.length<2&&s.classList.add("foldbox--single"),s.style.setProperty("--foldbox-speed",t.speed+"ms");const o=d("div","foldbox__backdrop"),i=d("div","foldbox__toolbar"),n=d("div","foldbox__counter",{"aria-live":"polite"}),a=d("div","foldbox__actions"),l=d("div","foldbox__progress");if(l.appendChild(d("span")),this.buttons={},t.zoom&&(this.buttons.zoom=a.appendChild(x("zoomIn",e.zoomIn))),t.slideshow&&this.items.length>1&&(this.buttons.play=a.appendChild(x("play",e.play))),t.fullscreen&&(document.fullscreenEnabled||document.webkitFullscreenEnabled)&&(this.buttons.fullscreen=a.appendChild(x("fullscreen",e.fullscreen))),t.download){const m=d("a","foldbox__btn foldbox__btn--download",{"aria-label":e.download,title:e.download,download:""});m.innerHTML=v("download"),this.buttons.download=a.appendChild(m)}this.buttons.close=a.appendChild(x("close",e.close)),t.counter&&i.appendChild(n),i.appendChild(a);const c=d("div","foldbox__stage"),h=d("div","foldbox__track");this.slides=this.items.map(function(m,z){const _=d("div","foldbox__slide foldbox__slide--"+m.type,{"data-index":String(z),"aria-hidden":"true"});return h.appendChild(_),_}),c.appendChild(h);const f=x("prev",e.prev),r=x("next",e.next);f.classList.add("foldbox__nav","foldbox__nav--prev"),r.classList.add("foldbox__nav","foldbox__nav--next"),this.buttons.prev=f,this.buttons.next=r;const p=d("div","foldbox__footer"),u=d("div","foldbox__caption");p.appendChild(u);let g=null;if(t.thumbnails&&this.items.length>1){g=d("div","foldbox__thumbs");const m=String(this.items.length);this.thumbButtons=this.items.map(function(z,_){const E=d("button","foldbox__thumb foldbox__thumb--"+z.type,{type:"button","aria-label":e.counter.replace("%1",String(_+1)).replace("%2",m),"data-index":String(_)});if(z.thumb){const F=d("img","",{alt:"",loading:"lazy",draggable:"false"});F.src=z.thumb,E.appendChild(F)}return g.appendChild(E),E}),p.appendChild(g)}s.appendChild(o),s.appendChild(i),s.appendChild(l),s.appendChild(c),this.items.length>1&&(s.appendChild(f),s.appendChild(r)),s.appendChild(p),document.body.appendChild(s),this.root=s,this.stage=c,this.track=h,this.counter=n,this.caption=u,this.footer=p,this.thumbs=g,this.progress=l,this.backdrop=o},bind(){const t=this,e=function(s,o,i,n){s.addEventListener(o,i,n),(t.handlers[o]=t.handlers[o]||[]).push([s,i,n])};e(this.buttons.close,"click",function(){t.close()}),e(this.buttons.prev,"click",function(){t.prev()}),e(this.buttons.next,"click",function(){t.next()}),this.buttons.zoom&&e(this.buttons.zoom,"click",function(){t.toggleZoom()}),this.buttons.play&&e(this.buttons.play,"click",function(){t.timer?t.pause():t.play()}),this.buttons.fullscreen&&(e(this.buttons.fullscreen,"click",function(){t.toggleFullscreen()}),e(document,"fullscreenchange",function(){t.onFullscreenChange()}),e(document,"webkitfullscreenchange",function(){t.onFullscreenChange()})),this.thumbs&&e(this.thumbs,"click",function(s){const o=s.target.closest(".foldbox__thumb");o&&t.goTo(parseInt(o.getAttribute("data-index"),10))}),e(document,"keydown",function(s){t.onKey(s)}),e(this.stage,"pointerdown",function(s){t.onPointerDown(s)}),e(window,"pointermove",function(s){t.onPointerMove(s)}),e(window,"pointerup",function(s){t.onPointerUp(s)}),e(window,"pointercancel",function(s){t.onPointerUp(s)}),e(this.stage,"dblclick",function(s){t.options.zoom&&s.target.classList.contains("foldbox__img")&&t.toggleZoom(s.clientX,s.clientY)}),e(this.stage,"wheel",function(s){t.onWheel(s)},{passive:!1}),e(this.stage,"click",function(s){if(t.dragged){t.dragged=!1;return}const o=s.target.closest(".foldbox__play");if(o){t.playEmbed(parseInt(o.getAttribute("data-index"),10));return}t.options.closeOnBackdrop&&(s.target.classList.contains("foldbox__slide")||s.target===t.stage||s.target.classList.contains("foldbox__track"))&&t.close()}),e(window,"resize",function(){t.clampZoom(),t.applyZoom(!1)})},unbind(){const t=this.handlers;Object.keys(t).forEach(function(e){t[e].forEach(function(s){s[0].removeEventListener(e,s[1],s[2])})}),this.handlers={}},goTo(t,e){const s=this.items.length;this.options.loop?t=(t%s+s)%s:t=Math.min(Math.max(t,0),s-1);const o=this.index;if(!(t!==o||e))return this;const n=t!==o&&this.slides[o]&&this.slides[o].contains(document.activeElement);this.slides[o]&&this.leaveSlide(o),this.index=t,this.resetZoom();const a=this;return this.slides.forEach(function(l,c){const h=c===t;l.classList.toggle("is-active",h),l.setAttribute("aria-hidden",h?"false":"true"),l.inert=!h,a.isNear(c)&&a.load(c)}),n&&this.root.focus({preventScroll:!0}),this.track.style.transition=e?"none":"",this.options.animation!=="fade"&&(this.track.style.transform="translate3d("+-t*100+"%, 0, 0)"),e&&(this.track.offsetWidth,this.track.style.transition=""),this.updateUi(),this.timer&&this.restartProgress(),e||this.emit("onChange"),this},next(){return!this.options.loop&&this.index>=this.items.length-1?(this.bounce(-1),this):this.goTo(this.index+1)},prev(){return!this.options.loop&&this.index<=0?(this.bounce(1),this):this.goTo(this.index-1)},bounce(t){if(w()||!this.track.animate)return;const e=this.options.animation==="fade"?0:-this.index*100;this.track.animate([{transform:"translate3d("+e+"%,0,0)"},{transform:"translate3d(calc("+e+"% + "+t*40+"px),0,0)"},{transform:"translate3d("+e+"%,0,0)"}],{duration:300,easing:"ease-out"})},isNear(t){const e=this.items.length,s=Math.abs(t-this.index);return s<=1||this.options.loop&&e>2&&s===e-1},updateUi(){const t=this.options,e=this.items[this.index],s=this.items.length;this.counter.textContent=t.labels.counter.replace("%1",String(this.index+1)).replace("%2",String(s)),t.captions&&e.caption?(t.htmlCaptions?this.caption.innerHTML=e.caption:this.caption.textContent=e.caption,this.caption.hidden=!1):(this.caption.innerHTML="",this.caption.hidden=!0),this.buttons.prev&&(this.buttons.prev.disabled=!t.loop&&this.index===0,this.buttons.next.disabled=!t.loop&&this.index===s-1);const o=this.slides[this.index].classList.contains("has-error");if(this.buttons.zoom&&(this.buttons.zoom.hidden=e.type!=="image"||o),this.buttons.download){const i=Z(e.download===!1?"":e.download||(o?"":e.type==="image"?e.src:e.type==="video"?e.sources[0].src:""));this.buttons.download.hidden=!i,i?(this.buttons.download.href=i,new URL(i,document.baseURI).origin!==window.location.origin?(this.buttons.download.target="_blank",this.buttons.download.rel="noopener"):(this.buttons.download.removeAttribute("target"),this.buttons.download.removeAttribute("rel"))):this.buttons.download.removeAttribute("href")}if(this.thumbButtons){const i=this.index;this.thumbButtons.forEach(function(c,h){c.classList.toggle("is-active",h===i),h===i?c.setAttribute("aria-current","true"):c.removeAttribute("aria-current")});const n=this.thumbButtons[i],a=this.thumbs,l=n.offsetLeft-(a.clientWidth-n.offsetWidth)/2;typeof a.scrollTo=="function"?a.scrollTo({left:l,behavior:w()?"auto":"smooth"}):a.scrollLeft=l}},load(t){const e=this.slides[t];if(e.getAttribute("data-loaded"))return;e.setAttribute("data-loaded","1");const s=this.items[t],o=this.options.labels;if(s.type==="image"){const a=d("div","foldbox__zoom"),l=d("img","foldbox__img",{alt:s.alt||"",draggable:"false"});e.classList.add("is-loading"),l.addEventListener("load",function(){e.classList.remove("is-loading")});const c=this;l.addEventListener("error",function(){e.classList.remove("is-loading"),e.classList.add("has-error"),a.textContent=o.error,t===c.index&&c.isOpen&&c.updateUi()}),s.srcset&&(l.srcset=s.srcset,l.sizes="100vw"),l.src=s.src,a.appendChild(l),e.appendChild(a);return}if(s.type==="video"){const a=d("video","foldbox__video",{controls:"",playsinline:"",preload:"metadata"});s.poster&&(a.poster=s.poster),s.sources.forEach(function(c){const h=d("source");h.src=c.src,c.type&&(h.type=c.type),a.appendChild(h)});const l=this;a.addEventListener("play",function(){l.pause()}),e.appendChild(a);return}const i=d("button","foldbox__play",{type:"button","aria-label":o.playVideo,"data-index":String(t)}),n=s.poster||s.thumb;if(n){const a=d("img","",{alt:s.alt||"",draggable:"false"});a.src=n,i.appendChild(a)}i.appendChild(d("span","foldbox__play-icon")),e.appendChild(i)},embedUrl(t){const e=this.options;if(t.type==="youtube"){const o=e.youtubeNoCookie?"https://www.youtube-nocookie.com":"https://www.youtube.com",i=t.start?{start:t.start}:{};return o+"/embed/"+encodeURIComponent(t.videoId)+"?"+I(Object.assign({autoplay:1,playsinline:1},i,e.youtubeParams))}const s=Object.assign({autoplay:1},e.vimeoParams);return t.hash&&(s.h=t.hash),"https://player.vimeo.com/video/"+encodeURIComponent(t.videoId)+"?"+I(s)+(t.start?"#t="+t.start+"s":"")},playEmbed(t){const e=this.items[t],s=this.slides[t];if(!e||e.type!=="youtube"&&e.type!=="vimeo")return;t!==this.index&&this.goTo(t),this.pause();const o=d("iframe","foldbox__iframe",{src:this.embedUrl(e),title:e.title||e.alt||this.options.labels.playVideo,allow:"autoplay; fullscreen; picture-in-picture; encrypted-media",allowfullscreen:"",referrerpolicy:"strict-origin-when-cross-origin"}),i=d("div","foldbox__embed");i.appendChild(o);const n=s.contains(document.activeElement);s.innerHTML="",s.appendChild(i),n&&o.focus(),s.setAttribute("data-playing","1")},leaveSlide(t){const e=this.slides[t],s=e.querySelector("video");s&&!s.paused&&s.pause(),e.getAttribute("data-playing")&&(e.innerHTML="",e.removeAttribute("data-playing"),e.removeAttribute("data-loaded"),this.load(t))},zoomFromOrigin(){const t=this.options.origin,e=this.slides[this.index].querySelector(".foldbox__img");if(!t||!e||w()||!e.animate)return;const s=this,o=function(){const i=t.getBoundingClientRect(),n=e.getBoundingClientRect();if(!i.width||!n.width)return;const a=Math.max(i.width/n.width,i.height/n.height),l=i.left+i.width/2-(n.left+n.width/2),c=i.top+i.height/2-(n.top+n.height/2);e.animate([{transform:"translate("+l+"px,"+c+"px) scale("+a+")",opacity:.6},{transform:"none",opacity:1}],{duration:s.options.speed,easing:"cubic-bezier(.2,.8,.2,1)"})};e.complete&&e.naturalWidth?o():e.addEventListener("load",o,{once:!0})},currentImage(){const t=this.items[this.index];return t&&t.type==="image"?this.slides[this.index].querySelector(".foldbox__img"):null},applyZoom(t){const e=this.currentImage();if(!e)return;const s=this.zoomState,o=e.parentNode;if(o.style.transition=t?"":"none",o.style.transform=s.scale===1?"":"translate3d("+s.x+"px,"+s.y+"px,0) scale("+s.scale+")",this.root.classList.toggle("is-zoomed",s.scale>1),this.buttons.zoom){const i=s.scale>1,n=i?this.options.labels.zoomOut:this.options.labels.zoomIn;this.buttons.zoom.innerHTML=v(i?"zoomOut":"zoomIn"),this.buttons.zoom.setAttribute("aria-label",n),this.buttons.zoom.title=n}},clampZoom(){const t=this.currentImage();if(!t)return;const e=this.zoomState,s=Math.max(0,(t.offsetWidth*e.scale-this.stage.clientWidth)/2),o=Math.max(0,(t.offsetHeight*e.scale-this.stage.clientHeight)/2);e.x=Math.min(s,Math.max(-s,e.x)),e.y=Math.min(o,Math.max(-o,e.y))},zoomTo(t,e,s,o){if(!this.currentImage())return;const n=this.zoomState;t=Math.min(Math.max(t,1),this.options.maxZoom);const a=this.stage.getBoundingClientRect(),l=e===void 0?a.left+a.width/2:e,c=s===void 0?a.top+a.height/2:s,h=(l-(a.left+a.width/2)-n.x)/n.scale,f=(c-(a.top+a.height/2)-n.y)/n.scale;n.x=l-(a.left+a.width/2)-h*t,n.y=c-(a.top+a.height/2)-f*t,n.scale=t,t===1&&(n.x=0,n.y=0),this.clampZoom(),this.applyZoom(o)},toggleZoom(t,e){this.zoomState.scale>1?this.zoomTo(1,void 0,void 0,!0):this.zoomTo(Math.min(2,this.options.maxZoom),t,e,!0)},resetZoom(){const t=this.zoomState.scale!==1;this.zoomState={scale:1,x:0,y:0},this.root&&(this.root.classList.remove("is-zoomed"),this.slides.forEach(function(e){const s=e.querySelector(".foldbox__zoom");s&&(s.style.transform="")}),(t||this.buttons.zoom)&&this.applyZoom(!1))},onWheel(t){if(!this.options.zoom||!this.currentImage()||!t.ctrlKey&&this.zoomState.scale===1)return;t.preventDefault();const e=Math.exp(-t.deltaY*(t.ctrlKey?.01:.002));this.zoomTo(this.zoomState.scale*e,t.clientX,t.clientY,!1)},onPointerDown(t){if(!(t.button!==void 0&&t.button!==0)&&!(t.target.closest("video, iframe, .foldbox__play, a, button")&&this.zoomState.scale===1&&!t.target.closest(".foldbox__play"))){if(this.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),this.pointers.size===1)this.gesture={startX:t.clientX,startY:t.clientY,zoomX:this.zoomState.x,zoomY:this.zoomState.y,time:Date.now(),axis:null},this.dragged=!1;else if(this.pointers.size===2&&this.options.zoom&&this.currentImage()){const e=Array.from(this.pointers.values());this.pinch={distance:Math.hypot(e[0].x-e[1].x,e[0].y-e[1].y),scale:this.zoomState.scale},this.resetDrag()}}},onPointerMove(t){if(!this.pointers.has(t.pointerId))return;if(this.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),this.pinch&&this.pointers.size===2){const i=Array.from(this.pointers.values()),n=Math.hypot(i[0].x-i[1].x,i[0].y-i[1].y);this.zoomTo(this.pinch.scale*n/this.pinch.distance,(i[0].x+i[1].x)/2,(i[0].y+i[1].y)/2,!1),this.dragged=!0;return}const e=this.gesture;if(!e)return;const s=t.clientX-e.startX,o=t.clientY-e.startY;if((Math.abs(s)>5||Math.abs(o)>5)&&(this.dragged=!0),this.zoomState.scale>1){this.zoomState.x=e.zoomX+s,this.zoomState.y=e.zoomY+o,this.clampZoom(),this.applyZoom(!1);return}if(!e.axis&&this.dragged&&(e.axis=Math.abs(s)>=Math.abs(o)?"x":"y"),e.axis==="x"&&this.options.swipe&&this.items.length>1){this.track.style.transition="none";const i=this.options.animation==="fade"?0:-this.index*100;this.track.style.transform="translate3d(calc("+i+"% + "+s+"px),0,0)"}else e.axis==="y"&&this.options.swipeToClose&&(this.stage.style.transition="none",this.stage.style.transform="translate3d(0,"+o+"px,0)",this.backdrop.style.opacity=String(Math.max(.2,1-Math.abs(o)/400)))},onPointerUp(t){if(!this.pointers.has(t.pointerId))return;if(this.pointers.delete(t.pointerId),this.pinch){if(this.pointers.size<2){this.pinch=null,this.gesture=null;const n=this.pointers.values().next().value;n&&this.zoomState.scale>1&&(this.gesture={startX:n.x,startY:n.y,zoomX:this.zoomState.x,zoomY:this.zoomState.y,time:Date.now(),axis:null})}return}const e=this.gesture;if(this.gesture=null,!e||this.zoomState.scale>1)return;const s=t.clientX-e.startX,o=t.clientY-e.startY,i=Date.now()-e.time<250;e.axis==="x"&&this.options.swipe&&this.items.length>1?(this.track.style.transition="",s<-60||i&&s<-20?this.next():(s>60||i&&s>20)&&this.prev(),this.track.style.transform=this.options.animation==="fade"?"":"translate3d("+-this.index*100+"%,0,0)"):e.axis==="y"&&this.options.swipeToClose&&(Math.abs(o)>120||i&&Math.abs(o)>50?this.close():this.resetDrag())},resetDrag(){this.stage.style.transition="",this.stage.style.transform="",this.backdrop.style.opacity="",this.track.style.transition="",this.options.animation!=="fade"&&(this.track.style.transform="translate3d("+-this.index*100+"%,0,0)")},onKey(t){if(!this.isOpen)return;if(t.key==="Escape"){t.preventDefault(),this.close();return}if(t.key==="Tab"){this.trapFocus(t);return}if(!this.options.keyboard||t.target.closest("video")||t.altKey||t.ctrlKey||t.metaKey)return;const e={ArrowLeft:[1,0],ArrowRight:[-1,0],ArrowUp:[0,1],ArrowDown:[0,-1]}[t.key];if(e&&this.zoomState.scale>1){t.preventDefault(),this.zoomState.x+=e[0]*80,this.zoomState.y+=e[1]*80,this.clampZoom(),this.applyZoom(!0);return}switch(t.key){case"ArrowLeft":t.preventDefault(),this.prev();break;case"ArrowRight":t.preventDefault(),this.next();break;case"Home":t.preventDefault(),this.goTo(0);break;case"End":t.preventDefault(),this.goTo(this.items.length-1);break}},trapFocus(t){const e=Array.prototype.filter.call(this.root.querySelectorAll('button, a[href], video, iframe, [tabindex]:not([tabindex="-1"])'),function(i){return!i.disabled&&!i.hidden&&i.offsetParent!==null&&!i.closest('[aria-hidden="true"]')});if(!e.length){t.preventDefault();return}const s=e[0],o=e[e.length-1];t.shiftKey&&(document.activeElement===s||!this.root.contains(document.activeElement))?(t.preventDefault(),o.focus()):!t.shiftKey&&(document.activeElement===o||!this.root.contains(document.activeElement))&&(t.preventDefault(),s.focus())},play(){if(this.timer||this.items.length<2)return this;!this.options.loop&&this.index>=this.items.length-1&&this.goTo(0);const t=this;return this.root.classList.add("is-playing"),this.setPlayButton(!0),this.timer=window.setInterval(function(){if(!t.options.loop&&t.index>=t.items.length-1){t.pause();return}t.goTo(t.index+1)},this.options.slideshowInterval),this.restartProgress(),this},pause(){return this.timer?(window.clearInterval(this.timer),this.timer=null,this.root&&(this.root.classList.remove("is-playing"),this.progress.firstChild.style.transition="none",this.progress.firstChild.style.transform="scaleX(0)"),this.setPlayButton(!1),this):this},setPlayButton(t){const e=this.buttons&&this.buttons.play;if(!e)return;const s=t?this.options.labels.pause:this.options.labels.play;e.innerHTML=v(t?"pause":"play"),e.setAttribute("aria-label",s),e.title=s,e.setAttribute("aria-pressed",t?"true":"false")},restartProgress(){const t=this.progress.firstChild;t.style.transition="none",t.style.transform="scaleX(0)",t.offsetWidth,t.style.transition="transform "+this.options.slideshowInterval+"ms linear",t.style.transform="scaleX(1)"},isFullscreen(){return(document.fullscreenElement||document.webkitFullscreenElement)===this.root},toggleFullscreen(){if(this.isFullscreen())(document.exitFullscreen||document.webkitExitFullscreen).call(document);else{const t=this.root.requestFullscreen||this.root.webkitRequestFullscreen;if(t){const e=t.call(this.root);e&&e.catch&&e.catch(function(){})}}},onFullscreenChange(){const t=this.isFullscreen();this.root.classList.toggle("is-fullscreen",t);const e=this.buttons.fullscreen;if(e){const s=t?this.options.labels.exitFullscreen:this.options.labels.fullscreen;e.innerHTML=v(t?"exitFullscreen":"fullscreen"),e.setAttribute("aria-label",s),e.title=s}this.resetZoom()},lockScroll(){const t=document.documentElement,e=window.innerWidth-t.clientWidth;this.savedScroll={overflow:t.style.overflow,paddingRight:t.style.paddingRight},t.style.overflow="hidden",e>0&&(t.style.paddingRight=e+"px")},unlockScroll(){const t=document.documentElement;this.savedScroll&&(t.style.overflow=this.savedScroll.overflow,t.style.paddingRight=this.savedScroll.paddingRight)},close(t){if(!this.isOpen)return this;this.isOpen=!1,this.pause(),this.isFullscreen()&&(document.exitFullscreen||document.webkitExitFullscreen).call(document),this.leaveSlide(this.index),this.unbind(),this.unlockScroll(),b===this&&(b=null);const e=this.root,s=function(){e.parentNode&&e.parentNode.removeChild(e)};return e.classList.remove("is-open"),e.classList.add("is-closing"),t||w()?s():window.setTimeout(s,this.options.speed),this.lastFocus&&typeof this.lastFocus.focus=="function"&&this.lastFocus.focus({preventScroll:!0}),this.emit("onClose"),this},destroy(){return this.close(!0)},emit(t){const e=this.options[t];typeof e=="function"&&e.call(this,this.index,this.items[this.index],this)}};function A(t,e){this.grid=t,this.options=Object.assign({itemSelector:":scope > *",duration:400,easing:"ease"},e||{}),window.getComputedStyle(t).position==="static"&&(t.style.position="relative")}A.prototype={items(){return Array.prototype.filter.call(this.grid.querySelectorAll(this.options.itemSelector),function(t){return!t.classList.contains("foldbox-ghost")})},filter(t,e){const s=function(r){return typeof t=="function"?!!t(r):!t||t==="*"||r.matches(t)},o=this.items(),i=this.options,n=function(){o.forEach(function(r){typeof r.getAnimations=="function"&&r.getAnimations().forEach(function(p){p.cancel()})})};if(Array.prototype.forEach.call(this.grid.querySelectorAll(":scope > .foldbox-ghost"),function(r){r.remove()}),e||w()||typeof this.grid.animate!="function")return n(),o.forEach(function(r){r.hidden=!s(r)}),this;const a=this.grid,l=a.getBoundingClientRect(),c=new Map;o.forEach(function(r){r.hidden||c.set(r,r.getBoundingClientRect())}),n();const h=[];o.forEach(function(r){if(r.hidden||s(r))return;const p=c.get(r),u=r.cloneNode(!0);u.setAttribute("aria-hidden","true"),u.inert=!0,u.classList.add("foldbox-ghost"),u.style.position="absolute",u.style.margin="0",u.style.pointerEvents="none",u.style.left=p.left-l.left-a.clientLeft+"px",u.style.top=p.top-l.top-a.clientTop+"px",u.style.width=p.width+"px",h.push(u)}),o.forEach(function(r){r.hidden=!s(r)});const f=new Map;return o.forEach(function(r){r.hidden||f.set(r,r.getBoundingClientRect())}),h.forEach(function(r){a.appendChild(r),r.animate([{opacity:1,transform:"scale(1)"},{opacity:0,transform:"scale(0.6)"}],{duration:i.duration,easing:"ease-in"}).finished.then(function(){r.remove()})}),o.forEach(function(r){if(r.hidden)return;const p=c.get(r);if(!p){r.animate([{opacity:0,transform:"scale(0.6)"},{opacity:1,transform:"scale(1)"}],{duration:i.duration,easing:"ease-out"});return}const u=f.get(r),g=p.left-u.left,m=p.top-u.top;(g||m)&&r.animate([{transform:"translate("+g+"px, "+m+"px)"},{transform:"none"}],{duration:i.duration,easing:i.easing})}),this}};function N(t,e){const s=typeof t=="string"?document.querySelector(t):t;if(!s)return function(){};const o=Object.assign({selector:"a[href]",htmlCaptions:!1},e||{}),i=function(n){if(n.defaultPrevented||n.button!==0||n.ctrlKey||n.metaKey||n.shiftKey||n.altKey)return;const a=n.target.closest(o.selector);if(!a||!s.contains(a))return;n.preventDefault();const l=Array.prototype.slice.call(s.querySelectorAll(o.selector)),c=l.map(function(h){const f=h.querySelector("img");return{src:h.getAttribute("href"),thumb:h.getAttribute("data-thumb")||(f?f.currentSrc||f.src:""),alt:f?f.alt:"",caption:h.getAttribute("data-caption")||"",type:h.getAttribute("data-type")||void 0,poster:h.getAttribute("data-poster")||void 0,download:h.getAttribute("data-download")==="false"?!1:h.hasAttribute("data-download")?h.getAttribute("data-download"):void 0}});T(c,Object.assign({},o,{index:l.indexOf(a),origin:a.querySelector("img")||a}))};return s.addEventListener("click",i),function(){s.removeEventListener("click",i)}}function T(t,e){return new L(t,e).open()}return{version:M,defaults:C,open:T,bind:N,grid(t,e){return new A(t,e)},close(){b&&b.close()},Lightbox:L,Grid:A}});
package/package.json CHANGED
@@ -1,6 +1,35 @@
1
1
  {
2
- "name": "foldbox",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
2
+ "name": "foldbox",
3
+ "version": "1.2.1",
4
+ "description": "Lightweight lightbox and filterable grid for photos and videos: thumbnails, zoom, fullscreen, slideshow, YouTube, Vimeo and MP4.",
5
+ "main": "dist/foldbox.min.js",
6
+ "style": "dist/foldbox.min.css",
7
+ "files": [
8
+ "src",
9
+ "dist"
10
+ ],
11
+ "scripts": {
12
+ "build": "esbuild src/foldbox.js --minify --legal-comments=inline --target=es2018 --outfile=dist/foldbox.min.js && esbuild src/foldbox.css --minify --legal-comments=inline --outfile=dist/foldbox.min.css",
13
+ "site": "rm -rf _site && mkdir _site && cp -R site/. _site/ && cp -R dist _site/dist && touch _site/.nojekyll"
14
+ },
15
+ "keywords": [
16
+ "lightbox",
17
+ "gallery",
18
+ "video",
19
+ "youtube",
20
+ "vimeo",
21
+ "zoom",
22
+ "filter",
23
+ "grid"
24
+ ],
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/wpgenius/foldbox.git"
28
+ },
29
+ "author": "WPGenius",
30
+ "license": "MIT",
31
+ "devDependencies": {
32
+ "esbuild": "0.24.0"
33
+ },
34
+ "homepage": "https://wpgenius.github.io/foldbox/"
35
+ }