vendor: 7,363 bytes, lines 1-126
1/*! 2 * Lightbox for Bootstrap 5 v1.8.3 (https://trvswgnr.github.io/bs5-lightbox/) 3 * Copyright 2023 Travis Aaron Wagner (https://github.com/trvswgnr/) 4 * Licensed under MIT (https://github.com/trvswgnr/bs5-lightbox/blob/main/LICENSE) 5 */ 6! function () { 7 "use strict"; 8 var t = { 9 d: function (e, s) { 10 for (var a in s) t.o(s, a) && !t.o(e, a) && Object.defineProperty(e, a, { 11 enumerable: !0, 12 get: s[a] 13 }) 14 }, 15 o: function (t, e) { 16 return Object.prototype.hasOwnProperty.call(t, e) 17 } 18 }, 19 e = {}; 20 t.d(e, { 21 default: function () { 22 return i 23 } 24 }); 25 var s = window.bootstrap; 26 const a = { 27 Modal: s.Modal, 28 Carousel: s.Carousel 29 }; 30 class o { 31 constructor(t) { 32 let e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}; 33 this.hash = this.randomHash(), this.settings = Object.assign(Object.assign(Object.assign({}, a.Modal.Default), a.Carousel.Default), { 34 interval: !1, 35 target: '[data-bs-toggle="lightbox"]', 36 gallery: "", 37 size: "xl", 38 constrain: !0 39 }), this.settings = Object.assign(Object.assign({}, this.settings), e), 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.el = t, this.type = t.dataset.type || "", this.src = this.getSrc(t), this.sources = this.getGalleryItems(), this.createCarousel(), this.createModal() 40 41 } 42 show() { 43 document.body.appendChild(this.modalElement), this.modal.show() 44 } 45 hide() { 46 this.modal.hide() 47 } 48 setOptionsFromSettings(t) { 49 return Object.keys(t).reduce(((t, e) => Object.assign(t, { 50 [e]: this.settings[e] 51 })), {}) 52 } 53 getSrc(t) { 54 let e = t.dataset.src || t.dataset.remote || t.href || "http://via.placeholder.com/1600x900"; 55 if ("html" === t.dataset.type) return e; 56 /\:\/\//.test(e) || (e = window.location.origin + e); 57 const s = new URL(e); 58 return (t.dataset.footer || t.dataset.caption) && s.searchParams.set("caption", t.dataset.footer || t.dataset.caption), s.toString() 59 } 60 getGalleryItems() { 61 let t; 62 if (this.settings.gallery) { 63 if (Array.isArray(this.settings.gallery)) return this.settings.gallery; 64 t = this.settings.gallery 65 } else this.el.dataset.gallery && (t = this.el.dataset.gallery); 66 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)] 67 } 68 getYoutubeId(t) { 69 if (!t) return !1; 70 const e = t.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/); 71 return !(!e || 11 !== e[2].length) && e[2] 72 } 73 getYoutubeLink(t) { 74 const e = this.getYoutubeId(t); 75 if (!e) return !1; 76 const s = t.split("?"); 77 let a = s.length > 1 ? "?" + s[1] : ""; 78 return "https://www.youtube.com/embed/".concat(e).concat(a) 79 } 80 getInstagramEmbed(t) { 81 if (/instagram/.test(t)) return t += /\/embed$/.test(t) ? "" : "/embed", '<iframe credentialless src="'.concat(t, '" class="start-50 translate-middle-x" style="max-width: 500px" frameborder="0" scrolling="no" allowtransparency="true"></iframe>') 82 } 83 isEmbed(t) { 84 const e = new RegExp("(" + o.allowedEmbedTypes.join("|") + ")").test(t), 85 s = /\.(png|jpe?g|gif|svg|webp)/i.test(t) || "image" === this.el.dataset.type; 86 return e || !s 87 } 88 createCarousel() { 89// console.log(this); 90 const t = document.createElement("template"), 91 e = o.allowedMediaTypes.join("|"), 92 s = this.sources.map(((t, s) => { 93 t = t.replace(/\/$/, ""); 94 const a = new RegExp("^(".concat(e, ")"), "i"), 95 o = /^html/.test(t), 96 i = /^image/.test(t); 97 a.test(t) && (t = t.replace(a, "")); 98 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", 99 l = new URLSearchParams(t.split("?")[1]); 100 let r = "", 101 c = t; 102 if (l.get("caption")) { 103 try { 104 c = new URL(t), c.searchParams.delete("caption"), c = c.toString() 105 } catch (e) { 106 c = t 107 } 108 r = '<p class="lightbox-caption m-0 p-2 text-left text-white">'.concat(l.get("caption"), "</p>") 109 } 110 let d = '<img src="'.concat(c, '" class="d-block ').concat(n, ' img-fluid" alt="" style="z-index: 1; object-fit: contain;" />'), 111 h = ""; 112 const u = this.getInstagramEmbed(t), 113 m = this.getYoutubeLink(t); 114 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 credentialless src="'.concat(t, '" ').concat(h, " allowfullscreen></iframe>")), o && (d = t); 115 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>") 116 })).join(""), 117 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>'); 118 let n = "lightbox-carousel carousel slide"; 119 "fullscreen" === this.settings.size && (n += " position-absolute w-100 translate-middle top-50 start-50"); 120 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>"); 121 t.innerHTML = l.trim(), this.carouselElement = t.content.firstChild; 122 const r = Object.assign(Object.assign({}, this.carouselOptions), { 123 keyboard: !1 124 }); 125 this.carousel = new a.Carousel(this.carouselElement, r); 126 const c = this.type && "image" !== this.type ? this.type + this.src : this.src;
127 const keyHandler = (t) => { 128 if ("ArrowLeft" === t.code) { 129 const t = document.getElementById("#lightboxCarousel-".concat(this.hash, "-prev")); 130 return t && t.click(), !1 131 } 132 if ("ArrowRight" === t.code) { 133 const t = document.getElementById("#lightboxCarousel-".concat(this.hash, "-next")); 134 var oEvent = window.event; 135 return t && t.click(), !1 136 } 137 if ($(".btn-close").length > 0) { 138 if (t.keyCode === 27) { 139 const masterClass = $(this.el).attr("class"); 140 $(".carousel-inner").children('.carousel-item').each(function (index) { 141 if ($(this).attr('class') === "carousel-item active") { 142 if (masterClass === "imageList") { 143 setTimeout(() => { $("#relateImg" + index).focus();}, 1); 144 return; 145 } else if (masterClass === "videoList") { 146 setTimeout(() => { $("#relateVideo" + index).focus();}, 1); 147 return; 148 } 149 } 150 }); 151 } 152 } 153 if (document.activeElement != null && document.activeElement.className != null && document.activeElement.className === "btn-close position-absolute top-0 end-0 p-3") { 154 const masterClass = $(this.el).attr("class"); 155 if (t.keyCode === 13) { 156 $(".carousel-inner").children('.carousel-item').each(function (index) { 157 if ($(this).attr('class') === "carousel-item active") { 158 if (masterClass === "imageList") { 159 setTimeout(() => { $("#relateImg" + index).focus();}, 1); 160 return; 161 } else if (masterClass === "videoList") { 162 setTimeout(() => { $("#relateVideo" + index).focus();}, 1); 163 return; 164 } 165 166 } 167 }); 168 } 169 } 170 const t1 = document.getElementById("#lightboxCarousel-".concat(this.hash, "-next")); 171 const t2 = document.getElementById("#lightboxCarousel-".concat(this.hash, "-prev")); 172 if (document.activeElement != null && t1 != null) { 173 if (document.activeElement.id != null && t1.id != null && document.activeElement.id === t1.id) { 174 if (!t.shiftKey && t.keyCode === 9) { 175 t.preventDefault(); 176 setTimeout(() => { $(".btn-close").focus();}, 200); 177 return; 178 } 179 } 180 } else if (t1 == null && t2 == null && $(".btn-close").length !== 0){ 181 if (t.keyCode === 9) { 182 t.preventDefault(); 183 setTimeout(() => { $(".btn-close").focus();}, 200); 184 return; 185 } 186 } 187 } 188 return this.carousel.to(this.findGalleryItemIndex(this.sources, c)), !0 === this.carouselOptions.keyboard && document.addEventListener("keydown", keyHandler), document.addEventListener("hidden.bs.modal", function(){document.removeEventListener("keydown", keyHandler);}), this.carousel 189 } 190 findGalleryItemIndex(t, e) { 191 let s = 0; 192 for (const a of t) { 193 if (a.includes(e)) return s; 194 s++ 195 } 196 return 0 197 } 198 createModal() { 199// console.log(this); 200 const t = document.createElement("template"), 201 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>"); 202 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.addEventListener("shown.bs.modal", function(){ var closeBtn = document.querySelector(".btn-close"); closeBtn.focus(); }) , this.modalElement.querySelector("[data-bs-dismiss]").addEventListener("click", (() => this.modal.hide())), this.modal = new a.Modal(this.modalElement, this.modalOptions), this.modal 203 } 204 randomHash() { 205 let t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 8; 206 return Array.from({ 207 length: t 208 }, (() => Math.floor(36 * Math.random()).toString(36))).join("") 209 } 210 } 211 o.allowedEmbedTypes = ["embed", "youtube", "vimeo", "instagram", "url"], o.allowedMediaTypes = [...o.allowedEmbedTypes, "image", "html"], o.defaultSelector = '[data-bs-toggle="lightbox"]', o.initialize = function (t) { 212 t.preventDefault(); 213 new o(this).show() 214 }
214, document.querySelectorAll(o.defaultSelector).forEach((t => t.addEventListener("click", o.initialize))), "undefined" != typeof window && window.bootstrap && (window.bootstrap.Lightbox = o); 215 var i = o; 216 window.Lightbox = e.default 217}(); 218//# sourceMappingURL=index.bundle.min.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.