@midzer/tobii
Advanced tools
Comparing version 2.4.0 to 2.5.0
# Changelog | ||
## v2.5.0 | ||
### New | ||
- Apply opacity to buttons on :hover | ||
- Change opacity on close button | ||
- Support for audio element | ||
- Bigger inline content in demo and | ||
- Introduce captionHTML parameter | ||
- Replace em function | ||
### Fixed | ||
- Big local video elements | ||
- Missing close button in rare cases | ||
- Update lightbox on remove element | ||
- Adding/removing elements dynamically | ||
- YouTube link in demo | ||
## v2.4.0 | ||
@@ -4,0 +23,0 @@ |
@@ -1,1 +0,1 @@ | ||
class e{constructor(){this.figcaptionId=0,this.userSettings=null}init(e,t,i){this.userSettings=i;const r=document.createElement("figure"),n=document.createElement("figcaption"),s=document.createElement("img"),a=e.querySelector("img"),o=document.createElement("div");r.style.opacity="0",a&&(s.alt=a.alt||""),s.setAttribute("src",""),s.setAttribute("data-src",e.href),e.hasAttribute("data-srcset")&&s.setAttribute("data-srcset",e.getAttribute("data-srcset")),r.appendChild(s),this.userSettings.captions&&("function"==typeof this.userSettings.captionText?n.textContent=this.userSettings.captionText(e):"self"===this.userSettings.captionsSelector&&e.getAttribute(this.userSettings.captionAttribute)?n.textContent=e.getAttribute(this.userSettings.captionAttribute):"img"===this.userSettings.captionsSelector&&a&&a.getAttribute(this.userSettings.captionAttribute)&&(n.textContent=a.getAttribute(this.userSettings.captionAttribute)),n.textContent&&(n.id=`tobii-figcaption-${this.figcaptionId}`,r.appendChild(n),s.setAttribute("aria-labelledby",n.id),++this.figcaptionId)),t.appendChild(r),o.className="tobii__loader",o.setAttribute("role","progressbar"),o.setAttribute("aria-label",this.userSettings.loadingIndicatorLabel),t.appendChild(o),t.setAttribute("data-type","image"),t.classList.add("tobii-image")}onPreload(e){this.onLoad(e)}onLoad(e){const t=e.querySelector("img");if(!t.hasAttribute("data-src"))return;const i=e.querySelector("figure"),r=e.querySelector(".tobii__loader");t.addEventListener("load",()=>{e.removeChild(r),i.style.opacity="1"}),t.addEventListener("error",()=>{e.removeChild(r),i.style.opacity="1"}),t.setAttribute("src",t.getAttribute("data-src")),t.removeAttribute("data-src"),t.hasAttribute("data-srcset")&&t.setAttribute("srcset",t.getAttribute("data-srcset"))}onLeave(e){}onCleanup(e){}onReset(){this.figcaptionId=0}}class t{constructor(){this.userSettings=null}init(e,t,i){this.userSettings=i;const r=e.hasAttribute("data-target")?e.getAttribute("data-target"):e.getAttribute("href");t.setAttribute("data-HREF",r),e.getAttribute("data-allow")&&t.setAttribute("data-allow",e.getAttribute("data-allow")),e.hasAttribute("data-width")&&t.setAttribute("data-width",`${e.getAttribute("data-width")}`),e.hasAttribute("data-height")&&t.setAttribute("data-height",`${e.getAttribute("data-height")}`),t.setAttribute("data-type","iframe"),t.classList.add("tobii-iframe")}onPreload(e){}onLoad(e){let t=e.querySelector("iframe");const i=document.createElement("div");if(i.className="tobii__loader",i.setAttribute("role","progressbar"),i.setAttribute("aria-label",this.userSettings.loadingIndicatorLabel),e.appendChild(i),null==t){t=document.createElement("iframe");const i=e.getAttribute("data-href");t.setAttribute("frameborder","0"),t.setAttribute("src",i),t.setAttribute("allowfullscreen",""),i.indexOf("youtube.com")>-1?t.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"):i.indexOf("vimeo.com")>-1?t.setAttribute("allow","autoplay; picture-in-picture"):e.hasAttribute("data-allow")&&t.setAttribute("allow",e.getAttribute("data-allow")),e.getAttribute("data-width")&&(t.style.maxWidth=`${e.getAttribute("data-width")}`),e.getAttribute("data-height")&&(t.style.maxHeight=`${e.getAttribute("data-height")}`),t.style.opacity="0",e.appendChild(t),t.addEventListener("load",()=>{t.style.opacity="1";const i=e.querySelector(".tobii__loader");i&&e.removeChild(i)}),t.addEventListener("error",()=>{t.style.opacity="1";const i=e.querySelector(".tobii__loader");i&&e.removeChild(i)})}else t.setAttribute("src",e.getAttribute("data-href"))}onLeave(e){}onCleanup(e){const t=e.querySelector("iframe");t.setAttribute("src",""),t.style.opacity="0"}onReset(){}}class i{constructor(){this.userSettings=null}init(e,t,i){this.userSettings=i;const r=e.hasAttribute("data-target")?e.getAttribute("data-target"):e.getAttribute("href"),n=document.querySelector(r).cloneNode(!0);if(!n)throw new Error(`Ups, I can't find the target ${r}.`);t.appendChild(n),t.setAttribute("data-type","html"),t.classList.add("tobii-html")}onPreload(e){}onLoad(e){const t=e.querySelector("video");t&&(t.hasAttribute("data-time")&&t.readyState>0&&(t.currentTime=t.getAttribute("data-time")),this.userSettings.autoplayVideo&&t.play())}onLeave(e){const t=e.querySelector("video");t&&(t.paused||t.pause(),t.readyState>0&&t.setAttribute("data-time",t.currentTime))}onCleanup(e){const t=e.querySelector("video");if(t&&t.readyState>0&&t.readyState<3&&t.duration!==t.currentTime){const i=t.cloneNode(!0);this._removeSources(t),t.load(),t.parentNode.removeChild(t),e.appendChild(i)}}onReset(){}_removeSources(e){const t=e.querySelectorAll("src");t&&t.forEach(e=>{e.setAttribute("src","")})}}class r{constructor(){this.playerId=0,this.PLAYER=[],this.userSettings=null}init(e,t,i){this.userSettings=i;const r=document.createElement("div");t.appendChild(r),this.PLAYER[this.playerId]=new window.YT.Player(r,{host:"https://www.youtube-nocookie.com",height:e.getAttribute("data-height")||"360",width:e.getAttribute("data-width")||"640",videoId:e.getAttribute("data-id"),playerVars:{controls:e.getAttribute("data-controls")||1,rel:0,playsinline:1}}),t.setAttribute("data-player",this.playerId),t.setAttribute("data-type","youtube"),t.classList.add("tobii-youtube"),this.playerId++}onPreload(e){}onLoad(e){this.userSettings.autoplayVideo&&this.PLAYER[e.getAttribute("data-player")].playVideo()}onLeave(e){1===this.PLAYER[e.getAttribute("data-player")].getPlayerState()&&this.PLAYER[e.getAttribute("data-player")].pauseVideo()}onCleanup(e){1===this.PLAYER[e.getAttribute("data-player")].getPlayerState()&&this.PLAYER[e.getAttribute("data-player")].pauseVideo()}onReset(){}}module.exports=function n(s){const a={image:new e,html:new i,iframe:new t,youtube:new r},o=['a[href]:not([tabindex^="-"]):not([inert])','area[href]:not([tabindex^="-"]):not([inert])',"input:not([disabled]):not([inert])","select:not([disabled]):not([inert])","textarea:not([disabled]):not([inert])","button:not([disabled]):not([inert])",'iframe:not([tabindex^="-"]):not([inert])','audio:not([tabindex^="-"]):not([inert])','video:not([tabindex^="-"]):not([inert])','[contenteditable]:not([tabindex^="-"]):not([inert])','[tabindex]:not([tabindex^="-"]):not([inert])'];let d={};const l=[],u={gallery:[],slider:null,sliderElements:[],elementsLength:0,currentIndex:0,x:0};let c=null,b=null,p=null,h=null,m=null,g={},y=!1,v=!1,f=!1,w=null,A=null,E=null,L=!1,x=!1,_={},I=null,S=null;const C=e=>{if(null===document.querySelector('[data-type="youtube"]')||x)P(e);else{if(null===document.getElementById("iframe_api")){const e=document.createElement("script"),t=document.getElementsByTagName("script")[0];e.id="iframe_api",e.src="https://www.youtube.com/iframe_api",t.parentNode.insertBefore(e,t)}-1===l.indexOf(e)&&l.push(e),window.onYouTubePlayerAPIReady=()=>{l.forEach(e=>{P(e)}),x=!0}}},T=e=>e.hasAttribute("data-group")?e.getAttribute("data-group"):"default",P=e=>{if(I=T(e),Object.prototype.hasOwnProperty.call(_,I)||(_[I]=JSON.parse(JSON.stringify(u)),Y()),-1!==_[I].gallery.indexOf(e))throw new Error("Ups, element already added.");if(_[I].gallery.push(e),_[I].elementsLength++,d.zoom&&e.querySelector("img")&&"false"!==e.getAttribute("data-zoom")||"true"===e.getAttribute("data-zoom")){const t=document.createElement("div");t.className="tobii-zoom__icon",t.innerHTML=d.zoomText,e.classList.add("tobii-zoom"),e.appendChild(t)}e.addEventListener("click",F),N(e),ue()&&I===S&&(oe(),de(null))},q=e=>{const t=T(e);if(-1===_[t].gallery.indexOf(e))throw new Error(`Ups, I can't find a slide for the element ${e}.`);{const i=_[t].gallery.indexOf(e),r=_[t].sliderElements[i];if(ue()&&t===S&&i===_[t].currentIndex){if(1===_[t].elementsLength)throw U(),new Error("Ups, I've closed. There are no slides more to show.");0===_[t].currentIndex?R():z()}if(_[t].elementsLength--,d.zoom&&e.querySelector(".tobii-zoom__icon")){const t=e.querySelector(".tobii-zoom__icon");t.parentNode.classList.remove("tobii-zoom"),t.parentNode.removeChild(t)}e.removeEventListener("click",F),r.parentNode.removeChild(r)}},Y=()=>{_[I].slider=document.createElement("div"),_[I].slider.className="tobii__slider",_[I].slider.setAttribute("aria-hidden","true"),c.appendChild(_[I].slider)},N=e=>{const t=k(e),i=document.createElement("div"),r=document.createElement("div");i.className="tobii__slide",i.style.position="absolute",i.style.left=100*_[I].x+"%",i.setAttribute("aria-hidden","true"),t.init(e,r,d),i.appendChild(r),_[I].slider.appendChild(i),_[I].sliderElements.push(i),++_[I].x},k=e=>{const t=e.getAttribute("data-type");return void 0!==a[t]?a[t]:(e.hasAttribute("data-type")&&console.log("Unknown lightbox element type: "+t),a.image)},O=e=>{if(S=null!==S?S:I,ue())throw new Error("Ups, I'm aleady open.");if(!ue()&&(e||(e=0),-1===e||e>=_[S].elementsLength))throw new Error(`Ups, I can't find slide ${e}.`);document.documentElement.classList.add("tobii-is-open"),document.body.classList.add("tobii-is-open"),document.body.classList.add("tobii-is-open-"+S),oe(),d.close||(h.disabled=!1,h.setAttribute("aria-hidden","true")),w=document.activeElement;const t=window.location.href;window.history.pushState({tobii:"close"},"Image",t),_[S].currentIndex=e,V(),se(),$(_[S].currentIndex),_[S].slider.setAttribute("aria-hidden","false"),c.setAttribute("aria-hidden","false"),de(null),X(_[S].currentIndex+1),X(_[S].currentIndex-1),_[S].slider.classList.add("tobii__slider--animate");const i=new window.CustomEvent("open",{detail:{group:S}});c.dispatchEvent(i)},U=()=>{if(!ue())throw new Error("Ups, I'm already closed.");document.documentElement.classList.remove("tobii-is-open"),document.body.classList.remove("tobii-is-open"),document.body.classList.remove("tobii-is-open-"+S),ae(),null!==window.history.state&&"close"===window.history.state.tobii&&window.history.back(),w.focus(),H(_[S].currentIndex),D(_[S].currentIndex),c.setAttribute("aria-hidden","true"),_[S].slider.setAttribute("aria-hidden","true"),_[S].currentIndex=0,_[S].slider.classList.remove("tobii__slider--animate");const e=new window.CustomEvent("close",{detail:{group:S}});c.dispatchEvent(e)},X=e=>{if(void 0===_[S].sliderElements[e])return;const t=_[S].sliderElements[e].querySelector("[data-type]");k(t).onPreload(t)},$=e=>{if(void 0===_[S].sliderElements[e])return;const t=_[S].sliderElements[e].querySelector("[data-type]"),i=k(t);_[S].sliderElements[e].classList.add("tobii__slide--is-active"),_[S].sliderElements[e].setAttribute("aria-hidden","false"),i.onLoad(t)},z=()=>{if(!ue())throw new Error("Ups, I'm closed.");_[S].currentIndex>0&&(H(_[S].currentIndex),$(--_[S].currentIndex),de("left"),D(_[S].currentIndex+1),X(_[S].currentIndex-1));const e=new window.CustomEvent("previous",{detail:{group:S}});c.dispatchEvent(e)},R=()=>{if(!ue())throw new Error("Ups, I'm closed.");_[S].currentIndex<_[S].elementsLength-1&&(H(_[S].currentIndex),$(++_[S].currentIndex),de("right"),D(_[S].currentIndex-1),X(_[S].currentIndex+1));const e=new window.CustomEvent("next",{detail:{group:S}});c.dispatchEvent(e)},M=e=>{if(ue())throw new Error("Ups, I'm open.");if(!e)throw new Error("Ups, no group specified.");if(e&&!Object.prototype.hasOwnProperty.call(_,e))throw new Error(`Ups, I don't have a group called "${e}".`);S=e},H=e=>{if(void 0===_[S].sliderElements[e])return;const t=_[S].sliderElements[e].querySelector("[data-type]"),i=k(t);_[S].sliderElements[e].classList.remove("tobii__slide--is-active"),_[S].sliderElements[e].setAttribute("aria-hidden","true"),i.onLeave(t)},D=e=>{if(void 0===_[S].sliderElements[e])return;const t=_[S].sliderElements[e].querySelector("[data-type]");k(t).onCleanup(t)},B=()=>{S=null!==S?S:I,A=-_[S].currentIndex*c.offsetWidth,_[S].slider.style.transform=`translate3d(${A}px, 0, 0)`,E=A},V=()=>{g={startX:0,endX:0,startY:0,endY:0}},j=()=>{const e=g.endX-g.startX,t=g.endY-g.startY,i=Math.abs(e),r=Math.abs(t);e>0&&i>d.threshold&&_[S].currentIndex>0?z():e<0&&i>d.threshold&&_[S].currentIndex!==_[S].elementsLength-1?R():t<0&&r>d.threshold&&d.swipeClose?U():B()},W=()=>{L||(L=!0,window.requestAnimationFrame(()=>{B(),L=!1}))},F=e=>{e.preventDefault(),S=T(e.currentTarget),O(_[S].gallery.indexOf(e.currentTarget))},G=e=>{e.target===b?z():e.target===p?R():(e.target===h||!1===y&&!1===v&&e.target.classList.contains("tobii__slide")&&d.docClose)&&U(),e.stopPropagation()},J=e=>{const t=Array.prototype.slice.call(c.querySelectorAll(`.tobii__btn:not([disabled]), .tobii__slide--is-active ${o.join(", .tobii__slide--is-active ")}`)).filter(e=>!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)),i=t.indexOf(document.activeElement);9===e.keyCode||"Tab"===e.code?e.shiftKey&&0===i?(t[t.length-1].focus(),e.preventDefault()):e.shiftKey||i!==t.length-1||(t[0].focus(),e.preventDefault()):27===e.keyCode||"Escape"===e.code?(e.preventDefault(),U()):37===e.keyCode||"ArrowLeft"===e.code?(e.preventDefault(),z()):39!==e.keyCode&&"ArrowRight"!==e.code||(e.preventDefault(),R())},K=e=>{be(e.target)||(e.stopPropagation(),y=!1,v=!1,f=!0,g.startX=e.touches[0].pageX,g.startY=e.touches[0].pageY,ce()&&_[S].slider.classList.add("tobii__slider--is-dragging"))},Q=e=>{e.stopPropagation(),f&&(g.endX=e.touches[0].pageX,g.endY=e.touches[0].pageY,ne())},Z=e=>{e.stopPropagation(),f=!1,_[S].slider.classList.remove("tobii__slider--is-dragging"),g.endX&&j(),V()},ee=e=>{be(e.target)||(e.preventDefault(),e.stopPropagation(),y=!1,v=!1,f=!0,g.startX=e.pageX,g.startY=e.pageY,ce()&&_[S].slider.classList.add("tobii__slider--is-dragging"))},te=e=>{e.preventDefault(),f&&(g.endX=e.pageX,g.endY=e.pageY,ne())},ie=e=>{e.stopPropagation(),f=!1,_[S].slider.classList.remove("tobii__slider--is-dragging"),g.endX&&j(),V()},re=()=>{f=!1},ne=()=>{Math.abs(g.startX-g.endX)>0&&!v&&_[S].elementsLength>1?(_[S].slider.style.transform=`translate3d(${E-Math.round(g.startX-g.endX)}px, 0, 0)`,y=!0,v=!1):Math.abs(g.startY-g.endY)>0&&!y&&d.swipeClose&&(_[S].slider.style.transform=`translate3d(${E}px, -${Math.round(g.startY-g.endY)}px, 0)`,y=!1,v=!0)},se=()=>{d.keyboard&&window.addEventListener("keydown",J),window.addEventListener("resize",W),window.addEventListener("popstate",U),c.addEventListener("click",G),d.draggable&&ce()&&(c.addEventListener("touchstart",K),c.addEventListener("touchmove",Q),c.addEventListener("touchend",Z),c.addEventListener("mousedown",ee),c.addEventListener("mouseup",ie),c.addEventListener("mousemove",te),c.addEventListener("contextmenu",re))},ae=()=>{d.keyboard&&window.removeEventListener("keydown",J),window.removeEventListener("resize",W),window.removeEventListener("popstate",U),c.removeEventListener("click",G),d.draggable&&ce()&&(c.removeEventListener("touchstart",K),c.removeEventListener("touchmove",Q),c.removeEventListener("touchend",Z),c.removeEventListener("mousedown",ee),c.removeEventListener("mouseup",ie),c.removeEventListener("mousemove",te),c.removeEventListener("contextmenu",re))},oe=()=>{(d.draggable&&d.swipeClose&&ce()&&!_[S].slider.classList.contains("tobii__slider--is-draggable")||d.draggable&&_[S].elementsLength>1&&!_[S].slider.classList.contains("tobii__slider--is-draggable"))&&_[S].slider.classList.add("tobii__slider--is-draggable"),!d.nav||1===_[S].elementsLength||"auto"===d.nav&&ce()?(b.setAttribute("aria-hidden","true"),b.disabled=!0,p.setAttribute("aria-hidden","true"),p.disabled=!0):(b.setAttribute("aria-hidden","false"),b.disabled=!1,p.setAttribute("aria-hidden","false"),p.disabled=!1),m.setAttribute("aria-hidden",d.counter&&1!==_[S].elementsLength?"false":"true")},de=e=>{B(),m.textContent=`${_[S].currentIndex+1}/${_[S].elementsLength}`,(e=>{(!0===d.nav||"auto"===d.nav)&&!ce()&&_[S].elementsLength>1?(b.setAttribute("aria-hidden","true"),b.disabled=!0,p.setAttribute("aria-hidden","true"),p.disabled=!0,1===_[S].elementsLength?d.close&&h.focus():0===_[S].currentIndex?(p.setAttribute("aria-hidden","false"),p.disabled=!1,p.focus()):_[S].currentIndex===_[S].elementsLength-1?(b.setAttribute("aria-hidden","false"),b.disabled=!1,b.focus()):(b.setAttribute("aria-hidden","false"),b.disabled=!1,p.setAttribute("aria-hidden","false"),p.disabled=!1,"left"===e?b.focus():p.focus())):d.close&&h.focus()})(e)},le=()=>{ue()&&U(),Object.entries(_).forEach(e=>{e[1].gallery.forEach(e=>{q(e)})}),_={},I=S=null;for(const e in a)a[e].onReset()},ue=()=>"false"===c.getAttribute("aria-hidden"),ce=()=>"ontouchstart"in window,be=e=>-1!==["TEXTAREA","OPTION","INPUT","SELECT"].indexOf(e.nodeName)||e===b||e===p||e===h;return(e=>{if(document.querySelector("div.tobii"))return void console.log("Multiple lightbox instances not supported.");d=(e=>({selector:".lightbox",captions:!0,captionsSelector:"img",captionAttribute:"alt",captionText:null,nav:"auto",navText:['<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="15 6 9 12 15 18" /></svg>','<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="9 6 15 12 9 18" /></svg>'],navLabel:["Previous image","Next image"],close:!0,closeText:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><line x1="18" y1="6" x2="6" y2="18" /><line x1="6" y1="6" x2="18" y2="18" /></svg>',closeLabel:"Close lightbox",loadingIndicatorLabel:"Image loading",counter:!0,download:!1,downloadText:"",downloadLabel:"Download image",keyboard:!0,zoom:!0,zoomText:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="16 4 20 4 20 8" /><line x1="14" y1="10" x2="20" y2="4" /><polyline points="8 20 4 20 4 16" /><line x1="4" y1="20" x2="10" y2="14" /><polyline points="16 20 20 20 20 16" /><line x1="14" y1="14" x2="20" y2="20" /><polyline points="8 4 4 4 4 8" /><line x1="4" y1="4" x2="10" y2="10" /></svg>',docClose:!0,swipeClose:!0,hideScrollbar:!0,draggable:!0,threshold:100,rtl:!1,loop:!1,autoplayVideo:!1,modal:!1,theme:"tobii--theme-default",...e}))(e),c||(c=document.createElement("div"),c.setAttribute("role","dialog"),c.setAttribute("aria-hidden","true"),c.classList.add("tobii"),c.classList.add(d.theme),b=document.createElement("button"),b.className="tobii__btn tobii__btn--previous",b.setAttribute("type","button"),b.setAttribute("aria-label",d.navLabel[0]),b.innerHTML=d.navText[0],c.appendChild(b),p=document.createElement("button"),p.className="tobii__btn tobii__btn--next",p.setAttribute("type","button"),p.setAttribute("aria-label",d.navLabel[1]),p.innerHTML=d.navText[1],c.appendChild(p),h=document.createElement("button"),h.className="tobii__btn tobii__btn--close",h.setAttribute("type","button"),h.setAttribute("aria-label",d.closeLabel),h.innerHTML=d.closeText,c.appendChild(h),m=document.createElement("div"),m.className="tobii__counter",c.appendChild(m),document.body.appendChild(c));const t=document.querySelectorAll(d.selector);if(!t)throw new Error(`Ups, I can't find the selector ${d.selector} on this website.`);const i=[];t.forEach(e=>{const t=e.hasAttribute("data-group")?e.getAttribute("data-group"):"default";let r=e.href;e.hasAttribute("data-target")&&(r=e.getAttribute("data-target")),r+="__"+t,void 0!==i[r]?e.addEventListener("click",e=>{M(t),O(),e.preventDefault()}):(i[r]=1,C(e))})})(s),n.open=O,n.previous=z,n.next=R,n.close=U,n.add=C,n.remove=q,n.reset=le,n.destroy=()=>{le(),c.parentNode.removeChild(c)},n.isOpen=ue,n.slidesIndex=()=>_[S].currentIndex,n.select=e=>{const t=_[S].currentIndex;if(!ue())throw new Error("Ups, I'm closed.");if(ue()){if(!e&&0!==e)throw new Error("Ups, no slide specified.");if(e===_[S].currentIndex)throw new Error(`Ups, slide ${e} is already selected.`);if(-1===e||e>=_[S].elementsLength)throw new Error(`Ups, I can't find slide ${e}.`)}_[S].currentIndex=e,H(t),$(e),e<t&&(de("left"),D(t),X(e-1)),e>t&&(de("right"),D(t),X(e+1))},n.slidesCount=()=>_[S].elementsLength,n.selectGroup=M,n.currentGroup=()=>null!==S?S:I,n.on=(e,t)=>{c.addEventListener(e,t)},n.off=(e,t)=>{c.removeEventListener(e,t)},n}; | ||
class e{constructor(){this.figcaptionId=0,this.userSettings=null}init(e,t,i){this.userSettings=i;const r=document.createElement("figure"),n=document.createElement("figcaption"),s=document.createElement("img"),a=e.querySelector("img"),o=document.createElement("div");if(r.style.opacity="0",a&&(s.alt=a.alt||""),s.setAttribute("src",""),s.setAttribute("data-src",e.href),e.hasAttribute("data-srcset")&&s.setAttribute("data-srcset",e.getAttribute("data-srcset")),r.appendChild(s),this.userSettings.captions){let t;"function"==typeof this.userSettings.captionText?t=this.userSettings.captionText(e):"self"===this.userSettings.captionsSelector&&e.getAttribute(this.userSettings.captionAttribute)?t=e.getAttribute(this.userSettings.captionAttribute):"img"===this.userSettings.captionsSelector&&a&&a.getAttribute(this.userSettings.captionAttribute)&&(t=a.getAttribute(this.userSettings.captionAttribute)),this.userSettings.captionHTML?n.innerHTML=t:n.textContent=t,t&&(n.id=`tobii-figcaption-${this.figcaptionId}`,r.appendChild(n),s.setAttribute("aria-labelledby",n.id),++this.figcaptionId)}t.appendChild(r),o.className="tobii__loader",o.setAttribute("role","progressbar"),o.setAttribute("aria-label",this.userSettings.loadingIndicatorLabel),t.appendChild(o),t.setAttribute("data-type","image"),t.classList.add("tobii-image")}onPreload(e){this.onLoad(e)}onLoad(e){const t=e.querySelector("img");if(!t.hasAttribute("data-src"))return;const i=e.querySelector("figure"),r=e.querySelector(".tobii__loader");t.addEventListener("load",()=>{e.removeChild(r),i.style.opacity="1"}),t.addEventListener("error",()=>{e.removeChild(r),i.style.opacity="1"}),t.setAttribute("src",t.getAttribute("data-src")),t.removeAttribute("data-src"),t.hasAttribute("data-srcset")&&t.setAttribute("srcset",t.getAttribute("data-srcset"))}onLeave(e){}onCleanup(e){}onReset(){this.figcaptionId=0}}class t{constructor(){this.userSettings=null}init(e,t,i){this.userSettings=i;const r=e.hasAttribute("data-target")?e.getAttribute("data-target"):e.getAttribute("href");t.setAttribute("data-HREF",r),e.getAttribute("data-allow")&&t.setAttribute("data-allow",e.getAttribute("data-allow")),e.hasAttribute("data-width")&&t.setAttribute("data-width",`${e.getAttribute("data-width")}`),e.hasAttribute("data-height")&&t.setAttribute("data-height",`${e.getAttribute("data-height")}`),t.setAttribute("data-type","iframe"),t.classList.add("tobii-iframe")}onPreload(e){}onLoad(e){let t=e.querySelector("iframe");const i=document.createElement("div");if(i.className="tobii__loader",i.setAttribute("role","progressbar"),i.setAttribute("aria-label",this.userSettings.loadingIndicatorLabel),e.appendChild(i),null==t){t=document.createElement("iframe");const i=e.getAttribute("data-href");t.setAttribute("frameborder","0"),t.setAttribute("src",i),t.setAttribute("allowfullscreen",""),i.indexOf("youtube.com")>-1?t.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"):i.indexOf("vimeo.com")>-1?t.setAttribute("allow","autoplay; picture-in-picture"):e.hasAttribute("data-allow")&&t.setAttribute("allow",e.getAttribute("data-allow")),e.getAttribute("data-width")&&(t.style.maxWidth=`${e.getAttribute("data-width")}`),e.getAttribute("data-height")&&(t.style.maxHeight=`${e.getAttribute("data-height")}`),t.style.opacity="0",e.appendChild(t),t.addEventListener("load",()=>{t.style.opacity="1";const i=e.querySelector(".tobii__loader");i&&e.removeChild(i)}),t.addEventListener("error",()=>{t.style.opacity="1";const i=e.querySelector(".tobii__loader");i&&e.removeChild(i)})}else t.setAttribute("src",e.getAttribute("data-href"))}onLeave(e){}onCleanup(e){const t=e.querySelector("iframe");t.setAttribute("src",""),t.style.opacity="0"}onReset(){}}class i{constructor(){this.userSettings=null}init(e,t,i){this.userSettings=i;const r=e.hasAttribute("data-target")?e.getAttribute("data-target"):e.getAttribute("href"),n=document.querySelector(r).cloneNode(!0);if(!n)throw new Error(`Ups, I can't find the target ${r}.`);t.appendChild(n),t.setAttribute("data-type","html"),t.classList.add("tobii-html")}onPreload(e){}onLoad(e,t){const i=e.querySelector("video");i&&(i.hasAttribute("data-time")&&i.readyState>0&&(i.currentTime=i.getAttribute("data-time")),this.userSettings.autoplayVideo&&i.play());const r=e.querySelector("audio");r&&this.userSettings.autoplayAudio&&r.play(),e.classList.add("tobii-group-"+t)}onLeave(e){const t=e.querySelector("video");t&&(t.paused||t.pause(),t.readyState>0&&t.setAttribute("data-time",t.currentTime));const i=e.querySelector("audio");i&&(i.paused||i.pause())}onCleanup(e){const t=e.querySelector("video");if(t&&t.readyState>0&&t.readyState<3&&t.duration!==t.currentTime){const i=t.cloneNode(!0);this._removeSources(t),t.load(),t.parentNode.removeChild(t),e.appendChild(i)}}onReset(){}_removeSources(e){const t=e.querySelectorAll("src");t&&t.forEach(e=>{e.setAttribute("src","")})}}class r{constructor(){this.playerId=0,this.PLAYER=[],this.userSettings=null}init(e,t,i){this.userSettings=i;const r=document.createElement("div");t.appendChild(r),this.PLAYER[this.playerId]=new window.YT.Player(r,{host:"https://www.youtube-nocookie.com",height:e.getAttribute("data-height")||"360",width:e.getAttribute("data-width")||"640",videoId:e.getAttribute("data-id"),playerVars:{controls:e.getAttribute("data-controls")||1,rel:0,playsinline:1}}),t.setAttribute("data-player",this.playerId),t.setAttribute("data-type","youtube"),t.classList.add("tobii-youtube"),this.playerId++}onPreload(e){}onLoad(e){this.userSettings.autoplayVideo&&this.PLAYER[e.getAttribute("data-player")].playVideo()}onLeave(e){1===this.PLAYER[e.getAttribute("data-player")].getPlayerState()&&this.PLAYER[e.getAttribute("data-player")].pauseVideo()}onCleanup(e){1===this.PLAYER[e.getAttribute("data-player")].getPlayerState()&&this.PLAYER[e.getAttribute("data-player")].pauseVideo()}onReset(){}}module.exports=function n(s){const a={image:new e,html:new i,iframe:new t,youtube:new r},o=['a[href]:not([tabindex^="-"]):not([inert])','area[href]:not([tabindex^="-"]):not([inert])',"input:not([disabled]):not([inert])","select:not([disabled]):not([inert])","textarea:not([disabled]):not([inert])","button:not([disabled]):not([inert])",'iframe:not([tabindex^="-"]):not([inert])','audio:not([tabindex^="-"]):not([inert])','video:not([tabindex^="-"]):not([inert])','[contenteditable]:not([tabindex^="-"]):not([inert])','[tabindex]:not([tabindex^="-"]):not([inert])'];let d={};const l=[],u={gallery:[],slider:null,sliderElements:[],elementsLength:0,currentIndex:0,x:0};let c=null,p=null,b=null,h=null,g=null,m={},y=!1,v=!1,f=!1,w=null,A=null,E=null,L=!1,x=!1,_={},S=null,I=null;const C=e=>{if(null===document.querySelector('[data-type="youtube"]')||x)P(e);else{if(null===document.getElementById("iframe_api")){const e=document.createElement("script"),t=document.getElementsByTagName("script")[0];e.id="iframe_api",e.src="https://www.youtube.com/iframe_api",t.parentNode.insertBefore(e,t)}-1===l.indexOf(e)&&l.push(e),window.onYouTubePlayerAPIReady=()=>{l.forEach(e=>{P(e)}),x=!0}}},T=e=>e.hasAttribute("data-group")?e.getAttribute("data-group"):"default",P=e=>{if(S=T(e),Object.prototype.hasOwnProperty.call(_,S)||(_[S]=JSON.parse(JSON.stringify(u)),Y()),-1!==_[S].gallery.indexOf(e))throw new Error("Ups, element already added.");if(_[S].gallery.push(e),_[S].elementsLength++,d.zoom&&e.querySelector("img")&&"false"!==e.getAttribute("data-zoom")||"true"===e.getAttribute("data-zoom")){const t=document.createElement("div");t.className="tobii-zoom__icon",t.innerHTML=d.zoomText,e.classList.add("tobii-zoom"),e.appendChild(t)}e.addEventListener("click",F),N(e),ue()&&S===I&&(oe(),de())},q=e=>{const t=T(e);if(-1===_[t].gallery.indexOf(e))throw new Error(`Ups, I can't find a slide for the element ${e}.`);{const i=_[t].gallery.indexOf(e),r=_[t].sliderElements[i];if(ue()&&t===I&&i===_[t].currentIndex){if(1===_[t].elementsLength)throw U(),new Error("Ups, I've closed. There are no slides more to show.");0===_[t].currentIndex?M():z(),oe(),de()}if(_[t].gallery.splice(_[t].gallery.indexOf(e)),_[t].sliderElements.splice(_[t].gallery.indexOf(e)),_[t].elementsLength--,--_[t].x,d.zoom&&e.querySelector(".tobii-zoom__icon")){const t=e.querySelector(".tobii-zoom__icon");t.parentNode.classList.remove("tobii-zoom"),t.parentNode.removeChild(t)}e.removeEventListener("click",F),r.parentNode.removeChild(r)}},Y=()=>{_[S].slider=document.createElement("div"),_[S].slider.className="tobii__slider",_[S].slider.setAttribute("aria-hidden","true"),c.appendChild(_[S].slider)},N=e=>{const t=k(e),i=document.createElement("div"),r=document.createElement("div");i.className="tobii__slide",i.style.position="absolute",i.style.left=100*_[S].x+"%",i.setAttribute("aria-hidden","true"),t.init(e,r,d),i.appendChild(r),_[S].slider.appendChild(i),_[S].sliderElements.push(i),++_[S].x},k=e=>{const t=e.getAttribute("data-type");return void 0!==a[t]?a[t]:(e.hasAttribute("data-type")&&console.log("Unknown lightbox element type: "+t),a.image)},O=e=>{if(I=null!==I?I:S,ue())throw new Error("Ups, I'm aleady open.");if(!ue()&&(e||(e=0),-1===e||e>=_[I].elementsLength))throw new Error(`Ups, I can't find slide ${e}.`);document.documentElement.classList.add("tobii-is-open"),document.body.classList.add("tobii-is-open"),document.body.classList.add("tobii-is-open-"+I),oe(),d.close||(h.disabled=!1,h.setAttribute("aria-hidden","true")),w=document.activeElement;const t=window.location.href;window.history.pushState({tobii:"close"},"Image",t),_[I].currentIndex=e,V(),se(),$(_[I].currentIndex),_[I].slider.setAttribute("aria-hidden","false"),c.setAttribute("aria-hidden","false"),de(),X(_[I].currentIndex+1),X(_[I].currentIndex-1),_[I].slider.classList.add("tobii__slider--animate");const i=new window.CustomEvent("open",{detail:{group:I}});c.dispatchEvent(i)},U=()=>{if(!ue())throw new Error("Ups, I'm already closed.");document.documentElement.classList.remove("tobii-is-open"),document.body.classList.remove("tobii-is-open"),document.body.classList.remove("tobii-is-open-"+I),ae(),null!==window.history.state&&"close"===window.history.state.tobii&&window.history.back(),w.focus(),H(_[I].currentIndex),D(_[I].currentIndex),c.setAttribute("aria-hidden","true"),_[I].slider.setAttribute("aria-hidden","true"),_[I].currentIndex=0,_[I].slider.classList.remove("tobii__slider--animate");const e=new window.CustomEvent("close",{detail:{group:I}});c.dispatchEvent(e)},X=e=>{if(void 0===_[I].sliderElements[e])return;const t=_[I].sliderElements[e].querySelector("[data-type]");k(t).onPreload(t)},$=e=>{if(void 0===_[I].sliderElements[e])return;const t=_[I].sliderElements[e].querySelector("[data-type]"),i=k(t);_[I].sliderElements[e].classList.add("tobii__slide--is-active"),_[I].sliderElements[e].setAttribute("aria-hidden","false"),i.onLoad(t,I)},z=()=>{if(!ue())throw new Error("Ups, I'm closed.");_[I].currentIndex>0&&(H(_[I].currentIndex),$(--_[I].currentIndex),de("left"),D(_[I].currentIndex+1),X(_[I].currentIndex-1));const e=new window.CustomEvent("previous",{detail:{group:I}});c.dispatchEvent(e)},M=()=>{if(!ue())throw new Error("Ups, I'm closed.");_[I].currentIndex<_[I].elementsLength-1&&(H(_[I].currentIndex),$(++_[I].currentIndex),de("right"),D(_[I].currentIndex-1),X(_[I].currentIndex+1));const e=new window.CustomEvent("next",{detail:{group:I}});c.dispatchEvent(e)},R=e=>{if(ue())throw new Error("Ups, I'm open.");if(!e)throw new Error("Ups, no group specified.");if(e&&!Object.prototype.hasOwnProperty.call(_,e))throw new Error(`Ups, I don't have a group called "${e}".`);I=e},H=e=>{if(void 0===_[I].sliderElements[e])return;const t=_[I].sliderElements[e].querySelector("[data-type]"),i=k(t);_[I].sliderElements[e].classList.remove("tobii__slide--is-active"),_[I].sliderElements[e].setAttribute("aria-hidden","true"),i.onLeave(t)},D=e=>{if(void 0===_[I].sliderElements[e])return;const t=_[I].sliderElements[e].querySelector("[data-type]");k(t).onCleanup(t)},B=()=>{I=null!==I?I:S,A=-_[I].currentIndex*c.offsetWidth,_[I].slider.style.transform=`translate3d(${A}px, 0, 0)`,E=A},V=()=>{m={startX:0,endX:0,startY:0,endY:0}},j=()=>{const e=m.endX-m.startX,t=m.endY-m.startY,i=Math.abs(e),r=Math.abs(t);e>0&&i>d.threshold&&_[I].currentIndex>0?z():e<0&&i>d.threshold&&_[I].currentIndex!==_[I].elementsLength-1?M():t<0&&r>d.threshold&&d.swipeClose?U():B()},W=()=>{L||(L=!0,window.requestAnimationFrame(()=>{B(),L=!1}))},F=e=>{e.preventDefault(),I=T(e.currentTarget),O(_[I].gallery.indexOf(e.currentTarget))},G=e=>{e.target===p?z():e.target===b?M():(e.target===h||!1===y&&!1===v&&e.target.classList.contains("tobii__slide")&&d.docClose)&&U(),e.stopPropagation()},J=e=>{const t=Array.prototype.slice.call(c.querySelectorAll(`.tobii__btn:not([disabled]), .tobii__slide--is-active ${o.join(", .tobii__slide--is-active ")}`)).filter(e=>!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)),i=t.indexOf(document.activeElement);9===e.keyCode||"Tab"===e.code?e.shiftKey&&0===i?(t[t.length-1].focus(),e.preventDefault()):e.shiftKey||i!==t.length-1||(t[0].focus(),e.preventDefault()):27===e.keyCode||"Escape"===e.code?(e.preventDefault(),U()):37===e.keyCode||"ArrowLeft"===e.code?(e.preventDefault(),z()):39!==e.keyCode&&"ArrowRight"!==e.code||(e.preventDefault(),M())},K=e=>{pe(e.target)||(e.stopPropagation(),y=!1,v=!1,f=!0,m.startX=e.touches[0].pageX,m.startY=e.touches[0].pageY,ce()&&_[I].slider.classList.add("tobii__slider--is-dragging"))},Q=e=>{e.stopPropagation(),f&&(m.endX=e.touches[0].pageX,m.endY=e.touches[0].pageY,ne())},Z=e=>{e.stopPropagation(),f=!1,_[I].slider.classList.remove("tobii__slider--is-dragging"),m.endX&&j(),V()},ee=e=>{pe(e.target)||(e.preventDefault(),e.stopPropagation(),y=!1,v=!1,f=!0,m.startX=e.pageX,m.startY=e.pageY,ce()&&_[I].slider.classList.add("tobii__slider--is-dragging"))},te=e=>{e.preventDefault(),f&&(m.endX=e.pageX,m.endY=e.pageY,ne())},ie=e=>{e.stopPropagation(),f=!1,_[I].slider.classList.remove("tobii__slider--is-dragging"),m.endX&&j(),V()},re=()=>{f=!1},ne=()=>{Math.abs(m.startX-m.endX)>0&&!v&&_[I].elementsLength>1?(_[I].slider.style.transform=`translate3d(${E-Math.round(m.startX-m.endX)}px, 0, 0)`,y=!0,v=!1):Math.abs(m.startY-m.endY)>0&&!y&&d.swipeClose&&(_[I].slider.style.transform=`translate3d(${E}px, -${Math.round(m.startY-m.endY)}px, 0)`,y=!1,v=!0)},se=()=>{d.keyboard&&window.addEventListener("keydown",J),window.addEventListener("resize",W),window.addEventListener("popstate",U),c.addEventListener("click",G),d.draggable&&ce()&&(c.addEventListener("touchstart",K),c.addEventListener("touchmove",Q),c.addEventListener("touchend",Z),c.addEventListener("mousedown",ee),c.addEventListener("mouseup",ie),c.addEventListener("mousemove",te),c.addEventListener("contextmenu",re))},ae=()=>{d.keyboard&&window.removeEventListener("keydown",J),window.removeEventListener("resize",W),window.removeEventListener("popstate",U),c.removeEventListener("click",G),d.draggable&&ce()&&(c.removeEventListener("touchstart",K),c.removeEventListener("touchmove",Q),c.removeEventListener("touchend",Z),c.removeEventListener("mousedown",ee),c.removeEventListener("mouseup",ie),c.removeEventListener("mousemove",te),c.removeEventListener("contextmenu",re))},oe=()=>{(d.draggable&&d.swipeClose&&ce()&&!_[I].slider.classList.contains("tobii__slider--is-draggable")||d.draggable&&_[I].elementsLength>1&&!_[I].slider.classList.contains("tobii__slider--is-draggable"))&&_[I].slider.classList.add("tobii__slider--is-draggable"),!d.nav||1===_[I].elementsLength||"auto"===d.nav&&ce()?(p.setAttribute("aria-hidden","true"),p.disabled=!0,b.setAttribute("aria-hidden","true"),b.disabled=!0):(p.setAttribute("aria-hidden","false"),p.disabled=!1,b.setAttribute("aria-hidden","false"),b.disabled=!1),g.setAttribute("aria-hidden",d.counter&&1!==_[I].elementsLength?"false":"true")},de=(e=null)=>{B(),g.textContent=`${_[I].currentIndex+1}/${_[I].elementsLength}`,(e=>{(!0===d.nav||"auto"===d.nav)&&!ce()&&_[I].elementsLength>1?(p.setAttribute("aria-hidden","true"),p.disabled=!0,b.setAttribute("aria-hidden","true"),b.disabled=!0,1===_[I].elementsLength?d.close&&h.focus():0===_[I].currentIndex?(b.setAttribute("aria-hidden","false"),b.disabled=!1,b.focus()):_[I].currentIndex===_[I].elementsLength-1?(p.setAttribute("aria-hidden","false"),p.disabled=!1,p.focus()):(p.setAttribute("aria-hidden","false"),p.disabled=!1,b.setAttribute("aria-hidden","false"),b.disabled=!1,"left"===e?p.focus():b.focus())):d.close&&h.focus()})(e)},le=()=>{ue()&&U(),Object.entries(_).forEach(e=>{e[1].gallery.forEach(e=>{q(e)})}),_={},S=I=null;for(const e in a)a[e].onReset()},ue=()=>"false"===c.getAttribute("aria-hidden"),ce=()=>"ontouchstart"in window,pe=e=>-1!==["TEXTAREA","OPTION","INPUT","SELECT"].indexOf(e.nodeName)||e===p||e===b||e===h;return(e=>{if(document.querySelector("div.tobii"))return void console.log("Multiple lightbox instances not supported.");d=(e=>({selector:".lightbox",captions:!0,captionsSelector:"img",captionAttribute:"alt",captionText:null,captionHTML:!1,nav:"auto",navText:['<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="15 6 9 12 15 18" /></svg>','<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="9 6 15 12 9 18" /></svg>'],navLabel:["Previous image","Next image"],close:!0,closeText:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><line x1="18" y1="6" x2="6" y2="18" /><line x1="6" y1="6" x2="18" y2="18" /></svg>',closeLabel:"Close lightbox",loadingIndicatorLabel:"Image loading",counter:!0,download:!1,downloadText:"",downloadLabel:"Download image",keyboard:!0,zoom:!0,zoomText:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="16 4 20 4 20 8" /><line x1="14" y1="10" x2="20" y2="4" /><polyline points="8 20 4 20 4 16" /><line x1="4" y1="20" x2="10" y2="14" /><polyline points="16 20 20 20 20 16" /><line x1="14" y1="14" x2="20" y2="20" /><polyline points="8 4 4 4 4 8" /><line x1="4" y1="4" x2="10" y2="10" /></svg>',docClose:!0,swipeClose:!0,hideScrollbar:!0,draggable:!0,threshold:100,rtl:!1,loop:!1,autoplayVideo:!1,modal:!1,theme:"tobii--theme-default",...e}))(e),c||(c=document.createElement("div"),c.setAttribute("role","dialog"),c.setAttribute("aria-hidden","true"),c.classList.add("tobii"),c.classList.add(d.theme),p=document.createElement("button"),p.className="tobii__btn tobii__btn--previous",p.setAttribute("type","button"),p.setAttribute("aria-label",d.navLabel[0]),p.innerHTML=d.navText[0],c.appendChild(p),b=document.createElement("button"),b.className="tobii__btn tobii__btn--next",b.setAttribute("type","button"),b.setAttribute("aria-label",d.navLabel[1]),b.innerHTML=d.navText[1],c.appendChild(b),h=document.createElement("button"),h.className="tobii__btn tobii__btn--close",h.setAttribute("type","button"),h.setAttribute("aria-label",d.closeLabel),h.innerHTML=d.closeText,c.appendChild(h),g=document.createElement("div"),g.className="tobii__counter",c.appendChild(g),document.body.appendChild(c));const t=document.querySelectorAll(d.selector);if(!t)throw new Error(`Ups, I can't find the selector ${d.selector} on this website.`);const i=[];t.forEach(e=>{const t=e.hasAttribute("data-group")?e.getAttribute("data-group"):"default";let r=e.href;e.hasAttribute("data-target")&&(r=e.getAttribute("data-target")),r+="__"+t,void 0!==i[r]?e.addEventListener("click",e=>{R(t),O(),e.preventDefault()}):(i[r]=1,C(e))})})(s),n.open=O,n.previous=z,n.next=M,n.close=U,n.add=C,n.remove=q,n.reset=le,n.destroy=()=>{le(),c.parentNode.removeChild(c)},n.isOpen=ue,n.slidesIndex=()=>_[I].currentIndex,n.select=e=>{const t=_[I].currentIndex;if(!ue())throw new Error("Ups, I'm closed.");if(ue()){if(!e&&0!==e)throw new Error("Ups, no slide specified.");if(e===_[I].currentIndex)throw new Error(`Ups, slide ${e} is already selected.`);if(-1===e||e>=_[I].elementsLength)throw new Error(`Ups, I can't find slide ${e}.`)}_[I].currentIndex=e,H(t),$(e),e<t&&(de("left"),D(t),X(e-1)),e>t&&(de("right"),D(t),X(e+1))},n.slidesCount=()=>_[I].elementsLength,n.selectGroup=R,n.currentGroup=()=>null!==I?I:S,n.on=(e,t)=>{c.addEventListener(e,t)},n.off=(e,t)=>{c.removeEventListener(e,t)},n}; |
@@ -1,1 +0,1 @@ | ||
!function(){if("function"!=typeof window.CustomEvent){var e=function(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var i=document.createEvent("CustomEvent");return i.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),i};e.prototype=window.Event.prototype,window.CustomEvent=e}function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n])}return e}).apply(this,arguments)}window.NodeList&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=function(e,t){t=t||window;for(var i=0;i<this.length;i++)e.call(t,this[i],i,this)});var i=/*#__PURE__*/function(){function e(){this.figcaptionId=0,this.userSettings=null}var t=e.prototype;return t.init=function(e,t,i){this.userSettings=i;var n=document.createElement("figure"),r=document.createElement("figcaption"),o=document.createElement("img"),a=e.querySelector("img"),s=document.createElement("div");n.style.opacity="0",a&&(o.alt=a.alt||""),o.setAttribute("src",""),o.setAttribute("data-src",e.href),e.hasAttribute("data-srcset")&&o.setAttribute("data-srcset",e.getAttribute("data-srcset")),n.appendChild(o),this.userSettings.captions&&("function"==typeof this.userSettings.captionText?r.textContent=this.userSettings.captionText(e):"self"===this.userSettings.captionsSelector&&e.getAttribute(this.userSettings.captionAttribute)?r.textContent=e.getAttribute(this.userSettings.captionAttribute):"img"===this.userSettings.captionsSelector&&a&&a.getAttribute(this.userSettings.captionAttribute)&&(r.textContent=a.getAttribute(this.userSettings.captionAttribute)),r.textContent&&(r.id="tobii-figcaption-"+this.figcaptionId,n.appendChild(r),o.setAttribute("aria-labelledby",r.id),++this.figcaptionId)),t.appendChild(n),s.className="tobii__loader",s.setAttribute("role","progressbar"),s.setAttribute("aria-label",this.userSettings.loadingIndicatorLabel),t.appendChild(s),t.setAttribute("data-type","image"),t.classList.add("tobii-image")},t.onPreload=function(e){this.onLoad(e)},t.onLoad=function(e){var t=e.querySelector("img");if(t.hasAttribute("data-src")){var i=e.querySelector("figure"),n=e.querySelector(".tobii__loader");t.addEventListener("load",function(){e.removeChild(n),i.style.opacity="1"}),t.addEventListener("error",function(){e.removeChild(n),i.style.opacity="1"}),t.setAttribute("src",t.getAttribute("data-src")),t.removeAttribute("data-src"),t.hasAttribute("data-srcset")&&t.setAttribute("srcset",t.getAttribute("data-srcset"))}},t.onLeave=function(e){},t.onCleanup=function(e){},t.onReset=function(){this.figcaptionId=0},e}(),n=/*#__PURE__*/function(){function e(){this.userSettings=null}var t=e.prototype;return t.init=function(e,t,i){this.userSettings=i;var n=e.hasAttribute("data-target")?e.getAttribute("data-target"):e.getAttribute("href");t.setAttribute("data-HREF",n),e.getAttribute("data-allow")&&t.setAttribute("data-allow",e.getAttribute("data-allow")),e.hasAttribute("data-width")&&t.setAttribute("data-width",""+e.getAttribute("data-width")),e.hasAttribute("data-height")&&t.setAttribute("data-height",""+e.getAttribute("data-height")),t.setAttribute("data-type","iframe"),t.classList.add("tobii-iframe")},t.onPreload=function(e){},t.onLoad=function(e){var t=e.querySelector("iframe"),i=document.createElement("div");if(i.className="tobii__loader",i.setAttribute("role","progressbar"),i.setAttribute("aria-label",this.userSettings.loadingIndicatorLabel),e.appendChild(i),null==t){t=document.createElement("iframe");var n=e.getAttribute("data-href");t.setAttribute("frameborder","0"),t.setAttribute("src",n),t.setAttribute("allowfullscreen",""),n.indexOf("youtube.com")>-1?t.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"):n.indexOf("vimeo.com")>-1?t.setAttribute("allow","autoplay; picture-in-picture"):e.hasAttribute("data-allow")&&t.setAttribute("allow",e.getAttribute("data-allow")),e.getAttribute("data-width")&&(t.style.maxWidth=""+e.getAttribute("data-width")),e.getAttribute("data-height")&&(t.style.maxHeight=""+e.getAttribute("data-height")),t.style.opacity="0",e.appendChild(t),t.addEventListener("load",function(){t.style.opacity="1";var i=e.querySelector(".tobii__loader");i&&e.removeChild(i)}),t.addEventListener("error",function(){t.style.opacity="1";var i=e.querySelector(".tobii__loader");i&&e.removeChild(i)})}else t.setAttribute("src",e.getAttribute("data-href"))},t.onLeave=function(e){},t.onCleanup=function(e){var t=e.querySelector("iframe");t.setAttribute("src",""),t.style.opacity="0"},t.onReset=function(){},e}(),r=/*#__PURE__*/function(){function e(){this.userSettings=null}var t=e.prototype;return t.init=function(e,t,i){this.userSettings=i;var n=e.hasAttribute("data-target")?e.getAttribute("data-target"):e.getAttribute("href"),r=document.querySelector(n).cloneNode(!0);if(!r)throw new Error("Ups, I can't find the target "+n+".");t.appendChild(r),t.setAttribute("data-type","html"),t.classList.add("tobii-html")},t.onPreload=function(e){},t.onLoad=function(e){var t=e.querySelector("video");t&&(t.hasAttribute("data-time")&&t.readyState>0&&(t.currentTime=t.getAttribute("data-time")),this.userSettings.autoplayVideo&&t.play())},t.onLeave=function(e){var t=e.querySelector("video");t&&(t.paused||t.pause(),t.readyState>0&&t.setAttribute("data-time",t.currentTime))},t.onCleanup=function(e){var t=e.querySelector("video");if(t&&t.readyState>0&&t.readyState<3&&t.duration!==t.currentTime){var i=t.cloneNode(!0);this._removeSources(t),t.load(),t.parentNode.removeChild(t),e.appendChild(i)}},t.onReset=function(){},t._removeSources=function(e){var t=e.querySelectorAll("src");t&&t.forEach(function(e){e.setAttribute("src","")})},e}(),o=/*#__PURE__*/function(){function e(){this.playerId=0,this.PLAYER=[],this.userSettings=null}var t=e.prototype;return t.init=function(e,t,i){this.userSettings=i;var n=document.createElement("div");t.appendChild(n),this.PLAYER[this.playerId]=new window.YT.Player(n,{host:"https://www.youtube-nocookie.com",height:e.getAttribute("data-height")||"360",width:e.getAttribute("data-width")||"640",videoId:e.getAttribute("data-id"),playerVars:{controls:e.getAttribute("data-controls")||1,rel:0,playsinline:1}}),t.setAttribute("data-player",this.playerId),t.setAttribute("data-type","youtube"),t.classList.add("tobii-youtube"),this.playerId++},t.onPreload=function(e){},t.onLoad=function(e){this.userSettings.autoplayVideo&&this.PLAYER[e.getAttribute("data-player")].playVideo()},t.onLeave=function(e){1===this.PLAYER[e.getAttribute("data-player")].getPlayerState()&&this.PLAYER[e.getAttribute("data-player")].pauseVideo()},t.onCleanup=function(e){1===this.PLAYER[e.getAttribute("data-player")].getPlayerState()&&this.PLAYER[e.getAttribute("data-player")].pauseVideo()},t.onReset=function(){},e}();function a(e){var s={image:new i,html:new r,iframe:new n,youtube:new o},d=['a[href]:not([tabindex^="-"]):not([inert])','area[href]:not([tabindex^="-"]):not([inert])',"input:not([disabled]):not([inert])","select:not([disabled]):not([inert])","textarea:not([disabled]):not([inert])","button:not([disabled]):not([inert])",'iframe:not([tabindex^="-"]):not([inert])','audio:not([tabindex^="-"]):not([inert])','video:not([tabindex^="-"]):not([inert])','[contenteditable]:not([tabindex^="-"]):not([inert])','[tabindex]:not([tabindex^="-"]):not([inert])'],l={},u=[],c={gallery:[],slider:null,sliderElements:[],elementsLength:0,currentIndex:0,x:0},p=null,b=null,h=null,f=null,m=null,g={},v=!1,y=!1,w=!1,A=null,E=null,L=null,x=!1,_=!1,I={},S=null,C=null,T=function(e){if(null===document.querySelector('[data-type="youtube"]')||_)N(e);else{if(null===document.getElementById("iframe_api")){var t=document.createElement("script"),i=document.getElementsByTagName("script")[0];t.id="iframe_api",t.src="https://www.youtube.com/iframe_api",i.parentNode.insertBefore(t,i)}-1===u.indexOf(e)&&u.push(e),window.onYouTubePlayerAPIReady=function(){u.forEach(function(e){N(e)}),_=!0}}},P=function(e){return e.hasAttribute("data-group")?e.getAttribute("data-group"):"default"},N=function(e){if(S=P(e),Object.prototype.hasOwnProperty.call(I,S)||(I[S]=JSON.parse(JSON.stringify(c)),Y()),-1!==I[S].gallery.indexOf(e))throw new Error("Ups, element already added.");if(I[S].gallery.push(e),I[S].elementsLength++,l.zoom&&e.querySelector("img")&&"false"!==e.getAttribute("data-zoom")||"true"===e.getAttribute("data-zoom")){var t=document.createElement("div");t.className="tobii-zoom__icon",t.innerHTML=l.zoomText,e.classList.add("tobii-zoom"),e.appendChild(t)}e.addEventListener("click",J),O(e),ce()&&S===C&&(de(),le(null))},q=function(e){var t=P(e);if(-1===I[t].gallery.indexOf(e))throw new Error("Ups, I can't find a slide for the element "+e+".");var i=I[t].gallery.indexOf(e),n=I[t].sliderElements[i];if(ce()&&t===C&&i===I[t].currentIndex){if(1===I[t].elementsLength)throw X(),new Error("Ups, I've closed. There are no slides more to show.");0===I[t].currentIndex?H():M()}if(I[t].elementsLength--,l.zoom&&e.querySelector(".tobii-zoom__icon")){var r=e.querySelector(".tobii-zoom__icon");r.parentNode.classList.remove("tobii-zoom"),r.parentNode.removeChild(r)}e.removeEventListener("click",J),n.parentNode.removeChild(n)},Y=function(){I[S].slider=document.createElement("div"),I[S].slider.className="tobii__slider",I[S].slider.setAttribute("aria-hidden","true"),p.appendChild(I[S].slider)},O=function(e){var t=k(e),i=document.createElement("div"),n=document.createElement("div");i.className="tobii__slide",i.style.position="absolute",i.style.left=100*I[S].x+"%",i.setAttribute("aria-hidden","true"),t.init(e,n,l),i.appendChild(n),I[S].slider.appendChild(i),I[S].sliderElements.push(i),++I[S].x},k=function(e){var t=e.getAttribute("data-type");return void 0!==s[t]?s[t]:(e.hasAttribute("data-type")&&console.log("Unknown lightbox element type: "+t),s.image)},U=function(e){if(C=null!==C?C:S,ce())throw new Error("Ups, I'm aleady open.");if(!ce()&&(e||(e=0),-1===e||e>=I[C].elementsLength))throw new Error("Ups, I can't find slide "+e+".");document.documentElement.classList.add("tobii-is-open"),document.body.classList.add("tobii-is-open"),document.body.classList.add("tobii-is-open-"+C),de(),l.close||(f.disabled=!1,f.setAttribute("aria-hidden","true")),A=document.activeElement;var t=window.location.href;window.history.pushState({tobii:"close"},"Image",t),I[C].currentIndex=e,W(),ae(),R(I[C].currentIndex),I[C].slider.setAttribute("aria-hidden","false"),p.setAttribute("aria-hidden","false"),le(null),z(I[C].currentIndex+1),z(I[C].currentIndex-1),I[C].slider.classList.add("tobii__slider--animate");var i=new window.CustomEvent("open",{detail:{group:C}});p.dispatchEvent(i)},X=function(){if(!ce())throw new Error("Ups, I'm already closed.");document.documentElement.classList.remove("tobii-is-open"),document.body.classList.remove("tobii-is-open"),document.body.classList.remove("tobii-is-open-"+C),se(),null!==window.history.state&&"close"===window.history.state.tobii&&window.history.back(),A.focus(),B(I[C].currentIndex),V(I[C].currentIndex),p.setAttribute("aria-hidden","true"),I[C].slider.setAttribute("aria-hidden","true"),I[C].currentIndex=0,I[C].slider.classList.remove("tobii__slider--animate");var e=new window.CustomEvent("close",{detail:{group:C}});p.dispatchEvent(e)},z=function(e){if(void 0!==I[C].sliderElements[e]){var t=I[C].sliderElements[e].querySelector("[data-type]");k(t).onPreload(t)}},R=function(e){if(void 0!==I[C].sliderElements[e]){var t=I[C].sliderElements[e].querySelector("[data-type]"),i=k(t);I[C].sliderElements[e].classList.add("tobii__slide--is-active"),I[C].sliderElements[e].setAttribute("aria-hidden","false"),i.onLoad(t)}},M=function(){if(!ce())throw new Error("Ups, I'm closed.");I[C].currentIndex>0&&(B(I[C].currentIndex),R(--I[C].currentIndex),le("left"),V(I[C].currentIndex+1),z(I[C].currentIndex-1));var e=new window.CustomEvent("previous",{detail:{group:C}});p.dispatchEvent(e)},H=function(){if(!ce())throw new Error("Ups, I'm closed.");I[C].currentIndex<I[C].elementsLength-1&&(B(I[C].currentIndex),R(++I[C].currentIndex),le("right"),V(I[C].currentIndex-1),z(I[C].currentIndex+1));var e=new window.CustomEvent("next",{detail:{group:C}});p.dispatchEvent(e)},D=function(e){if(ce())throw new Error("Ups, I'm open.");if(!e)throw new Error("Ups, no group specified.");if(e&&!Object.prototype.hasOwnProperty.call(I,e))throw new Error("Ups, I don't have a group called \""+e+'".');C=e},B=function(e){if(void 0!==I[C].sliderElements[e]){var t=I[C].sliderElements[e].querySelector("[data-type]"),i=k(t);I[C].sliderElements[e].classList.remove("tobii__slide--is-active"),I[C].sliderElements[e].setAttribute("aria-hidden","true"),i.onLeave(t)}},V=function(e){if(void 0!==I[C].sliderElements[e]){var t=I[C].sliderElements[e].querySelector("[data-type]");k(t).onCleanup(t)}},j=function(){I[C=null!==C?C:S].slider.style.transform="translate3d("+(E=-I[C].currentIndex*p.offsetWidth)+"px, 0, 0)",L=E},W=function(){g={startX:0,endX:0,startY:0,endY:0}},F=function(){var e=g.endX-g.startX,t=g.endY-g.startY,i=Math.abs(e),n=Math.abs(t);e>0&&i>l.threshold&&I[C].currentIndex>0?M():e<0&&i>l.threshold&&I[C].currentIndex!==I[C].elementsLength-1?H():t<0&&n>l.threshold&&l.swipeClose?X():j()},G=function(){x||(x=!0,window.requestAnimationFrame(function(){j(),x=!1}))},J=function(e){e.preventDefault(),C=P(e.currentTarget),U(I[C].gallery.indexOf(e.currentTarget))},K=function(e){e.target===b?M():e.target===h?H():(e.target===f||!1===v&&!1===y&&e.target.classList.contains("tobii__slide")&&l.docClose)&&X(),e.stopPropagation()},Q=function(e){var t=Array.prototype.slice.call(p.querySelectorAll(".tobii__btn:not([disabled]), .tobii__slide--is-active "+d.join(", .tobii__slide--is-active "))).filter(function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)}),i=t.indexOf(document.activeElement);9===e.keyCode||"Tab"===e.code?e.shiftKey&&0===i?(t[t.length-1].focus(),e.preventDefault()):e.shiftKey||i!==t.length-1||(t[0].focus(),e.preventDefault()):27===e.keyCode||"Escape"===e.code?(e.preventDefault(),X()):37===e.keyCode||"ArrowLeft"===e.code?(e.preventDefault(),M()):39!==e.keyCode&&"ArrowRight"!==e.code||(e.preventDefault(),H())},Z=function(e){be(e.target)||(e.stopPropagation(),v=!1,y=!1,w=!0,g.startX=e.touches[0].pageX,g.startY=e.touches[0].pageY,pe()&&I[C].slider.classList.add("tobii__slider--is-dragging"))},$=function(e){e.stopPropagation(),w&&(g.endX=e.touches[0].pageX,g.endY=e.touches[0].pageY,oe())},ee=function(e){e.stopPropagation(),w=!1,I[C].slider.classList.remove("tobii__slider--is-dragging"),g.endX&&F(),W()},te=function(e){be(e.target)||(e.preventDefault(),e.stopPropagation(),v=!1,y=!1,w=!0,g.startX=e.pageX,g.startY=e.pageY,pe()&&I[C].slider.classList.add("tobii__slider--is-dragging"))},ie=function(e){e.preventDefault(),w&&(g.endX=e.pageX,g.endY=e.pageY,oe())},ne=function(e){e.stopPropagation(),w=!1,I[C].slider.classList.remove("tobii__slider--is-dragging"),g.endX&&F(),W()},re=function(){w=!1},oe=function(){Math.abs(g.startX-g.endX)>0&&!y&&I[C].elementsLength>1?(I[C].slider.style.transform="translate3d("+(L-Math.round(g.startX-g.endX))+"px, 0, 0)",v=!0,y=!1):Math.abs(g.startY-g.endY)>0&&!v&&l.swipeClose&&(I[C].slider.style.transform="translate3d("+L+"px, -"+Math.round(g.startY-g.endY)+"px, 0)",v=!1,y=!0)},ae=function(){l.keyboard&&window.addEventListener("keydown",Q),window.addEventListener("resize",G),window.addEventListener("popstate",X),p.addEventListener("click",K),l.draggable&&pe()&&(p.addEventListener("touchstart",Z),p.addEventListener("touchmove",$),p.addEventListener("touchend",ee),p.addEventListener("mousedown",te),p.addEventListener("mouseup",ne),p.addEventListener("mousemove",ie),p.addEventListener("contextmenu",re))},se=function(){l.keyboard&&window.removeEventListener("keydown",Q),window.removeEventListener("resize",G),window.removeEventListener("popstate",X),p.removeEventListener("click",K),l.draggable&&pe()&&(p.removeEventListener("touchstart",Z),p.removeEventListener("touchmove",$),p.removeEventListener("touchend",ee),p.removeEventListener("mousedown",te),p.removeEventListener("mouseup",ne),p.removeEventListener("mousemove",ie),p.removeEventListener("contextmenu",re))},de=function(){(l.draggable&&l.swipeClose&&pe()&&!I[C].slider.classList.contains("tobii__slider--is-draggable")||l.draggable&&I[C].elementsLength>1&&!I[C].slider.classList.contains("tobii__slider--is-draggable"))&&I[C].slider.classList.add("tobii__slider--is-draggable"),!l.nav||1===I[C].elementsLength||"auto"===l.nav&&pe()?(b.setAttribute("aria-hidden","true"),b.disabled=!0,h.setAttribute("aria-hidden","true"),h.disabled=!0):(b.setAttribute("aria-hidden","false"),b.disabled=!1,h.setAttribute("aria-hidden","false"),h.disabled=!1),m.setAttribute("aria-hidden",l.counter&&1!==I[C].elementsLength?"false":"true")},le=function(e){j(),m.textContent=I[C].currentIndex+1+"/"+I[C].elementsLength,function(e){(!0===l.nav||"auto"===l.nav)&&!pe()&&I[C].elementsLength>1?(b.setAttribute("aria-hidden","true"),b.disabled=!0,h.setAttribute("aria-hidden","true"),h.disabled=!0,1===I[C].elementsLength?l.close&&f.focus():0===I[C].currentIndex?(h.setAttribute("aria-hidden","false"),h.disabled=!1,h.focus()):I[C].currentIndex===I[C].elementsLength-1?(b.setAttribute("aria-hidden","false"),b.disabled=!1,b.focus()):(b.setAttribute("aria-hidden","false"),b.disabled=!1,h.setAttribute("aria-hidden","false"),h.disabled=!1,"left"===e?b.focus():h.focus())):l.close&&f.focus()}(e)},ue=function(){ce()&&X();var e=Object.entries(I);for(var t in e.forEach(function(e){e[1].gallery.forEach(function(e){q(e)})}),I={},S=C=null,s)s[t].onReset()},ce=function(){return"false"===p.getAttribute("aria-hidden")},pe=function(){return"ontouchstart"in window},be=function(e){return-1!==["TEXTAREA","OPTION","INPUT","SELECT"].indexOf(e.nodeName)||e===b||e===h||e===f};return function(e){if(document.querySelector("div.tobii"))console.log("Multiple lightbox instances not supported.");else{l=function(e){return t({},{selector:".lightbox",captions:!0,captionsSelector:"img",captionAttribute:"alt",captionText:null,nav:"auto",navText:['<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="15 6 9 12 15 18" /></svg>','<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="9 6 15 12 9 18" /></svg>'],navLabel:["Previous image","Next image"],close:!0,closeText:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><line x1="18" y1="6" x2="6" y2="18" /><line x1="6" y1="6" x2="18" y2="18" /></svg>',closeLabel:"Close lightbox",loadingIndicatorLabel:"Image loading",counter:!0,download:!1,downloadText:"",downloadLabel:"Download image",keyboard:!0,zoom:!0,zoomText:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="16 4 20 4 20 8" /><line x1="14" y1="10" x2="20" y2="4" /><polyline points="8 20 4 20 4 16" /><line x1="4" y1="20" x2="10" y2="14" /><polyline points="16 20 20 20 20 16" /><line x1="14" y1="14" x2="20" y2="20" /><polyline points="8 4 4 4 4 8" /><line x1="4" y1="4" x2="10" y2="10" /></svg>',docClose:!0,swipeClose:!0,hideScrollbar:!0,draggable:!0,threshold:100,rtl:!1,loop:!1,autoplayVideo:!1,modal:!1,theme:"tobii--theme-default"},e)}(e),p||((p=document.createElement("div")).setAttribute("role","dialog"),p.setAttribute("aria-hidden","true"),p.classList.add("tobii"),p.classList.add(l.theme),(b=document.createElement("button")).className="tobii__btn tobii__btn--previous",b.setAttribute("type","button"),b.setAttribute("aria-label",l.navLabel[0]),b.innerHTML=l.navText[0],p.appendChild(b),(h=document.createElement("button")).className="tobii__btn tobii__btn--next",h.setAttribute("type","button"),h.setAttribute("aria-label",l.navLabel[1]),h.innerHTML=l.navText[1],p.appendChild(h),(f=document.createElement("button")).className="tobii__btn tobii__btn--close",f.setAttribute("type","button"),f.setAttribute("aria-label",l.closeLabel),f.innerHTML=l.closeText,p.appendChild(f),(m=document.createElement("div")).className="tobii__counter",p.appendChild(m),document.body.appendChild(p));var i=document.querySelectorAll(l.selector);if(!i)throw new Error("Ups, I can't find the selector "+l.selector+" on this website.");var n=[];i.forEach(function(e){var t=e.hasAttribute("data-group")?e.getAttribute("data-group"):"default",i=e.href;e.hasAttribute("data-target")&&(i=e.getAttribute("data-target")),void 0!==n[i+="__"+t]?e.addEventListener("click",function(e){D(t),U(),e.preventDefault()}):(n[i]=1,T(e))})}}(e),a.open=U,a.previous=M,a.next=H,a.close=X,a.add=T,a.remove=q,a.reset=ue,a.destroy=function(){ue(),p.parentNode.removeChild(p)},a.isOpen=ce,a.slidesIndex=function(){return I[C].currentIndex},a.select=function(e){var t=I[C].currentIndex;if(!ce())throw new Error("Ups, I'm closed.");if(ce()){if(!e&&0!==e)throw new Error("Ups, no slide specified.");if(e===I[C].currentIndex)throw new Error("Ups, slide "+e+" is already selected.");if(-1===e||e>=I[C].elementsLength)throw new Error("Ups, I can't find slide "+e+".")}I[C].currentIndex=e,B(t),R(e),e<t&&(le("left"),V(t),z(e-1)),e>t&&(le("right"),V(t),z(e+1))},a.slidesCount=function(){return I[C].elementsLength},a.selectGroup=D,a.currentGroup=function(){return null!==C?C:S},a.on=function(e,t){p.addEventListener(e,t)},a.off=function(e,t){p.removeEventListener(e,t)},a}typeof module<"u"?module.exports=a:self.Tobii=a}(); | ||
!function(){if("function"!=typeof window.CustomEvent){var e=function(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var i=document.createEvent("CustomEvent");return i.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),i};e.prototype=window.Event.prototype,window.CustomEvent=e}function t(){return t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n])}return e},t.apply(this,arguments)}window.NodeList&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=function(e,t){t=t||window;for(var i=0;i<this.length;i++)e.call(t,this[i],i,this)});var i=/*#__PURE__*/function(){function e(){this.figcaptionId=0,this.userSettings=null}var t=e.prototype;return t.init=function(e,t,i){this.userSettings=i;var n,r=document.createElement("figure"),o=document.createElement("figcaption"),a=document.createElement("img"),s=e.querySelector("img"),d=document.createElement("div");r.style.opacity="0",s&&(a.alt=s.alt||""),a.setAttribute("src",""),a.setAttribute("data-src",e.href),e.hasAttribute("data-srcset")&&a.setAttribute("data-srcset",e.getAttribute("data-srcset")),r.appendChild(a),this.userSettings.captions&&("function"==typeof this.userSettings.captionText?n=this.userSettings.captionText(e):"self"===this.userSettings.captionsSelector&&e.getAttribute(this.userSettings.captionAttribute)?n=e.getAttribute(this.userSettings.captionAttribute):"img"===this.userSettings.captionsSelector&&s&&s.getAttribute(this.userSettings.captionAttribute)&&(n=s.getAttribute(this.userSettings.captionAttribute)),this.userSettings.captionHTML?o.innerHTML=n:o.textContent=n,n&&(o.id="tobii-figcaption-"+this.figcaptionId,r.appendChild(o),a.setAttribute("aria-labelledby",o.id),++this.figcaptionId)),t.appendChild(r),d.className="tobii__loader",d.setAttribute("role","progressbar"),d.setAttribute("aria-label",this.userSettings.loadingIndicatorLabel),t.appendChild(d),t.setAttribute("data-type","image"),t.classList.add("tobii-image")},t.onPreload=function(e){this.onLoad(e)},t.onLoad=function(e){var t=e.querySelector("img");if(t.hasAttribute("data-src")){var i=e.querySelector("figure"),n=e.querySelector(".tobii__loader");t.addEventListener("load",function(){e.removeChild(n),i.style.opacity="1"}),t.addEventListener("error",function(){e.removeChild(n),i.style.opacity="1"}),t.setAttribute("src",t.getAttribute("data-src")),t.removeAttribute("data-src"),t.hasAttribute("data-srcset")&&t.setAttribute("srcset",t.getAttribute("data-srcset"))}},t.onLeave=function(e){},t.onCleanup=function(e){},t.onReset=function(){this.figcaptionId=0},e}(),n=/*#__PURE__*/function(){function e(){this.userSettings=null}var t=e.prototype;return t.init=function(e,t,i){this.userSettings=i;var n=e.hasAttribute("data-target")?e.getAttribute("data-target"):e.getAttribute("href");t.setAttribute("data-HREF",n),e.getAttribute("data-allow")&&t.setAttribute("data-allow",e.getAttribute("data-allow")),e.hasAttribute("data-width")&&t.setAttribute("data-width",""+e.getAttribute("data-width")),e.hasAttribute("data-height")&&t.setAttribute("data-height",""+e.getAttribute("data-height")),t.setAttribute("data-type","iframe"),t.classList.add("tobii-iframe")},t.onPreload=function(e){},t.onLoad=function(e){var t=e.querySelector("iframe"),i=document.createElement("div");if(i.className="tobii__loader",i.setAttribute("role","progressbar"),i.setAttribute("aria-label",this.userSettings.loadingIndicatorLabel),e.appendChild(i),null==t){t=document.createElement("iframe");var n=e.getAttribute("data-href");t.setAttribute("frameborder","0"),t.setAttribute("src",n),t.setAttribute("allowfullscreen",""),n.indexOf("youtube.com")>-1?t.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"):n.indexOf("vimeo.com")>-1?t.setAttribute("allow","autoplay; picture-in-picture"):e.hasAttribute("data-allow")&&t.setAttribute("allow",e.getAttribute("data-allow")),e.getAttribute("data-width")&&(t.style.maxWidth=""+e.getAttribute("data-width")),e.getAttribute("data-height")&&(t.style.maxHeight=""+e.getAttribute("data-height")),t.style.opacity="0",e.appendChild(t),t.addEventListener("load",function(){t.style.opacity="1";var i=e.querySelector(".tobii__loader");i&&e.removeChild(i)}),t.addEventListener("error",function(){t.style.opacity="1";var i=e.querySelector(".tobii__loader");i&&e.removeChild(i)})}else t.setAttribute("src",e.getAttribute("data-href"))},t.onLeave=function(e){},t.onCleanup=function(e){var t=e.querySelector("iframe");t.setAttribute("src",""),t.style.opacity="0"},t.onReset=function(){},e}(),r=/*#__PURE__*/function(){function e(){this.userSettings=null}var t=e.prototype;return t.init=function(e,t,i){this.userSettings=i;var n=e.hasAttribute("data-target")?e.getAttribute("data-target"):e.getAttribute("href"),r=document.querySelector(n).cloneNode(!0);if(!r)throw new Error("Ups, I can't find the target "+n+".");t.appendChild(r),t.setAttribute("data-type","html"),t.classList.add("tobii-html")},t.onPreload=function(e){},t.onLoad=function(e,t){var i=e.querySelector("video");i&&(i.hasAttribute("data-time")&&i.readyState>0&&(i.currentTime=i.getAttribute("data-time")),this.userSettings.autoplayVideo&&i.play());var n=e.querySelector("audio");n&&this.userSettings.autoplayAudio&&n.play(),e.classList.add("tobii-group-"+t)},t.onLeave=function(e){var t=e.querySelector("video");t&&(t.paused||t.pause(),t.readyState>0&&t.setAttribute("data-time",t.currentTime));var i=e.querySelector("audio");i&&(i.paused||i.pause())},t.onCleanup=function(e){var t=e.querySelector("video");if(t&&t.readyState>0&&t.readyState<3&&t.duration!==t.currentTime){var i=t.cloneNode(!0);this._removeSources(t),t.load(),t.parentNode.removeChild(t),e.appendChild(i)}},t.onReset=function(){},t._removeSources=function(e){var t=e.querySelectorAll("src");t&&t.forEach(function(e){e.setAttribute("src","")})},e}(),o=/*#__PURE__*/function(){function e(){this.playerId=0,this.PLAYER=[],this.userSettings=null}var t=e.prototype;return t.init=function(e,t,i){this.userSettings=i;var n=document.createElement("div");t.appendChild(n),this.PLAYER[this.playerId]=new window.YT.Player(n,{host:"https://www.youtube-nocookie.com",height:e.getAttribute("data-height")||"360",width:e.getAttribute("data-width")||"640",videoId:e.getAttribute("data-id"),playerVars:{controls:e.getAttribute("data-controls")||1,rel:0,playsinline:1}}),t.setAttribute("data-player",this.playerId),t.setAttribute("data-type","youtube"),t.classList.add("tobii-youtube"),this.playerId++},t.onPreload=function(e){},t.onLoad=function(e){this.userSettings.autoplayVideo&&this.PLAYER[e.getAttribute("data-player")].playVideo()},t.onLeave=function(e){1===this.PLAYER[e.getAttribute("data-player")].getPlayerState()&&this.PLAYER[e.getAttribute("data-player")].pauseVideo()},t.onCleanup=function(e){1===this.PLAYER[e.getAttribute("data-player")].getPlayerState()&&this.PLAYER[e.getAttribute("data-player")].pauseVideo()},t.onReset=function(){},e}();function a(e){var s={image:new i,html:new r,iframe:new n,youtube:new o},d=['a[href]:not([tabindex^="-"]):not([inert])','area[href]:not([tabindex^="-"]):not([inert])',"input:not([disabled]):not([inert])","select:not([disabled]):not([inert])","textarea:not([disabled]):not([inert])","button:not([disabled]):not([inert])",'iframe:not([tabindex^="-"]):not([inert])','audio:not([tabindex^="-"]):not([inert])','video:not([tabindex^="-"]):not([inert])','[contenteditable]:not([tabindex^="-"]):not([inert])','[tabindex]:not([tabindex^="-"]):not([inert])'],l={},u=[],c={gallery:[],slider:null,sliderElements:[],elementsLength:0,currentIndex:0,x:0},p=null,b=null,h=null,f=null,m=null,g={},v=!1,y=!1,w=!1,A=null,E=null,L=null,x=!1,_=!1,S={},I=null,C=null,T=function(e){if(null===document.querySelector('[data-type="youtube"]')||_)q(e);else{if(null===document.getElementById("iframe_api")){var t=document.createElement("script"),i=document.getElementsByTagName("script")[0];t.id="iframe_api",t.src="https://www.youtube.com/iframe_api",i.parentNode.insertBefore(t,i)}-1===u.indexOf(e)&&u.push(e),window.onYouTubePlayerAPIReady=function(){u.forEach(function(e){q(e)}),_=!0}}},P=function(e){return e.hasAttribute("data-group")?e.getAttribute("data-group"):"default"},q=function(e){if(I=P(e),Object.prototype.hasOwnProperty.call(S,I)||(S[I]=JSON.parse(JSON.stringify(c)),Y()),-1!==S[I].gallery.indexOf(e))throw new Error("Ups, element already added.");if(S[I].gallery.push(e),S[I].elementsLength++,l.zoom&&e.querySelector("img")&&"false"!==e.getAttribute("data-zoom")||"true"===e.getAttribute("data-zoom")){var t=document.createElement("div");t.className="tobii-zoom__icon",t.innerHTML=l.zoomText,e.classList.add("tobii-zoom"),e.appendChild(t)}e.addEventListener("click",J),O(e),ce()&&I===C&&(de(),le())},N=function(e){var t=P(e);if(-1===S[t].gallery.indexOf(e))throw new Error("Ups, I can't find a slide for the element "+e+".");var i=S[t].gallery.indexOf(e),n=S[t].sliderElements[i];if(ce()&&t===C&&i===S[t].currentIndex){if(1===S[t].elementsLength)throw X(),new Error("Ups, I've closed. There are no slides more to show.");0===S[t].currentIndex?H():R(),de(),le()}if(S[t].gallery.splice(S[t].gallery.indexOf(e)),S[t].sliderElements.splice(S[t].gallery.indexOf(e)),S[t].elementsLength--,--S[t].x,l.zoom&&e.querySelector(".tobii-zoom__icon")){var r=e.querySelector(".tobii-zoom__icon");r.parentNode.classList.remove("tobii-zoom"),r.parentNode.removeChild(r)}e.removeEventListener("click",J),n.parentNode.removeChild(n)},Y=function(){S[I].slider=document.createElement("div"),S[I].slider.className="tobii__slider",S[I].slider.setAttribute("aria-hidden","true"),p.appendChild(S[I].slider)},O=function(e){var t=k(e),i=document.createElement("div"),n=document.createElement("div");i.className="tobii__slide",i.style.position="absolute",i.style.left=100*S[I].x+"%",i.setAttribute("aria-hidden","true"),t.init(e,n,l),i.appendChild(n),S[I].slider.appendChild(i),S[I].sliderElements.push(i),++S[I].x},k=function(e){var t=e.getAttribute("data-type");return void 0!==s[t]?s[t]:(e.hasAttribute("data-type")&&console.log("Unknown lightbox element type: "+t),s.image)},U=function(e){if(C=null!==C?C:I,ce())throw new Error("Ups, I'm aleady open.");if(!ce()&&(e||(e=0),-1===e||e>=S[C].elementsLength))throw new Error("Ups, I can't find slide "+e+".");document.documentElement.classList.add("tobii-is-open"),document.body.classList.add("tobii-is-open"),document.body.classList.add("tobii-is-open-"+C),de(),l.close||(f.disabled=!1,f.setAttribute("aria-hidden","true")),A=document.activeElement;var t=window.location.href;window.history.pushState({tobii:"close"},"Image",t),S[C].currentIndex=e,W(),ae(),M(S[C].currentIndex),S[C].slider.setAttribute("aria-hidden","false"),p.setAttribute("aria-hidden","false"),le(),z(S[C].currentIndex+1),z(S[C].currentIndex-1),S[C].slider.classList.add("tobii__slider--animate");var i=new window.CustomEvent("open",{detail:{group:C}});p.dispatchEvent(i)},X=function(){if(!ce())throw new Error("Ups, I'm already closed.");document.documentElement.classList.remove("tobii-is-open"),document.body.classList.remove("tobii-is-open"),document.body.classList.remove("tobii-is-open-"+C),se(),null!==window.history.state&&"close"===window.history.state.tobii&&window.history.back(),A.focus(),B(S[C].currentIndex),V(S[C].currentIndex),p.setAttribute("aria-hidden","true"),S[C].slider.setAttribute("aria-hidden","true"),S[C].currentIndex=0,S[C].slider.classList.remove("tobii__slider--animate");var e=new window.CustomEvent("close",{detail:{group:C}});p.dispatchEvent(e)},z=function(e){if(void 0!==S[C].sliderElements[e]){var t=S[C].sliderElements[e].querySelector("[data-type]");k(t).onPreload(t)}},M=function(e){if(void 0!==S[C].sliderElements[e]){var t=S[C].sliderElements[e].querySelector("[data-type]"),i=k(t);S[C].sliderElements[e].classList.add("tobii__slide--is-active"),S[C].sliderElements[e].setAttribute("aria-hidden","false"),i.onLoad(t,C)}},R=function(){if(!ce())throw new Error("Ups, I'm closed.");S[C].currentIndex>0&&(B(S[C].currentIndex),M(--S[C].currentIndex),le("left"),V(S[C].currentIndex+1),z(S[C].currentIndex-1));var e=new window.CustomEvent("previous",{detail:{group:C}});p.dispatchEvent(e)},H=function(){if(!ce())throw new Error("Ups, I'm closed.");S[C].currentIndex<S[C].elementsLength-1&&(B(S[C].currentIndex),M(++S[C].currentIndex),le("right"),V(S[C].currentIndex-1),z(S[C].currentIndex+1));var e=new window.CustomEvent("next",{detail:{group:C}});p.dispatchEvent(e)},D=function(e){if(ce())throw new Error("Ups, I'm open.");if(!e)throw new Error("Ups, no group specified.");if(e&&!Object.prototype.hasOwnProperty.call(S,e))throw new Error("Ups, I don't have a group called \""+e+'".');C=e},B=function(e){if(void 0!==S[C].sliderElements[e]){var t=S[C].sliderElements[e].querySelector("[data-type]"),i=k(t);S[C].sliderElements[e].classList.remove("tobii__slide--is-active"),S[C].sliderElements[e].setAttribute("aria-hidden","true"),i.onLeave(t)}},V=function(e){if(void 0!==S[C].sliderElements[e]){var t=S[C].sliderElements[e].querySelector("[data-type]");k(t).onCleanup(t)}},j=function(){S[C=null!==C?C:I].slider.style.transform="translate3d("+(E=-S[C].currentIndex*p.offsetWidth)+"px, 0, 0)",L=E},W=function(){g={startX:0,endX:0,startY:0,endY:0}},F=function(){var e=g.endX-g.startX,t=g.endY-g.startY,i=Math.abs(e),n=Math.abs(t);e>0&&i>l.threshold&&S[C].currentIndex>0?R():e<0&&i>l.threshold&&S[C].currentIndex!==S[C].elementsLength-1?H():t<0&&n>l.threshold&&l.swipeClose?X():j()},G=function(){x||(x=!0,window.requestAnimationFrame(function(){j(),x=!1}))},J=function(e){e.preventDefault(),C=P(e.currentTarget),U(S[C].gallery.indexOf(e.currentTarget))},K=function(e){e.target===b?R():e.target===h?H():(e.target===f||!1===v&&!1===y&&e.target.classList.contains("tobii__slide")&&l.docClose)&&X(),e.stopPropagation()},Q=function(e){var t=Array.prototype.slice.call(p.querySelectorAll(".tobii__btn:not([disabled]), .tobii__slide--is-active "+d.join(", .tobii__slide--is-active "))).filter(function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)}),i=t.indexOf(document.activeElement);9===e.keyCode||"Tab"===e.code?e.shiftKey&&0===i?(t[t.length-1].focus(),e.preventDefault()):e.shiftKey||i!==t.length-1||(t[0].focus(),e.preventDefault()):27===e.keyCode||"Escape"===e.code?(e.preventDefault(),X()):37===e.keyCode||"ArrowLeft"===e.code?(e.preventDefault(),R()):39!==e.keyCode&&"ArrowRight"!==e.code||(e.preventDefault(),H())},Z=function(e){be(e.target)||(e.stopPropagation(),v=!1,y=!1,w=!0,g.startX=e.touches[0].pageX,g.startY=e.touches[0].pageY,pe()&&S[C].slider.classList.add("tobii__slider--is-dragging"))},$=function(e){e.stopPropagation(),w&&(g.endX=e.touches[0].pageX,g.endY=e.touches[0].pageY,oe())},ee=function(e){e.stopPropagation(),w=!1,S[C].slider.classList.remove("tobii__slider--is-dragging"),g.endX&&F(),W()},te=function(e){be(e.target)||(e.preventDefault(),e.stopPropagation(),v=!1,y=!1,w=!0,g.startX=e.pageX,g.startY=e.pageY,pe()&&S[C].slider.classList.add("tobii__slider--is-dragging"))},ie=function(e){e.preventDefault(),w&&(g.endX=e.pageX,g.endY=e.pageY,oe())},ne=function(e){e.stopPropagation(),w=!1,S[C].slider.classList.remove("tobii__slider--is-dragging"),g.endX&&F(),W()},re=function(){w=!1},oe=function(){Math.abs(g.startX-g.endX)>0&&!y&&S[C].elementsLength>1?(S[C].slider.style.transform="translate3d("+(L-Math.round(g.startX-g.endX))+"px, 0, 0)",v=!0,y=!1):Math.abs(g.startY-g.endY)>0&&!v&&l.swipeClose&&(S[C].slider.style.transform="translate3d("+L+"px, -"+Math.round(g.startY-g.endY)+"px, 0)",v=!1,y=!0)},ae=function(){l.keyboard&&window.addEventListener("keydown",Q),window.addEventListener("resize",G),window.addEventListener("popstate",X),p.addEventListener("click",K),l.draggable&&pe()&&(p.addEventListener("touchstart",Z),p.addEventListener("touchmove",$),p.addEventListener("touchend",ee),p.addEventListener("mousedown",te),p.addEventListener("mouseup",ne),p.addEventListener("mousemove",ie),p.addEventListener("contextmenu",re))},se=function(){l.keyboard&&window.removeEventListener("keydown",Q),window.removeEventListener("resize",G),window.removeEventListener("popstate",X),p.removeEventListener("click",K),l.draggable&&pe()&&(p.removeEventListener("touchstart",Z),p.removeEventListener("touchmove",$),p.removeEventListener("touchend",ee),p.removeEventListener("mousedown",te),p.removeEventListener("mouseup",ne),p.removeEventListener("mousemove",ie),p.removeEventListener("contextmenu",re))},de=function(){(l.draggable&&l.swipeClose&&pe()&&!S[C].slider.classList.contains("tobii__slider--is-draggable")||l.draggable&&S[C].elementsLength>1&&!S[C].slider.classList.contains("tobii__slider--is-draggable"))&&S[C].slider.classList.add("tobii__slider--is-draggable"),!l.nav||1===S[C].elementsLength||"auto"===l.nav&&pe()?(b.setAttribute("aria-hidden","true"),b.disabled=!0,h.setAttribute("aria-hidden","true"),h.disabled=!0):(b.setAttribute("aria-hidden","false"),b.disabled=!1,h.setAttribute("aria-hidden","false"),h.disabled=!1),m.setAttribute("aria-hidden",l.counter&&1!==S[C].elementsLength?"false":"true")},le=function(e){void 0===e&&(e=null),j(),m.textContent=S[C].currentIndex+1+"/"+S[C].elementsLength,function(e){(!0===l.nav||"auto"===l.nav)&&!pe()&&S[C].elementsLength>1?(b.setAttribute("aria-hidden","true"),b.disabled=!0,h.setAttribute("aria-hidden","true"),h.disabled=!0,1===S[C].elementsLength?l.close&&f.focus():0===S[C].currentIndex?(h.setAttribute("aria-hidden","false"),h.disabled=!1,h.focus()):S[C].currentIndex===S[C].elementsLength-1?(b.setAttribute("aria-hidden","false"),b.disabled=!1,b.focus()):(b.setAttribute("aria-hidden","false"),b.disabled=!1,h.setAttribute("aria-hidden","false"),h.disabled=!1,"left"===e?b.focus():h.focus())):l.close&&f.focus()}(e)},ue=function(){ce()&&X();var e=Object.entries(S);for(var t in e.forEach(function(e){e[1].gallery.forEach(function(e){N(e)})}),S={},I=C=null,s)s[t].onReset()},ce=function(){return"false"===p.getAttribute("aria-hidden")},pe=function(){return"ontouchstart"in window},be=function(e){return-1!==["TEXTAREA","OPTION","INPUT","SELECT"].indexOf(e.nodeName)||e===b||e===h||e===f};return function(e){if(document.querySelector("div.tobii"))console.log("Multiple lightbox instances not supported.");else{l=function(e){return t({},{selector:".lightbox",captions:!0,captionsSelector:"img",captionAttribute:"alt",captionText:null,captionHTML:!1,nav:"auto",navText:['<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="15 6 9 12 15 18" /></svg>','<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="9 6 15 12 9 18" /></svg>'],navLabel:["Previous image","Next image"],close:!0,closeText:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><line x1="18" y1="6" x2="6" y2="18" /><line x1="6" y1="6" x2="18" y2="18" /></svg>',closeLabel:"Close lightbox",loadingIndicatorLabel:"Image loading",counter:!0,download:!1,downloadText:"",downloadLabel:"Download image",keyboard:!0,zoom:!0,zoomText:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="16 4 20 4 20 8" /><line x1="14" y1="10" x2="20" y2="4" /><polyline points="8 20 4 20 4 16" /><line x1="4" y1="20" x2="10" y2="14" /><polyline points="16 20 20 20 20 16" /><line x1="14" y1="14" x2="20" y2="20" /><polyline points="8 4 4 4 4 8" /><line x1="4" y1="4" x2="10" y2="10" /></svg>',docClose:!0,swipeClose:!0,hideScrollbar:!0,draggable:!0,threshold:100,rtl:!1,loop:!1,autoplayVideo:!1,modal:!1,theme:"tobii--theme-default"},e)}(e),p||((p=document.createElement("div")).setAttribute("role","dialog"),p.setAttribute("aria-hidden","true"),p.classList.add("tobii"),p.classList.add(l.theme),(b=document.createElement("button")).className="tobii__btn tobii__btn--previous",b.setAttribute("type","button"),b.setAttribute("aria-label",l.navLabel[0]),b.innerHTML=l.navText[0],p.appendChild(b),(h=document.createElement("button")).className="tobii__btn tobii__btn--next",h.setAttribute("type","button"),h.setAttribute("aria-label",l.navLabel[1]),h.innerHTML=l.navText[1],p.appendChild(h),(f=document.createElement("button")).className="tobii__btn tobii__btn--close",f.setAttribute("type","button"),f.setAttribute("aria-label",l.closeLabel),f.innerHTML=l.closeText,p.appendChild(f),(m=document.createElement("div")).className="tobii__counter",p.appendChild(m),document.body.appendChild(p));var i=document.querySelectorAll(l.selector);if(!i)throw new Error("Ups, I can't find the selector "+l.selector+" on this website.");var n=[];i.forEach(function(e){var t=e.hasAttribute("data-group")?e.getAttribute("data-group"):"default",i=e.href;e.hasAttribute("data-target")&&(i=e.getAttribute("data-target")),void 0!==n[i+="__"+t]?e.addEventListener("click",function(e){D(t),U(),e.preventDefault()}):(n[i]=1,T(e))})}}(e),a.open=U,a.previous=R,a.next=H,a.close=X,a.add=T,a.remove=N,a.reset=ue,a.destroy=function(){ue(),p.parentNode.removeChild(p)},a.isOpen=ce,a.slidesIndex=function(){return S[C].currentIndex},a.select=function(e){var t=S[C].currentIndex;if(!ce())throw new Error("Ups, I'm closed.");if(ce()){if(!e&&0!==e)throw new Error("Ups, no slide specified.");if(e===S[C].currentIndex)throw new Error("Ups, slide "+e+" is already selected.");if(-1===e||e>=S[C].elementsLength)throw new Error("Ups, I can't find slide "+e+".")}S[C].currentIndex=e,B(t),M(e),e<t&&(le("left"),V(t),z(e-1)),e>t&&(le("right"),V(t),z(e+1))},a.slidesCount=function(){return S[C].elementsLength},a.selectGroup=D,a.currentGroup=function(){return null!==C?C:I},a.on=function(e,t){p.addEventListener(e,t)},a.off=function(e,t){p.removeEventListener(e,t)},a}typeof module<"u"?module.exports=a:self.Tobii=a}(); |
@@ -1,1 +0,1 @@ | ||
function e(){return(e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e}).apply(this,arguments)}class t{constructor(){this.figcaptionId=0,this.userSettings=null}init(e,t,i){this.userSettings=i;const r=document.createElement("figure"),n=document.createElement("figcaption"),a=document.createElement("img"),s=e.querySelector("img"),o=document.createElement("div");r.style.opacity="0",s&&(a.alt=s.alt||""),a.setAttribute("src",""),a.setAttribute("data-src",e.href),e.hasAttribute("data-srcset")&&a.setAttribute("data-srcset",e.getAttribute("data-srcset")),r.appendChild(a),this.userSettings.captions&&("function"==typeof this.userSettings.captionText?n.textContent=this.userSettings.captionText(e):"self"===this.userSettings.captionsSelector&&e.getAttribute(this.userSettings.captionAttribute)?n.textContent=e.getAttribute(this.userSettings.captionAttribute):"img"===this.userSettings.captionsSelector&&s&&s.getAttribute(this.userSettings.captionAttribute)&&(n.textContent=s.getAttribute(this.userSettings.captionAttribute)),n.textContent&&(n.id=`tobii-figcaption-${this.figcaptionId}`,r.appendChild(n),a.setAttribute("aria-labelledby",n.id),++this.figcaptionId)),t.appendChild(r),o.className="tobii__loader",o.setAttribute("role","progressbar"),o.setAttribute("aria-label",this.userSettings.loadingIndicatorLabel),t.appendChild(o),t.setAttribute("data-type","image"),t.classList.add("tobii-image")}onPreload(e){this.onLoad(e)}onLoad(e){const t=e.querySelector("img");if(!t.hasAttribute("data-src"))return;const i=e.querySelector("figure"),r=e.querySelector(".tobii__loader");t.addEventListener("load",()=>{e.removeChild(r),i.style.opacity="1"}),t.addEventListener("error",()=>{e.removeChild(r),i.style.opacity="1"}),t.setAttribute("src",t.getAttribute("data-src")),t.removeAttribute("data-src"),t.hasAttribute("data-srcset")&&t.setAttribute("srcset",t.getAttribute("data-srcset"))}onLeave(e){}onCleanup(e){}onReset(){this.figcaptionId=0}}class i{constructor(){this.userSettings=null}init(e,t,i){this.userSettings=i;const r=e.hasAttribute("data-target")?e.getAttribute("data-target"):e.getAttribute("href");t.setAttribute("data-HREF",r),e.getAttribute("data-allow")&&t.setAttribute("data-allow",e.getAttribute("data-allow")),e.hasAttribute("data-width")&&t.setAttribute("data-width",`${e.getAttribute("data-width")}`),e.hasAttribute("data-height")&&t.setAttribute("data-height",`${e.getAttribute("data-height")}`),t.setAttribute("data-type","iframe"),t.classList.add("tobii-iframe")}onPreload(e){}onLoad(e){let t=e.querySelector("iframe");const i=document.createElement("div");if(i.className="tobii__loader",i.setAttribute("role","progressbar"),i.setAttribute("aria-label",this.userSettings.loadingIndicatorLabel),e.appendChild(i),null==t){t=document.createElement("iframe");const i=e.getAttribute("data-href");t.setAttribute("frameborder","0"),t.setAttribute("src",i),t.setAttribute("allowfullscreen",""),i.indexOf("youtube.com")>-1?t.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"):i.indexOf("vimeo.com")>-1?t.setAttribute("allow","autoplay; picture-in-picture"):e.hasAttribute("data-allow")&&t.setAttribute("allow",e.getAttribute("data-allow")),e.getAttribute("data-width")&&(t.style.maxWidth=`${e.getAttribute("data-width")}`),e.getAttribute("data-height")&&(t.style.maxHeight=`${e.getAttribute("data-height")}`),t.style.opacity="0",e.appendChild(t),t.addEventListener("load",()=>{t.style.opacity="1";const i=e.querySelector(".tobii__loader");i&&e.removeChild(i)}),t.addEventListener("error",()=>{t.style.opacity="1";const i=e.querySelector(".tobii__loader");i&&e.removeChild(i)})}else t.setAttribute("src",e.getAttribute("data-href"))}onLeave(e){}onCleanup(e){const t=e.querySelector("iframe");t.setAttribute("src",""),t.style.opacity="0"}onReset(){}}class r{constructor(){this.userSettings=null}init(e,t,i){this.userSettings=i;const r=e.hasAttribute("data-target")?e.getAttribute("data-target"):e.getAttribute("href"),n=document.querySelector(r).cloneNode(!0);if(!n)throw new Error(`Ups, I can't find the target ${r}.`);t.appendChild(n),t.setAttribute("data-type","html"),t.classList.add("tobii-html")}onPreload(e){}onLoad(e){const t=e.querySelector("video");t&&(t.hasAttribute("data-time")&&t.readyState>0&&(t.currentTime=t.getAttribute("data-time")),this.userSettings.autoplayVideo&&t.play())}onLeave(e){const t=e.querySelector("video");t&&(t.paused||t.pause(),t.readyState>0&&t.setAttribute("data-time",t.currentTime))}onCleanup(e){const t=e.querySelector("video");if(t&&t.readyState>0&&t.readyState<3&&t.duration!==t.currentTime){const i=t.cloneNode(!0);this._removeSources(t),t.load(),t.parentNode.removeChild(t),e.appendChild(i)}}onReset(){}_removeSources(e){const t=e.querySelectorAll("src");t&&t.forEach(e=>{e.setAttribute("src","")})}}class n{constructor(){this.playerId=0,this.PLAYER=[],this.userSettings=null}init(e,t,i){this.userSettings=i;const r=document.createElement("div");t.appendChild(r),this.PLAYER[this.playerId]=new window.YT.Player(r,{host:"https://www.youtube-nocookie.com",height:e.getAttribute("data-height")||"360",width:e.getAttribute("data-width")||"640",videoId:e.getAttribute("data-id"),playerVars:{controls:e.getAttribute("data-controls")||1,rel:0,playsinline:1}}),t.setAttribute("data-player",this.playerId),t.setAttribute("data-type","youtube"),t.classList.add("tobii-youtube"),this.playerId++}onPreload(e){}onLoad(e){this.userSettings.autoplayVideo&&this.PLAYER[e.getAttribute("data-player")].playVideo()}onLeave(e){1===this.PLAYER[e.getAttribute("data-player")].getPlayerState()&&this.PLAYER[e.getAttribute("data-player")].pauseVideo()}onCleanup(e){1===this.PLAYER[e.getAttribute("data-player")].getPlayerState()&&this.PLAYER[e.getAttribute("data-player")].pauseVideo()}onReset(){}}function a(s){const o={image:new t,html:new r,iframe:new i,youtube:new n},d=['a[href]:not([tabindex^="-"]):not([inert])','area[href]:not([tabindex^="-"]):not([inert])',"input:not([disabled]):not([inert])","select:not([disabled]):not([inert])","textarea:not([disabled]):not([inert])","button:not([disabled]):not([inert])",'iframe:not([tabindex^="-"]):not([inert])','audio:not([tabindex^="-"]):not([inert])','video:not([tabindex^="-"]):not([inert])','[contenteditable]:not([tabindex^="-"]):not([inert])','[tabindex]:not([tabindex^="-"]):not([inert])'];let l={};const u=[],c={gallery:[],slider:null,sliderElements:[],elementsLength:0,currentIndex:0,x:0};let b=null,p=null,h=null,m=null,g=null,y={},v=!1,f=!1,w=!1,A=null,E=null,L=null,x=!1,_=!1,I={},S=null,C=null;const T=e=>{if(null===document.querySelector('[data-type="youtube"]')||_)q(e);else{if(null===document.getElementById("iframe_api")){const e=document.createElement("script"),t=document.getElementsByTagName("script")[0];e.id="iframe_api",e.src="https://www.youtube.com/iframe_api",t.parentNode.insertBefore(e,t)}-1===u.indexOf(e)&&u.push(e),window.onYouTubePlayerAPIReady=()=>{u.forEach(e=>{q(e)}),_=!0}}},P=e=>e.hasAttribute("data-group")?e.getAttribute("data-group"):"default",q=e=>{if(S=P(e),Object.prototype.hasOwnProperty.call(I,S)||(I[S]=JSON.parse(JSON.stringify(c)),N()),-1!==I[S].gallery.indexOf(e))throw new Error("Ups, element already added.");if(I[S].gallery.push(e),I[S].elementsLength++,l.zoom&&e.querySelector("img")&&"false"!==e.getAttribute("data-zoom")||"true"===e.getAttribute("data-zoom")){const t=document.createElement("div");t.className="tobii-zoom__icon",t.innerHTML=l.zoomText,e.classList.add("tobii-zoom"),e.appendChild(t)}e.addEventListener("click",G),O(e),ce()&&S===C&&(de(),le(null))},Y=e=>{const t=P(e);if(-1===I[t].gallery.indexOf(e))throw new Error(`Ups, I can't find a slide for the element ${e}.`);{const i=I[t].gallery.indexOf(e),r=I[t].sliderElements[i];if(ce()&&t===C&&i===I[t].currentIndex){if(1===I[t].elementsLength)throw X(),new Error("Ups, I've closed. There are no slides more to show.");0===I[t].currentIndex?M():R()}if(I[t].elementsLength--,l.zoom&&e.querySelector(".tobii-zoom__icon")){const t=e.querySelector(".tobii-zoom__icon");t.parentNode.classList.remove("tobii-zoom"),t.parentNode.removeChild(t)}e.removeEventListener("click",G),r.parentNode.removeChild(r)}},N=()=>{I[S].slider=document.createElement("div"),I[S].slider.className="tobii__slider",I[S].slider.setAttribute("aria-hidden","true"),b.appendChild(I[S].slider)},O=e=>{const t=k(e),i=document.createElement("div"),r=document.createElement("div");i.className="tobii__slide",i.style.position="absolute",i.style.left=100*I[S].x+"%",i.setAttribute("aria-hidden","true"),t.init(e,r,l),i.appendChild(r),I[S].slider.appendChild(i),I[S].sliderElements.push(i),++I[S].x},k=e=>{const t=e.getAttribute("data-type");return void 0!==o[t]?o[t]:(e.hasAttribute("data-type")&&console.log("Unknown lightbox element type: "+t),o.image)},U=e=>{if(C=null!==C?C:S,ce())throw new Error("Ups, I'm aleady open.");if(!ce()&&(e||(e=0),-1===e||e>=I[C].elementsLength))throw new Error(`Ups, I can't find slide ${e}.`);document.documentElement.classList.add("tobii-is-open"),document.body.classList.add("tobii-is-open"),document.body.classList.add("tobii-is-open-"+C),de(),l.close||(m.disabled=!1,m.setAttribute("aria-hidden","true")),A=document.activeElement;const t=window.location.href;window.history.pushState({tobii:"close"},"Image",t),I[C].currentIndex=e,j(),se(),z(I[C].currentIndex),I[C].slider.setAttribute("aria-hidden","false"),b.setAttribute("aria-hidden","false"),le(null),$(I[C].currentIndex+1),$(I[C].currentIndex-1),I[C].slider.classList.add("tobii__slider--animate");const i=new window.CustomEvent("open",{detail:{group:C}});b.dispatchEvent(i)},X=()=>{if(!ce())throw new Error("Ups, I'm already closed.");document.documentElement.classList.remove("tobii-is-open"),document.body.classList.remove("tobii-is-open"),document.body.classList.remove("tobii-is-open-"+C),oe(),null!==window.history.state&&"close"===window.history.state.tobii&&window.history.back(),A.focus(),D(I[C].currentIndex),B(I[C].currentIndex),b.setAttribute("aria-hidden","true"),I[C].slider.setAttribute("aria-hidden","true"),I[C].currentIndex=0,I[C].slider.classList.remove("tobii__slider--animate");const e=new window.CustomEvent("close",{detail:{group:C}});b.dispatchEvent(e)},$=e=>{if(void 0===I[C].sliderElements[e])return;const t=I[C].sliderElements[e].querySelector("[data-type]");k(t).onPreload(t)},z=e=>{if(void 0===I[C].sliderElements[e])return;const t=I[C].sliderElements[e].querySelector("[data-type]"),i=k(t);I[C].sliderElements[e].classList.add("tobii__slide--is-active"),I[C].sliderElements[e].setAttribute("aria-hidden","false"),i.onLoad(t)},R=()=>{if(!ce())throw new Error("Ups, I'm closed.");I[C].currentIndex>0&&(D(I[C].currentIndex),z(--I[C].currentIndex),le("left"),B(I[C].currentIndex+1),$(I[C].currentIndex-1));const e=new window.CustomEvent("previous",{detail:{group:C}});b.dispatchEvent(e)},M=()=>{if(!ce())throw new Error("Ups, I'm closed.");I[C].currentIndex<I[C].elementsLength-1&&(D(I[C].currentIndex),z(++I[C].currentIndex),le("right"),B(I[C].currentIndex-1),$(I[C].currentIndex+1));const e=new window.CustomEvent("next",{detail:{group:C}});b.dispatchEvent(e)},H=e=>{if(ce())throw new Error("Ups, I'm open.");if(!e)throw new Error("Ups, no group specified.");if(e&&!Object.prototype.hasOwnProperty.call(I,e))throw new Error(`Ups, I don't have a group called "${e}".`);C=e},D=e=>{if(void 0===I[C].sliderElements[e])return;const t=I[C].sliderElements[e].querySelector("[data-type]"),i=k(t);I[C].sliderElements[e].classList.remove("tobii__slide--is-active"),I[C].sliderElements[e].setAttribute("aria-hidden","true"),i.onLeave(t)},B=e=>{if(void 0===I[C].sliderElements[e])return;const t=I[C].sliderElements[e].querySelector("[data-type]");k(t).onCleanup(t)},V=()=>{C=null!==C?C:S,E=-I[C].currentIndex*b.offsetWidth,I[C].slider.style.transform=`translate3d(${E}px, 0, 0)`,L=E},j=()=>{y={startX:0,endX:0,startY:0,endY:0}},W=()=>{const e=y.endX-y.startX,t=y.endY-y.startY,i=Math.abs(e),r=Math.abs(t);e>0&&i>l.threshold&&I[C].currentIndex>0?R():e<0&&i>l.threshold&&I[C].currentIndex!==I[C].elementsLength-1?M():t<0&&r>l.threshold&&l.swipeClose?X():V()},F=()=>{x||(x=!0,window.requestAnimationFrame(()=>{V(),x=!1}))},G=e=>{e.preventDefault(),C=P(e.currentTarget),U(I[C].gallery.indexOf(e.currentTarget))},J=e=>{e.target===p?R():e.target===h?M():(e.target===m||!1===v&&!1===f&&e.target.classList.contains("tobii__slide")&&l.docClose)&&X(),e.stopPropagation()},K=e=>{const t=Array.prototype.slice.call(b.querySelectorAll(`.tobii__btn:not([disabled]), .tobii__slide--is-active ${d.join(", .tobii__slide--is-active ")}`)).filter(e=>!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)),i=t.indexOf(document.activeElement);9===e.keyCode||"Tab"===e.code?e.shiftKey&&0===i?(t[t.length-1].focus(),e.preventDefault()):e.shiftKey||i!==t.length-1||(t[0].focus(),e.preventDefault()):27===e.keyCode||"Escape"===e.code?(e.preventDefault(),X()):37===e.keyCode||"ArrowLeft"===e.code?(e.preventDefault(),R()):39!==e.keyCode&&"ArrowRight"!==e.code||(e.preventDefault(),M())},Q=e=>{pe(e.target)||(e.stopPropagation(),v=!1,f=!1,w=!0,y.startX=e.touches[0].pageX,y.startY=e.touches[0].pageY,be()&&I[C].slider.classList.add("tobii__slider--is-dragging"))},Z=e=>{e.stopPropagation(),w&&(y.endX=e.touches[0].pageX,y.endY=e.touches[0].pageY,ae())},ee=e=>{e.stopPropagation(),w=!1,I[C].slider.classList.remove("tobii__slider--is-dragging"),y.endX&&W(),j()},te=e=>{pe(e.target)||(e.preventDefault(),e.stopPropagation(),v=!1,f=!1,w=!0,y.startX=e.pageX,y.startY=e.pageY,be()&&I[C].slider.classList.add("tobii__slider--is-dragging"))},ie=e=>{e.preventDefault(),w&&(y.endX=e.pageX,y.endY=e.pageY,ae())},re=e=>{e.stopPropagation(),w=!1,I[C].slider.classList.remove("tobii__slider--is-dragging"),y.endX&&W(),j()},ne=()=>{w=!1},ae=()=>{Math.abs(y.startX-y.endX)>0&&!f&&I[C].elementsLength>1?(I[C].slider.style.transform=`translate3d(${L-Math.round(y.startX-y.endX)}px, 0, 0)`,v=!0,f=!1):Math.abs(y.startY-y.endY)>0&&!v&&l.swipeClose&&(I[C].slider.style.transform=`translate3d(${L}px, -${Math.round(y.startY-y.endY)}px, 0)`,v=!1,f=!0)},se=()=>{l.keyboard&&window.addEventListener("keydown",K),window.addEventListener("resize",F),window.addEventListener("popstate",X),b.addEventListener("click",J),l.draggable&&be()&&(b.addEventListener("touchstart",Q),b.addEventListener("touchmove",Z),b.addEventListener("touchend",ee),b.addEventListener("mousedown",te),b.addEventListener("mouseup",re),b.addEventListener("mousemove",ie),b.addEventListener("contextmenu",ne))},oe=()=>{l.keyboard&&window.removeEventListener("keydown",K),window.removeEventListener("resize",F),window.removeEventListener("popstate",X),b.removeEventListener("click",J),l.draggable&&be()&&(b.removeEventListener("touchstart",Q),b.removeEventListener("touchmove",Z),b.removeEventListener("touchend",ee),b.removeEventListener("mousedown",te),b.removeEventListener("mouseup",re),b.removeEventListener("mousemove",ie),b.removeEventListener("contextmenu",ne))},de=()=>{(l.draggable&&l.swipeClose&&be()&&!I[C].slider.classList.contains("tobii__slider--is-draggable")||l.draggable&&I[C].elementsLength>1&&!I[C].slider.classList.contains("tobii__slider--is-draggable"))&&I[C].slider.classList.add("tobii__slider--is-draggable"),!l.nav||1===I[C].elementsLength||"auto"===l.nav&&be()?(p.setAttribute("aria-hidden","true"),p.disabled=!0,h.setAttribute("aria-hidden","true"),h.disabled=!0):(p.setAttribute("aria-hidden","false"),p.disabled=!1,h.setAttribute("aria-hidden","false"),h.disabled=!1),g.setAttribute("aria-hidden",l.counter&&1!==I[C].elementsLength?"false":"true")},le=e=>{V(),g.textContent=`${I[C].currentIndex+1}/${I[C].elementsLength}`,(e=>{(!0===l.nav||"auto"===l.nav)&&!be()&&I[C].elementsLength>1?(p.setAttribute("aria-hidden","true"),p.disabled=!0,h.setAttribute("aria-hidden","true"),h.disabled=!0,1===I[C].elementsLength?l.close&&m.focus():0===I[C].currentIndex?(h.setAttribute("aria-hidden","false"),h.disabled=!1,h.focus()):I[C].currentIndex===I[C].elementsLength-1?(p.setAttribute("aria-hidden","false"),p.disabled=!1,p.focus()):(p.setAttribute("aria-hidden","false"),p.disabled=!1,h.setAttribute("aria-hidden","false"),h.disabled=!1,"left"===e?p.focus():h.focus())):l.close&&m.focus()})(e)},ue=()=>{ce()&&X(),Object.entries(I).forEach(e=>{e[1].gallery.forEach(e=>{Y(e)})}),I={},S=C=null;for(const e in o)o[e].onReset()},ce=()=>"false"===b.getAttribute("aria-hidden"),be=()=>"ontouchstart"in window,pe=e=>-1!==["TEXTAREA","OPTION","INPUT","SELECT"].indexOf(e.nodeName)||e===p||e===h||e===m;return(t=>{if(document.querySelector("div.tobii"))return void console.log("Multiple lightbox instances not supported.");l=(t=>e({},{selector:".lightbox",captions:!0,captionsSelector:"img",captionAttribute:"alt",captionText:null,nav:"auto",navText:['<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="15 6 9 12 15 18" /></svg>','<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="9 6 15 12 9 18" /></svg>'],navLabel:["Previous image","Next image"],close:!0,closeText:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><line x1="18" y1="6" x2="6" y2="18" /><line x1="6" y1="6" x2="18" y2="18" /></svg>',closeLabel:"Close lightbox",loadingIndicatorLabel:"Image loading",counter:!0,download:!1,downloadText:"",downloadLabel:"Download image",keyboard:!0,zoom:!0,zoomText:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="16 4 20 4 20 8" /><line x1="14" y1="10" x2="20" y2="4" /><polyline points="8 20 4 20 4 16" /><line x1="4" y1="20" x2="10" y2="14" /><polyline points="16 20 20 20 20 16" /><line x1="14" y1="14" x2="20" y2="20" /><polyline points="8 4 4 4 4 8" /><line x1="4" y1="4" x2="10" y2="10" /></svg>',docClose:!0,swipeClose:!0,hideScrollbar:!0,draggable:!0,threshold:100,rtl:!1,loop:!1,autoplayVideo:!1,modal:!1,theme:"tobii--theme-default"},t))(t),b||(b=document.createElement("div"),b.setAttribute("role","dialog"),b.setAttribute("aria-hidden","true"),b.classList.add("tobii"),b.classList.add(l.theme),p=document.createElement("button"),p.className="tobii__btn tobii__btn--previous",p.setAttribute("type","button"),p.setAttribute("aria-label",l.navLabel[0]),p.innerHTML=l.navText[0],b.appendChild(p),h=document.createElement("button"),h.className="tobii__btn tobii__btn--next",h.setAttribute("type","button"),h.setAttribute("aria-label",l.navLabel[1]),h.innerHTML=l.navText[1],b.appendChild(h),m=document.createElement("button"),m.className="tobii__btn tobii__btn--close",m.setAttribute("type","button"),m.setAttribute("aria-label",l.closeLabel),m.innerHTML=l.closeText,b.appendChild(m),g=document.createElement("div"),g.className="tobii__counter",b.appendChild(g),document.body.appendChild(b));const i=document.querySelectorAll(l.selector);if(!i)throw new Error(`Ups, I can't find the selector ${l.selector} on this website.`);const r=[];i.forEach(e=>{const t=e.hasAttribute("data-group")?e.getAttribute("data-group"):"default";let i=e.href;e.hasAttribute("data-target")&&(i=e.getAttribute("data-target")),i+="__"+t,void 0!==r[i]?e.addEventListener("click",e=>{H(t),U(),e.preventDefault()}):(r[i]=1,T(e))})})(s),a.open=U,a.previous=R,a.next=M,a.close=X,a.add=T,a.remove=Y,a.reset=ue,a.destroy=()=>{ue(),b.parentNode.removeChild(b)},a.isOpen=ce,a.slidesIndex=()=>I[C].currentIndex,a.select=e=>{const t=I[C].currentIndex;if(!ce())throw new Error("Ups, I'm closed.");if(ce()){if(!e&&0!==e)throw new Error("Ups, no slide specified.");if(e===I[C].currentIndex)throw new Error(`Ups, slide ${e} is already selected.`);if(-1===e||e>=I[C].elementsLength)throw new Error(`Ups, I can't find slide ${e}.`)}I[C].currentIndex=e,D(t),z(e),e<t&&(le("left"),B(t),$(e-1)),e>t&&(le("right"),B(t),$(e+1))},a.slidesCount=()=>I[C].elementsLength,a.selectGroup=H,a.currentGroup=()=>null!==C?C:S,a.on=(e,t)=>{b.addEventListener(e,t)},a.off=(e,t)=>{b.removeEventListener(e,t)},a}export{a as default}; | ||
function e(){return e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e},e.apply(this,arguments)}class t{constructor(){this.figcaptionId=0,this.userSettings=null}init(e,t,i){this.userSettings=i;const r=document.createElement("figure"),n=document.createElement("figcaption"),a=document.createElement("img"),s=e.querySelector("img"),o=document.createElement("div");if(r.style.opacity="0",s&&(a.alt=s.alt||""),a.setAttribute("src",""),a.setAttribute("data-src",e.href),e.hasAttribute("data-srcset")&&a.setAttribute("data-srcset",e.getAttribute("data-srcset")),r.appendChild(a),this.userSettings.captions){let t;"function"==typeof this.userSettings.captionText?t=this.userSettings.captionText(e):"self"===this.userSettings.captionsSelector&&e.getAttribute(this.userSettings.captionAttribute)?t=e.getAttribute(this.userSettings.captionAttribute):"img"===this.userSettings.captionsSelector&&s&&s.getAttribute(this.userSettings.captionAttribute)&&(t=s.getAttribute(this.userSettings.captionAttribute)),this.userSettings.captionHTML?n.innerHTML=t:n.textContent=t,t&&(n.id=`tobii-figcaption-${this.figcaptionId}`,r.appendChild(n),a.setAttribute("aria-labelledby",n.id),++this.figcaptionId)}t.appendChild(r),o.className="tobii__loader",o.setAttribute("role","progressbar"),o.setAttribute("aria-label",this.userSettings.loadingIndicatorLabel),t.appendChild(o),t.setAttribute("data-type","image"),t.classList.add("tobii-image")}onPreload(e){this.onLoad(e)}onLoad(e){const t=e.querySelector("img");if(!t.hasAttribute("data-src"))return;const i=e.querySelector("figure"),r=e.querySelector(".tobii__loader");t.addEventListener("load",()=>{e.removeChild(r),i.style.opacity="1"}),t.addEventListener("error",()=>{e.removeChild(r),i.style.opacity="1"}),t.setAttribute("src",t.getAttribute("data-src")),t.removeAttribute("data-src"),t.hasAttribute("data-srcset")&&t.setAttribute("srcset",t.getAttribute("data-srcset"))}onLeave(e){}onCleanup(e){}onReset(){this.figcaptionId=0}}class i{constructor(){this.userSettings=null}init(e,t,i){this.userSettings=i;const r=e.hasAttribute("data-target")?e.getAttribute("data-target"):e.getAttribute("href");t.setAttribute("data-HREF",r),e.getAttribute("data-allow")&&t.setAttribute("data-allow",e.getAttribute("data-allow")),e.hasAttribute("data-width")&&t.setAttribute("data-width",`${e.getAttribute("data-width")}`),e.hasAttribute("data-height")&&t.setAttribute("data-height",`${e.getAttribute("data-height")}`),t.setAttribute("data-type","iframe"),t.classList.add("tobii-iframe")}onPreload(e){}onLoad(e){let t=e.querySelector("iframe");const i=document.createElement("div");if(i.className="tobii__loader",i.setAttribute("role","progressbar"),i.setAttribute("aria-label",this.userSettings.loadingIndicatorLabel),e.appendChild(i),null==t){t=document.createElement("iframe");const i=e.getAttribute("data-href");t.setAttribute("frameborder","0"),t.setAttribute("src",i),t.setAttribute("allowfullscreen",""),i.indexOf("youtube.com")>-1?t.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"):i.indexOf("vimeo.com")>-1?t.setAttribute("allow","autoplay; picture-in-picture"):e.hasAttribute("data-allow")&&t.setAttribute("allow",e.getAttribute("data-allow")),e.getAttribute("data-width")&&(t.style.maxWidth=`${e.getAttribute("data-width")}`),e.getAttribute("data-height")&&(t.style.maxHeight=`${e.getAttribute("data-height")}`),t.style.opacity="0",e.appendChild(t),t.addEventListener("load",()=>{t.style.opacity="1";const i=e.querySelector(".tobii__loader");i&&e.removeChild(i)}),t.addEventListener("error",()=>{t.style.opacity="1";const i=e.querySelector(".tobii__loader");i&&e.removeChild(i)})}else t.setAttribute("src",e.getAttribute("data-href"))}onLeave(e){}onCleanup(e){const t=e.querySelector("iframe");t.setAttribute("src",""),t.style.opacity="0"}onReset(){}}class r{constructor(){this.userSettings=null}init(e,t,i){this.userSettings=i;const r=e.hasAttribute("data-target")?e.getAttribute("data-target"):e.getAttribute("href"),n=document.querySelector(r).cloneNode(!0);if(!n)throw new Error(`Ups, I can't find the target ${r}.`);t.appendChild(n),t.setAttribute("data-type","html"),t.classList.add("tobii-html")}onPreload(e){}onLoad(e,t){const i=e.querySelector("video");i&&(i.hasAttribute("data-time")&&i.readyState>0&&(i.currentTime=i.getAttribute("data-time")),this.userSettings.autoplayVideo&&i.play());const r=e.querySelector("audio");r&&this.userSettings.autoplayAudio&&r.play(),e.classList.add("tobii-group-"+t)}onLeave(e){const t=e.querySelector("video");t&&(t.paused||t.pause(),t.readyState>0&&t.setAttribute("data-time",t.currentTime));const i=e.querySelector("audio");i&&(i.paused||i.pause())}onCleanup(e){const t=e.querySelector("video");if(t&&t.readyState>0&&t.readyState<3&&t.duration!==t.currentTime){const i=t.cloneNode(!0);this._removeSources(t),t.load(),t.parentNode.removeChild(t),e.appendChild(i)}}onReset(){}_removeSources(e){const t=e.querySelectorAll("src");t&&t.forEach(e=>{e.setAttribute("src","")})}}class n{constructor(){this.playerId=0,this.PLAYER=[],this.userSettings=null}init(e,t,i){this.userSettings=i;const r=document.createElement("div");t.appendChild(r),this.PLAYER[this.playerId]=new window.YT.Player(r,{host:"https://www.youtube-nocookie.com",height:e.getAttribute("data-height")||"360",width:e.getAttribute("data-width")||"640",videoId:e.getAttribute("data-id"),playerVars:{controls:e.getAttribute("data-controls")||1,rel:0,playsinline:1}}),t.setAttribute("data-player",this.playerId),t.setAttribute("data-type","youtube"),t.classList.add("tobii-youtube"),this.playerId++}onPreload(e){}onLoad(e){this.userSettings.autoplayVideo&&this.PLAYER[e.getAttribute("data-player")].playVideo()}onLeave(e){1===this.PLAYER[e.getAttribute("data-player")].getPlayerState()&&this.PLAYER[e.getAttribute("data-player")].pauseVideo()}onCleanup(e){1===this.PLAYER[e.getAttribute("data-player")].getPlayerState()&&this.PLAYER[e.getAttribute("data-player")].pauseVideo()}onReset(){}}function a(s){const o={image:new t,html:new r,iframe:new i,youtube:new n},d=['a[href]:not([tabindex^="-"]):not([inert])','area[href]:not([tabindex^="-"]):not([inert])',"input:not([disabled]):not([inert])","select:not([disabled]):not([inert])","textarea:not([disabled]):not([inert])","button:not([disabled]):not([inert])",'iframe:not([tabindex^="-"]):not([inert])','audio:not([tabindex^="-"]):not([inert])','video:not([tabindex^="-"]):not([inert])','[contenteditable]:not([tabindex^="-"]):not([inert])','[tabindex]:not([tabindex^="-"]):not([inert])'];let l={};const u=[],c={gallery:[],slider:null,sliderElements:[],elementsLength:0,currentIndex:0,x:0};let p=null,b=null,h=null,g=null,m=null,y={},v=!1,f=!1,w=!1,A=null,E=null,L=null,x=!1,_=!1,S={},I=null,C=null;const T=e=>{if(null===document.querySelector('[data-type="youtube"]')||_)q(e);else{if(null===document.getElementById("iframe_api")){const e=document.createElement("script"),t=document.getElementsByTagName("script")[0];e.id="iframe_api",e.src="https://www.youtube.com/iframe_api",t.parentNode.insertBefore(e,t)}-1===u.indexOf(e)&&u.push(e),window.onYouTubePlayerAPIReady=()=>{u.forEach(e=>{q(e)}),_=!0}}},P=e=>e.hasAttribute("data-group")?e.getAttribute("data-group"):"default",q=e=>{if(I=P(e),Object.prototype.hasOwnProperty.call(S,I)||(S[I]=JSON.parse(JSON.stringify(c)),N()),-1!==S[I].gallery.indexOf(e))throw new Error("Ups, element already added.");if(S[I].gallery.push(e),S[I].elementsLength++,l.zoom&&e.querySelector("img")&&"false"!==e.getAttribute("data-zoom")||"true"===e.getAttribute("data-zoom")){const t=document.createElement("div");t.className="tobii-zoom__icon",t.innerHTML=l.zoomText,e.classList.add("tobii-zoom"),e.appendChild(t)}e.addEventListener("click",G),O(e),ce()&&I===C&&(de(),le())},Y=e=>{const t=P(e);if(-1===S[t].gallery.indexOf(e))throw new Error(`Ups, I can't find a slide for the element ${e}.`);{const i=S[t].gallery.indexOf(e),r=S[t].sliderElements[i];if(ce()&&t===C&&i===S[t].currentIndex){if(1===S[t].elementsLength)throw X(),new Error("Ups, I've closed. There are no slides more to show.");0===S[t].currentIndex?R():M(),de(),le()}if(S[t].gallery.splice(S[t].gallery.indexOf(e)),S[t].sliderElements.splice(S[t].gallery.indexOf(e)),S[t].elementsLength--,--S[t].x,l.zoom&&e.querySelector(".tobii-zoom__icon")){const t=e.querySelector(".tobii-zoom__icon");t.parentNode.classList.remove("tobii-zoom"),t.parentNode.removeChild(t)}e.removeEventListener("click",G),r.parentNode.removeChild(r)}},N=()=>{S[I].slider=document.createElement("div"),S[I].slider.className="tobii__slider",S[I].slider.setAttribute("aria-hidden","true"),p.appendChild(S[I].slider)},O=e=>{const t=k(e),i=document.createElement("div"),r=document.createElement("div");i.className="tobii__slide",i.style.position="absolute",i.style.left=100*S[I].x+"%",i.setAttribute("aria-hidden","true"),t.init(e,r,l),i.appendChild(r),S[I].slider.appendChild(i),S[I].sliderElements.push(i),++S[I].x},k=e=>{const t=e.getAttribute("data-type");return void 0!==o[t]?o[t]:(e.hasAttribute("data-type")&&console.log("Unknown lightbox element type: "+t),o.image)},U=e=>{if(C=null!==C?C:I,ce())throw new Error("Ups, I'm aleady open.");if(!ce()&&(e||(e=0),-1===e||e>=S[C].elementsLength))throw new Error(`Ups, I can't find slide ${e}.`);document.documentElement.classList.add("tobii-is-open"),document.body.classList.add("tobii-is-open"),document.body.classList.add("tobii-is-open-"+C),de(),l.close||(g.disabled=!1,g.setAttribute("aria-hidden","true")),A=document.activeElement;const t=window.location.href;window.history.pushState({tobii:"close"},"Image",t),S[C].currentIndex=e,j(),se(),z(S[C].currentIndex),S[C].slider.setAttribute("aria-hidden","false"),p.setAttribute("aria-hidden","false"),le(),$(S[C].currentIndex+1),$(S[C].currentIndex-1),S[C].slider.classList.add("tobii__slider--animate");const i=new window.CustomEvent("open",{detail:{group:C}});p.dispatchEvent(i)},X=()=>{if(!ce())throw new Error("Ups, I'm already closed.");document.documentElement.classList.remove("tobii-is-open"),document.body.classList.remove("tobii-is-open"),document.body.classList.remove("tobii-is-open-"+C),oe(),null!==window.history.state&&"close"===window.history.state.tobii&&window.history.back(),A.focus(),D(S[C].currentIndex),B(S[C].currentIndex),p.setAttribute("aria-hidden","true"),S[C].slider.setAttribute("aria-hidden","true"),S[C].currentIndex=0,S[C].slider.classList.remove("tobii__slider--animate");const e=new window.CustomEvent("close",{detail:{group:C}});p.dispatchEvent(e)},$=e=>{if(void 0===S[C].sliderElements[e])return;const t=S[C].sliderElements[e].querySelector("[data-type]");k(t).onPreload(t)},z=e=>{if(void 0===S[C].sliderElements[e])return;const t=S[C].sliderElements[e].querySelector("[data-type]"),i=k(t);S[C].sliderElements[e].classList.add("tobii__slide--is-active"),S[C].sliderElements[e].setAttribute("aria-hidden","false"),i.onLoad(t,C)},M=()=>{if(!ce())throw new Error("Ups, I'm closed.");S[C].currentIndex>0&&(D(S[C].currentIndex),z(--S[C].currentIndex),le("left"),B(S[C].currentIndex+1),$(S[C].currentIndex-1));const e=new window.CustomEvent("previous",{detail:{group:C}});p.dispatchEvent(e)},R=()=>{if(!ce())throw new Error("Ups, I'm closed.");S[C].currentIndex<S[C].elementsLength-1&&(D(S[C].currentIndex),z(++S[C].currentIndex),le("right"),B(S[C].currentIndex-1),$(S[C].currentIndex+1));const e=new window.CustomEvent("next",{detail:{group:C}});p.dispatchEvent(e)},H=e=>{if(ce())throw new Error("Ups, I'm open.");if(!e)throw new Error("Ups, no group specified.");if(e&&!Object.prototype.hasOwnProperty.call(S,e))throw new Error(`Ups, I don't have a group called "${e}".`);C=e},D=e=>{if(void 0===S[C].sliderElements[e])return;const t=S[C].sliderElements[e].querySelector("[data-type]"),i=k(t);S[C].sliderElements[e].classList.remove("tobii__slide--is-active"),S[C].sliderElements[e].setAttribute("aria-hidden","true"),i.onLeave(t)},B=e=>{if(void 0===S[C].sliderElements[e])return;const t=S[C].sliderElements[e].querySelector("[data-type]");k(t).onCleanup(t)},V=()=>{C=null!==C?C:I,E=-S[C].currentIndex*p.offsetWidth,S[C].slider.style.transform=`translate3d(${E}px, 0, 0)`,L=E},j=()=>{y={startX:0,endX:0,startY:0,endY:0}},W=()=>{const e=y.endX-y.startX,t=y.endY-y.startY,i=Math.abs(e),r=Math.abs(t);e>0&&i>l.threshold&&S[C].currentIndex>0?M():e<0&&i>l.threshold&&S[C].currentIndex!==S[C].elementsLength-1?R():t<0&&r>l.threshold&&l.swipeClose?X():V()},F=()=>{x||(x=!0,window.requestAnimationFrame(()=>{V(),x=!1}))},G=e=>{e.preventDefault(),C=P(e.currentTarget),U(S[C].gallery.indexOf(e.currentTarget))},J=e=>{e.target===b?M():e.target===h?R():(e.target===g||!1===v&&!1===f&&e.target.classList.contains("tobii__slide")&&l.docClose)&&X(),e.stopPropagation()},K=e=>{const t=Array.prototype.slice.call(p.querySelectorAll(`.tobii__btn:not([disabled]), .tobii__slide--is-active ${d.join(", .tobii__slide--is-active ")}`)).filter(e=>!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)),i=t.indexOf(document.activeElement);9===e.keyCode||"Tab"===e.code?e.shiftKey&&0===i?(t[t.length-1].focus(),e.preventDefault()):e.shiftKey||i!==t.length-1||(t[0].focus(),e.preventDefault()):27===e.keyCode||"Escape"===e.code?(e.preventDefault(),X()):37===e.keyCode||"ArrowLeft"===e.code?(e.preventDefault(),M()):39!==e.keyCode&&"ArrowRight"!==e.code||(e.preventDefault(),R())},Q=e=>{be(e.target)||(e.stopPropagation(),v=!1,f=!1,w=!0,y.startX=e.touches[0].pageX,y.startY=e.touches[0].pageY,pe()&&S[C].slider.classList.add("tobii__slider--is-dragging"))},Z=e=>{e.stopPropagation(),w&&(y.endX=e.touches[0].pageX,y.endY=e.touches[0].pageY,ae())},ee=e=>{e.stopPropagation(),w=!1,S[C].slider.classList.remove("tobii__slider--is-dragging"),y.endX&&W(),j()},te=e=>{be(e.target)||(e.preventDefault(),e.stopPropagation(),v=!1,f=!1,w=!0,y.startX=e.pageX,y.startY=e.pageY,pe()&&S[C].slider.classList.add("tobii__slider--is-dragging"))},ie=e=>{e.preventDefault(),w&&(y.endX=e.pageX,y.endY=e.pageY,ae())},re=e=>{e.stopPropagation(),w=!1,S[C].slider.classList.remove("tobii__slider--is-dragging"),y.endX&&W(),j()},ne=()=>{w=!1},ae=()=>{Math.abs(y.startX-y.endX)>0&&!f&&S[C].elementsLength>1?(S[C].slider.style.transform=`translate3d(${L-Math.round(y.startX-y.endX)}px, 0, 0)`,v=!0,f=!1):Math.abs(y.startY-y.endY)>0&&!v&&l.swipeClose&&(S[C].slider.style.transform=`translate3d(${L}px, -${Math.round(y.startY-y.endY)}px, 0)`,v=!1,f=!0)},se=()=>{l.keyboard&&window.addEventListener("keydown",K),window.addEventListener("resize",F),window.addEventListener("popstate",X),p.addEventListener("click",J),l.draggable&&pe()&&(p.addEventListener("touchstart",Q),p.addEventListener("touchmove",Z),p.addEventListener("touchend",ee),p.addEventListener("mousedown",te),p.addEventListener("mouseup",re),p.addEventListener("mousemove",ie),p.addEventListener("contextmenu",ne))},oe=()=>{l.keyboard&&window.removeEventListener("keydown",K),window.removeEventListener("resize",F),window.removeEventListener("popstate",X),p.removeEventListener("click",J),l.draggable&&pe()&&(p.removeEventListener("touchstart",Q),p.removeEventListener("touchmove",Z),p.removeEventListener("touchend",ee),p.removeEventListener("mousedown",te),p.removeEventListener("mouseup",re),p.removeEventListener("mousemove",ie),p.removeEventListener("contextmenu",ne))},de=()=>{(l.draggable&&l.swipeClose&&pe()&&!S[C].slider.classList.contains("tobii__slider--is-draggable")||l.draggable&&S[C].elementsLength>1&&!S[C].slider.classList.contains("tobii__slider--is-draggable"))&&S[C].slider.classList.add("tobii__slider--is-draggable"),!l.nav||1===S[C].elementsLength||"auto"===l.nav&&pe()?(b.setAttribute("aria-hidden","true"),b.disabled=!0,h.setAttribute("aria-hidden","true"),h.disabled=!0):(b.setAttribute("aria-hidden","false"),b.disabled=!1,h.setAttribute("aria-hidden","false"),h.disabled=!1),m.setAttribute("aria-hidden",l.counter&&1!==S[C].elementsLength?"false":"true")},le=(e=null)=>{V(),m.textContent=`${S[C].currentIndex+1}/${S[C].elementsLength}`,(e=>{(!0===l.nav||"auto"===l.nav)&&!pe()&&S[C].elementsLength>1?(b.setAttribute("aria-hidden","true"),b.disabled=!0,h.setAttribute("aria-hidden","true"),h.disabled=!0,1===S[C].elementsLength?l.close&&g.focus():0===S[C].currentIndex?(h.setAttribute("aria-hidden","false"),h.disabled=!1,h.focus()):S[C].currentIndex===S[C].elementsLength-1?(b.setAttribute("aria-hidden","false"),b.disabled=!1,b.focus()):(b.setAttribute("aria-hidden","false"),b.disabled=!1,h.setAttribute("aria-hidden","false"),h.disabled=!1,"left"===e?b.focus():h.focus())):l.close&&g.focus()})(e)},ue=()=>{ce()&&X(),Object.entries(S).forEach(e=>{e[1].gallery.forEach(e=>{Y(e)})}),S={},I=C=null;for(const e in o)o[e].onReset()},ce=()=>"false"===p.getAttribute("aria-hidden"),pe=()=>"ontouchstart"in window,be=e=>-1!==["TEXTAREA","OPTION","INPUT","SELECT"].indexOf(e.nodeName)||e===b||e===h||e===g;return(t=>{if(document.querySelector("div.tobii"))return void console.log("Multiple lightbox instances not supported.");l=(t=>e({},{selector:".lightbox",captions:!0,captionsSelector:"img",captionAttribute:"alt",captionText:null,captionHTML:!1,nav:"auto",navText:['<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="15 6 9 12 15 18" /></svg>','<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="9 6 15 12 9 18" /></svg>'],navLabel:["Previous image","Next image"],close:!0,closeText:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><line x1="18" y1="6" x2="6" y2="18" /><line x1="6" y1="6" x2="18" y2="18" /></svg>',closeLabel:"Close lightbox",loadingIndicatorLabel:"Image loading",counter:!0,download:!1,downloadText:"",downloadLabel:"Download image",keyboard:!0,zoom:!0,zoomText:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="16 4 20 4 20 8" /><line x1="14" y1="10" x2="20" y2="4" /><polyline points="8 20 4 20 4 16" /><line x1="4" y1="20" x2="10" y2="14" /><polyline points="16 20 20 20 20 16" /><line x1="14" y1="14" x2="20" y2="20" /><polyline points="8 4 4 4 4 8" /><line x1="4" y1="4" x2="10" y2="10" /></svg>',docClose:!0,swipeClose:!0,hideScrollbar:!0,draggable:!0,threshold:100,rtl:!1,loop:!1,autoplayVideo:!1,modal:!1,theme:"tobii--theme-default"},t))(t),p||(p=document.createElement("div"),p.setAttribute("role","dialog"),p.setAttribute("aria-hidden","true"),p.classList.add("tobii"),p.classList.add(l.theme),b=document.createElement("button"),b.className="tobii__btn tobii__btn--previous",b.setAttribute("type","button"),b.setAttribute("aria-label",l.navLabel[0]),b.innerHTML=l.navText[0],p.appendChild(b),h=document.createElement("button"),h.className="tobii__btn tobii__btn--next",h.setAttribute("type","button"),h.setAttribute("aria-label",l.navLabel[1]),h.innerHTML=l.navText[1],p.appendChild(h),g=document.createElement("button"),g.className="tobii__btn tobii__btn--close",g.setAttribute("type","button"),g.setAttribute("aria-label",l.closeLabel),g.innerHTML=l.closeText,p.appendChild(g),m=document.createElement("div"),m.className="tobii__counter",p.appendChild(m),document.body.appendChild(p));const i=document.querySelectorAll(l.selector);if(!i)throw new Error(`Ups, I can't find the selector ${l.selector} on this website.`);const r=[];i.forEach(e=>{const t=e.hasAttribute("data-group")?e.getAttribute("data-group"):"default";let i=e.href;e.hasAttribute("data-target")&&(i=e.getAttribute("data-target")),i+="__"+t,void 0!==r[i]?e.addEventListener("click",e=>{H(t),U(),e.preventDefault()}):(r[i]=1,T(e))})})(s),a.open=U,a.previous=M,a.next=R,a.close=X,a.add=T,a.remove=Y,a.reset=ue,a.destroy=()=>{ue(),p.parentNode.removeChild(p)},a.isOpen=ce,a.slidesIndex=()=>S[C].currentIndex,a.select=e=>{const t=S[C].currentIndex;if(!ce())throw new Error("Ups, I'm closed.");if(ce()){if(!e&&0!==e)throw new Error("Ups, no slide specified.");if(e===S[C].currentIndex)throw new Error(`Ups, slide ${e} is already selected.`);if(-1===e||e>=S[C].elementsLength)throw new Error(`Ups, I can't find slide ${e}.`)}S[C].currentIndex=e,D(t),z(e),e<t&&(le("left"),B(t),$(e-1)),e>t&&(le("right"),B(t),$(e+1))},a.slidesCount=()=>S[C].elementsLength,a.selectGroup=H,a.currentGroup=()=>null!==C?C:I,a.on=(e,t)=>{p.addEventListener(e,t)},a.off=(e,t)=>{p.removeEventListener(e,t)},a}export{a as default}; |
@@ -1,1 +0,1 @@ | ||
class e{constructor(){this.figcaptionId=0,this.userSettings=null}init(e,t,i){this.userSettings=i;const r=document.createElement("figure"),n=document.createElement("figcaption"),a=document.createElement("img"),s=e.querySelector("img"),o=document.createElement("div");r.style.opacity="0",s&&(a.alt=s.alt||""),a.setAttribute("src",""),a.setAttribute("data-src",e.href),e.hasAttribute("data-srcset")&&a.setAttribute("data-srcset",e.getAttribute("data-srcset")),r.appendChild(a),this.userSettings.captions&&("function"==typeof this.userSettings.captionText?n.textContent=this.userSettings.captionText(e):"self"===this.userSettings.captionsSelector&&e.getAttribute(this.userSettings.captionAttribute)?n.textContent=e.getAttribute(this.userSettings.captionAttribute):"img"===this.userSettings.captionsSelector&&s&&s.getAttribute(this.userSettings.captionAttribute)&&(n.textContent=s.getAttribute(this.userSettings.captionAttribute)),n.textContent&&(n.id=`tobii-figcaption-${this.figcaptionId}`,r.appendChild(n),a.setAttribute("aria-labelledby",n.id),++this.figcaptionId)),t.appendChild(r),o.className="tobii__loader",o.setAttribute("role","progressbar"),o.setAttribute("aria-label",this.userSettings.loadingIndicatorLabel),t.appendChild(o),t.setAttribute("data-type","image"),t.classList.add("tobii-image")}onPreload(e){this.onLoad(e)}onLoad(e){const t=e.querySelector("img");if(!t.hasAttribute("data-src"))return;const i=e.querySelector("figure"),r=e.querySelector(".tobii__loader");t.addEventListener("load",()=>{e.removeChild(r),i.style.opacity="1"}),t.addEventListener("error",()=>{e.removeChild(r),i.style.opacity="1"}),t.setAttribute("src",t.getAttribute("data-src")),t.removeAttribute("data-src"),t.hasAttribute("data-srcset")&&t.setAttribute("srcset",t.getAttribute("data-srcset"))}onLeave(e){}onCleanup(e){}onReset(){this.figcaptionId=0}}class t{constructor(){this.userSettings=null}init(e,t,i){this.userSettings=i;const r=e.hasAttribute("data-target")?e.getAttribute("data-target"):e.getAttribute("href");t.setAttribute("data-HREF",r),e.getAttribute("data-allow")&&t.setAttribute("data-allow",e.getAttribute("data-allow")),e.hasAttribute("data-width")&&t.setAttribute("data-width",`${e.getAttribute("data-width")}`),e.hasAttribute("data-height")&&t.setAttribute("data-height",`${e.getAttribute("data-height")}`),t.setAttribute("data-type","iframe"),t.classList.add("tobii-iframe")}onPreload(e){}onLoad(e){let t=e.querySelector("iframe");const i=document.createElement("div");if(i.className="tobii__loader",i.setAttribute("role","progressbar"),i.setAttribute("aria-label",this.userSettings.loadingIndicatorLabel),e.appendChild(i),null==t){t=document.createElement("iframe");const i=e.getAttribute("data-href");t.setAttribute("frameborder","0"),t.setAttribute("src",i),t.setAttribute("allowfullscreen",""),i.indexOf("youtube.com")>-1?t.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"):i.indexOf("vimeo.com")>-1?t.setAttribute("allow","autoplay; picture-in-picture"):e.hasAttribute("data-allow")&&t.setAttribute("allow",e.getAttribute("data-allow")),e.getAttribute("data-width")&&(t.style.maxWidth=`${e.getAttribute("data-width")}`),e.getAttribute("data-height")&&(t.style.maxHeight=`${e.getAttribute("data-height")}`),t.style.opacity="0",e.appendChild(t),t.addEventListener("load",()=>{t.style.opacity="1";const i=e.querySelector(".tobii__loader");i&&e.removeChild(i)}),t.addEventListener("error",()=>{t.style.opacity="1";const i=e.querySelector(".tobii__loader");i&&e.removeChild(i)})}else t.setAttribute("src",e.getAttribute("data-href"))}onLeave(e){}onCleanup(e){const t=e.querySelector("iframe");t.setAttribute("src",""),t.style.opacity="0"}onReset(){}}class i{constructor(){this.userSettings=null}init(e,t,i){this.userSettings=i;const r=e.hasAttribute("data-target")?e.getAttribute("data-target"):e.getAttribute("href"),n=document.querySelector(r).cloneNode(!0);if(!n)throw new Error(`Ups, I can't find the target ${r}.`);t.appendChild(n),t.setAttribute("data-type","html"),t.classList.add("tobii-html")}onPreload(e){}onLoad(e){const t=e.querySelector("video");t&&(t.hasAttribute("data-time")&&t.readyState>0&&(t.currentTime=t.getAttribute("data-time")),this.userSettings.autoplayVideo&&t.play())}onLeave(e){const t=e.querySelector("video");t&&(t.paused||t.pause(),t.readyState>0&&t.setAttribute("data-time",t.currentTime))}onCleanup(e){const t=e.querySelector("video");if(t&&t.readyState>0&&t.readyState<3&&t.duration!==t.currentTime){const i=t.cloneNode(!0);this._removeSources(t),t.load(),t.parentNode.removeChild(t),e.appendChild(i)}}onReset(){}_removeSources(e){const t=e.querySelectorAll("src");t&&t.forEach(e=>{e.setAttribute("src","")})}}class r{constructor(){this.playerId=0,this.PLAYER=[],this.userSettings=null}init(e,t,i){this.userSettings=i;const r=document.createElement("div");t.appendChild(r),this.PLAYER[this.playerId]=new window.YT.Player(r,{host:"https://www.youtube-nocookie.com",height:e.getAttribute("data-height")||"360",width:e.getAttribute("data-width")||"640",videoId:e.getAttribute("data-id"),playerVars:{controls:e.getAttribute("data-controls")||1,rel:0,playsinline:1}}),t.setAttribute("data-player",this.playerId),t.setAttribute("data-type","youtube"),t.classList.add("tobii-youtube"),this.playerId++}onPreload(e){}onLoad(e){this.userSettings.autoplayVideo&&this.PLAYER[e.getAttribute("data-player")].playVideo()}onLeave(e){1===this.PLAYER[e.getAttribute("data-player")].getPlayerState()&&this.PLAYER[e.getAttribute("data-player")].pauseVideo()}onCleanup(e){1===this.PLAYER[e.getAttribute("data-player")].getPlayerState()&&this.PLAYER[e.getAttribute("data-player")].pauseVideo()}onReset(){}}function n(a){const s={image:new e,html:new i,iframe:new t,youtube:new r},o=['a[href]:not([tabindex^="-"]):not([inert])','area[href]:not([tabindex^="-"]):not([inert])',"input:not([disabled]):not([inert])","select:not([disabled]):not([inert])","textarea:not([disabled]):not([inert])","button:not([disabled]):not([inert])",'iframe:not([tabindex^="-"]):not([inert])','audio:not([tabindex^="-"]):not([inert])','video:not([tabindex^="-"]):not([inert])','[contenteditable]:not([tabindex^="-"]):not([inert])','[tabindex]:not([tabindex^="-"]):not([inert])'];let d={};const l=[],u={gallery:[],slider:null,sliderElements:[],elementsLength:0,currentIndex:0,x:0};let c=null,b=null,p=null,h=null,m=null,g={},y=!1,v=!1,f=!1,w=null,A=null,E=null,L=!1,x=!1,_={},I=null,S=null;const C=e=>{if(null===document.querySelector('[data-type="youtube"]')||x)P(e);else{if(null===document.getElementById("iframe_api")){const e=document.createElement("script"),t=document.getElementsByTagName("script")[0];e.id="iframe_api",e.src="https://www.youtube.com/iframe_api",t.parentNode.insertBefore(e,t)}-1===l.indexOf(e)&&l.push(e),window.onYouTubePlayerAPIReady=()=>{l.forEach(e=>{P(e)}),x=!0}}},T=e=>e.hasAttribute("data-group")?e.getAttribute("data-group"):"default",P=e=>{if(I=T(e),Object.prototype.hasOwnProperty.call(_,I)||(_[I]=JSON.parse(JSON.stringify(u)),Y()),-1!==_[I].gallery.indexOf(e))throw new Error("Ups, element already added.");if(_[I].gallery.push(e),_[I].elementsLength++,d.zoom&&e.querySelector("img")&&"false"!==e.getAttribute("data-zoom")||"true"===e.getAttribute("data-zoom")){const t=document.createElement("div");t.className="tobii-zoom__icon",t.innerHTML=d.zoomText,e.classList.add("tobii-zoom"),e.appendChild(t)}e.addEventListener("click",F),N(e),ue()&&I===S&&(oe(),de(null))},q=e=>{const t=T(e);if(-1===_[t].gallery.indexOf(e))throw new Error(`Ups, I can't find a slide for the element ${e}.`);{const i=_[t].gallery.indexOf(e),r=_[t].sliderElements[i];if(ue()&&t===S&&i===_[t].currentIndex){if(1===_[t].elementsLength)throw U(),new Error("Ups, I've closed. There are no slides more to show.");0===_[t].currentIndex?R():z()}if(_[t].elementsLength--,d.zoom&&e.querySelector(".tobii-zoom__icon")){const t=e.querySelector(".tobii-zoom__icon");t.parentNode.classList.remove("tobii-zoom"),t.parentNode.removeChild(t)}e.removeEventListener("click",F),r.parentNode.removeChild(r)}},Y=()=>{_[I].slider=document.createElement("div"),_[I].slider.className="tobii__slider",_[I].slider.setAttribute("aria-hidden","true"),c.appendChild(_[I].slider)},N=e=>{const t=k(e),i=document.createElement("div"),r=document.createElement("div");i.className="tobii__slide",i.style.position="absolute",i.style.left=100*_[I].x+"%",i.setAttribute("aria-hidden","true"),t.init(e,r,d),i.appendChild(r),_[I].slider.appendChild(i),_[I].sliderElements.push(i),++_[I].x},k=e=>{const t=e.getAttribute("data-type");return void 0!==s[t]?s[t]:(e.hasAttribute("data-type")&&console.log("Unknown lightbox element type: "+t),s.image)},O=e=>{if(S=null!==S?S:I,ue())throw new Error("Ups, I'm aleady open.");if(!ue()&&(e||(e=0),-1===e||e>=_[S].elementsLength))throw new Error(`Ups, I can't find slide ${e}.`);document.documentElement.classList.add("tobii-is-open"),document.body.classList.add("tobii-is-open"),document.body.classList.add("tobii-is-open-"+S),oe(),d.close||(h.disabled=!1,h.setAttribute("aria-hidden","true")),w=document.activeElement;const t=window.location.href;window.history.pushState({tobii:"close"},"Image",t),_[S].currentIndex=e,V(),ae(),$(_[S].currentIndex),_[S].slider.setAttribute("aria-hidden","false"),c.setAttribute("aria-hidden","false"),de(null),X(_[S].currentIndex+1),X(_[S].currentIndex-1),_[S].slider.classList.add("tobii__slider--animate");const i=new window.CustomEvent("open",{detail:{group:S}});c.dispatchEvent(i)},U=()=>{if(!ue())throw new Error("Ups, I'm already closed.");document.documentElement.classList.remove("tobii-is-open"),document.body.classList.remove("tobii-is-open"),document.body.classList.remove("tobii-is-open-"+S),se(),null!==window.history.state&&"close"===window.history.state.tobii&&window.history.back(),w.focus(),H(_[S].currentIndex),D(_[S].currentIndex),c.setAttribute("aria-hidden","true"),_[S].slider.setAttribute("aria-hidden","true"),_[S].currentIndex=0,_[S].slider.classList.remove("tobii__slider--animate");const e=new window.CustomEvent("close",{detail:{group:S}});c.dispatchEvent(e)},X=e=>{if(void 0===_[S].sliderElements[e])return;const t=_[S].sliderElements[e].querySelector("[data-type]");k(t).onPreload(t)},$=e=>{if(void 0===_[S].sliderElements[e])return;const t=_[S].sliderElements[e].querySelector("[data-type]"),i=k(t);_[S].sliderElements[e].classList.add("tobii__slide--is-active"),_[S].sliderElements[e].setAttribute("aria-hidden","false"),i.onLoad(t)},z=()=>{if(!ue())throw new Error("Ups, I'm closed.");_[S].currentIndex>0&&(H(_[S].currentIndex),$(--_[S].currentIndex),de("left"),D(_[S].currentIndex+1),X(_[S].currentIndex-1));const e=new window.CustomEvent("previous",{detail:{group:S}});c.dispatchEvent(e)},R=()=>{if(!ue())throw new Error("Ups, I'm closed.");_[S].currentIndex<_[S].elementsLength-1&&(H(_[S].currentIndex),$(++_[S].currentIndex),de("right"),D(_[S].currentIndex-1),X(_[S].currentIndex+1));const e=new window.CustomEvent("next",{detail:{group:S}});c.dispatchEvent(e)},M=e=>{if(ue())throw new Error("Ups, I'm open.");if(!e)throw new Error("Ups, no group specified.");if(e&&!Object.prototype.hasOwnProperty.call(_,e))throw new Error(`Ups, I don't have a group called "${e}".`);S=e},H=e=>{if(void 0===_[S].sliderElements[e])return;const t=_[S].sliderElements[e].querySelector("[data-type]"),i=k(t);_[S].sliderElements[e].classList.remove("tobii__slide--is-active"),_[S].sliderElements[e].setAttribute("aria-hidden","true"),i.onLeave(t)},D=e=>{if(void 0===_[S].sliderElements[e])return;const t=_[S].sliderElements[e].querySelector("[data-type]");k(t).onCleanup(t)},B=()=>{S=null!==S?S:I,A=-_[S].currentIndex*c.offsetWidth,_[S].slider.style.transform=`translate3d(${A}px, 0, 0)`,E=A},V=()=>{g={startX:0,endX:0,startY:0,endY:0}},j=()=>{const e=g.endX-g.startX,t=g.endY-g.startY,i=Math.abs(e),r=Math.abs(t);e>0&&i>d.threshold&&_[S].currentIndex>0?z():e<0&&i>d.threshold&&_[S].currentIndex!==_[S].elementsLength-1?R():t<0&&r>d.threshold&&d.swipeClose?U():B()},W=()=>{L||(L=!0,window.requestAnimationFrame(()=>{B(),L=!1}))},F=e=>{e.preventDefault(),S=T(e.currentTarget),O(_[S].gallery.indexOf(e.currentTarget))},G=e=>{e.target===b?z():e.target===p?R():(e.target===h||!1===y&&!1===v&&e.target.classList.contains("tobii__slide")&&d.docClose)&&U(),e.stopPropagation()},J=e=>{const t=Array.prototype.slice.call(c.querySelectorAll(`.tobii__btn:not([disabled]), .tobii__slide--is-active ${o.join(", .tobii__slide--is-active ")}`)).filter(e=>!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)),i=t.indexOf(document.activeElement);9===e.keyCode||"Tab"===e.code?e.shiftKey&&0===i?(t[t.length-1].focus(),e.preventDefault()):e.shiftKey||i!==t.length-1||(t[0].focus(),e.preventDefault()):27===e.keyCode||"Escape"===e.code?(e.preventDefault(),U()):37===e.keyCode||"ArrowLeft"===e.code?(e.preventDefault(),z()):39!==e.keyCode&&"ArrowRight"!==e.code||(e.preventDefault(),R())},K=e=>{be(e.target)||(e.stopPropagation(),y=!1,v=!1,f=!0,g.startX=e.touches[0].pageX,g.startY=e.touches[0].pageY,ce()&&_[S].slider.classList.add("tobii__slider--is-dragging"))},Q=e=>{e.stopPropagation(),f&&(g.endX=e.touches[0].pageX,g.endY=e.touches[0].pageY,ne())},Z=e=>{e.stopPropagation(),f=!1,_[S].slider.classList.remove("tobii__slider--is-dragging"),g.endX&&j(),V()},ee=e=>{be(e.target)||(e.preventDefault(),e.stopPropagation(),y=!1,v=!1,f=!0,g.startX=e.pageX,g.startY=e.pageY,ce()&&_[S].slider.classList.add("tobii__slider--is-dragging"))},te=e=>{e.preventDefault(),f&&(g.endX=e.pageX,g.endY=e.pageY,ne())},ie=e=>{e.stopPropagation(),f=!1,_[S].slider.classList.remove("tobii__slider--is-dragging"),g.endX&&j(),V()},re=()=>{f=!1},ne=()=>{Math.abs(g.startX-g.endX)>0&&!v&&_[S].elementsLength>1?(_[S].slider.style.transform=`translate3d(${E-Math.round(g.startX-g.endX)}px, 0, 0)`,y=!0,v=!1):Math.abs(g.startY-g.endY)>0&&!y&&d.swipeClose&&(_[S].slider.style.transform=`translate3d(${E}px, -${Math.round(g.startY-g.endY)}px, 0)`,y=!1,v=!0)},ae=()=>{d.keyboard&&window.addEventListener("keydown",J),window.addEventListener("resize",W),window.addEventListener("popstate",U),c.addEventListener("click",G),d.draggable&&ce()&&(c.addEventListener("touchstart",K),c.addEventListener("touchmove",Q),c.addEventListener("touchend",Z),c.addEventListener("mousedown",ee),c.addEventListener("mouseup",ie),c.addEventListener("mousemove",te),c.addEventListener("contextmenu",re))},se=()=>{d.keyboard&&window.removeEventListener("keydown",J),window.removeEventListener("resize",W),window.removeEventListener("popstate",U),c.removeEventListener("click",G),d.draggable&&ce()&&(c.removeEventListener("touchstart",K),c.removeEventListener("touchmove",Q),c.removeEventListener("touchend",Z),c.removeEventListener("mousedown",ee),c.removeEventListener("mouseup",ie),c.removeEventListener("mousemove",te),c.removeEventListener("contextmenu",re))},oe=()=>{(d.draggable&&d.swipeClose&&ce()&&!_[S].slider.classList.contains("tobii__slider--is-draggable")||d.draggable&&_[S].elementsLength>1&&!_[S].slider.classList.contains("tobii__slider--is-draggable"))&&_[S].slider.classList.add("tobii__slider--is-draggable"),!d.nav||1===_[S].elementsLength||"auto"===d.nav&&ce()?(b.setAttribute("aria-hidden","true"),b.disabled=!0,p.setAttribute("aria-hidden","true"),p.disabled=!0):(b.setAttribute("aria-hidden","false"),b.disabled=!1,p.setAttribute("aria-hidden","false"),p.disabled=!1),m.setAttribute("aria-hidden",d.counter&&1!==_[S].elementsLength?"false":"true")},de=e=>{B(),m.textContent=`${_[S].currentIndex+1}/${_[S].elementsLength}`,(e=>{(!0===d.nav||"auto"===d.nav)&&!ce()&&_[S].elementsLength>1?(b.setAttribute("aria-hidden","true"),b.disabled=!0,p.setAttribute("aria-hidden","true"),p.disabled=!0,1===_[S].elementsLength?d.close&&h.focus():0===_[S].currentIndex?(p.setAttribute("aria-hidden","false"),p.disabled=!1,p.focus()):_[S].currentIndex===_[S].elementsLength-1?(b.setAttribute("aria-hidden","false"),b.disabled=!1,b.focus()):(b.setAttribute("aria-hidden","false"),b.disabled=!1,p.setAttribute("aria-hidden","false"),p.disabled=!1,"left"===e?b.focus():p.focus())):d.close&&h.focus()})(e)},le=()=>{ue()&&U(),Object.entries(_).forEach(e=>{e[1].gallery.forEach(e=>{q(e)})}),_={},I=S=null;for(const e in s)s[e].onReset()},ue=()=>"false"===c.getAttribute("aria-hidden"),ce=()=>"ontouchstart"in window,be=e=>-1!==["TEXTAREA","OPTION","INPUT","SELECT"].indexOf(e.nodeName)||e===b||e===p||e===h;return(e=>{if(document.querySelector("div.tobii"))return void console.log("Multiple lightbox instances not supported.");d=(e=>({selector:".lightbox",captions:!0,captionsSelector:"img",captionAttribute:"alt",captionText:null,nav:"auto",navText:['<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="15 6 9 12 15 18" /></svg>','<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="9 6 15 12 9 18" /></svg>'],navLabel:["Previous image","Next image"],close:!0,closeText:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><line x1="18" y1="6" x2="6" y2="18" /><line x1="6" y1="6" x2="18" y2="18" /></svg>',closeLabel:"Close lightbox",loadingIndicatorLabel:"Image loading",counter:!0,download:!1,downloadText:"",downloadLabel:"Download image",keyboard:!0,zoom:!0,zoomText:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="16 4 20 4 20 8" /><line x1="14" y1="10" x2="20" y2="4" /><polyline points="8 20 4 20 4 16" /><line x1="4" y1="20" x2="10" y2="14" /><polyline points="16 20 20 20 20 16" /><line x1="14" y1="14" x2="20" y2="20" /><polyline points="8 4 4 4 4 8" /><line x1="4" y1="4" x2="10" y2="10" /></svg>',docClose:!0,swipeClose:!0,hideScrollbar:!0,draggable:!0,threshold:100,rtl:!1,loop:!1,autoplayVideo:!1,modal:!1,theme:"tobii--theme-default",...e}))(e),c||(c=document.createElement("div"),c.setAttribute("role","dialog"),c.setAttribute("aria-hidden","true"),c.classList.add("tobii"),c.classList.add(d.theme),b=document.createElement("button"),b.className="tobii__btn tobii__btn--previous",b.setAttribute("type","button"),b.setAttribute("aria-label",d.navLabel[0]),b.innerHTML=d.navText[0],c.appendChild(b),p=document.createElement("button"),p.className="tobii__btn tobii__btn--next",p.setAttribute("type","button"),p.setAttribute("aria-label",d.navLabel[1]),p.innerHTML=d.navText[1],c.appendChild(p),h=document.createElement("button"),h.className="tobii__btn tobii__btn--close",h.setAttribute("type","button"),h.setAttribute("aria-label",d.closeLabel),h.innerHTML=d.closeText,c.appendChild(h),m=document.createElement("div"),m.className="tobii__counter",c.appendChild(m),document.body.appendChild(c));const t=document.querySelectorAll(d.selector);if(!t)throw new Error(`Ups, I can't find the selector ${d.selector} on this website.`);const i=[];t.forEach(e=>{const t=e.hasAttribute("data-group")?e.getAttribute("data-group"):"default";let r=e.href;e.hasAttribute("data-target")&&(r=e.getAttribute("data-target")),r+="__"+t,void 0!==i[r]?e.addEventListener("click",e=>{M(t),O(),e.preventDefault()}):(i[r]=1,C(e))})})(a),n.open=O,n.previous=z,n.next=R,n.close=U,n.add=C,n.remove=q,n.reset=le,n.destroy=()=>{le(),c.parentNode.removeChild(c)},n.isOpen=ue,n.slidesIndex=()=>_[S].currentIndex,n.select=e=>{const t=_[S].currentIndex;if(!ue())throw new Error("Ups, I'm closed.");if(ue()){if(!e&&0!==e)throw new Error("Ups, no slide specified.");if(e===_[S].currentIndex)throw new Error(`Ups, slide ${e} is already selected.`);if(-1===e||e>=_[S].elementsLength)throw new Error(`Ups, I can't find slide ${e}.`)}_[S].currentIndex=e,H(t),$(e),e<t&&(de("left"),D(t),X(e-1)),e>t&&(de("right"),D(t),X(e+1))},n.slidesCount=()=>_[S].elementsLength,n.selectGroup=M,n.currentGroup=()=>null!==S?S:I,n.on=(e,t)=>{c.addEventListener(e,t)},n.off=(e,t)=>{c.removeEventListener(e,t)},n}export{n as default}; | ||
class e{constructor(){this.figcaptionId=0,this.userSettings=null}init(e,t,i){this.userSettings=i;const r=document.createElement("figure"),n=document.createElement("figcaption"),s=document.createElement("img"),a=e.querySelector("img"),o=document.createElement("div");if(r.style.opacity="0",a&&(s.alt=a.alt||""),s.setAttribute("src",""),s.setAttribute("data-src",e.href),e.hasAttribute("data-srcset")&&s.setAttribute("data-srcset",e.getAttribute("data-srcset")),r.appendChild(s),this.userSettings.captions){let t;"function"==typeof this.userSettings.captionText?t=this.userSettings.captionText(e):"self"===this.userSettings.captionsSelector&&e.getAttribute(this.userSettings.captionAttribute)?t=e.getAttribute(this.userSettings.captionAttribute):"img"===this.userSettings.captionsSelector&&a&&a.getAttribute(this.userSettings.captionAttribute)&&(t=a.getAttribute(this.userSettings.captionAttribute)),this.userSettings.captionHTML?n.innerHTML=t:n.textContent=t,t&&(n.id=`tobii-figcaption-${this.figcaptionId}`,r.appendChild(n),s.setAttribute("aria-labelledby",n.id),++this.figcaptionId)}t.appendChild(r),o.className="tobii__loader",o.setAttribute("role","progressbar"),o.setAttribute("aria-label",this.userSettings.loadingIndicatorLabel),t.appendChild(o),t.setAttribute("data-type","image"),t.classList.add("tobii-image")}onPreload(e){this.onLoad(e)}onLoad(e){const t=e.querySelector("img");if(!t.hasAttribute("data-src"))return;const i=e.querySelector("figure"),r=e.querySelector(".tobii__loader");t.addEventListener("load",()=>{e.removeChild(r),i.style.opacity="1"}),t.addEventListener("error",()=>{e.removeChild(r),i.style.opacity="1"}),t.setAttribute("src",t.getAttribute("data-src")),t.removeAttribute("data-src"),t.hasAttribute("data-srcset")&&t.setAttribute("srcset",t.getAttribute("data-srcset"))}onLeave(e){}onCleanup(e){}onReset(){this.figcaptionId=0}}class t{constructor(){this.userSettings=null}init(e,t,i){this.userSettings=i;const r=e.hasAttribute("data-target")?e.getAttribute("data-target"):e.getAttribute("href");t.setAttribute("data-HREF",r),e.getAttribute("data-allow")&&t.setAttribute("data-allow",e.getAttribute("data-allow")),e.hasAttribute("data-width")&&t.setAttribute("data-width",`${e.getAttribute("data-width")}`),e.hasAttribute("data-height")&&t.setAttribute("data-height",`${e.getAttribute("data-height")}`),t.setAttribute("data-type","iframe"),t.classList.add("tobii-iframe")}onPreload(e){}onLoad(e){let t=e.querySelector("iframe");const i=document.createElement("div");if(i.className="tobii__loader",i.setAttribute("role","progressbar"),i.setAttribute("aria-label",this.userSettings.loadingIndicatorLabel),e.appendChild(i),null==t){t=document.createElement("iframe");const i=e.getAttribute("data-href");t.setAttribute("frameborder","0"),t.setAttribute("src",i),t.setAttribute("allowfullscreen",""),i.indexOf("youtube.com")>-1?t.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"):i.indexOf("vimeo.com")>-1?t.setAttribute("allow","autoplay; picture-in-picture"):e.hasAttribute("data-allow")&&t.setAttribute("allow",e.getAttribute("data-allow")),e.getAttribute("data-width")&&(t.style.maxWidth=`${e.getAttribute("data-width")}`),e.getAttribute("data-height")&&(t.style.maxHeight=`${e.getAttribute("data-height")}`),t.style.opacity="0",e.appendChild(t),t.addEventListener("load",()=>{t.style.opacity="1";const i=e.querySelector(".tobii__loader");i&&e.removeChild(i)}),t.addEventListener("error",()=>{t.style.opacity="1";const i=e.querySelector(".tobii__loader");i&&e.removeChild(i)})}else t.setAttribute("src",e.getAttribute("data-href"))}onLeave(e){}onCleanup(e){const t=e.querySelector("iframe");t.setAttribute("src",""),t.style.opacity="0"}onReset(){}}class i{constructor(){this.userSettings=null}init(e,t,i){this.userSettings=i;const r=e.hasAttribute("data-target")?e.getAttribute("data-target"):e.getAttribute("href"),n=document.querySelector(r).cloneNode(!0);if(!n)throw new Error(`Ups, I can't find the target ${r}.`);t.appendChild(n),t.setAttribute("data-type","html"),t.classList.add("tobii-html")}onPreload(e){}onLoad(e,t){const i=e.querySelector("video");i&&(i.hasAttribute("data-time")&&i.readyState>0&&(i.currentTime=i.getAttribute("data-time")),this.userSettings.autoplayVideo&&i.play());const r=e.querySelector("audio");r&&this.userSettings.autoplayAudio&&r.play(),e.classList.add("tobii-group-"+t)}onLeave(e){const t=e.querySelector("video");t&&(t.paused||t.pause(),t.readyState>0&&t.setAttribute("data-time",t.currentTime));const i=e.querySelector("audio");i&&(i.paused||i.pause())}onCleanup(e){const t=e.querySelector("video");if(t&&t.readyState>0&&t.readyState<3&&t.duration!==t.currentTime){const i=t.cloneNode(!0);this._removeSources(t),t.load(),t.parentNode.removeChild(t),e.appendChild(i)}}onReset(){}_removeSources(e){const t=e.querySelectorAll("src");t&&t.forEach(e=>{e.setAttribute("src","")})}}class r{constructor(){this.playerId=0,this.PLAYER=[],this.userSettings=null}init(e,t,i){this.userSettings=i;const r=document.createElement("div");t.appendChild(r),this.PLAYER[this.playerId]=new window.YT.Player(r,{host:"https://www.youtube-nocookie.com",height:e.getAttribute("data-height")||"360",width:e.getAttribute("data-width")||"640",videoId:e.getAttribute("data-id"),playerVars:{controls:e.getAttribute("data-controls")||1,rel:0,playsinline:1}}),t.setAttribute("data-player",this.playerId),t.setAttribute("data-type","youtube"),t.classList.add("tobii-youtube"),this.playerId++}onPreload(e){}onLoad(e){this.userSettings.autoplayVideo&&this.PLAYER[e.getAttribute("data-player")].playVideo()}onLeave(e){1===this.PLAYER[e.getAttribute("data-player")].getPlayerState()&&this.PLAYER[e.getAttribute("data-player")].pauseVideo()}onCleanup(e){1===this.PLAYER[e.getAttribute("data-player")].getPlayerState()&&this.PLAYER[e.getAttribute("data-player")].pauseVideo()}onReset(){}}function n(s){const a={image:new e,html:new i,iframe:new t,youtube:new r},o=['a[href]:not([tabindex^="-"]):not([inert])','area[href]:not([tabindex^="-"]):not([inert])',"input:not([disabled]):not([inert])","select:not([disabled]):not([inert])","textarea:not([disabled]):not([inert])","button:not([disabled]):not([inert])",'iframe:not([tabindex^="-"]):not([inert])','audio:not([tabindex^="-"]):not([inert])','video:not([tabindex^="-"]):not([inert])','[contenteditable]:not([tabindex^="-"]):not([inert])','[tabindex]:not([tabindex^="-"]):not([inert])'];let d={};const l=[],u={gallery:[],slider:null,sliderElements:[],elementsLength:0,currentIndex:0,x:0};let c=null,p=null,b=null,h=null,g=null,m={},y=!1,v=!1,f=!1,w=null,A=null,E=null,L=!1,x=!1,_={},S=null,I=null;const C=e=>{if(null===document.querySelector('[data-type="youtube"]')||x)P(e);else{if(null===document.getElementById("iframe_api")){const e=document.createElement("script"),t=document.getElementsByTagName("script")[0];e.id="iframe_api",e.src="https://www.youtube.com/iframe_api",t.parentNode.insertBefore(e,t)}-1===l.indexOf(e)&&l.push(e),window.onYouTubePlayerAPIReady=()=>{l.forEach(e=>{P(e)}),x=!0}}},T=e=>e.hasAttribute("data-group")?e.getAttribute("data-group"):"default",P=e=>{if(S=T(e),Object.prototype.hasOwnProperty.call(_,S)||(_[S]=JSON.parse(JSON.stringify(u)),Y()),-1!==_[S].gallery.indexOf(e))throw new Error("Ups, element already added.");if(_[S].gallery.push(e),_[S].elementsLength++,d.zoom&&e.querySelector("img")&&"false"!==e.getAttribute("data-zoom")||"true"===e.getAttribute("data-zoom")){const t=document.createElement("div");t.className="tobii-zoom__icon",t.innerHTML=d.zoomText,e.classList.add("tobii-zoom"),e.appendChild(t)}e.addEventListener("click",F),N(e),ue()&&S===I&&(oe(),de())},q=e=>{const t=T(e);if(-1===_[t].gallery.indexOf(e))throw new Error(`Ups, I can't find a slide for the element ${e}.`);{const i=_[t].gallery.indexOf(e),r=_[t].sliderElements[i];if(ue()&&t===I&&i===_[t].currentIndex){if(1===_[t].elementsLength)throw U(),new Error("Ups, I've closed. There are no slides more to show.");0===_[t].currentIndex?M():z(),oe(),de()}if(_[t].gallery.splice(_[t].gallery.indexOf(e)),_[t].sliderElements.splice(_[t].gallery.indexOf(e)),_[t].elementsLength--,--_[t].x,d.zoom&&e.querySelector(".tobii-zoom__icon")){const t=e.querySelector(".tobii-zoom__icon");t.parentNode.classList.remove("tobii-zoom"),t.parentNode.removeChild(t)}e.removeEventListener("click",F),r.parentNode.removeChild(r)}},Y=()=>{_[S].slider=document.createElement("div"),_[S].slider.className="tobii__slider",_[S].slider.setAttribute("aria-hidden","true"),c.appendChild(_[S].slider)},N=e=>{const t=k(e),i=document.createElement("div"),r=document.createElement("div");i.className="tobii__slide",i.style.position="absolute",i.style.left=100*_[S].x+"%",i.setAttribute("aria-hidden","true"),t.init(e,r,d),i.appendChild(r),_[S].slider.appendChild(i),_[S].sliderElements.push(i),++_[S].x},k=e=>{const t=e.getAttribute("data-type");return void 0!==a[t]?a[t]:(e.hasAttribute("data-type")&&console.log("Unknown lightbox element type: "+t),a.image)},O=e=>{if(I=null!==I?I:S,ue())throw new Error("Ups, I'm aleady open.");if(!ue()&&(e||(e=0),-1===e||e>=_[I].elementsLength))throw new Error(`Ups, I can't find slide ${e}.`);document.documentElement.classList.add("tobii-is-open"),document.body.classList.add("tobii-is-open"),document.body.classList.add("tobii-is-open-"+I),oe(),d.close||(h.disabled=!1,h.setAttribute("aria-hidden","true")),w=document.activeElement;const t=window.location.href;window.history.pushState({tobii:"close"},"Image",t),_[I].currentIndex=e,V(),se(),$(_[I].currentIndex),_[I].slider.setAttribute("aria-hidden","false"),c.setAttribute("aria-hidden","false"),de(),X(_[I].currentIndex+1),X(_[I].currentIndex-1),_[I].slider.classList.add("tobii__slider--animate");const i=new window.CustomEvent("open",{detail:{group:I}});c.dispatchEvent(i)},U=()=>{if(!ue())throw new Error("Ups, I'm already closed.");document.documentElement.classList.remove("tobii-is-open"),document.body.classList.remove("tobii-is-open"),document.body.classList.remove("tobii-is-open-"+I),ae(),null!==window.history.state&&"close"===window.history.state.tobii&&window.history.back(),w.focus(),H(_[I].currentIndex),D(_[I].currentIndex),c.setAttribute("aria-hidden","true"),_[I].slider.setAttribute("aria-hidden","true"),_[I].currentIndex=0,_[I].slider.classList.remove("tobii__slider--animate");const e=new window.CustomEvent("close",{detail:{group:I}});c.dispatchEvent(e)},X=e=>{if(void 0===_[I].sliderElements[e])return;const t=_[I].sliderElements[e].querySelector("[data-type]");k(t).onPreload(t)},$=e=>{if(void 0===_[I].sliderElements[e])return;const t=_[I].sliderElements[e].querySelector("[data-type]"),i=k(t);_[I].sliderElements[e].classList.add("tobii__slide--is-active"),_[I].sliderElements[e].setAttribute("aria-hidden","false"),i.onLoad(t,I)},z=()=>{if(!ue())throw new Error("Ups, I'm closed.");_[I].currentIndex>0&&(H(_[I].currentIndex),$(--_[I].currentIndex),de("left"),D(_[I].currentIndex+1),X(_[I].currentIndex-1));const e=new window.CustomEvent("previous",{detail:{group:I}});c.dispatchEvent(e)},M=()=>{if(!ue())throw new Error("Ups, I'm closed.");_[I].currentIndex<_[I].elementsLength-1&&(H(_[I].currentIndex),$(++_[I].currentIndex),de("right"),D(_[I].currentIndex-1),X(_[I].currentIndex+1));const e=new window.CustomEvent("next",{detail:{group:I}});c.dispatchEvent(e)},R=e=>{if(ue())throw new Error("Ups, I'm open.");if(!e)throw new Error("Ups, no group specified.");if(e&&!Object.prototype.hasOwnProperty.call(_,e))throw new Error(`Ups, I don't have a group called "${e}".`);I=e},H=e=>{if(void 0===_[I].sliderElements[e])return;const t=_[I].sliderElements[e].querySelector("[data-type]"),i=k(t);_[I].sliderElements[e].classList.remove("tobii__slide--is-active"),_[I].sliderElements[e].setAttribute("aria-hidden","true"),i.onLeave(t)},D=e=>{if(void 0===_[I].sliderElements[e])return;const t=_[I].sliderElements[e].querySelector("[data-type]");k(t).onCleanup(t)},B=()=>{I=null!==I?I:S,A=-_[I].currentIndex*c.offsetWidth,_[I].slider.style.transform=`translate3d(${A}px, 0, 0)`,E=A},V=()=>{m={startX:0,endX:0,startY:0,endY:0}},j=()=>{const e=m.endX-m.startX,t=m.endY-m.startY,i=Math.abs(e),r=Math.abs(t);e>0&&i>d.threshold&&_[I].currentIndex>0?z():e<0&&i>d.threshold&&_[I].currentIndex!==_[I].elementsLength-1?M():t<0&&r>d.threshold&&d.swipeClose?U():B()},W=()=>{L||(L=!0,window.requestAnimationFrame(()=>{B(),L=!1}))},F=e=>{e.preventDefault(),I=T(e.currentTarget),O(_[I].gallery.indexOf(e.currentTarget))},G=e=>{e.target===p?z():e.target===b?M():(e.target===h||!1===y&&!1===v&&e.target.classList.contains("tobii__slide")&&d.docClose)&&U(),e.stopPropagation()},J=e=>{const t=Array.prototype.slice.call(c.querySelectorAll(`.tobii__btn:not([disabled]), .tobii__slide--is-active ${o.join(", .tobii__slide--is-active ")}`)).filter(e=>!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)),i=t.indexOf(document.activeElement);9===e.keyCode||"Tab"===e.code?e.shiftKey&&0===i?(t[t.length-1].focus(),e.preventDefault()):e.shiftKey||i!==t.length-1||(t[0].focus(),e.preventDefault()):27===e.keyCode||"Escape"===e.code?(e.preventDefault(),U()):37===e.keyCode||"ArrowLeft"===e.code?(e.preventDefault(),z()):39!==e.keyCode&&"ArrowRight"!==e.code||(e.preventDefault(),M())},K=e=>{pe(e.target)||(e.stopPropagation(),y=!1,v=!1,f=!0,m.startX=e.touches[0].pageX,m.startY=e.touches[0].pageY,ce()&&_[I].slider.classList.add("tobii__slider--is-dragging"))},Q=e=>{e.stopPropagation(),f&&(m.endX=e.touches[0].pageX,m.endY=e.touches[0].pageY,ne())},Z=e=>{e.stopPropagation(),f=!1,_[I].slider.classList.remove("tobii__slider--is-dragging"),m.endX&&j(),V()},ee=e=>{pe(e.target)||(e.preventDefault(),e.stopPropagation(),y=!1,v=!1,f=!0,m.startX=e.pageX,m.startY=e.pageY,ce()&&_[I].slider.classList.add("tobii__slider--is-dragging"))},te=e=>{e.preventDefault(),f&&(m.endX=e.pageX,m.endY=e.pageY,ne())},ie=e=>{e.stopPropagation(),f=!1,_[I].slider.classList.remove("tobii__slider--is-dragging"),m.endX&&j(),V()},re=()=>{f=!1},ne=()=>{Math.abs(m.startX-m.endX)>0&&!v&&_[I].elementsLength>1?(_[I].slider.style.transform=`translate3d(${E-Math.round(m.startX-m.endX)}px, 0, 0)`,y=!0,v=!1):Math.abs(m.startY-m.endY)>0&&!y&&d.swipeClose&&(_[I].slider.style.transform=`translate3d(${E}px, -${Math.round(m.startY-m.endY)}px, 0)`,y=!1,v=!0)},se=()=>{d.keyboard&&window.addEventListener("keydown",J),window.addEventListener("resize",W),window.addEventListener("popstate",U),c.addEventListener("click",G),d.draggable&&ce()&&(c.addEventListener("touchstart",K),c.addEventListener("touchmove",Q),c.addEventListener("touchend",Z),c.addEventListener("mousedown",ee),c.addEventListener("mouseup",ie),c.addEventListener("mousemove",te),c.addEventListener("contextmenu",re))},ae=()=>{d.keyboard&&window.removeEventListener("keydown",J),window.removeEventListener("resize",W),window.removeEventListener("popstate",U),c.removeEventListener("click",G),d.draggable&&ce()&&(c.removeEventListener("touchstart",K),c.removeEventListener("touchmove",Q),c.removeEventListener("touchend",Z),c.removeEventListener("mousedown",ee),c.removeEventListener("mouseup",ie),c.removeEventListener("mousemove",te),c.removeEventListener("contextmenu",re))},oe=()=>{(d.draggable&&d.swipeClose&&ce()&&!_[I].slider.classList.contains("tobii__slider--is-draggable")||d.draggable&&_[I].elementsLength>1&&!_[I].slider.classList.contains("tobii__slider--is-draggable"))&&_[I].slider.classList.add("tobii__slider--is-draggable"),!d.nav||1===_[I].elementsLength||"auto"===d.nav&&ce()?(p.setAttribute("aria-hidden","true"),p.disabled=!0,b.setAttribute("aria-hidden","true"),b.disabled=!0):(p.setAttribute("aria-hidden","false"),p.disabled=!1,b.setAttribute("aria-hidden","false"),b.disabled=!1),g.setAttribute("aria-hidden",d.counter&&1!==_[I].elementsLength?"false":"true")},de=(e=null)=>{B(),g.textContent=`${_[I].currentIndex+1}/${_[I].elementsLength}`,(e=>{(!0===d.nav||"auto"===d.nav)&&!ce()&&_[I].elementsLength>1?(p.setAttribute("aria-hidden","true"),p.disabled=!0,b.setAttribute("aria-hidden","true"),b.disabled=!0,1===_[I].elementsLength?d.close&&h.focus():0===_[I].currentIndex?(b.setAttribute("aria-hidden","false"),b.disabled=!1,b.focus()):_[I].currentIndex===_[I].elementsLength-1?(p.setAttribute("aria-hidden","false"),p.disabled=!1,p.focus()):(p.setAttribute("aria-hidden","false"),p.disabled=!1,b.setAttribute("aria-hidden","false"),b.disabled=!1,"left"===e?p.focus():b.focus())):d.close&&h.focus()})(e)},le=()=>{ue()&&U(),Object.entries(_).forEach(e=>{e[1].gallery.forEach(e=>{q(e)})}),_={},S=I=null;for(const e in a)a[e].onReset()},ue=()=>"false"===c.getAttribute("aria-hidden"),ce=()=>"ontouchstart"in window,pe=e=>-1!==["TEXTAREA","OPTION","INPUT","SELECT"].indexOf(e.nodeName)||e===p||e===b||e===h;return(e=>{if(document.querySelector("div.tobii"))return void console.log("Multiple lightbox instances not supported.");d=(e=>({selector:".lightbox",captions:!0,captionsSelector:"img",captionAttribute:"alt",captionText:null,captionHTML:!1,nav:"auto",navText:['<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="15 6 9 12 15 18" /></svg>','<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="9 6 15 12 9 18" /></svg>'],navLabel:["Previous image","Next image"],close:!0,closeText:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><line x1="18" y1="6" x2="6" y2="18" /><line x1="6" y1="6" x2="18" y2="18" /></svg>',closeLabel:"Close lightbox",loadingIndicatorLabel:"Image loading",counter:!0,download:!1,downloadText:"",downloadLabel:"Download image",keyboard:!0,zoom:!0,zoomText:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="16 4 20 4 20 8" /><line x1="14" y1="10" x2="20" y2="4" /><polyline points="8 20 4 20 4 16" /><line x1="4" y1="20" x2="10" y2="14" /><polyline points="16 20 20 20 20 16" /><line x1="14" y1="14" x2="20" y2="20" /><polyline points="8 4 4 4 4 8" /><line x1="4" y1="4" x2="10" y2="10" /></svg>',docClose:!0,swipeClose:!0,hideScrollbar:!0,draggable:!0,threshold:100,rtl:!1,loop:!1,autoplayVideo:!1,modal:!1,theme:"tobii--theme-default",...e}))(e),c||(c=document.createElement("div"),c.setAttribute("role","dialog"),c.setAttribute("aria-hidden","true"),c.classList.add("tobii"),c.classList.add(d.theme),p=document.createElement("button"),p.className="tobii__btn tobii__btn--previous",p.setAttribute("type","button"),p.setAttribute("aria-label",d.navLabel[0]),p.innerHTML=d.navText[0],c.appendChild(p),b=document.createElement("button"),b.className="tobii__btn tobii__btn--next",b.setAttribute("type","button"),b.setAttribute("aria-label",d.navLabel[1]),b.innerHTML=d.navText[1],c.appendChild(b),h=document.createElement("button"),h.className="tobii__btn tobii__btn--close",h.setAttribute("type","button"),h.setAttribute("aria-label",d.closeLabel),h.innerHTML=d.closeText,c.appendChild(h),g=document.createElement("div"),g.className="tobii__counter",c.appendChild(g),document.body.appendChild(c));const t=document.querySelectorAll(d.selector);if(!t)throw new Error(`Ups, I can't find the selector ${d.selector} on this website.`);const i=[];t.forEach(e=>{const t=e.hasAttribute("data-group")?e.getAttribute("data-group"):"default";let r=e.href;e.hasAttribute("data-target")&&(r=e.getAttribute("data-target")),r+="__"+t,void 0!==i[r]?e.addEventListener("click",e=>{R(t),O(),e.preventDefault()}):(i[r]=1,C(e))})})(s),n.open=O,n.previous=z,n.next=M,n.close=U,n.add=C,n.remove=q,n.reset=le,n.destroy=()=>{le(),c.parentNode.removeChild(c)},n.isOpen=ue,n.slidesIndex=()=>_[I].currentIndex,n.select=e=>{const t=_[I].currentIndex;if(!ue())throw new Error("Ups, I'm closed.");if(ue()){if(!e&&0!==e)throw new Error("Ups, no slide specified.");if(e===_[I].currentIndex)throw new Error(`Ups, slide ${e} is already selected.`);if(-1===e||e>=_[I].elementsLength)throw new Error(`Ups, I can't find slide ${e}.`)}_[I].currentIndex=e,H(t),$(e),e<t&&(de("left"),D(t),X(e-1)),e>t&&(de("right"),D(t),X(e+1))},n.slidesCount=()=>_[I].elementsLength,n.selectGroup=R,n.currentGroup=()=>null!==I?I:S,n.on=(e,t)=>{c.addEventListener(e,t)},n.off=(e,t)=>{c.removeEventListener(e,t)},n}export{n as default}; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e||self).Tobii=t()}(this,function(){class e{constructor(){this.figcaptionId=0,this.userSettings=null}init(e,t,i){this.userSettings=i;const r=document.createElement("figure"),n=document.createElement("figcaption"),s=document.createElement("img"),a=e.querySelector("img"),o=document.createElement("div");r.style.opacity="0",a&&(s.alt=a.alt||""),s.setAttribute("src",""),s.setAttribute("data-src",e.href),e.hasAttribute("data-srcset")&&s.setAttribute("data-srcset",e.getAttribute("data-srcset")),r.appendChild(s),this.userSettings.captions&&("function"==typeof this.userSettings.captionText?n.textContent=this.userSettings.captionText(e):"self"===this.userSettings.captionsSelector&&e.getAttribute(this.userSettings.captionAttribute)?n.textContent=e.getAttribute(this.userSettings.captionAttribute):"img"===this.userSettings.captionsSelector&&a&&a.getAttribute(this.userSettings.captionAttribute)&&(n.textContent=a.getAttribute(this.userSettings.captionAttribute)),n.textContent&&(n.id=`tobii-figcaption-${this.figcaptionId}`,r.appendChild(n),s.setAttribute("aria-labelledby",n.id),++this.figcaptionId)),t.appendChild(r),o.className="tobii__loader",o.setAttribute("role","progressbar"),o.setAttribute("aria-label",this.userSettings.loadingIndicatorLabel),t.appendChild(o),t.setAttribute("data-type","image"),t.classList.add("tobii-image")}onPreload(e){this.onLoad(e)}onLoad(e){const t=e.querySelector("img");if(!t.hasAttribute("data-src"))return;const i=e.querySelector("figure"),r=e.querySelector(".tobii__loader");t.addEventListener("load",()=>{e.removeChild(r),i.style.opacity="1"}),t.addEventListener("error",()=>{e.removeChild(r),i.style.opacity="1"}),t.setAttribute("src",t.getAttribute("data-src")),t.removeAttribute("data-src"),t.hasAttribute("data-srcset")&&t.setAttribute("srcset",t.getAttribute("data-srcset"))}onLeave(e){}onCleanup(e){}onReset(){this.figcaptionId=0}}class t{constructor(){this.userSettings=null}init(e,t,i){this.userSettings=i;const r=e.hasAttribute("data-target")?e.getAttribute("data-target"):e.getAttribute("href");t.setAttribute("data-HREF",r),e.getAttribute("data-allow")&&t.setAttribute("data-allow",e.getAttribute("data-allow")),e.hasAttribute("data-width")&&t.setAttribute("data-width",`${e.getAttribute("data-width")}`),e.hasAttribute("data-height")&&t.setAttribute("data-height",`${e.getAttribute("data-height")}`),t.setAttribute("data-type","iframe"),t.classList.add("tobii-iframe")}onPreload(e){}onLoad(e){let t=e.querySelector("iframe");const i=document.createElement("div");if(i.className="tobii__loader",i.setAttribute("role","progressbar"),i.setAttribute("aria-label",this.userSettings.loadingIndicatorLabel),e.appendChild(i),null==t){t=document.createElement("iframe");const i=e.getAttribute("data-href");t.setAttribute("frameborder","0"),t.setAttribute("src",i),t.setAttribute("allowfullscreen",""),i.indexOf("youtube.com")>-1?t.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"):i.indexOf("vimeo.com")>-1?t.setAttribute("allow","autoplay; picture-in-picture"):e.hasAttribute("data-allow")&&t.setAttribute("allow",e.getAttribute("data-allow")),e.getAttribute("data-width")&&(t.style.maxWidth=`${e.getAttribute("data-width")}`),e.getAttribute("data-height")&&(t.style.maxHeight=`${e.getAttribute("data-height")}`),t.style.opacity="0",e.appendChild(t),t.addEventListener("load",()=>{t.style.opacity="1";const i=e.querySelector(".tobii__loader");i&&e.removeChild(i)}),t.addEventListener("error",()=>{t.style.opacity="1";const i=e.querySelector(".tobii__loader");i&&e.removeChild(i)})}else t.setAttribute("src",e.getAttribute("data-href"))}onLeave(e){}onCleanup(e){const t=e.querySelector("iframe");t.setAttribute("src",""),t.style.opacity="0"}onReset(){}}class i{constructor(){this.userSettings=null}init(e,t,i){this.userSettings=i;const r=e.hasAttribute("data-target")?e.getAttribute("data-target"):e.getAttribute("href"),n=document.querySelector(r).cloneNode(!0);if(!n)throw new Error(`Ups, I can't find the target ${r}.`);t.appendChild(n),t.setAttribute("data-type","html"),t.classList.add("tobii-html")}onPreload(e){}onLoad(e){const t=e.querySelector("video");t&&(t.hasAttribute("data-time")&&t.readyState>0&&(t.currentTime=t.getAttribute("data-time")),this.userSettings.autoplayVideo&&t.play())}onLeave(e){const t=e.querySelector("video");t&&(t.paused||t.pause(),t.readyState>0&&t.setAttribute("data-time",t.currentTime))}onCleanup(e){const t=e.querySelector("video");if(t&&t.readyState>0&&t.readyState<3&&t.duration!==t.currentTime){const i=t.cloneNode(!0);this._removeSources(t),t.load(),t.parentNode.removeChild(t),e.appendChild(i)}}onReset(){}_removeSources(e){const t=e.querySelectorAll("src");t&&t.forEach(e=>{e.setAttribute("src","")})}}class r{constructor(){this.playerId=0,this.PLAYER=[],this.userSettings=null}init(e,t,i){this.userSettings=i;const r=document.createElement("div");t.appendChild(r),this.PLAYER[this.playerId]=new window.YT.Player(r,{host:"https://www.youtube-nocookie.com",height:e.getAttribute("data-height")||"360",width:e.getAttribute("data-width")||"640",videoId:e.getAttribute("data-id"),playerVars:{controls:e.getAttribute("data-controls")||1,rel:0,playsinline:1}}),t.setAttribute("data-player",this.playerId),t.setAttribute("data-type","youtube"),t.classList.add("tobii-youtube"),this.playerId++}onPreload(e){}onLoad(e){this.userSettings.autoplayVideo&&this.PLAYER[e.getAttribute("data-player")].playVideo()}onLeave(e){1===this.PLAYER[e.getAttribute("data-player")].getPlayerState()&&this.PLAYER[e.getAttribute("data-player")].pauseVideo()}onCleanup(e){1===this.PLAYER[e.getAttribute("data-player")].getPlayerState()&&this.PLAYER[e.getAttribute("data-player")].pauseVideo()}onReset(){}}return function n(s){const a={image:new e,html:new i,iframe:new t,youtube:new r},o=['a[href]:not([tabindex^="-"]):not([inert])','area[href]:not([tabindex^="-"]):not([inert])',"input:not([disabled]):not([inert])","select:not([disabled]):not([inert])","textarea:not([disabled]):not([inert])","button:not([disabled]):not([inert])",'iframe:not([tabindex^="-"]):not([inert])','audio:not([tabindex^="-"]):not([inert])','video:not([tabindex^="-"]):not([inert])','[contenteditable]:not([tabindex^="-"]):not([inert])','[tabindex]:not([tabindex^="-"]):not([inert])'];let d={};const l=[],u={gallery:[],slider:null,sliderElements:[],elementsLength:0,currentIndex:0,x:0};let c=null,b=null,p=null,h=null,m=null,g={},f=!1,y=!1,v=!1,w=null,A=null,E=null,L=!1,x=!1,_={},I=null,S=null;const C=e=>{if(null===document.querySelector('[data-type="youtube"]')||x)P(e);else{if(null===document.getElementById("iframe_api")){const e=document.createElement("script"),t=document.getElementsByTagName("script")[0];e.id="iframe_api",e.src="https://www.youtube.com/iframe_api",t.parentNode.insertBefore(e,t)}-1===l.indexOf(e)&&l.push(e),window.onYouTubePlayerAPIReady=()=>{l.forEach(e=>{P(e)}),x=!0}}},T=e=>e.hasAttribute("data-group")?e.getAttribute("data-group"):"default",P=e=>{if(I=T(e),Object.prototype.hasOwnProperty.call(_,I)||(_[I]=JSON.parse(JSON.stringify(u)),Y()),-1!==_[I].gallery.indexOf(e))throw new Error("Ups, element already added.");if(_[I].gallery.push(e),_[I].elementsLength++,d.zoom&&e.querySelector("img")&&"false"!==e.getAttribute("data-zoom")||"true"===e.getAttribute("data-zoom")){const t=document.createElement("div");t.className="tobii-zoom__icon",t.innerHTML=d.zoomText,e.classList.add("tobii-zoom"),e.appendChild(t)}e.addEventListener("click",F),N(e),ue()&&I===S&&(oe(),de(null))},q=e=>{const t=T(e);if(-1===_[t].gallery.indexOf(e))throw new Error(`Ups, I can't find a slide for the element ${e}.`);{const i=_[t].gallery.indexOf(e),r=_[t].sliderElements[i];if(ue()&&t===S&&i===_[t].currentIndex){if(1===_[t].elementsLength)throw U(),new Error("Ups, I've closed. There are no slides more to show.");0===_[t].currentIndex?R():z()}if(_[t].elementsLength--,d.zoom&&e.querySelector(".tobii-zoom__icon")){const t=e.querySelector(".tobii-zoom__icon");t.parentNode.classList.remove("tobii-zoom"),t.parentNode.removeChild(t)}e.removeEventListener("click",F),r.parentNode.removeChild(r)}},Y=()=>{_[I].slider=document.createElement("div"),_[I].slider.className="tobii__slider",_[I].slider.setAttribute("aria-hidden","true"),c.appendChild(_[I].slider)},N=e=>{const t=k(e),i=document.createElement("div"),r=document.createElement("div");i.className="tobii__slide",i.style.position="absolute",i.style.left=100*_[I].x+"%",i.setAttribute("aria-hidden","true"),t.init(e,r,d),i.appendChild(r),_[I].slider.appendChild(i),_[I].sliderElements.push(i),++_[I].x},k=e=>{const t=e.getAttribute("data-type");return void 0!==a[t]?a[t]:(e.hasAttribute("data-type")&&console.log("Unknown lightbox element type: "+t),a.image)},O=e=>{if(S=null!==S?S:I,ue())throw new Error("Ups, I'm aleady open.");if(!ue()&&(e||(e=0),-1===e||e>=_[S].elementsLength))throw new Error(`Ups, I can't find slide ${e}.`);document.documentElement.classList.add("tobii-is-open"),document.body.classList.add("tobii-is-open"),document.body.classList.add("tobii-is-open-"+S),oe(),d.close||(h.disabled=!1,h.setAttribute("aria-hidden","true")),w=document.activeElement;const t=window.location.href;window.history.pushState({tobii:"close"},"Image",t),_[S].currentIndex=e,V(),se(),$(_[S].currentIndex),_[S].slider.setAttribute("aria-hidden","false"),c.setAttribute("aria-hidden","false"),de(null),X(_[S].currentIndex+1),X(_[S].currentIndex-1),_[S].slider.classList.add("tobii__slider--animate");const i=new window.CustomEvent("open",{detail:{group:S}});c.dispatchEvent(i)},U=()=>{if(!ue())throw new Error("Ups, I'm already closed.");document.documentElement.classList.remove("tobii-is-open"),document.body.classList.remove("tobii-is-open"),document.body.classList.remove("tobii-is-open-"+S),ae(),null!==window.history.state&&"close"===window.history.state.tobii&&window.history.back(),w.focus(),H(_[S].currentIndex),D(_[S].currentIndex),c.setAttribute("aria-hidden","true"),_[S].slider.setAttribute("aria-hidden","true"),_[S].currentIndex=0,_[S].slider.classList.remove("tobii__slider--animate");const e=new window.CustomEvent("close",{detail:{group:S}});c.dispatchEvent(e)},X=e=>{if(void 0===_[S].sliderElements[e])return;const t=_[S].sliderElements[e].querySelector("[data-type]");k(t).onPreload(t)},$=e=>{if(void 0===_[S].sliderElements[e])return;const t=_[S].sliderElements[e].querySelector("[data-type]"),i=k(t);_[S].sliderElements[e].classList.add("tobii__slide--is-active"),_[S].sliderElements[e].setAttribute("aria-hidden","false"),i.onLoad(t)},z=()=>{if(!ue())throw new Error("Ups, I'm closed.");_[S].currentIndex>0&&(H(_[S].currentIndex),$(--_[S].currentIndex),de("left"),D(_[S].currentIndex+1),X(_[S].currentIndex-1));const e=new window.CustomEvent("previous",{detail:{group:S}});c.dispatchEvent(e)},R=()=>{if(!ue())throw new Error("Ups, I'm closed.");_[S].currentIndex<_[S].elementsLength-1&&(H(_[S].currentIndex),$(++_[S].currentIndex),de("right"),D(_[S].currentIndex-1),X(_[S].currentIndex+1));const e=new window.CustomEvent("next",{detail:{group:S}});c.dispatchEvent(e)},M=e=>{if(ue())throw new Error("Ups, I'm open.");if(!e)throw new Error("Ups, no group specified.");if(e&&!Object.prototype.hasOwnProperty.call(_,e))throw new Error(`Ups, I don't have a group called "${e}".`);S=e},H=e=>{if(void 0===_[S].sliderElements[e])return;const t=_[S].sliderElements[e].querySelector("[data-type]"),i=k(t);_[S].sliderElements[e].classList.remove("tobii__slide--is-active"),_[S].sliderElements[e].setAttribute("aria-hidden","true"),i.onLeave(t)},D=e=>{if(void 0===_[S].sliderElements[e])return;const t=_[S].sliderElements[e].querySelector("[data-type]");k(t).onCleanup(t)},B=()=>{S=null!==S?S:I,A=-_[S].currentIndex*c.offsetWidth,_[S].slider.style.transform=`translate3d(${A}px, 0, 0)`,E=A},V=()=>{g={startX:0,endX:0,startY:0,endY:0}},j=()=>{const e=g.endX-g.startX,t=g.endY-g.startY,i=Math.abs(e),r=Math.abs(t);e>0&&i>d.threshold&&_[S].currentIndex>0?z():e<0&&i>d.threshold&&_[S].currentIndex!==_[S].elementsLength-1?R():t<0&&r>d.threshold&&d.swipeClose?U():B()},W=()=>{L||(L=!0,window.requestAnimationFrame(()=>{B(),L=!1}))},F=e=>{e.preventDefault(),S=T(e.currentTarget),O(_[S].gallery.indexOf(e.currentTarget))},G=e=>{e.target===b?z():e.target===p?R():(e.target===h||!1===f&&!1===y&&e.target.classList.contains("tobii__slide")&&d.docClose)&&U(),e.stopPropagation()},J=e=>{const t=Array.prototype.slice.call(c.querySelectorAll(`.tobii__btn:not([disabled]), .tobii__slide--is-active ${o.join(", .tobii__slide--is-active ")}`)).filter(e=>!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)),i=t.indexOf(document.activeElement);9===e.keyCode||"Tab"===e.code?e.shiftKey&&0===i?(t[t.length-1].focus(),e.preventDefault()):e.shiftKey||i!==t.length-1||(t[0].focus(),e.preventDefault()):27===e.keyCode||"Escape"===e.code?(e.preventDefault(),U()):37===e.keyCode||"ArrowLeft"===e.code?(e.preventDefault(),z()):39!==e.keyCode&&"ArrowRight"!==e.code||(e.preventDefault(),R())},K=e=>{be(e.target)||(e.stopPropagation(),f=!1,y=!1,v=!0,g.startX=e.touches[0].pageX,g.startY=e.touches[0].pageY,ce()&&_[S].slider.classList.add("tobii__slider--is-dragging"))},Q=e=>{e.stopPropagation(),v&&(g.endX=e.touches[0].pageX,g.endY=e.touches[0].pageY,ne())},Z=e=>{e.stopPropagation(),v=!1,_[S].slider.classList.remove("tobii__slider--is-dragging"),g.endX&&j(),V()},ee=e=>{be(e.target)||(e.preventDefault(),e.stopPropagation(),f=!1,y=!1,v=!0,g.startX=e.pageX,g.startY=e.pageY,ce()&&_[S].slider.classList.add("tobii__slider--is-dragging"))},te=e=>{e.preventDefault(),v&&(g.endX=e.pageX,g.endY=e.pageY,ne())},ie=e=>{e.stopPropagation(),v=!1,_[S].slider.classList.remove("tobii__slider--is-dragging"),g.endX&&j(),V()},re=()=>{v=!1},ne=()=>{Math.abs(g.startX-g.endX)>0&&!y&&_[S].elementsLength>1?(_[S].slider.style.transform=`translate3d(${E-Math.round(g.startX-g.endX)}px, 0, 0)`,f=!0,y=!1):Math.abs(g.startY-g.endY)>0&&!f&&d.swipeClose&&(_[S].slider.style.transform=`translate3d(${E}px, -${Math.round(g.startY-g.endY)}px, 0)`,f=!1,y=!0)},se=()=>{d.keyboard&&window.addEventListener("keydown",J),window.addEventListener("resize",W),window.addEventListener("popstate",U),c.addEventListener("click",G),d.draggable&&ce()&&(c.addEventListener("touchstart",K),c.addEventListener("touchmove",Q),c.addEventListener("touchend",Z),c.addEventListener("mousedown",ee),c.addEventListener("mouseup",ie),c.addEventListener("mousemove",te),c.addEventListener("contextmenu",re))},ae=()=>{d.keyboard&&window.removeEventListener("keydown",J),window.removeEventListener("resize",W),window.removeEventListener("popstate",U),c.removeEventListener("click",G),d.draggable&&ce()&&(c.removeEventListener("touchstart",K),c.removeEventListener("touchmove",Q),c.removeEventListener("touchend",Z),c.removeEventListener("mousedown",ee),c.removeEventListener("mouseup",ie),c.removeEventListener("mousemove",te),c.removeEventListener("contextmenu",re))},oe=()=>{(d.draggable&&d.swipeClose&&ce()&&!_[S].slider.classList.contains("tobii__slider--is-draggable")||d.draggable&&_[S].elementsLength>1&&!_[S].slider.classList.contains("tobii__slider--is-draggable"))&&_[S].slider.classList.add("tobii__slider--is-draggable"),!d.nav||1===_[S].elementsLength||"auto"===d.nav&&ce()?(b.setAttribute("aria-hidden","true"),b.disabled=!0,p.setAttribute("aria-hidden","true"),p.disabled=!0):(b.setAttribute("aria-hidden","false"),b.disabled=!1,p.setAttribute("aria-hidden","false"),p.disabled=!1),m.setAttribute("aria-hidden",d.counter&&1!==_[S].elementsLength?"false":"true")},de=e=>{B(),m.textContent=`${_[S].currentIndex+1}/${_[S].elementsLength}`,(e=>{(!0===d.nav||"auto"===d.nav)&&!ce()&&_[S].elementsLength>1?(b.setAttribute("aria-hidden","true"),b.disabled=!0,p.setAttribute("aria-hidden","true"),p.disabled=!0,1===_[S].elementsLength?d.close&&h.focus():0===_[S].currentIndex?(p.setAttribute("aria-hidden","false"),p.disabled=!1,p.focus()):_[S].currentIndex===_[S].elementsLength-1?(b.setAttribute("aria-hidden","false"),b.disabled=!1,b.focus()):(b.setAttribute("aria-hidden","false"),b.disabled=!1,p.setAttribute("aria-hidden","false"),p.disabled=!1,"left"===e?b.focus():p.focus())):d.close&&h.focus()})(e)},le=()=>{ue()&&U(),Object.entries(_).forEach(e=>{e[1].gallery.forEach(e=>{q(e)})}),_={},I=S=null;for(const e in a)a[e].onReset()},ue=()=>"false"===c.getAttribute("aria-hidden"),ce=()=>"ontouchstart"in window,be=e=>-1!==["TEXTAREA","OPTION","INPUT","SELECT"].indexOf(e.nodeName)||e===b||e===p||e===h;return(e=>{if(document.querySelector("div.tobii"))return void console.log("Multiple lightbox instances not supported.");d=(e=>({selector:".lightbox",captions:!0,captionsSelector:"img",captionAttribute:"alt",captionText:null,nav:"auto",navText:['<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="15 6 9 12 15 18" /></svg>','<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="9 6 15 12 9 18" /></svg>'],navLabel:["Previous image","Next image"],close:!0,closeText:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><line x1="18" y1="6" x2="6" y2="18" /><line x1="6" y1="6" x2="18" y2="18" /></svg>',closeLabel:"Close lightbox",loadingIndicatorLabel:"Image loading",counter:!0,download:!1,downloadText:"",downloadLabel:"Download image",keyboard:!0,zoom:!0,zoomText:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="16 4 20 4 20 8" /><line x1="14" y1="10" x2="20" y2="4" /><polyline points="8 20 4 20 4 16" /><line x1="4" y1="20" x2="10" y2="14" /><polyline points="16 20 20 20 20 16" /><line x1="14" y1="14" x2="20" y2="20" /><polyline points="8 4 4 4 4 8" /><line x1="4" y1="4" x2="10" y2="10" /></svg>',docClose:!0,swipeClose:!0,hideScrollbar:!0,draggable:!0,threshold:100,rtl:!1,loop:!1,autoplayVideo:!1,modal:!1,theme:"tobii--theme-default",...e}))(e),c||(c=document.createElement("div"),c.setAttribute("role","dialog"),c.setAttribute("aria-hidden","true"),c.classList.add("tobii"),c.classList.add(d.theme),b=document.createElement("button"),b.className="tobii__btn tobii__btn--previous",b.setAttribute("type","button"),b.setAttribute("aria-label",d.navLabel[0]),b.innerHTML=d.navText[0],c.appendChild(b),p=document.createElement("button"),p.className="tobii__btn tobii__btn--next",p.setAttribute("type","button"),p.setAttribute("aria-label",d.navLabel[1]),p.innerHTML=d.navText[1],c.appendChild(p),h=document.createElement("button"),h.className="tobii__btn tobii__btn--close",h.setAttribute("type","button"),h.setAttribute("aria-label",d.closeLabel),h.innerHTML=d.closeText,c.appendChild(h),m=document.createElement("div"),m.className="tobii__counter",c.appendChild(m),document.body.appendChild(c));const t=document.querySelectorAll(d.selector);if(!t)throw new Error(`Ups, I can't find the selector ${d.selector} on this website.`);const i=[];t.forEach(e=>{const t=e.hasAttribute("data-group")?e.getAttribute("data-group"):"default";let r=e.href;e.hasAttribute("data-target")&&(r=e.getAttribute("data-target")),r+="__"+t,void 0!==i[r]?e.addEventListener("click",e=>{M(t),O(),e.preventDefault()}):(i[r]=1,C(e))})})(s),n.open=O,n.previous=z,n.next=R,n.close=U,n.add=C,n.remove=q,n.reset=le,n.destroy=()=>{le(),c.parentNode.removeChild(c)},n.isOpen=ue,n.slidesIndex=()=>_[S].currentIndex,n.select=e=>{const t=_[S].currentIndex;if(!ue())throw new Error("Ups, I'm closed.");if(ue()){if(!e&&0!==e)throw new Error("Ups, no slide specified.");if(e===_[S].currentIndex)throw new Error(`Ups, slide ${e} is already selected.`);if(-1===e||e>=_[S].elementsLength)throw new Error(`Ups, I can't find slide ${e}.`)}_[S].currentIndex=e,H(t),$(e),e<t&&(de("left"),D(t),X(e-1)),e>t&&(de("right"),D(t),X(e+1))},n.slidesCount=()=>_[S].elementsLength,n.selectGroup=M,n.currentGroup=()=>null!==S?S:I,n.on=(e,t)=>{c.addEventListener(e,t)},n.off=(e,t)=>{c.removeEventListener(e,t)},n}}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e||self).Tobii=t()}(this,function(){class e{constructor(){this.figcaptionId=0,this.userSettings=null}init(e,t,i){this.userSettings=i;const r=document.createElement("figure"),n=document.createElement("figcaption"),s=document.createElement("img"),a=e.querySelector("img"),o=document.createElement("div");if(r.style.opacity="0",a&&(s.alt=a.alt||""),s.setAttribute("src",""),s.setAttribute("data-src",e.href),e.hasAttribute("data-srcset")&&s.setAttribute("data-srcset",e.getAttribute("data-srcset")),r.appendChild(s),this.userSettings.captions){let t;"function"==typeof this.userSettings.captionText?t=this.userSettings.captionText(e):"self"===this.userSettings.captionsSelector&&e.getAttribute(this.userSettings.captionAttribute)?t=e.getAttribute(this.userSettings.captionAttribute):"img"===this.userSettings.captionsSelector&&a&&a.getAttribute(this.userSettings.captionAttribute)&&(t=a.getAttribute(this.userSettings.captionAttribute)),this.userSettings.captionHTML?n.innerHTML=t:n.textContent=t,t&&(n.id=`tobii-figcaption-${this.figcaptionId}`,r.appendChild(n),s.setAttribute("aria-labelledby",n.id),++this.figcaptionId)}t.appendChild(r),o.className="tobii__loader",o.setAttribute("role","progressbar"),o.setAttribute("aria-label",this.userSettings.loadingIndicatorLabel),t.appendChild(o),t.setAttribute("data-type","image"),t.classList.add("tobii-image")}onPreload(e){this.onLoad(e)}onLoad(e){const t=e.querySelector("img");if(!t.hasAttribute("data-src"))return;const i=e.querySelector("figure"),r=e.querySelector(".tobii__loader");t.addEventListener("load",()=>{e.removeChild(r),i.style.opacity="1"}),t.addEventListener("error",()=>{e.removeChild(r),i.style.opacity="1"}),t.setAttribute("src",t.getAttribute("data-src")),t.removeAttribute("data-src"),t.hasAttribute("data-srcset")&&t.setAttribute("srcset",t.getAttribute("data-srcset"))}onLeave(e){}onCleanup(e){}onReset(){this.figcaptionId=0}}class t{constructor(){this.userSettings=null}init(e,t,i){this.userSettings=i;const r=e.hasAttribute("data-target")?e.getAttribute("data-target"):e.getAttribute("href");t.setAttribute("data-HREF",r),e.getAttribute("data-allow")&&t.setAttribute("data-allow",e.getAttribute("data-allow")),e.hasAttribute("data-width")&&t.setAttribute("data-width",`${e.getAttribute("data-width")}`),e.hasAttribute("data-height")&&t.setAttribute("data-height",`${e.getAttribute("data-height")}`),t.setAttribute("data-type","iframe"),t.classList.add("tobii-iframe")}onPreload(e){}onLoad(e){let t=e.querySelector("iframe");const i=document.createElement("div");if(i.className="tobii__loader",i.setAttribute("role","progressbar"),i.setAttribute("aria-label",this.userSettings.loadingIndicatorLabel),e.appendChild(i),null==t){t=document.createElement("iframe");const i=e.getAttribute("data-href");t.setAttribute("frameborder","0"),t.setAttribute("src",i),t.setAttribute("allowfullscreen",""),i.indexOf("youtube.com")>-1?t.setAttribute("allow","accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"):i.indexOf("vimeo.com")>-1?t.setAttribute("allow","autoplay; picture-in-picture"):e.hasAttribute("data-allow")&&t.setAttribute("allow",e.getAttribute("data-allow")),e.getAttribute("data-width")&&(t.style.maxWidth=`${e.getAttribute("data-width")}`),e.getAttribute("data-height")&&(t.style.maxHeight=`${e.getAttribute("data-height")}`),t.style.opacity="0",e.appendChild(t),t.addEventListener("load",()=>{t.style.opacity="1";const i=e.querySelector(".tobii__loader");i&&e.removeChild(i)}),t.addEventListener("error",()=>{t.style.opacity="1";const i=e.querySelector(".tobii__loader");i&&e.removeChild(i)})}else t.setAttribute("src",e.getAttribute("data-href"))}onLeave(e){}onCleanup(e){const t=e.querySelector("iframe");t.setAttribute("src",""),t.style.opacity="0"}onReset(){}}class i{constructor(){this.userSettings=null}init(e,t,i){this.userSettings=i;const r=e.hasAttribute("data-target")?e.getAttribute("data-target"):e.getAttribute("href"),n=document.querySelector(r).cloneNode(!0);if(!n)throw new Error(`Ups, I can't find the target ${r}.`);t.appendChild(n),t.setAttribute("data-type","html"),t.classList.add("tobii-html")}onPreload(e){}onLoad(e,t){const i=e.querySelector("video");i&&(i.hasAttribute("data-time")&&i.readyState>0&&(i.currentTime=i.getAttribute("data-time")),this.userSettings.autoplayVideo&&i.play());const r=e.querySelector("audio");r&&this.userSettings.autoplayAudio&&r.play(),e.classList.add("tobii-group-"+t)}onLeave(e){const t=e.querySelector("video");t&&(t.paused||t.pause(),t.readyState>0&&t.setAttribute("data-time",t.currentTime));const i=e.querySelector("audio");i&&(i.paused||i.pause())}onCleanup(e){const t=e.querySelector("video");if(t&&t.readyState>0&&t.readyState<3&&t.duration!==t.currentTime){const i=t.cloneNode(!0);this._removeSources(t),t.load(),t.parentNode.removeChild(t),e.appendChild(i)}}onReset(){}_removeSources(e){const t=e.querySelectorAll("src");t&&t.forEach(e=>{e.setAttribute("src","")})}}class r{constructor(){this.playerId=0,this.PLAYER=[],this.userSettings=null}init(e,t,i){this.userSettings=i;const r=document.createElement("div");t.appendChild(r),this.PLAYER[this.playerId]=new window.YT.Player(r,{host:"https://www.youtube-nocookie.com",height:e.getAttribute("data-height")||"360",width:e.getAttribute("data-width")||"640",videoId:e.getAttribute("data-id"),playerVars:{controls:e.getAttribute("data-controls")||1,rel:0,playsinline:1}}),t.setAttribute("data-player",this.playerId),t.setAttribute("data-type","youtube"),t.classList.add("tobii-youtube"),this.playerId++}onPreload(e){}onLoad(e){this.userSettings.autoplayVideo&&this.PLAYER[e.getAttribute("data-player")].playVideo()}onLeave(e){1===this.PLAYER[e.getAttribute("data-player")].getPlayerState()&&this.PLAYER[e.getAttribute("data-player")].pauseVideo()}onCleanup(e){1===this.PLAYER[e.getAttribute("data-player")].getPlayerState()&&this.PLAYER[e.getAttribute("data-player")].pauseVideo()}onReset(){}}return function n(s){const a={image:new e,html:new i,iframe:new t,youtube:new r},o=['a[href]:not([tabindex^="-"]):not([inert])','area[href]:not([tabindex^="-"]):not([inert])',"input:not([disabled]):not([inert])","select:not([disabled]):not([inert])","textarea:not([disabled]):not([inert])","button:not([disabled]):not([inert])",'iframe:not([tabindex^="-"]):not([inert])','audio:not([tabindex^="-"]):not([inert])','video:not([tabindex^="-"]):not([inert])','[contenteditable]:not([tabindex^="-"]):not([inert])','[tabindex]:not([tabindex^="-"]):not([inert])'];let d={};const l=[],u={gallery:[],slider:null,sliderElements:[],elementsLength:0,currentIndex:0,x:0};let c=null,p=null,b=null,h=null,g=null,m={},y=!1,f=!1,v=!1,w=null,A=null,E=null,L=!1,x=!1,_={},S=null,I=null;const C=e=>{if(null===document.querySelector('[data-type="youtube"]')||x)P(e);else{if(null===document.getElementById("iframe_api")){const e=document.createElement("script"),t=document.getElementsByTagName("script")[0];e.id="iframe_api",e.src="https://www.youtube.com/iframe_api",t.parentNode.insertBefore(e,t)}-1===l.indexOf(e)&&l.push(e),window.onYouTubePlayerAPIReady=()=>{l.forEach(e=>{P(e)}),x=!0}}},T=e=>e.hasAttribute("data-group")?e.getAttribute("data-group"):"default",P=e=>{if(S=T(e),Object.prototype.hasOwnProperty.call(_,S)||(_[S]=JSON.parse(JSON.stringify(u)),Y()),-1!==_[S].gallery.indexOf(e))throw new Error("Ups, element already added.");if(_[S].gallery.push(e),_[S].elementsLength++,d.zoom&&e.querySelector("img")&&"false"!==e.getAttribute("data-zoom")||"true"===e.getAttribute("data-zoom")){const t=document.createElement("div");t.className="tobii-zoom__icon",t.innerHTML=d.zoomText,e.classList.add("tobii-zoom"),e.appendChild(t)}e.addEventListener("click",F),N(e),ue()&&S===I&&(oe(),de())},q=e=>{const t=T(e);if(-1===_[t].gallery.indexOf(e))throw new Error(`Ups, I can't find a slide for the element ${e}.`);{const i=_[t].gallery.indexOf(e),r=_[t].sliderElements[i];if(ue()&&t===I&&i===_[t].currentIndex){if(1===_[t].elementsLength)throw U(),new Error("Ups, I've closed. There are no slides more to show.");0===_[t].currentIndex?M():z(),oe(),de()}if(_[t].gallery.splice(_[t].gallery.indexOf(e)),_[t].sliderElements.splice(_[t].gallery.indexOf(e)),_[t].elementsLength--,--_[t].x,d.zoom&&e.querySelector(".tobii-zoom__icon")){const t=e.querySelector(".tobii-zoom__icon");t.parentNode.classList.remove("tobii-zoom"),t.parentNode.removeChild(t)}e.removeEventListener("click",F),r.parentNode.removeChild(r)}},Y=()=>{_[S].slider=document.createElement("div"),_[S].slider.className="tobii__slider",_[S].slider.setAttribute("aria-hidden","true"),c.appendChild(_[S].slider)},N=e=>{const t=k(e),i=document.createElement("div"),r=document.createElement("div");i.className="tobii__slide",i.style.position="absolute",i.style.left=100*_[S].x+"%",i.setAttribute("aria-hidden","true"),t.init(e,r,d),i.appendChild(r),_[S].slider.appendChild(i),_[S].sliderElements.push(i),++_[S].x},k=e=>{const t=e.getAttribute("data-type");return void 0!==a[t]?a[t]:(e.hasAttribute("data-type")&&console.log("Unknown lightbox element type: "+t),a.image)},O=e=>{if(I=null!==I?I:S,ue())throw new Error("Ups, I'm aleady open.");if(!ue()&&(e||(e=0),-1===e||e>=_[I].elementsLength))throw new Error(`Ups, I can't find slide ${e}.`);document.documentElement.classList.add("tobii-is-open"),document.body.classList.add("tobii-is-open"),document.body.classList.add("tobii-is-open-"+I),oe(),d.close||(h.disabled=!1,h.setAttribute("aria-hidden","true")),w=document.activeElement;const t=window.location.href;window.history.pushState({tobii:"close"},"Image",t),_[I].currentIndex=e,V(),se(),$(_[I].currentIndex),_[I].slider.setAttribute("aria-hidden","false"),c.setAttribute("aria-hidden","false"),de(),X(_[I].currentIndex+1),X(_[I].currentIndex-1),_[I].slider.classList.add("tobii__slider--animate");const i=new window.CustomEvent("open",{detail:{group:I}});c.dispatchEvent(i)},U=()=>{if(!ue())throw new Error("Ups, I'm already closed.");document.documentElement.classList.remove("tobii-is-open"),document.body.classList.remove("tobii-is-open"),document.body.classList.remove("tobii-is-open-"+I),ae(),null!==window.history.state&&"close"===window.history.state.tobii&&window.history.back(),w.focus(),H(_[I].currentIndex),D(_[I].currentIndex),c.setAttribute("aria-hidden","true"),_[I].slider.setAttribute("aria-hidden","true"),_[I].currentIndex=0,_[I].slider.classList.remove("tobii__slider--animate");const e=new window.CustomEvent("close",{detail:{group:I}});c.dispatchEvent(e)},X=e=>{if(void 0===_[I].sliderElements[e])return;const t=_[I].sliderElements[e].querySelector("[data-type]");k(t).onPreload(t)},$=e=>{if(void 0===_[I].sliderElements[e])return;const t=_[I].sliderElements[e].querySelector("[data-type]"),i=k(t);_[I].sliderElements[e].classList.add("tobii__slide--is-active"),_[I].sliderElements[e].setAttribute("aria-hidden","false"),i.onLoad(t,I)},z=()=>{if(!ue())throw new Error("Ups, I'm closed.");_[I].currentIndex>0&&(H(_[I].currentIndex),$(--_[I].currentIndex),de("left"),D(_[I].currentIndex+1),X(_[I].currentIndex-1));const e=new window.CustomEvent("previous",{detail:{group:I}});c.dispatchEvent(e)},M=()=>{if(!ue())throw new Error("Ups, I'm closed.");_[I].currentIndex<_[I].elementsLength-1&&(H(_[I].currentIndex),$(++_[I].currentIndex),de("right"),D(_[I].currentIndex-1),X(_[I].currentIndex+1));const e=new window.CustomEvent("next",{detail:{group:I}});c.dispatchEvent(e)},R=e=>{if(ue())throw new Error("Ups, I'm open.");if(!e)throw new Error("Ups, no group specified.");if(e&&!Object.prototype.hasOwnProperty.call(_,e))throw new Error(`Ups, I don't have a group called "${e}".`);I=e},H=e=>{if(void 0===_[I].sliderElements[e])return;const t=_[I].sliderElements[e].querySelector("[data-type]"),i=k(t);_[I].sliderElements[e].classList.remove("tobii__slide--is-active"),_[I].sliderElements[e].setAttribute("aria-hidden","true"),i.onLeave(t)},D=e=>{if(void 0===_[I].sliderElements[e])return;const t=_[I].sliderElements[e].querySelector("[data-type]");k(t).onCleanup(t)},B=()=>{I=null!==I?I:S,A=-_[I].currentIndex*c.offsetWidth,_[I].slider.style.transform=`translate3d(${A}px, 0, 0)`,E=A},V=()=>{m={startX:0,endX:0,startY:0,endY:0}},j=()=>{const e=m.endX-m.startX,t=m.endY-m.startY,i=Math.abs(e),r=Math.abs(t);e>0&&i>d.threshold&&_[I].currentIndex>0?z():e<0&&i>d.threshold&&_[I].currentIndex!==_[I].elementsLength-1?M():t<0&&r>d.threshold&&d.swipeClose?U():B()},W=()=>{L||(L=!0,window.requestAnimationFrame(()=>{B(),L=!1}))},F=e=>{e.preventDefault(),I=T(e.currentTarget),O(_[I].gallery.indexOf(e.currentTarget))},G=e=>{e.target===p?z():e.target===b?M():(e.target===h||!1===y&&!1===f&&e.target.classList.contains("tobii__slide")&&d.docClose)&&U(),e.stopPropagation()},J=e=>{const t=Array.prototype.slice.call(c.querySelectorAll(`.tobii__btn:not([disabled]), .tobii__slide--is-active ${o.join(", .tobii__slide--is-active ")}`)).filter(e=>!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)),i=t.indexOf(document.activeElement);9===e.keyCode||"Tab"===e.code?e.shiftKey&&0===i?(t[t.length-1].focus(),e.preventDefault()):e.shiftKey||i!==t.length-1||(t[0].focus(),e.preventDefault()):27===e.keyCode||"Escape"===e.code?(e.preventDefault(),U()):37===e.keyCode||"ArrowLeft"===e.code?(e.preventDefault(),z()):39!==e.keyCode&&"ArrowRight"!==e.code||(e.preventDefault(),M())},K=e=>{pe(e.target)||(e.stopPropagation(),y=!1,f=!1,v=!0,m.startX=e.touches[0].pageX,m.startY=e.touches[0].pageY,ce()&&_[I].slider.classList.add("tobii__slider--is-dragging"))},Q=e=>{e.stopPropagation(),v&&(m.endX=e.touches[0].pageX,m.endY=e.touches[0].pageY,ne())},Z=e=>{e.stopPropagation(),v=!1,_[I].slider.classList.remove("tobii__slider--is-dragging"),m.endX&&j(),V()},ee=e=>{pe(e.target)||(e.preventDefault(),e.stopPropagation(),y=!1,f=!1,v=!0,m.startX=e.pageX,m.startY=e.pageY,ce()&&_[I].slider.classList.add("tobii__slider--is-dragging"))},te=e=>{e.preventDefault(),v&&(m.endX=e.pageX,m.endY=e.pageY,ne())},ie=e=>{e.stopPropagation(),v=!1,_[I].slider.classList.remove("tobii__slider--is-dragging"),m.endX&&j(),V()},re=()=>{v=!1},ne=()=>{Math.abs(m.startX-m.endX)>0&&!f&&_[I].elementsLength>1?(_[I].slider.style.transform=`translate3d(${E-Math.round(m.startX-m.endX)}px, 0, 0)`,y=!0,f=!1):Math.abs(m.startY-m.endY)>0&&!y&&d.swipeClose&&(_[I].slider.style.transform=`translate3d(${E}px, -${Math.round(m.startY-m.endY)}px, 0)`,y=!1,f=!0)},se=()=>{d.keyboard&&window.addEventListener("keydown",J),window.addEventListener("resize",W),window.addEventListener("popstate",U),c.addEventListener("click",G),d.draggable&&ce()&&(c.addEventListener("touchstart",K),c.addEventListener("touchmove",Q),c.addEventListener("touchend",Z),c.addEventListener("mousedown",ee),c.addEventListener("mouseup",ie),c.addEventListener("mousemove",te),c.addEventListener("contextmenu",re))},ae=()=>{d.keyboard&&window.removeEventListener("keydown",J),window.removeEventListener("resize",W),window.removeEventListener("popstate",U),c.removeEventListener("click",G),d.draggable&&ce()&&(c.removeEventListener("touchstart",K),c.removeEventListener("touchmove",Q),c.removeEventListener("touchend",Z),c.removeEventListener("mousedown",ee),c.removeEventListener("mouseup",ie),c.removeEventListener("mousemove",te),c.removeEventListener("contextmenu",re))},oe=()=>{(d.draggable&&d.swipeClose&&ce()&&!_[I].slider.classList.contains("tobii__slider--is-draggable")||d.draggable&&_[I].elementsLength>1&&!_[I].slider.classList.contains("tobii__slider--is-draggable"))&&_[I].slider.classList.add("tobii__slider--is-draggable"),!d.nav||1===_[I].elementsLength||"auto"===d.nav&&ce()?(p.setAttribute("aria-hidden","true"),p.disabled=!0,b.setAttribute("aria-hidden","true"),b.disabled=!0):(p.setAttribute("aria-hidden","false"),p.disabled=!1,b.setAttribute("aria-hidden","false"),b.disabled=!1),g.setAttribute("aria-hidden",d.counter&&1!==_[I].elementsLength?"false":"true")},de=(e=null)=>{B(),g.textContent=`${_[I].currentIndex+1}/${_[I].elementsLength}`,(e=>{(!0===d.nav||"auto"===d.nav)&&!ce()&&_[I].elementsLength>1?(p.setAttribute("aria-hidden","true"),p.disabled=!0,b.setAttribute("aria-hidden","true"),b.disabled=!0,1===_[I].elementsLength?d.close&&h.focus():0===_[I].currentIndex?(b.setAttribute("aria-hidden","false"),b.disabled=!1,b.focus()):_[I].currentIndex===_[I].elementsLength-1?(p.setAttribute("aria-hidden","false"),p.disabled=!1,p.focus()):(p.setAttribute("aria-hidden","false"),p.disabled=!1,b.setAttribute("aria-hidden","false"),b.disabled=!1,"left"===e?p.focus():b.focus())):d.close&&h.focus()})(e)},le=()=>{ue()&&U(),Object.entries(_).forEach(e=>{e[1].gallery.forEach(e=>{q(e)})}),_={},S=I=null;for(const e in a)a[e].onReset()},ue=()=>"false"===c.getAttribute("aria-hidden"),ce=()=>"ontouchstart"in window,pe=e=>-1!==["TEXTAREA","OPTION","INPUT","SELECT"].indexOf(e.nodeName)||e===p||e===b||e===h;return(e=>{if(document.querySelector("div.tobii"))return void console.log("Multiple lightbox instances not supported.");d=(e=>({selector:".lightbox",captions:!0,captionsSelector:"img",captionAttribute:"alt",captionText:null,captionHTML:!1,nav:"auto",navText:['<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="15 6 9 12 15 18" /></svg>','<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="9 6 15 12 9 18" /></svg>'],navLabel:["Previous image","Next image"],close:!0,closeText:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><line x1="18" y1="6" x2="6" y2="18" /><line x1="6" y1="6" x2="18" y2="18" /></svg>',closeLabel:"Close lightbox",loadingIndicatorLabel:"Image loading",counter:!0,download:!1,downloadText:"",downloadLabel:"Download image",keyboard:!0,zoom:!0,zoomText:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path stroke="none" d="M0 0h24v24H0z"/><polyline points="16 4 20 4 20 8" /><line x1="14" y1="10" x2="20" y2="4" /><polyline points="8 20 4 20 4 16" /><line x1="4" y1="20" x2="10" y2="14" /><polyline points="16 20 20 20 20 16" /><line x1="14" y1="14" x2="20" y2="20" /><polyline points="8 4 4 4 4 8" /><line x1="4" y1="4" x2="10" y2="10" /></svg>',docClose:!0,swipeClose:!0,hideScrollbar:!0,draggable:!0,threshold:100,rtl:!1,loop:!1,autoplayVideo:!1,modal:!1,theme:"tobii--theme-default",...e}))(e),c||(c=document.createElement("div"),c.setAttribute("role","dialog"),c.setAttribute("aria-hidden","true"),c.classList.add("tobii"),c.classList.add(d.theme),p=document.createElement("button"),p.className="tobii__btn tobii__btn--previous",p.setAttribute("type","button"),p.setAttribute("aria-label",d.navLabel[0]),p.innerHTML=d.navText[0],c.appendChild(p),b=document.createElement("button"),b.className="tobii__btn tobii__btn--next",b.setAttribute("type","button"),b.setAttribute("aria-label",d.navLabel[1]),b.innerHTML=d.navText[1],c.appendChild(b),h=document.createElement("button"),h.className="tobii__btn tobii__btn--close",h.setAttribute("type","button"),h.setAttribute("aria-label",d.closeLabel),h.innerHTML=d.closeText,c.appendChild(h),g=document.createElement("div"),g.className="tobii__counter",c.appendChild(g),document.body.appendChild(c));const t=document.querySelectorAll(d.selector);if(!t)throw new Error(`Ups, I can't find the selector ${d.selector} on this website.`);const i=[];t.forEach(e=>{const t=e.hasAttribute("data-group")?e.getAttribute("data-group"):"default";let r=e.href;e.hasAttribute("data-target")&&(r=e.getAttribute("data-target")),r+="__"+t,void 0!==i[r]?e.addEventListener("click",e=>{R(t),O(),e.preventDefault()}):(i[r]=1,C(e))})})(s),n.open=O,n.previous=z,n.next=M,n.close=U,n.add=C,n.remove=q,n.reset=le,n.destroy=()=>{le(),c.parentNode.removeChild(c)},n.isOpen=ue,n.slidesIndex=()=>_[I].currentIndex,n.select=e=>{const t=_[I].currentIndex;if(!ue())throw new Error("Ups, I'm closed.");if(ue()){if(!e&&0!==e)throw new Error("Ups, no slide specified.");if(e===_[I].currentIndex)throw new Error(`Ups, slide ${e} is already selected.`);if(-1===e||e>=_[I].elementsLength)throw new Error(`Ups, I can't find slide ${e}.`)}_[I].currentIndex=e,H(t),$(e),e<t&&(de("left"),D(t),X(e-1)),e>t&&(de("right"),D(t),X(e+1))},n.slidesCount=()=>_[I].elementsLength,n.selectGroup=R,n.currentGroup=()=>null!==I?I:S,n.on=(e,t)=>{c.addEventListener(e,t)},n.off=(e,t)=>{c.removeEventListener(e,t)},n}}); |
{ | ||
"name": "@midzer/tobii", | ||
"version": "2.4.0", | ||
"version": "2.5.0", | ||
"description": "An accessible, open-source lightbox with no dependencies.", | ||
@@ -22,10 +22,10 @@ "main": "dist/tobii.js", | ||
"cross-env": "^7.0.3", | ||
"eslint": "^8.17.0", | ||
"eslint": "^8.32.0", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-standard": "^5.0.0", | ||
"microbundle": "^0.15.0", | ||
"node-sass": "^7.0.1", | ||
"microbundle": "^0.15.1", | ||
"node-sass": "^7.0.3", | ||
"rimraf": "^3.0.2", | ||
"standard": "^17.0.0", | ||
"stylelint": "^14.8.5" | ||
"stylelint": "^14.16.1" | ||
}, | ||
@@ -32,0 +32,0 @@ "browserslist": { |
@@ -267,2 +267,3 @@ # Tobii | ||
| captionText | function | null | Custom callback which returns the caption text for the current element. The first argument of the callback is the element. If set, `captionsSelector` and `captionAttribute` are ignored. | | ||
| captionHTML | bool | false | Allow HTML captions. | | ||
| nav | bool, "auto" | "auto" | Display navigation buttons. "auto" hides buttons on touch-enabled devices. | | ||
@@ -284,2 +285,3 @@ | navText | string | ["inline svg", "inline svg"] | Text or HTML for the navigation buttons. | | ||
| autoplayVideo | bool | false | Videos will automatically start playing as soon as they can do so without stopping to finish loading the data. | | ||
| autoplayAudio | bool | false | Audio will automatically start playing. | | ||
@@ -286,0 +288,0 @@ ### Data attributes |
@@ -5,3 +5,3 @@ /** | ||
* @author midzer | ||
* @version 2.4.0 | ||
* @version 2.5.0 | ||
* @url https://github.com/midzer/tobii | ||
@@ -83,2 +83,3 @@ * | ||
captionText: null, | ||
captionHTML: false, | ||
nav: 'auto', | ||
@@ -263,3 +264,3 @@ navText: [ | ||
updateConfig() | ||
updateLightbox(null) | ||
updateLightbox() | ||
} | ||
@@ -293,3 +294,2 @@ } else { | ||
// TODO If there is only one slide left, deactivate horizontal dragging/ swiping | ||
// TODO Recalculate counter | ||
// TODO Set new absolute position per slide | ||
@@ -303,8 +303,12 @@ | ||
} | ||
updateConfig() | ||
updateLightbox() | ||
} | ||
} | ||
// TODO Remove element | ||
// groups[GROUP_NAME].gallery.splice(groups[GROUP_NAME].gallery.indexOf(el)) don't work | ||
groups[GROUP_NAME].gallery.splice(groups[GROUP_NAME].gallery.indexOf(el)) | ||
groups[GROUP_NAME].sliderElements.splice(groups[GROUP_NAME].gallery.indexOf(el)) | ||
groups[GROUP_NAME].elementsLength-- | ||
--groups[GROUP_NAME].x | ||
@@ -491,3 +495,3 @@ // Remove zoom icon if necessary | ||
updateLightbox(null) | ||
updateLightbox() | ||
@@ -593,3 +597,3 @@ // Preload previous and next slide | ||
model.onLoad(CONTAINER) | ||
model.onLoad(CONTAINER, activeGroup) | ||
} | ||
@@ -779,3 +783,3 @@ | ||
* | ||
* @param {string} dir - Current slide direction | ||
* @param {string|null} dir - Current slide direction | ||
*/ | ||
@@ -1219,3 +1223,3 @@ const updateFocus = (dir) => { | ||
*/ | ||
const updateLightbox = (dir) => { | ||
const updateLightbox = (dir = null) => { | ||
updateOffset() | ||
@@ -1222,0 +1226,0 @@ updateCounter() |
@@ -28,3 +28,3 @@ class HtmlType { | ||
onLoad (container) { | ||
onLoad (container, group) { | ||
const VIDEO = container.querySelector('video') | ||
@@ -43,2 +43,12 @@ | ||
} | ||
const audio = container.querySelector('audio') | ||
if (audio) { | ||
if (this.userSettings.autoplayAudio) { | ||
// Start playback (and loading if necessary) | ||
audio.play() | ||
} | ||
} | ||
container.classList.add('tobii-group-' + group) | ||
} | ||
@@ -60,2 +70,11 @@ | ||
} | ||
const audio = container.querySelector('audio') | ||
if (audio) { | ||
if (!audio.paused) { | ||
// Stop if is playing | ||
audio.pause() | ||
} | ||
} | ||
} | ||
@@ -62,0 +81,0 @@ |
@@ -35,13 +35,20 @@ class ImageType { | ||
if (this.userSettings.captions) { | ||
let captionContent | ||
if (typeof this.userSettings.captionText === 'function') { | ||
FIGCAPTION.textContent = this.userSettings.captionText(el) | ||
captionContent = this.userSettings.captionText(el) | ||
} else if (this.userSettings.captionsSelector === 'self' && | ||
el.getAttribute(this.userSettings.captionAttribute)) { | ||
FIGCAPTION.textContent = el.getAttribute(this.userSettings.captionAttribute) | ||
captionContent = el.getAttribute(this.userSettings.captionAttribute) | ||
} else if (this.userSettings.captionsSelector === 'img' && THUMBNAIL && | ||
THUMBNAIL.getAttribute(this.userSettings.captionAttribute)) { | ||
FIGCAPTION.textContent = THUMBNAIL.getAttribute(this.userSettings.captionAttribute) | ||
captionContent = THUMBNAIL.getAttribute(this.userSettings.captionAttribute) | ||
} | ||
if (FIGCAPTION.textContent) { | ||
if (this.userSettings.captionHTML) { | ||
FIGCAPTION.innerHTML = captionContent | ||
} else { | ||
FIGCAPTION.textContent = captionContent | ||
} | ||
if (captionContent) { | ||
FIGCAPTION.id = `tobii-figcaption-${this.figcaptionId}` | ||
@@ -48,0 +55,0 @@ FIGURE.appendChild(FIGCAPTION) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
180911
1908
376
20