bs5-lightbox
Advanced tools
Comparing version 1.8.0 to 1.8.1
/*! | ||
* Lightbox for Bootstrap 5 v1.8.0 (https://trvswgnr.github.io/bs5-lightbox/) | ||
* Lightbox for Bootstrap 5 v1.8.1 (https://trvswgnr.github.io/bs5-lightbox/) | ||
* Copyright 2022 Travis Aaron Wagner (https://github.com/trvswgnr/) | ||
* Licensed under MIT (https://github.com/trvswgnr/bs5-lightbox/blob/main/LICENSE) | ||
*/!function(){"use strict";var t={d:function(e,s){for(var a in s)t.o(s,a)&&!t.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:s[a]})},o:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}},e={};t.d(e,{default:function(){return i}});var s=window.bootstrap;const a={Modal:s.Modal,Carousel:s.Carousel};class o{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.hash=this.randomHash(),this.settings=Object.assign(Object.assign(Object.assign({},a.Modal.Default),a.Carousel.Default),{interval:!1,target:'[data-toggle="lightbox"]',gallery:"",size:"xl"}),this.modalOptions=(()=>this.setOptionsFromSettings(a.Modal.Default))(),this.carouselOptions=(()=>this.setOptionsFromSettings(a.Carousel.Default))(),"string"==typeof t&&(this.settings.target=t,t=document.querySelector(this.settings.target)),this.settings=Object.assign(Object.assign({},this.settings),e),this.el=t,this.type=t.dataset.type||"",this.src=this.getSrc(t),this.sources=this.getGalleryItems(),this.createCarousel(),this.createModal()}show(){document.body.appendChild(this.modalElement),this.modal.show()}hide(){this.modal.hide()}setOptionsFromSettings(t){return Object.keys(t).reduce(((t,e)=>Object.assign(t,{[e]:this.settings[e]})),{})}getSrc(t){let e=t.dataset.src||t.dataset.remote||t.href||"http://via.placeholder.com/1600x900";if("html"===t.dataset.type)return e;/\:\/\//.test(e)||(e=window.location.origin+e);const s=new URL(e);return(t.dataset.footer||t.dataset.caption)&&s.searchParams.set("caption",t.dataset.footer||t.dataset.caption),s.toString()}getGalleryItems(){let t;if(this.settings.gallery){if(Array.isArray(this.settings.gallery))return this.settings.gallery;t=this.settings.gallery}else this.el.dataset.gallery&&(t=this.el.dataset.gallery);return t?[...new Set(Array.from(document.querySelectorAll('[data-gallery="'.concat(t,'"]')),(t=>"".concat(t.dataset.type?t.dataset.type:"").concat(this.getSrc(t)))))]:["".concat(this.type?this.type:"").concat(this.src)]}getYoutubeId(t){if(!t)return!1;const e=t.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/);return!(!e||11!==e[2].length)&&e[2]}getInstagramEmbed(t){if(/instagram/.test(t))return t+=/\/embed$/.test(t)?"":"/embed",'<iframe src="'.concat(t,'" class="start-50 translate-middle-x" style="max-width: 500px" frameborder="0" scrolling="no" allowtransparency="true"></iframe>')}isEmbed(t){const e=new RegExp("("+o.allowedEmbedTypes.join("|")+")").test(t),s=/\.(png|jpe?g|gif|svg|webp)/i.test(t)||"image"===this.el.dataset.type;return e||!s}createCarousel(){const t=document.createElement("template"),e=o.allowedMediaTypes.join("|"),s=this.sources.map(((t,s)=>{t=t.replace(/\/$/,"");const a=new RegExp("^(".concat(e,")"),"i"),o=/^html/.test(t),i=/^image/.test(t);a.test(t)&&(t=t.replace(a,""));let n='<img src="'.concat(t,'" class="d-block w-100 h-100 img-fluid" style="z-index: 1; object-fit: contain;" />'),l="";const r=this.getInstagramEmbed(t),c=this.getYoutubeId(t);this.isEmbed(t)&&!i&&(c&&(t="https://www.youtube.com/embed/".concat(c),l='title="YouTube video player" frameborder="0" allow="accelerometer autoplay clipboard-write encrypted-media gyroscope picture-in-picture"'),n=r||'<iframe src="'.concat(t,'" ').concat(l," allowfullscreen></iframe>")),o&&(n=t);const d=new URLSearchParams(t.split("?")[1]);let h="";return d.get("caption")&&(h='<p class="lightbox-caption m-0 p-2 text-center text-white small"><em>'.concat(d.get("caption"),"</em></p>")),'\n\t\t\t\t<div class="carousel-item '.concat(s?"":"active",'" style="min-height: 100px">\n\t\t\t\t\t').concat('<div class="position-absolute top-50 start-50 translate-middle text-white"><div class="spinner-border" style="width: 3rem height: 3rem" role="status"></div></div>','\n\t\t\t\t\t<div class="ratio ratio-16x9" style="background-color: #000;">').concat(n,"</div>\n\t\t\t\t\t").concat(h,"\n\t\t\t\t</div>")})).join(""),i=this.sources.length<2?"":'\n\t\t\t<button id="#lightboxCarousel-'.concat(this.hash,'-prev" class="carousel-control carousel-control-prev h-75 m-auto" type="button" data-bs-target="#lightboxCarousel-').concat(this.hash,'" data-bs-slide="prev">\n\t\t\t\t<span class="carousel-control-prev-icon" aria-hidden="true"></span>\n\t\t\t\t<span class="visually-hidden">Previous</span>\n\t\t\t</button>\n\t\t\t<button id="#lightboxCarousel-').concat(this.hash,'-next" class="carousel-control carousel-control-next h-75 m-auto" type="button" data-bs-target="#lightboxCarousel-').concat(this.hash,'" data-bs-slide="next">\n\t\t\t\t<span class="carousel-control-next-icon" aria-hidden="true"></span>\n\t\t\t\t<span class="visually-hidden">Next</span>\n\t\t\t</button>');let n="lightbox-carousel carousel";"fullscreen"===this.settings.size&&(n+=" position-absolute w-100 translate-middle top-50 start-50");const l='\n\t\t\t<div id="lightboxCarousel-'.concat(this.hash,'" class="').concat(n,'" data-bs-ride="carousel" data-bs-interval="').concat(this.carouselOptions.interval,'">\n\t\t\t\t<div class="carousel-inner">\n\t\t\t\t\t').concat(s,"\n\t\t\t\t</div>\n\t\t\t\t").concat(i,"\n\t\t\t</div>");t.innerHTML=l.trim(),this.carouselElement=t.content.firstChild;const r=Object.assign(Object.assign({},this.carouselOptions),{keyboard:!1});this.carousel=new a.Carousel(this.carouselElement,r);const c=this.type&&"image"!==this.type?this.type+this.src:this.src;return this.carousel.to(this.findGalleryItemIndex(this.sources,c)),!0===this.carouselOptions.keyboard&&document.addEventListener("keydown",(t=>{if("ArrowLeft"===t.code){const t=document.getElementById("#lightboxCarousel-".concat(this.hash,"-prev"));return t&&t.click(),!1}if("ArrowRight"===t.code){const t=document.getElementById("#lightboxCarousel-".concat(this.hash,"-next"));return t&&t.click(),!1}})),this.carousel}findGalleryItemIndex(t,e){let s=0;for(const a of t){if(a.includes(e))return s;s++}return 0}createModal(){const t=document.createElement("template"),e='\n\t\t\t<div class="modal lightbox fade" id="lightboxModal-'.concat(this.hash,'" tabindex="-1" aria-hidden="true">\n\t\t\t\t<div class="modal-dialog modal-dialog-centered modal-').concat(this.settings.size,'">\n\t\t\t\t\t<div class="modal-content border-0 bg-transparent">\n\t\t\t\t\t\t<div class="modal-body p-0">\n\t\t\t\t\t\t\t<button type="button" class="btn-close position-absolute top-0 end-0 p-3" data-bs-dismiss="modal" aria-label="Close" style="z-index: 2; background: none;">').concat('<svg xmlns="http://www.w3.org/2000/svg" style="position: relative; top: -5px;" viewBox="0 0 16 16" fill="#fff"><path d="M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z"/></svg>',"</button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>");return t.innerHTML=e.trim(),this.modalElement=t.content.firstChild,this.modalElement.querySelector(".modal-body").appendChild(this.carouselElement),this.modalElement.addEventListener("hidden.bs.modal",(()=>this.modalElement.remove())),this.modalElement.querySelector("[data-bs-dismiss]").addEventListener("click",(()=>this.modal.hide())),this.modal=new a.Modal(this.modalElement,this.modalOptions),this.modal}randomHash(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8;return Array.from({length:t},(()=>Math.floor(36*Math.random()).toString(36))).join("")}}o.allowedEmbedTypes=["embed","youtube","vimeo","instagram","url"],o.allowedMediaTypes=[...o.allowedEmbedTypes,"image","html"],o.defaultSelector='[data-toggle="lightbox"]',o.initialize=function(t){t.preventDefault();new o(this).show()},document.querySelectorAll(o.defaultSelector).forEach((t=>t.addEventListener("click",o.initialize))),"undefined"!=typeof window&&window.bootstrap&&(window.bootstrap.Lightbox=o);var i=o;window.Lightbox=e.default}(); | ||
*/!function(){"use strict";var t={d:function(e,s){for(var a in s)t.o(s,a)&&!t.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:s[a]})},o:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}},e={};t.d(e,{default:function(){return i}});var s=window.bootstrap;const a={Modal:s.Modal,Carousel:s.Carousel};class o{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.hash=this.randomHash(),this.settings=Object.assign(Object.assign(Object.assign({},a.Modal.Default),a.Carousel.Default),{interval:!1,target:'[data-toggle="lightbox"]',gallery:"",size:"xl",constrain:!0}),this.modalOptions=(()=>this.setOptionsFromSettings(a.Modal.Default))(),this.carouselOptions=(()=>this.setOptionsFromSettings(a.Carousel.Default))(),"string"==typeof t&&(this.settings.target=t,t=document.querySelector(this.settings.target)),this.settings=Object.assign(Object.assign({},this.settings),e),this.el=t,this.type=t.dataset.type||"",this.src=this.getSrc(t),this.sources=this.getGalleryItems(),this.createCarousel(),this.createModal()}show(){document.body.appendChild(this.modalElement),this.modal.show()}hide(){this.modal.hide()}setOptionsFromSettings(t){return Object.keys(t).reduce(((t,e)=>Object.assign(t,{[e]:this.settings[e]})),{})}getSrc(t){let e=t.dataset.src||t.dataset.remote||t.href||"http://via.placeholder.com/1600x900";if("html"===t.dataset.type)return e;/\:\/\//.test(e)||(e=window.location.origin+e);const s=new URL(e);return(t.dataset.footer||t.dataset.caption)&&s.searchParams.set("caption",t.dataset.footer||t.dataset.caption),s.toString()}getGalleryItems(){let t;if(this.settings.gallery){if(Array.isArray(this.settings.gallery))return this.settings.gallery;t=this.settings.gallery}else this.el.dataset.gallery&&(t=this.el.dataset.gallery);return t?[...new Set(Array.from(document.querySelectorAll('[data-gallery="'.concat(t,'"]')),(t=>"".concat(t.dataset.type?t.dataset.type:"").concat(this.getSrc(t)))))]:["".concat(this.type?this.type:"").concat(this.src)]}getYoutubeId(t){if(!t)return!1;const e=t.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/);return!(!e||11!==e[2].length)&&e[2]}getYoutubeLink(t){const e=this.getYoutubeId(t);if(!e)return"false";const s=t.split("?");let a=s.length>1?"?"+s[1]:"";return"https://www.youtube.com/embed/".concat(e).concat(a)}getInstagramEmbed(t){if(/instagram/.test(t))return t+=/\/embed$/.test(t)?"":"/embed",'<iframe src="'.concat(t,'" class="start-50 translate-middle-x" style="max-width: 500px" frameborder="0" scrolling="no" allowtransparency="true"></iframe>')}isEmbed(t){const e=new RegExp("("+o.allowedEmbedTypes.join("|")+")").test(t),s=/\.(png|jpe?g|gif|svg|webp)/i.test(t)||"image"===this.el.dataset.type;return e||!s}createCarousel(){const t=document.createElement("template"),e=o.allowedMediaTypes.join("|"),s=this.sources.map(((t,s)=>{t=t.replace(/\/$/,"");const a=new RegExp("^(".concat(e,")"),"i"),o=/^html/.test(t),i=/^image/.test(t);a.test(t)&&(t=t.replace(a,""));const n=this.settings.constrain?"mw-100 mh-100 h-auto w-auto m-auto top-0 end-0 bottom-0 start-0":"h-100 w-100",l=new URLSearchParams(t.split("?")[1]);let r="",c=t;if(l.get("caption")){try{c=new URL(t),c.searchParams.delete("caption"),c=c.toString()}catch(e){c=t}r='<p class="lightbox-caption m-0 p-2 text-center text-white small"><em>'.concat(l.get("caption"),"</em></p>")}let d='<img src="'.concat(c,'" class="d-block ').concat(n,' img-fluid" style="z-index: 1; object-fit: contain;" />'),h="";const u=this.getInstagramEmbed(t),m=this.getYoutubeLink(t);this.isEmbed(t)&&!i&&(m&&(t=m,h='title="YouTube video player" frameborder="0" allow="accelerometer autoplay clipboard-write encrypted-media gyroscope picture-in-picture"'),d=u||'<iframe src="'.concat(t,'" ').concat(h," allowfullscreen></iframe>")),o&&(d=t);return'\n\t\t\t\t<div class="carousel-item '.concat(s?"":"active",'" style="min-height: 100px">\n\t\t\t\t\t').concat('<div class="position-absolute top-50 start-50 translate-middle text-white"><div class="spinner-border" style="width: 3rem height: 3rem" role="status"></div></div>','\n\t\t\t\t\t<div class="ratio ratio-16x9" style="background-color: #000;">').concat(d,"</div>\n\t\t\t\t\t").concat(r,"\n\t\t\t\t</div>")})).join(""),i=this.sources.length<2?"":'\n\t\t\t<button id="#lightboxCarousel-'.concat(this.hash,'-prev" class="carousel-control carousel-control-prev h-75 m-auto" type="button" data-bs-target="#lightboxCarousel-').concat(this.hash,'" data-bs-slide="prev">\n\t\t\t\t<span class="carousel-control-prev-icon" aria-hidden="true"></span>\n\t\t\t\t<span class="visually-hidden">Previous</span>\n\t\t\t</button>\n\t\t\t<button id="#lightboxCarousel-').concat(this.hash,'-next" class="carousel-control carousel-control-next h-75 m-auto" type="button" data-bs-target="#lightboxCarousel-').concat(this.hash,'" data-bs-slide="next">\n\t\t\t\t<span class="carousel-control-next-icon" aria-hidden="true"></span>\n\t\t\t\t<span class="visually-hidden">Next</span>\n\t\t\t</button>');let n="lightbox-carousel carousel slide";"fullscreen"===this.settings.size&&(n+=" position-absolute w-100 translate-middle top-50 start-50");const l='\n\t\t\t<div id="lightboxCarousel-'.concat(this.hash,'" class="').concat(n,'" data-bs-ride="carousel" data-bs-interval="').concat(this.carouselOptions.interval,'">\n\t\t\t\t<div class="carousel-inner">\n\t\t\t\t\t').concat(s,"\n\t\t\t\t</div>\n\t\t\t\t").concat(i,"\n\t\t\t</div>");t.innerHTML=l.trim(),this.carouselElement=t.content.firstChild;const r=Object.assign(Object.assign({},this.carouselOptions),{keyboard:!1});this.carousel=new a.Carousel(this.carouselElement,r);const c=this.type&&"image"!==this.type?this.type+this.src:this.src;return this.carousel.to(this.findGalleryItemIndex(this.sources,c)),!0===this.carouselOptions.keyboard&&document.addEventListener("keydown",(t=>{if("ArrowLeft"===t.code){const t=document.getElementById("#lightboxCarousel-".concat(this.hash,"-prev"));return t&&t.click(),!1}if("ArrowRight"===t.code){const t=document.getElementById("#lightboxCarousel-".concat(this.hash,"-next"));return t&&t.click(),!1}})),this.carousel}findGalleryItemIndex(t,e){let s=0;for(const a of t){if(a.includes(e))return s;s++}return 0}createModal(){const t=document.createElement("template"),e='\n\t\t\t<div class="modal lightbox fade" id="lightboxModal-'.concat(this.hash,'" tabindex="-1" aria-hidden="true">\n\t\t\t\t<div class="modal-dialog modal-dialog-centered modal-').concat(this.settings.size,'">\n\t\t\t\t\t<div class="modal-content border-0 bg-transparent">\n\t\t\t\t\t\t<div class="modal-body p-0">\n\t\t\t\t\t\t\t<button type="button" class="btn-close position-absolute top-0 end-0 p-3" data-bs-dismiss="modal" aria-label="Close" style="z-index: 2; background: none;">').concat('<svg xmlns="http://www.w3.org/2000/svg" style="position: relative; top: -5px;" viewBox="0 0 16 16" fill="#fff"><path d="M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z"/></svg>',"</button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>");return t.innerHTML=e.trim(),this.modalElement=t.content.firstChild,this.modalElement.querySelector(".modal-body").appendChild(this.carouselElement),this.modalElement.addEventListener("hidden.bs.modal",(()=>this.modalElement.remove())),this.modalElement.querySelector("[data-bs-dismiss]").addEventListener("click",(()=>this.modal.hide())),this.modal=new a.Modal(this.modalElement,this.modalOptions),this.modal}randomHash(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8;return Array.from({length:t},(()=>Math.floor(36*Math.random()).toString(36))).join("")}}o.allowedEmbedTypes=["embed","youtube","vimeo","instagram","url"],o.allowedMediaTypes=[...o.allowedEmbedTypes,"image","html"],o.defaultSelector='[data-toggle="lightbox"]',o.initialize=function(t){t.preventDefault();new o(this).show()},document.querySelectorAll(o.defaultSelector).forEach((t=>t.addEventListener("click",o.initialize))),"undefined"!=typeof window&&window.bootstrap&&(window.bootstrap.Lightbox=o);var i=o;window.Lightbox=e.default}(); | ||
//# sourceMappingURL=index.bundle.min.js.map |
@@ -8,39 +8,40 @@ /** | ||
declare class Lightbox { | ||
static allowedEmbedTypes: readonly ["embed", "youtube", "vimeo", "instagram", "url"]; | ||
static allowedMediaTypes: readonly ["embed", "youtube", "vimeo", "instagram", "url", "image", "html"]; | ||
static defaultSelector: "[data-toggle=\"lightbox\"]"; | ||
constructor(el: string | HTMLElement, options?: any); | ||
private hash; | ||
private settings; | ||
modalOptions: bootstrap.Modal.Options; | ||
carouselOptions: bootstrap.Carousel.Options; | ||
carouselElement: HTMLElement; | ||
modalElement: HTMLElement; | ||
modal: bootstrap.Modal; | ||
carousel: bootstrap.Carousel; | ||
sources: string[]; | ||
src: string; | ||
type: Lightbox.AllowedMedia; | ||
el: HTMLElement; | ||
static initialize: (e: Event) => void; | ||
show(): void; | ||
hide(): void; | ||
private setOptionsFromSettings; | ||
private getSrc; | ||
private getGalleryItems; | ||
private getYoutubeId; | ||
private getInstagramEmbed; | ||
private isEmbed; | ||
private createCarousel; | ||
private createModal; | ||
private randomHash; | ||
static allowedEmbedTypes: readonly ['embed', 'youtube', 'vimeo', 'instagram', 'url']; | ||
static allowedMediaTypes: readonly ['embed', 'youtube', 'vimeo', 'instagram', 'url', 'image', 'html']; | ||
static defaultSelector: '[data-toggle="lightbox"]'; | ||
constructor(el: string | HTMLElement, options?: any); | ||
private hash; | ||
private settings; | ||
modalOptions: bootstrap.Modal.Options; | ||
carouselOptions: bootstrap.Carousel.Options; | ||
carouselElement: HTMLElement; | ||
modalElement: HTMLElement; | ||
modal: bootstrap.Modal; | ||
carousel: bootstrap.Carousel; | ||
sources: string[]; | ||
src: string; | ||
type: Lightbox.AllowedMedia; | ||
el: HTMLElement; | ||
static initialize: (e: Event) => void; | ||
show(): void; | ||
hide(): void; | ||
private setOptionsFromSettings; | ||
private getSrc; | ||
private getGalleryItems; | ||
private getYoutubeId; | ||
private getInstagramEmbed; | ||
private isEmbed; | ||
private createCarousel; | ||
private createModal; | ||
private randomHash; | ||
} | ||
declare namespace Lightbox { | ||
type AllowedMedia = typeof Lightbox.allowedMediaTypes[number]; | ||
interface Options extends bootstrap.Modal.Options, bootstrap.Carousel.Options { | ||
target: string | HTMLElement; | ||
gallery: string | string[]; | ||
size: 'default' | 'sm' | 'lg' | 'xl' | 'fullscreen'; | ||
} | ||
type AllowedMedia = typeof Lightbox.allowedMediaTypes[number]; | ||
interface Options extends bootstrap.Modal.Options, bootstrap.Carousel.Options { | ||
target: string | HTMLElement; | ||
gallery: string | string[]; | ||
size: 'default' | 'sm' | 'lg' | 'xl' | 'fullscreen'; | ||
constrain: boolean; | ||
} | ||
} | ||
export default Lightbox; |
@@ -1,3 +0,7 @@ | ||
/*! For license information please see index.js.LICENSE.txt */ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("bootstrap")):"function"==typeof define&&define.amd?define("Lightbox",["bootstrap"],e):"object"==typeof exports?exports.Lightbox=e(require("bootstrap")):t.Lightbox=e(t.bootstrap)}(self,(function(t){return function(){"use strict";var e={988:function(e){e.exports=t}},s={};function a(t){var i=s[t];if(void 0!==i)return i.exports;var o=s[t]={exports:{}};return e[t](o,o.exports,a),o.exports}a.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return a.d(e,{a:e}),e},a.d=function(t,e){for(var s in e)a.o(e,s)&&!a.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},a.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)};var i={};return function(){var t=a(988);const e={Modal:t.Modal,Carousel:t.Carousel};class s{constructor(t,s={}){this.hash=this.randomHash(),this.settings=Object.assign(Object.assign(Object.assign({},e.Modal.Default),e.Carousel.Default),{interval:!1,target:'[data-toggle="lightbox"]',gallery:"",size:"xl"}),this.modalOptions=(()=>this.setOptionsFromSettings(e.Modal.Default))(),this.carouselOptions=(()=>this.setOptionsFromSettings(e.Carousel.Default))(),"string"==typeof t&&(this.settings.target=t,t=document.querySelector(this.settings.target)),this.settings=Object.assign(Object.assign({},this.settings),s),this.el=t,this.type=t.dataset.type||"",this.src=this.getSrc(t),this.sources=this.getGalleryItems(),this.createCarousel(),this.createModal()}show(){document.body.appendChild(this.modalElement),this.modal.show()}hide(){this.modal.hide()}setOptionsFromSettings(t){return Object.keys(t).reduce(((t,e)=>Object.assign(t,{[e]:this.settings[e]})),{})}getSrc(t){let e=t.dataset.src||t.dataset.remote||t.href||"http://via.placeholder.com/1600x900";if("html"===t.dataset.type)return e;/\:\/\//.test(e)||(e=window.location.origin+e);const s=new URL(e);return(t.dataset.footer||t.dataset.caption)&&s.searchParams.set("caption",t.dataset.footer||t.dataset.caption),s.toString()}getGalleryItems(){let t;if(this.settings.gallery){if(Array.isArray(this.settings.gallery))return this.settings.gallery;t=this.settings.gallery}else this.el.dataset.gallery&&(t=this.el.dataset.gallery);return t?[...new Set(Array.from(document.querySelectorAll(`[data-gallery="${t}"]`),(t=>`${t.dataset.type?t.dataset.type:""}${this.getSrc(t)}`)))]:[`${this.type?this.type:""}${this.src}`]}getYoutubeId(t){if(!t)return!1;const e=t.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/);return!(!e||11!==e[2].length)&&e[2]}getInstagramEmbed(t){if(/instagram/.test(t))return`<iframe src="${t+=/\/embed$/.test(t)?"":"/embed"}" class="start-50 translate-middle-x" style="max-width: 500px" frameborder="0" scrolling="no" allowtransparency="true"></iframe>`}isEmbed(t){const e=new RegExp("("+s.allowedEmbedTypes.join("|")+")").test(t),a=/\.(png|jpe?g|gif|svg|webp)/i.test(t)||"image"===this.el.dataset.type;return e||!a}createCarousel(){const t=document.createElement("template"),a=s.allowedMediaTypes.join("|"),i=this.sources.map(((t,e)=>{t=t.replace(/\/$/,"");const s=new RegExp(`^(${a})`,"i"),i=/^html/.test(t),o=/^image/.test(t);s.test(t)&&(t=t.replace(s,""));let r=`<img src="${t}" class="d-block w-100 h-100 img-fluid" style="z-index: 1; object-fit: contain;" />`,n="";const l=this.getInstagramEmbed(t),d=this.getYoutubeId(t);this.isEmbed(t)&&!o&&(d&&(t=`https://www.youtube.com/embed/${d}`,n='title="YouTube video player" frameborder="0" allow="accelerometer autoplay clipboard-write encrypted-media gyroscope picture-in-picture"'),r=l||`<iframe src="${t}" ${n} allowfullscreen></iframe>`),i&&(r=t);const c=new URLSearchParams(t.split("?")[1]);let h="";return c.get("caption")&&(h=`<p class="lightbox-caption m-0 p-2 text-center text-white small"><em>${c.get("caption")}</em></p>`),`\n\t\t\t\t<div class="carousel-item ${e?"":"active"}" style="min-height: 100px">\n\t\t\t\t\t<div class="position-absolute top-50 start-50 translate-middle text-white"><div class="spinner-border" style="width: 3rem height: 3rem" role="status"></div></div>\n\t\t\t\t\t<div class="ratio ratio-16x9" style="background-color: #000;">${r}</div>\n\t\t\t\t\t${h}\n\t\t\t\t</div>`})).join(""),o=this.sources.length<2?"":`\n\t\t\t<button id="#lightboxCarousel-${this.hash}-prev" class="carousel-control carousel-control-prev h-75 m-auto" type="button" data-bs-target="#lightboxCarousel-${this.hash}" data-bs-slide="prev">\n\t\t\t\t<span class="carousel-control-prev-icon" aria-hidden="true"></span>\n\t\t\t\t<span class="visually-hidden">Previous</span>\n\t\t\t</button>\n\t\t\t<button id="#lightboxCarousel-${this.hash}-next" class="carousel-control carousel-control-next h-75 m-auto" type="button" data-bs-target="#lightboxCarousel-${this.hash}" data-bs-slide="next">\n\t\t\t\t<span class="carousel-control-next-icon" aria-hidden="true"></span>\n\t\t\t\t<span class="visually-hidden">Next</span>\n\t\t\t</button>`;let r="lightbox-carousel carousel";"fullscreen"===this.settings.size&&(r+=" position-absolute w-100 translate-middle top-50 start-50");const n=`\n\t\t\t<div id="lightboxCarousel-${this.hash}" class="${r}" data-bs-ride="carousel" data-bs-interval="${this.carouselOptions.interval}">\n\t\t\t\t<div class="carousel-inner">\n\t\t\t\t\t${i}\n\t\t\t\t</div>\n\t\t\t\t${o}\n\t\t\t</div>`;t.innerHTML=n.trim(),this.carouselElement=t.content.firstChild;const l=Object.assign(Object.assign({},this.carouselOptions),{keyboard:!1});this.carousel=new e.Carousel(this.carouselElement,l);const d=this.type&&"image"!==this.type?this.type+this.src:this.src;return this.carousel.to(this.findGalleryItemIndex(this.sources,d)),!0===this.carouselOptions.keyboard&&document.addEventListener("keydown",(t=>{if("ArrowLeft"===t.code){const t=document.getElementById(`#lightboxCarousel-${this.hash}-prev`);return t&&t.click(),!1}if("ArrowRight"===t.code){const t=document.getElementById(`#lightboxCarousel-${this.hash}-next`);return t&&t.click(),!1}})),this.carousel}findGalleryItemIndex(t,e){let s=0;for(const a of t){if(a.includes(e))return s;s++}return 0}createModal(){const t=document.createElement("template"),s=`\n\t\t\t<div class="modal lightbox fade" id="lightboxModal-${this.hash}" tabindex="-1" aria-hidden="true">\n\t\t\t\t<div class="modal-dialog modal-dialog-centered modal-${this.settings.size}">\n\t\t\t\t\t<div class="modal-content border-0 bg-transparent">\n\t\t\t\t\t\t<div class="modal-body p-0">\n\t\t\t\t\t\t\t<button type="button" class="btn-close position-absolute top-0 end-0 p-3" data-bs-dismiss="modal" aria-label="Close" style="z-index: 2; background: none;"><svg xmlns="http://www.w3.org/2000/svg" style="position: relative; top: -5px;" viewBox="0 0 16 16" fill="#fff"><path d="M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z"/></svg></button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>`;return t.innerHTML=s.trim(),this.modalElement=t.content.firstChild,this.modalElement.querySelector(".modal-body").appendChild(this.carouselElement),this.modalElement.addEventListener("hidden.bs.modal",(()=>this.modalElement.remove())),this.modalElement.querySelector("[data-bs-dismiss]").addEventListener("click",(()=>this.modal.hide())),this.modal=new e.Modal(this.modalElement,this.modalOptions),this.modal}randomHash(t=8){return Array.from({length:t},(()=>Math.floor(36*Math.random()).toString(36))).join("")}}s.allowedEmbedTypes=["embed","youtube","vimeo","instagram","url"],s.allowedMediaTypes=[...s.allowedEmbedTypes,"image","html"],s.defaultSelector='[data-toggle="lightbox"]',s.initialize=function(t){t.preventDefault(),new s(this).show()},document.querySelectorAll(s.defaultSelector).forEach((t=>t.addEventListener("click",s.initialize))),"undefined"!=typeof window&&window.bootstrap&&(window.bootstrap.Lightbox=s),i.default=s}(),i.default}()})); | ||
/*! | ||
* Lightbox for Bootstrap 5 v1.8.1 (https://trvswgnr.github.io/bs5-lightbox/) | ||
* Copyright 2022 Travis Aaron Wagner (https://github.com/trvswgnr/) | ||
* Licensed under MIT (https://github.com/trvswgnr/bs5-lightbox/blob/main/LICENSE) | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("bootstrap")):"function"==typeof define&&define.amd?define("Lightbox",["bootstrap"],e):"object"==typeof exports?exports.Lightbox=e(require("bootstrap")):t.Lightbox=e(t.bootstrap)}(self,(function(t){return function(){"use strict";var e={988:function(e){e.exports=t}},s={};function a(t){var o=s[t];if(void 0!==o)return o.exports;var i=s[t]={exports:{}};return e[t](i,i.exports,a),i.exports}a.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return a.d(e,{a:e}),e},a.d=function(t,e){for(var s in e)a.o(e,s)&&!a.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},a.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)};var o={};return function(){var t=a(988);const e={Modal:t.Modal,Carousel:t.Carousel};class s{constructor(t,s={}){this.hash=this.randomHash(),this.settings=Object.assign(Object.assign(Object.assign({},e.Modal.Default),e.Carousel.Default),{interval:!1,target:'[data-toggle="lightbox"]',gallery:"",size:"xl",constrain:!0}),this.modalOptions=(()=>this.setOptionsFromSettings(e.Modal.Default))(),this.carouselOptions=(()=>this.setOptionsFromSettings(e.Carousel.Default))(),"string"==typeof t&&(this.settings.target=t,t=document.querySelector(this.settings.target)),this.settings=Object.assign(Object.assign({},this.settings),s),this.el=t,this.type=t.dataset.type||"",this.src=this.getSrc(t),this.sources=this.getGalleryItems(),this.createCarousel(),this.createModal()}show(){document.body.appendChild(this.modalElement),this.modal.show()}hide(){this.modal.hide()}setOptionsFromSettings(t){return Object.keys(t).reduce(((t,e)=>Object.assign(t,{[e]:this.settings[e]})),{})}getSrc(t){let e=t.dataset.src||t.dataset.remote||t.href||"http://via.placeholder.com/1600x900";if("html"===t.dataset.type)return e;/\:\/\//.test(e)||(e=window.location.origin+e);const s=new URL(e);return(t.dataset.footer||t.dataset.caption)&&s.searchParams.set("caption",t.dataset.footer||t.dataset.caption),s.toString()}getGalleryItems(){let t;if(this.settings.gallery){if(Array.isArray(this.settings.gallery))return this.settings.gallery;t=this.settings.gallery}else this.el.dataset.gallery&&(t=this.el.dataset.gallery);return t?[...new Set(Array.from(document.querySelectorAll(`[data-gallery="${t}"]`),(t=>`${t.dataset.type?t.dataset.type:""}${this.getSrc(t)}`)))]:[`${this.type?this.type:""}${this.src}`]}getYoutubeId(t){if(!t)return!1;const e=t.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/);return!(!e||11!==e[2].length)&&e[2]}getYoutubeLink(t){const e=this.getYoutubeId(t);if(!e)return"false";const s=t.split("?");return`https://www.youtube.com/embed/${e}${s.length>1?"?"+s[1]:""}`}getInstagramEmbed(t){if(/instagram/.test(t))return`<iframe src="${t+=/\/embed$/.test(t)?"":"/embed"}" class="start-50 translate-middle-x" style="max-width: 500px" frameborder="0" scrolling="no" allowtransparency="true"></iframe>`}isEmbed(t){const e=new RegExp("("+s.allowedEmbedTypes.join("|")+")").test(t),a=/\.(png|jpe?g|gif|svg|webp)/i.test(t)||"image"===this.el.dataset.type;return e||!a}createCarousel(){const t=document.createElement("template"),a=s.allowedMediaTypes.join("|"),o=this.sources.map(((t,e)=>{t=t.replace(/\/$/,"");const s=new RegExp(`^(${a})`,"i"),o=/^html/.test(t),i=/^image/.test(t);s.test(t)&&(t=t.replace(s,""));const n=this.settings.constrain?"mw-100 mh-100 h-auto w-auto m-auto top-0 end-0 bottom-0 start-0":"h-100 w-100",r=new URLSearchParams(t.split("?")[1]);let l="",d=t;if(r.get("caption")){try{d=new URL(t),d.searchParams.delete("caption"),d=d.toString()}catch(e){d=t}l=`<p class="lightbox-caption m-0 p-2 text-center text-white small"><em>${r.get("caption")}</em></p>`}let c=`<img src="${d}" class="d-block ${n} img-fluid" style="z-index: 1; object-fit: contain;" />`,h="";const u=this.getInstagramEmbed(t),m=this.getYoutubeLink(t);this.isEmbed(t)&&!i&&(m&&(t=m,h='title="YouTube video player" frameborder="0" allow="accelerometer autoplay clipboard-write encrypted-media gyroscope picture-in-picture"'),c=u||`<iframe src="${t}" ${h} allowfullscreen></iframe>`),o&&(c=t);return`\n\t\t\t\t<div class="carousel-item ${e?"":"active"}" style="min-height: 100px">\n\t\t\t\t\t<div class="position-absolute top-50 start-50 translate-middle text-white"><div class="spinner-border" style="width: 3rem height: 3rem" role="status"></div></div>\n\t\t\t\t\t<div class="ratio ratio-16x9" style="background-color: #000;">${c}</div>\n\t\t\t\t\t${l}\n\t\t\t\t</div>`})).join(""),i=this.sources.length<2?"":`\n\t\t\t<button id="#lightboxCarousel-${this.hash}-prev" class="carousel-control carousel-control-prev h-75 m-auto" type="button" data-bs-target="#lightboxCarousel-${this.hash}" data-bs-slide="prev">\n\t\t\t\t<span class="carousel-control-prev-icon" aria-hidden="true"></span>\n\t\t\t\t<span class="visually-hidden">Previous</span>\n\t\t\t</button>\n\t\t\t<button id="#lightboxCarousel-${this.hash}-next" class="carousel-control carousel-control-next h-75 m-auto" type="button" data-bs-target="#lightboxCarousel-${this.hash}" data-bs-slide="next">\n\t\t\t\t<span class="carousel-control-next-icon" aria-hidden="true"></span>\n\t\t\t\t<span class="visually-hidden">Next</span>\n\t\t\t</button>`;let n="lightbox-carousel carousel slide";"fullscreen"===this.settings.size&&(n+=" position-absolute w-100 translate-middle top-50 start-50");const r=`\n\t\t\t<div id="lightboxCarousel-${this.hash}" class="${n}" data-bs-ride="carousel" data-bs-interval="${this.carouselOptions.interval}">\n\t\t\t\t<div class="carousel-inner">\n\t\t\t\t\t${o}\n\t\t\t\t</div>\n\t\t\t\t${i}\n\t\t\t</div>`;t.innerHTML=r.trim(),this.carouselElement=t.content.firstChild;const l=Object.assign(Object.assign({},this.carouselOptions),{keyboard:!1});this.carousel=new e.Carousel(this.carouselElement,l);const d=this.type&&"image"!==this.type?this.type+this.src:this.src;return this.carousel.to(this.findGalleryItemIndex(this.sources,d)),!0===this.carouselOptions.keyboard&&document.addEventListener("keydown",(t=>{if("ArrowLeft"===t.code){const t=document.getElementById(`#lightboxCarousel-${this.hash}-prev`);return t&&t.click(),!1}if("ArrowRight"===t.code){const t=document.getElementById(`#lightboxCarousel-${this.hash}-next`);return t&&t.click(),!1}})),this.carousel}findGalleryItemIndex(t,e){let s=0;for(const a of t){if(a.includes(e))return s;s++}return 0}createModal(){const t=document.createElement("template"),s=`\n\t\t\t<div class="modal lightbox fade" id="lightboxModal-${this.hash}" tabindex="-1" aria-hidden="true">\n\t\t\t\t<div class="modal-dialog modal-dialog-centered modal-${this.settings.size}">\n\t\t\t\t\t<div class="modal-content border-0 bg-transparent">\n\t\t\t\t\t\t<div class="modal-body p-0">\n\t\t\t\t\t\t\t<button type="button" class="btn-close position-absolute top-0 end-0 p-3" data-bs-dismiss="modal" aria-label="Close" style="z-index: 2; background: none;"><svg xmlns="http://www.w3.org/2000/svg" style="position: relative; top: -5px;" viewBox="0 0 16 16" fill="#fff"><path d="M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z"/></svg></button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>`;return t.innerHTML=s.trim(),this.modalElement=t.content.firstChild,this.modalElement.querySelector(".modal-body").appendChild(this.carouselElement),this.modalElement.addEventListener("hidden.bs.modal",(()=>this.modalElement.remove())),this.modalElement.querySelector("[data-bs-dismiss]").addEventListener("click",(()=>this.modal.hide())),this.modal=new e.Modal(this.modalElement,this.modalOptions),this.modal}randomHash(t=8){return Array.from({length:t},(()=>Math.floor(36*Math.random()).toString(36))).join("")}}s.allowedEmbedTypes=["embed","youtube","vimeo","instagram","url"],s.allowedMediaTypes=[...s.allowedEmbedTypes,"image","html"],s.defaultSelector='[data-toggle="lightbox"]',s.initialize=function(t){t.preventDefault();new s(this).show()},document.querySelectorAll(s.defaultSelector).forEach((t=>t.addEventListener("click",s.initialize))),"undefined"!=typeof window&&window.bootstrap&&(window.bootstrap.Lightbox=s),o.default=s}(),o=o.default}()})); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "bs5-lightbox", | ||
"version": "1.8.0", | ||
"version": "1.8.1", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "name": "Travis Aaron Wagner", |
@@ -11,8 +11,12 @@ # Lightbox for Bootstrap 5 | ||
### Development on [Version 2](https://github.com/trvswgnr/bs5-lightbox/tree/full-rework) has started—currently looking for contributors! | ||
Use [Issues](https://github.com/trvswgnr/bs5-lightbox/issues) to request new features. If you would like to contribute, send me an email at [lightbox@travisaw.com](mailto:lightbox@travisaw.com). | ||
## Status | ||
[![github latest release](https://badgen.net/github/tag/trvswgnr/bs5-lightbox?label=release)](https://github.com/trvswgnr/bs5-lightbox/releases/latest) | ||
[![github latest release](https://badgen.net/github/tag/trvswgnr/bs5-lightbox?label=release&cache=600)](https://github.com/trvswgnr/bs5-lightbox/releases/latest) | ||
[![jsdelivr hits per month](https://data.jsdelivr.com/v1/package/npm/bs5-lightbox/badge?style=rounded)](https://www.jsdelivr.com/package/npm/bs5-lightbox) | ||
[![npm downloads](https://badgen.net/npm/dt/bs5-lightbox?label=npm%20downloads&color=blue)](https://www.npmjs.com/package/bs5-lightbox) | ||
[![npm minzipped size](https://badgen.net/bundlephobia/minzip/bs5-lightbox?label=gzip%20size&color=green)](https://bundlephobia.com/package/bs5-lightbox) | ||
[![npm version](https://badgen.net/npm/v/bs5-lightbox)](https://www.npmjs.com/package/bs5-lightbox) | ||
[![npm downloads](https://badgen.net/npm/dt/bs5-lightbox?label=npm%20downloads&color=blue&cache=600)](https://www.npmjs.com/package/bs5-lightbox) | ||
[![npm minzipped size](https://badgen.net/bundlephobia/minzip/bs5-lightbox?label=gzip%20size&color=green&cache=600)](https://bundlephobia.com/package/bs5-lightbox) | ||
[![npm version](https://badgen.net/npm/v/bs5-lightbox?cache=600)](https://www.npmjs.com/package/bs5-lightbox) | ||
![Libraries.io dependency status for latest release](https://img.shields.io/librariesio/release/npm/bs5-lightbox) | ||
@@ -29,3 +33,3 @@ [![Featured on Openbase](https://badges.openbase.com/js/featured/bs5-lightbox.svg?token=R2MqRDwb93ap0dYGkIBBPigErEYve+e1dnfTDZImQog=)](https://openbase.com/js/bs5-lightbox) | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/bs5-lightbox@1.8.0/dist/index.bundle.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/bs5-lightbox@1.8.1/dist/index.bundle.min.js"></script> | ||
``` | ||
@@ -40,3 +44,3 @@ | ||
``` | ||
By default it will target elements with the `data-toggle-"lightbox"` attribute. | ||
By default it will target elements with the `data-toggle="lightbox"` attribute. | ||
@@ -47,12 +51,10 @@ If you want to target a different element, import the `Lightbox` class and instantiate it: | ||
document.querySelectorAll('.my-lightbox-toggle').forEach((el) => el.addEventListener('click', (e) => { | ||
e.preventDefault(); | ||
const lightbox = new Lightbox(el); | ||
lightbox.show(); | ||
})); | ||
for (const el of document.querySelectorAll('.my-lightbox-toggle')) { | ||
el.addEventListener('click', Lightbox.initialize) | ||
} | ||
``` | ||
## Contributing | ||
Lightbox for Bootstrap 5 is written in TypeScript and compiled to pure JavaScript. | ||
Modify the src/index.ts file, run `npm run build` and create a pull request. | ||
Lightbox for Bootstrap 5 is written in pure JavaScript. | ||
Modify the src/index.js file, run `npm run build` and create a pull request. | ||
@@ -59,0 +61,0 @@ You can help make this project even better and keep it up to date by making a small contribution! [Fund this project](https://github.com/sponsors/trvswgnr). |
@@ -20,3 +20,4 @@ /** | ||
gallery: '', | ||
size: 'xl' | ||
size: 'xl', | ||
constrain: true | ||
}); | ||
@@ -82,2 +83,13 @@ this.modalOptions = (() => this.setOptionsFromSettings(bootstrap.Modal.Default))(); | ||
} | ||
getYoutubeLink(src) { | ||
const youtubeId = this.getYoutubeId(src); | ||
if (!youtubeId) { | ||
return 'false'; | ||
} | ||
const arr = src.split('?'); | ||
let params = arr.length > 1 ? '?' + arr[1] : ''; | ||
return `https://www.youtube.com/embed/${youtubeId}${params}`; | ||
} | ||
getInstagramEmbed(src) { | ||
@@ -109,9 +121,23 @@ if (/instagram/.test(src)) { | ||
} | ||
let inner = `<img src="${src}" class="d-block w-100 h-100 img-fluid" style="z-index: 1; object-fit: contain;" />`; | ||
const imgClasses = this.settings.constrain ? 'mw-100 mh-100 h-auto w-auto m-auto top-0 end-0 bottom-0 start-0' : 'h-100 w-100'; | ||
const params = new URLSearchParams(src.split('?')[1]); | ||
let caption = ''; | ||
let url = src; | ||
if (params.get('caption')) { | ||
try { | ||
url = new URL(src); | ||
url.searchParams.delete('caption'); | ||
url = url.toString(); | ||
} catch (e) { | ||
url = src; | ||
} | ||
caption = `<p class="lightbox-caption m-0 p-2 text-center text-white small"><em>${params.get('caption')}</em></p>`; | ||
} | ||
let inner = `<img src="${url}" class="d-block ${imgClasses} img-fluid" style="z-index: 1; object-fit: contain;" />`; | ||
let attributes = ''; | ||
const instagramEmbed = this.getInstagramEmbed(src); | ||
const youtubeId = this.getYoutubeId(src); | ||
const youtubeLink = this.getYoutubeLink(src); | ||
if (this.isEmbed(src) && !isForcedImage) { | ||
if (youtubeId) { | ||
src = `https://www.youtube.com/embed/${youtubeId}`; | ||
if (youtubeLink) { | ||
src = youtubeLink; | ||
attributes = 'title="YouTube video player" frameborder="0" allow="accelerometer autoplay clipboard-write encrypted-media gyroscope picture-in-picture"'; | ||
@@ -125,7 +151,2 @@ } | ||
const spinner = `<div class="position-absolute top-50 start-50 translate-middle text-white"><div class="spinner-border" style="width: 3rem height: 3rem" role="status"></div></div>`; | ||
const params = new URLSearchParams(src.split('?')[1]); | ||
let caption = ''; | ||
if (params.get('caption')) { | ||
caption = `<p class="lightbox-caption m-0 p-2 text-center text-white small"><em>${params.get('caption')}</em></p>`; | ||
} | ||
return ` | ||
@@ -151,3 +172,3 @@ <div class="carousel-item ${!i ? 'active' : ''}" style="min-height: 100px"> | ||
</button>`; | ||
let classes = 'lightbox-carousel carousel'; | ||
let classes = 'lightbox-carousel carousel slide'; | ||
if (this.settings.size === 'fullscreen') { | ||
@@ -154,0 +175,0 @@ classes += ' position-absolute w-100 translate-middle top-50 start-50'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
73383
0
100
366
62
0
9