New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

imagelightbox

Package Overview
Dependencies
Maintainers
0
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

imagelightbox - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

docs/assets/index-CxVwAvVb.js

425

dist/imagelightbox.jquery.js

@@ -1,3 +0,3 @@

import A from "jquery";
function B(e, n, o) {
import S from "jquery";
function z(e, n, o) {
const i = `${n}=${o}`;

@@ -26,27 +26,3 @@ let r = `?${i}`;

}
var y = /* @__PURE__ */ ((e) => (e[e.Left = 1] = "Left", e[e.None = 0] = "None", e[e.Right = -1] = "Right", e))(y || {});
function U() {
let e = j(
document.location.search,
"imageLightboxIndex"
);
e = j(e, "imageLightboxSet"), window.history.pushState({}, "", document.location.pathname + e);
}
function W(e, n, o) {
const i = o[e].dataset.ilb2Id ?? e.toString();
let r = B(
document.location.search,
"imageLightboxIndex",
i
);
const t = {
imageLightboxIndex: i,
imageLightboxSet: ""
};
n !== void 0 && (t.imageLightboxSet = n, r = B(r, "imageLightboxSet", n)), window.history.pushState(
t,
"",
document.location.pathname + r
);
}
var E = /* @__PURE__ */ ((e) => (e[e.Left = 1] = "Left", e[e.None = 0] = "None", e[e.Right = -1] = "Right", e))(E || {});
function G(e, n, o) {

@@ -61,3 +37,3 @@ if (K("imageLightboxSet") !== e)

}
function Y(e, n, o, i, r, t, s) {
function Y(e, n, o, i, r, t, l) {
const f = e.state;

@@ -76,3 +52,3 @@ if (!f || Object.keys(f).length === 0) {

let m = o.findIndex(
(h) => h.dataset.ilb2Id === u
(y) => y.dataset.ilb2Id === u
);

@@ -83,29 +59,53 @@ if (m < 0 && (m = parseInt(u, 10)), i === null) {

}
s(
l(
m,
m > i ? y.Right : y.Left,
m > i ? E.Right : E.Left,
!0
);
}
const v = document.createElement("div");
v.setAttribute("id", "ilb-container");
let P = null;
function Z(e, n, o) {
v.classList.remove("ilb-overlay"), document.body.classList.add("ilb-body"), document.body.appendChild(v), n && (P = (i) => {
function Z() {
let e = j(
document.location.search,
"imageLightboxIndex"
);
e = j(e, "imageLightboxSet"), window.history.pushState({}, "", document.location.pathname + e);
}
function W(e, n, o) {
const i = o[e].dataset.ilb2Id ?? e.toString();
let r = z(
document.location.search,
"imageLightboxIndex",
i
);
const t = {
imageLightboxIndex: i,
imageLightboxSet: ""
};
n !== void 0 && (t.imageLightboxSet = n, r = z(r, "imageLightboxSet", n)), window.history.pushState(
t,
"",
document.location.pathname + r
);
}
const b = document.createElement("div");
b.setAttribute("id", "ilb-container");
let R = null;
function _(e, n, o) {
b.classList.remove("ilb-overlay"), document.body.classList.add("ilb-body"), document.body.appendChild(b), n && (R = (i) => {
i.stopPropagation(), o();
}, v.addEventListener("click", P), v.addEventListener("touchend", P)), v.style.transition = `opacity ${e.toString()}ms ease`, setTimeout(() => {
v.style.opacity = "1";
}, b.addEventListener("click", R), b.addEventListener("touchend", R)), b.style.transition = `opacity ${e.toString()}ms ease`, setTimeout(() => {
b.style.opacity = "1";
}, 50);
}
function _() {
v.classList.add("ilb-overlay");
}
function ee() {
v.style.opacity = "0";
b.classList.add("ilb-overlay");
}
function h() {
return b;
}
function te() {
P !== null && (v.removeEventListener("click", P), v.removeEventListener("touchend", P)), v.remove(), v.textContent = "", document.body.classList.remove("ilb-body");
R !== null && (b.removeEventListener("click", R), b.removeEventListener("touchend", R)), b.remove(), b.textContent = "", document.body.classList.remove("ilb-body");
}
function E() {
return v;
function ne() {
b.style.opacity = "0";
}

@@ -115,4 +115,4 @@ const V = document.createElement("div");

V.appendChild(document.createElement("div"));
function Q() {
E().appendChild(V);
function B() {
h().appendChild(V);
}

@@ -125,15 +125,15 @@ function X() {

I.setAttribute("id", "ilb-arrow-left");
const O = document.createElement("div");
O.classList.add("ilb-button", "ilb-arrow");
O.setAttribute("id", "ilb-arrow-right");
let k = null, C = null;
function ne(e, n) {
const A = document.createElement("div");
A.classList.add("ilb-button", "ilb-arrow");
A.setAttribute("id", "ilb-arrow-right");
let k = null, O = null;
function ie(e, n) {
k = (o) => {
o.stopPropagation(), e();
}, C = (o) => {
}, O = (o) => {
o.stopPropagation(), n();
}, I.addEventListener("click", k), I.addEventListener("touchend", k), O.addEventListener("click", C), O.addEventListener("touchend", C), E().append(I, O);
}, I.addEventListener("click", k), I.addEventListener("touchend", k), A.addEventListener("click", O), A.addEventListener("touchend", O), h().append(I, A);
}
function ie() {
I.remove(), k !== null && (I.removeEventListener("click", k), I.removeEventListener("touchend", k)), C !== null && (O.removeEventListener("click", C), O.removeEventListener("touchend", C)), k = null, C = null;
function oe() {
I.remove(), k !== null && (I.removeEventListener("click", k), I.removeEventListener("touchend", k)), O !== null && (A.removeEventListener("click", O), A.removeEventListener("touchend", O)), k = null, O = null;
}

@@ -146,4 +146,4 @@ const L = document.createElement("caption");

});
function oe(e, n) {
e !== "" ? (E().appendChild(L), L.style.transition = `opacity ${n.toString()}ms ease`, setTimeout(() => {
function re(e, n) {
e !== "" ? (h().appendChild(L), L.style.transition = `opacity ${n.toString()}ms ease`, setTimeout(() => {
L.style.opacity = "1";

@@ -154,13 +154,13 @@ }, 1), L.textContent = e) : (L.style.opacity = "0", setTimeout(() => {

}
const R = document.createElement("button");
R.classList.add("ilb-button");
R.setAttribute("id", "ilb-close-button");
const M = document.createElement("button");
M.classList.add("ilb-button");
M.setAttribute("id", "ilb-close-button");
let H = null;
function re(e) {
function ae(e) {
H = (n) => {
n.stopPropagation(), e();
}, R.addEventListener("click", H), E().appendChild(R);
}, M.addEventListener("click", H), h().appendChild(M);
}
function ae() {
H !== null && R.removeEventListener("click", H), R.remove();
function se() {
H !== null && M.removeEventListener("click", H), M.remove();
}

@@ -171,3 +171,3 @@ const le = (

);
function se() {
function de() {
return (

@@ -178,28 +178,35 @@ // eslint-disable-next-line compat/compat -- The prefixed version fixes the incompatibility

}
const de = (e) => {
const ce = (e) => {
(e.requestFullscreen || e.webkitRequestFullScreen).call(e);
}, ce = () => {
}, ue = () => {
(document.exitFullscreen || document.webkitExitFullscreen).call(document);
};
function ue() {
se() === null ? de(E()) : ce();
function fe() {
de() === null ? ce(h()) : ue();
}
const M = document.createElement("button");
M.classList.add("ilb-button");
M.setAttribute("id", "ilb-fullscreen-button");
M.innerHTML = "&#x26F6;";
M.addEventListener("click", (e) => {
e.stopPropagation(), ue();
const T = document.createElement("button");
T.classList.add("ilb-button");
T.setAttribute("id", "ilb-fullscreen-button");
T.innerHTML = "&#x26F6;";
T.addEventListener("click", (e) => {
e.stopPropagation(), fe();
});
function fe() {
E().appendChild(M);
}
function me() {
M.remove();
h().appendChild(T);
}
function ge(e, n, o) {
function ge() {
T.remove();
}
function be(e, n, o) {
let i = 0, r = 0, t = document.createElement("img");
t.setAttribute("id", "ilb-image"), t.setAttribute("src", e.getAttribute("href") ?? "");
const s = document.createElement("div");
s.classList.add("ilb-image-container");
t.addEventListener("error", (d) => {
h().dispatchEvent(
new CustomEvent("ilb:error", {
bubbles: !0,
detail: { target: d.target }
})
);
}), t.setAttribute("id", "ilb-image"), t.setAttribute("src", e.getAttribute("href") ?? ""), t.setAttribute("srcset", e.dataset.ilb2Srcset ?? ""), t.setAttribute("sizes", e.dataset.ilb2Sizes ?? "");
const l = document.createElement("div");
l.classList.add("ilb-image-container");
let f;

@@ -209,12 +216,12 @@ const u = e.dataset.ilb2VideoId;

if (m) {
const c = o.get(u);
c !== void 0 ? [t, f] = c.element() : m = !1;
const d = o.get(u);
d !== void 0 ? [t, f] = d.element() : m = !1;
}
s.appendChild(t);
function h(c, g, b, N) {
l.appendChild(t);
function y(d, g, p, N) {
if (m) {
const a = o.get(u);
if ((a == null ? void 0 : a.shouldAutoplay()) === !0) {
const [l, d] = a.element();
d ? l.play() : l.autoplay = !0;
const [s, c] = a.element();
c ? s.play() : s.autoplay = !0;
}

@@ -227,3 +234,3 @@ } else

}
(a.pageX - t.offsetLeft) / t.width <= 1 / 3 ? g() : b();
(a.pageX - t.offsetLeft) / t.width <= 1 / 3 ? g() : p();
});

@@ -235,24 +242,24 @@ t.addEventListener("touchstart", (a) => {

}), t.addEventListener("touchend", (a) => {
a.stopPropagation(), t.style.transitionProperty = "left, opacity", r > 50 && g(), r < -50 && b(), t.style.left = "0";
a.stopPropagation(), t.style.transitionProperty = "left, opacity", r > 50 && g(), r < -50 && p(), t.style.left = "0";
}), t.addEventListener("touchcancel", (a) => {
a.stopPropagation(), t.style.transitionProperty = "left, opacity", t.style.left = "0";
}), c();
}), d();
}
function w(c, g) {
E().appendChild(s);
const b = Math.abs(100 - n.gutter);
t.style.maxHeight = `${b.toString()}%`, t.style.maxWidth = `${b.toString()}%`, t.style.left = `${(-100 * c).toString()}px`, t.style.transition = `all ease ${n.animationSpeed.toString()}ms`, setTimeout(g, 50);
function w(d, g) {
h().appendChild(l);
const p = Math.abs(100 - n.gutter);
t.style.maxHeight = `${p.toString()}%`, t.style.maxWidth = `${p.toString()}%`, t.style.left = `${(-100 * d).toString()}px`, t.style.transition = `all ease ${n.animationSpeed.toString()}ms`, setTimeout(g, 50);
}
function $(c, g) {
t.addEventListener("error", g), f === !0 ? c() : (t.addEventListener("load", c), t.addEventListener("loadedmetadata", c));
function $(d, g) {
t.addEventListener("error", g), f === !0 ? d() : (t.addEventListener("load", d), t.addEventListener("loadedmetadata", d));
}
function p(c, g, b, N) {
function v(d, g, p, N) {
t.style.left = "0", t.style.opacity = "1", setTimeout(() => {
h(c, g, b, N);
y(d, g, p, N);
}, n.animationSpeed);
}
function S(c, g) {
if (c !== y.None) {
const b = parseInt(t.style.left, 10) || 0;
t.style.left = `${(b + 100 * c).toString()}px`;
function C(d, g) {
if (d !== E.None) {
const p = parseInt(t.style.left, 10) || 0;
t.style.left = `${(p + 100 * d).toString()}px`;
}

@@ -264,3 +271,3 @@ t.style.opacity = "0", setTimeout(() => {

function F() {
s.remove();
l.remove();
}

@@ -271,4 +278,4 @@ return {

startLoading: $,
transitionIn: p,
transitionOut: S
transitionIn: v,
transitionOut: C
};

@@ -287,7 +294,7 @@ }

x.classList.add("ilb-navigation");
function z(e, n, o, i) {
function J(e, n, o, i) {
for (let r = 0; r < e.length; r++) {
const t = document.createElement("button");
t.style.transition = `background-color ${i.toString()}ms ease`;
const s = () => {
const l = () => {
const f = n();

@@ -299,18 +306,12 @@ if (t.classList.contains("ilb-navigation-active") || f === null || t.parentNode === null)

t
), m = u < f ? y.Left : y.Right;
), m = u < f ? E.Left : E.Right;
o(u, m);
};
t.addEventListener("click", s), t.addEventListener("touchend", s), x.appendChild(t);
t.addEventListener("click", l), t.addEventListener("touchend", l), x.appendChild(t);
}
}
function J(e) {
var n, o;
for (let i = 0; i < x.children.length; i++)
(n = x.children.item(i)) == null || n.classList.remove("ilb-navigation-active");
(o = x.children.item(e)) == null || o.classList.add("ilb-navigation-active");
}
function be(e, n, o, i) {
x.textContent = "", z(e, n, o, i);
function he(e, n, o, i) {
x.textContent = "", J(e, n, o, i);
const r = n();
r !== null && J(r), E().appendChild(x), x.addEventListener("click", (t) => {
r !== null && U(r), h().appendChild(x), x.addEventListener("click", (t) => {
t.stopPropagation();

@@ -321,3 +322,9 @@ }), x.addEventListener("touchend", (t) => {

}
function he(e, n) {
function U(e) {
var n, o;
for (let i = 0; i < x.children.length; i++)
(n = x.children.item(i)) == null || n.classList.remove("ilb-navigation-active");
(o = x.children.item(e)) == null || o.classList.add("ilb-navigation-active");
}
function ye(e, n) {
let o = e.dataset.ilb2Id;

@@ -327,7 +334,7 @@ o === void 0 && (o = `a${((1 + Math.random()) * 65536 | 0).toString(16)}`), e.dataset.ilb2VideoId = o;

r.setAttribute("id", "ilb-image"), r.preload = "metadata", r.dataset.ilb2VideoId = i;
let t = !1, s = !1;
for (const [h, w] of Object.entries(n))
switch (h) {
let t = !1, l = !1;
for (const [y, w] of Object.entries(n))
switch (y) {
case "autoplay":
s = !0;
l = !0;
break;

@@ -340,10 +347,10 @@ case "controls":

case "src":
r.setAttribute(h, w.toString());
r.setAttribute(y, w.toString());
break;
}
if (n.sources)
for (const h of n.sources) {
for (const y of n.sources) {
const w = document.createElement("source");
for (const [$, p] of Object.entries(h))
w.setAttribute($, p);
for (const [$, v] of Object.entries(y))
w.setAttribute($, v);
r.appendChild(w);

@@ -361,3 +368,3 @@ }

function m() {
return s;
return l;
}

@@ -370,3 +377,3 @@ return {

}
function ye() {
function Ee() {
const e = [];

@@ -377,3 +384,3 @@ function n(i) {

t !== void 0 && e.push(
he(r, JSON.parse(t))
ye(r, JSON.parse(t))
);

@@ -390,5 +397,5 @@ }

}
function Ee(e, n, o) {
const i = [], r = ye();
let t = null, s = null;
function Le(e, n, o) {
const i = [], r = Ee();
let t = null, l = null;
function f() {

@@ -400,43 +407,48 @@ return n;

}
function m(a, l) {
if (s === null)
function m(a, s) {
if (l === null)
return;
const d = s;
d.transitionOut(a, () => {
d.removeFromDOM(), l == null || l();
const c = l;
c.transitionOut(a, () => {
c.removeFromDOM(), s == null || s();
});
}
function h() {
s == null || s.transitionIn(
function y() {
l == null || l.transitionIn(
X,
/* eslint-disable @typescript-eslint/no-use-before-define -- Cyclical dependencies */
F,
c,
p
d,
v
);
}
function w(a) {
s == null || s.addToDOM(a, () => {
var d;
l == null || l.addToDOM(a, () => {
var c;
if (t === null)
return;
const l = i[t];
if (e.caption && oe(
l.dataset.ilb2Caption ?? ((d = l.getElementsByTagName("img").item(0)) == null ? void 0 : d.alt) ?? "",
const s = i[t];
if (e.caption && re(
s.dataset.ilb2Caption ?? ((c = s.getElementsByTagName("img").item(0)) == null ? void 0 : c.alt) ?? "",
e.animationSpeed
), h(), e.preloadNext && t + 1 < i.length) {
const D = i[t + 1];
document.createElement("img").setAttribute(
), y(), e.preloadNext && t + 1 < i.length) {
const P = i[t + 1], Q = document.createElement("img");
Q.setAttribute(
"src",
D.getAttribute("href") ?? ""
P.getAttribute("href") ?? ""
), Q.setAttribute(
"srcset",
P.dataset.ilb2Srcset ?? ""
), Q.setAttribute(
"sizes",
P.dataset.ilb2Sizes ?? ""
);
}
E().dispatchEvent(new Event("ilb:loaded", { bubbles: !0 }));
h().dispatchEvent(new Event("ilb:loaded", { bubbles: !0 }));
});
}
function $(a, l) {
const d = ge(i[a], e, r);
t = a, s = d, d.startLoading(
function $(a, s) {
const c = be(i[a], e, r);
t = a, l = c, c.startLoading(
() => {
w(l);
w(s);
},

@@ -448,9 +460,9 @@ () => {

}
function p(a = !1) {
t !== null && (e.activity && Q(), pe(), e.history && !a && U(), E().dispatchEvent(new Event("ilb:quit", { bubbles: !0 })), ee(), m(y.None, () => {
t = null, s = null, ie(), ae(), me(), te();
function v(a = !1) {
t !== null && (e.activity && B(), pe(), e.history && !a && Z(), h().dispatchEvent(new Event("ilb:quit", { bubbles: !0 })), ne(), m(E.None, () => {
t = null, l = null, oe(), se(), ge(), te();
}));
}
function S(a, l, d = !1) {
t !== null && (e.history && !d && W(a, f(), u()), e.activity && Q(), J(a), m(l), $(a, l));
function C(a, s, c = !1) {
t !== null && (e.history && !c && W(a, f(), u()), e.activity && B(), U(a), m(s), $(a, s));
}

@@ -463,3 +475,3 @@ function F() {

if (e.quitOnEnd) {
p();
v();
return;

@@ -471,5 +483,5 @@ }

new Event("ilb:previous", { bubbles: !0 })
), S(a, y.Left);
), C(a, E.Left);
}
function c() {
function d() {
if (t === null)

@@ -480,3 +492,3 @@ return;

if (e.quitOnEnd) {
p();
v();
return;

@@ -488,31 +500,31 @@ }

new Event("ilb:next", { bubbles: !0 })
), S(a, y.Right);
), C(a, E.Right);
}
function g(a, l = !1) {
t === null && (Z(e.animationSpeed, e.quitOnDocClick, p), e.activity && Q(), ve(e, p, F, c), e.arrows && ne(F, c), e.button && re(p), e.fullscreen && le && fe(), e.overlay && _(), e.history && !l && W(a, f(), u()), i[a].dispatchEvent(
function g(a, s = !1) {
t === null && (_(e.animationSpeed, e.quitOnDocClick, v), e.activity && B(), ve(e, v, F, d), e.arrows && ie(F, d), e.button && ae(v), e.fullscreen && le && me(), e.overlay && ee(), e.history && !s && W(a, f(), u()), i[a].dispatchEvent(
new Event("ilb:start", { bubbles: !0 })
), $(a, y.None), e.navigation && be(
), $(a, E.None), e.navigation && he(
u(),
() => t,
S,
C,
e.animationSpeed
));
}
function b(a) {
const l = i.indexOf(a);
l < 0 || g(l);
function p(a) {
const s = i.indexOf(a);
s < 0 || g(s);
}
function N(a) {
const l = a.filter((d) => !i.includes(d)).filter(
(d) => d.tagName.toLowerCase() === "a" && (new RegExp(`.(${e.allowedTypes})$`, "i").test(d.href) || d.dataset.ilb2Video !== void 0)
const s = a.filter((c) => !i.includes(c)).filter(
(c) => c.tagName.toLowerCase() === "a" && (new RegExp(`.(${e.allowedTypes})$`, "i").test(c.href) || c.dataset.ilb2Srcset !== void 0 || c.dataset.ilb2Video !== void 0)
);
r.add(l), i.push(...l);
for (const d of l)
d.addEventListener("click", (D) => {
D.preventDefault(), D.stopPropagation(), b(d);
r.add(s), i.push(...s);
for (const c of s)
c.addEventListener("click", (P) => {
P.preventDefault(), P.stopPropagation(), p(c);
});
z(
l,
J(
s,
() => t,
S,
C,
e.animationSpeed

@@ -522,10 +534,10 @@ );

return N(o), e.history && window.addEventListener("popstate", (a) => {
Y(a, f(), u(), t, g, p, S);
Y(a, f(), u(), t, g, v, C);
}), {
addImages: N,
close: p,
close: v,
images: u,
next: c,
next: d,
open: g,
openWithImage: b,
openWithImage: p,
previous: F,

@@ -535,3 +547,3 @@ set: f

}
class Le {
class xe {
constructor(n, o) {

@@ -557,3 +569,3 @@ const i = {

};
this.s = Ee(
this.s = Le(
i,

@@ -589,4 +601,4 @@ n.length > 0 ? n[0].dataset.imagelightbox ?? "" : "",

}
A.fn.imageLightbox = function(e) {
const n = new Le(
S.fn.imageLightbox = function(e) {
const n = new xe(
this.get(),

@@ -609,18 +621,21 @@ e

};
const T = A(document);
T.on("ilb:start", (e) => {
A("#ilb-container").trigger("start.ilb2", e.target);
const D = S(document);
D.on("ilb:start", (e) => {
S("#ilb-container").trigger("start.ilb2", e.target);
});
T.on("ilb:quit", () => {
A("#ilb-container").trigger("quit.ilb2");
D.on("ilb:quit", () => {
S("#ilb-container").trigger("quit.ilb2");
});
T.on("ilb:loaded", () => {
A("#ilb-container").trigger("loaded.ilb2");
D.on("ilb:loaded", () => {
S("#ilb-container").trigger("loaded.ilb2");
});
T.on("ilb:previous", (e) => {
A("#ilb-container").trigger("previous.ilb2", e.target);
D.on("ilb:previous", (e) => {
S("#ilb-container").trigger("previous.ilb2", e.target);
});
T.on("ilb:next", (e) => {
A("#ilb-container").trigger("next.ilb2", e.target);
D.on("ilb:next", (e) => {
S("#ilb-container").trigger("next.ilb2", e.target);
});
D.on("ilb:error", (e) => {
S("#ilb-container").trigger("error.ilb2", e.detail);
});
//# sourceMappingURL=imagelightbox.jquery.js.map

@@ -1,2 +0,2 @@

function q(e, n, r) {
function Q(e, n, r) {
const i = `${n}=${r}`;

@@ -10,3 +10,3 @@ let o = `?${i}`;

}
function Q(e) {
function B(e) {
const n = new RegExp(`[?&]${e}(=([^&#]*)|&|#|$)`).exec(

@@ -18,3 +18,3 @@ document.location.search

}
function B(e, n) {
function z(e, n) {
let r = e;

@@ -27,31 +27,7 @@ if (r) {

}
var y = /* @__PURE__ */ ((e) => (e[e.Left = 1] = "Left", e[e.None = 0] = "None", e[e.Right = -1] = "Right", e))(y || {});
function z() {
let e = B(
document.location.search,
"imageLightboxIndex"
);
e = B(e, "imageLightboxSet"), window.history.pushState({}, "", document.location.pathname + e);
}
function K(e, n, r) {
const i = r[e].dataset.ilb2Id ?? e.toString();
let o = q(
document.location.search,
"imageLightboxIndex",
i
);
const t = {
imageLightboxIndex: i,
imageLightboxSet: ""
};
n !== void 0 && (t.imageLightboxSet = n, o = q(o, "imageLightboxSet", n)), window.history.pushState(
t,
"",
document.location.pathname + o
);
}
var E = /* @__PURE__ */ ((e) => (e[e.Left = 1] = "Left", e[e.None = 0] = "None", e[e.Right = -1] = "Right", e))(E || {});
function J(e, n, r) {
if (Q("imageLightboxSet") !== e)
if (B("imageLightboxSet") !== e)
return;
const i = Q("imageLightboxIndex");
const i = B("imageLightboxIndex");
if (i === void 0)

@@ -62,3 +38,3 @@ return;

}
function U(e, n, r, i, o, t, s) {
function U(e, n, r, i, o, t, l) {
const f = e.state;

@@ -77,3 +53,3 @@ if (!f || Object.keys(f).length === 0) {

let m = r.findIndex(
(h) => h.dataset.ilb2Id === u
(y) => y.dataset.ilb2Id === u
);

@@ -84,29 +60,53 @@ if (m < 0 && (m = parseInt(u, 10)), i === null) {

}
s(
l(
m,
m > i ? y.Right : y.Left,
m > i ? E.Right : E.Left,
!0
);
}
const g = document.createElement("div");
g.setAttribute("id", "ilb-container");
let N = null;
function G(e, n, r) {
g.classList.remove("ilb-overlay"), document.body.classList.add("ilb-body"), document.body.appendChild(g), n && (N = (i) => {
function G() {
let e = z(
document.location.search,
"imageLightboxIndex"
);
e = z(e, "imageLightboxSet"), window.history.pushState({}, "", document.location.pathname + e);
}
function K(e, n, r) {
const i = r[e].dataset.ilb2Id ?? e.toString();
let o = Q(
document.location.search,
"imageLightboxIndex",
i
);
const t = {
imageLightboxIndex: i,
imageLightboxSet: ""
};
n !== void 0 && (t.imageLightboxSet = n, o = Q(o, "imageLightboxSet", n)), window.history.pushState(
t,
"",
document.location.pathname + o
);
}
const p = document.createElement("div");
p.setAttribute("id", "ilb-container");
let R = null;
function Y(e, n, r) {
p.classList.remove("ilb-overlay"), document.body.classList.add("ilb-body"), document.body.appendChild(p), n && (R = (i) => {
i.stopPropagation(), r();
}, g.addEventListener("click", N), g.addEventListener("touchend", N)), g.style.transition = `opacity ${e.toString()}ms ease`, setTimeout(() => {
g.style.opacity = "1";
}, p.addEventListener("click", R), p.addEventListener("touchend", R)), p.style.transition = `opacity ${e.toString()}ms ease`, setTimeout(() => {
p.style.opacity = "1";
}, 50);
}
function Y() {
g.classList.add("ilb-overlay");
}
function Z() {
g.style.opacity = "0";
p.classList.add("ilb-overlay");
}
function h() {
return p;
}
function _() {
N !== null && (g.removeEventListener("click", N), g.removeEventListener("touchend", N)), g.remove(), g.textContent = "", document.body.classList.remove("ilb-body");
R !== null && (p.removeEventListener("click", R), p.removeEventListener("touchend", R)), p.remove(), p.textContent = "", document.body.classList.remove("ilb-body");
}
function E() {
return g;
function ee() {
p.style.opacity = "0";
}

@@ -116,4 +116,4 @@ const H = document.createElement("div");

H.appendChild(document.createElement("div"));
function V() {
E().appendChild(H);
function q() {
h().appendChild(H);
}

@@ -129,12 +129,12 @@ function j() {

O.setAttribute("id", "ilb-arrow-right");
let k = null, C = null;
function ee(e, n) {
k = (r) => {
let C = null, k = null;
function te(e, n) {
C = (r) => {
r.stopPropagation(), e();
}, C = (r) => {
}, k = (r) => {
r.stopPropagation(), n();
}, I.addEventListener("click", k), I.addEventListener("touchend", k), O.addEventListener("click", C), O.addEventListener("touchend", C), E().append(I, O);
}, I.addEventListener("click", C), I.addEventListener("touchend", C), O.addEventListener("click", k), O.addEventListener("touchend", k), h().append(I, O);
}
function te() {
I.remove(), k !== null && (I.removeEventListener("click", k), I.removeEventListener("touchend", k)), C !== null && (O.removeEventListener("click", C), O.removeEventListener("touchend", C)), k = null, C = null;
function ne() {
I.remove(), C !== null && (I.removeEventListener("click", C), I.removeEventListener("touchend", C)), k !== null && (O.removeEventListener("click", k), O.removeEventListener("touchend", k)), C = null, k = null;
}

@@ -147,4 +147,4 @@ const L = document.createElement("caption");

});
function ne(e, n) {
e !== "" ? (E().appendChild(L), L.style.transition = `opacity ${n.toString()}ms ease`, setTimeout(() => {
function ie(e, n) {
e !== "" ? (h().appendChild(L), L.style.transition = `opacity ${n.toString()}ms ease`, setTimeout(() => {
L.style.opacity = "1";

@@ -155,19 +155,19 @@ }, 1), L.textContent = e) : (L.style.opacity = "0", setTimeout(() => {

}
const R = document.createElement("button");
R.classList.add("ilb-button");
R.setAttribute("id", "ilb-close-button");
const M = document.createElement("button");
M.classList.add("ilb-button");
M.setAttribute("id", "ilb-close-button");
let D = null;
function ie(e) {
function oe(e) {
D = (n) => {
n.stopPropagation(), e();
}, R.addEventListener("click", D), E().appendChild(R);
}, M.addEventListener("click", D), h().appendChild(M);
}
function oe() {
D !== null && R.removeEventListener("click", D), R.remove();
function ae() {
D !== null && M.removeEventListener("click", D), M.remove();
}
const ae = (
const re = (
// eslint-disable-next-line compat/compat -- The prefixed version fixes the incompatibility
document.fullscreenEnabled || (document.webkitFullscreenEnabled ?? !1)
);
function re() {
function se() {
return (

@@ -180,26 +180,33 @@ // eslint-disable-next-line compat/compat -- The prefixed version fixes the incompatibility

(e.requestFullscreen || e.webkitRequestFullScreen).call(e);
}, se = () => {
}, de = () => {
(document.exitFullscreen || document.webkitExitFullscreen).call(document);
};
function de() {
re() === null ? le(E()) : se();
function ce() {
se() === null ? le(h()) : de();
}
const M = document.createElement("button");
M.classList.add("ilb-button");
M.setAttribute("id", "ilb-fullscreen-button");
M.innerHTML = "&#x26F6;";
M.addEventListener("click", (e) => {
e.stopPropagation(), de();
const P = document.createElement("button");
P.classList.add("ilb-button");
P.setAttribute("id", "ilb-fullscreen-button");
P.innerHTML = "&#x26F6;";
P.addEventListener("click", (e) => {
e.stopPropagation(), ce();
});
function ce() {
E().appendChild(M);
}
function ue() {
M.remove();
h().appendChild(P);
}
function fe(e, n, r) {
function fe() {
P.remove();
}
function me(e, n, r) {
let i = 0, o = 0, t = document.createElement("img");
t.setAttribute("id", "ilb-image"), t.setAttribute("src", e.getAttribute("href") ?? "");
const s = document.createElement("div");
s.classList.add("ilb-image-container");
t.addEventListener("error", (d) => {
h().dispatchEvent(
new CustomEvent("ilb:error", {
bubbles: !0,
detail: { target: d.target }
})
);
}), t.setAttribute("id", "ilb-image"), t.setAttribute("src", e.getAttribute("href") ?? ""), t.setAttribute("srcset", e.dataset.ilb2Srcset ?? ""), t.setAttribute("sizes", e.dataset.ilb2Sizes ?? "");
const l = document.createElement("div");
l.classList.add("ilb-image-container");
let f;

@@ -209,12 +216,12 @@ const u = e.dataset.ilb2VideoId;

if (m) {
const c = r.get(u);
c !== void 0 ? [t, f] = c.element() : m = !1;
const d = r.get(u);
d !== void 0 ? [t, f] = d.element() : m = !1;
}
s.appendChild(t);
function h(c, v, b, F) {
l.appendChild(t);
function y(d, v, b, F) {
if (m) {
const a = r.get(u);
if ((a == null ? void 0 : a.shouldAutoplay()) === !0) {
const [l, d] = a.element();
d ? l.play() : l.autoplay = !0;
const [s, c] = a.element();
c ? s.play() : s.autoplay = !0;
}

@@ -237,21 +244,21 @@ } else

a.stopPropagation(), t.style.transitionProperty = "left, opacity", t.style.left = "0";
}), c();
}), d();
}
function x(c, v) {
E().appendChild(s);
function x(d, v) {
h().appendChild(l);
const b = Math.abs(100 - n.gutter);
t.style.maxHeight = `${b.toString()}%`, t.style.maxWidth = `${b.toString()}%`, t.style.left = `${(-100 * c).toString()}px`, t.style.transition = `all ease ${n.animationSpeed.toString()}ms`, setTimeout(v, 50);
t.style.maxHeight = `${b.toString()}%`, t.style.maxWidth = `${b.toString()}%`, t.style.left = `${(-100 * d).toString()}px`, t.style.transition = `all ease ${n.animationSpeed.toString()}ms`, setTimeout(v, 50);
}
function A(c, v) {
t.addEventListener("error", v), f === !0 ? c() : (t.addEventListener("load", c), t.addEventListener("loadedmetadata", c));
function A(d, v) {
t.addEventListener("error", v), f === !0 ? d() : (t.addEventListener("load", d), t.addEventListener("loadedmetadata", d));
}
function p(c, v, b, F) {
function g(d, v, b, F) {
t.style.left = "0", t.style.opacity = "1", setTimeout(() => {
h(c, v, b, F);
y(d, v, b, F);
}, n.animationSpeed);
}
function S(c, v) {
if (c !== y.None) {
function S(d, v) {
if (d !== E.None) {
const b = parseInt(t.style.left, 10) || 0;
t.style.left = `${(b + 100 * c).toString()}px`;
t.style.left = `${(b + 100 * d).toString()}px`;
}

@@ -263,3 +270,3 @@ t.style.opacity = "0", setTimeout(() => {

function $() {
s.remove();
l.remove();
}

@@ -270,3 +277,3 @@ return {

startLoading: A,
transitionIn: p,
transitionIn: g,
transitionOut: S

@@ -276,3 +283,3 @@ };

let T = null;
function me(e, n, r, i) {
function ve(e, n, r, i) {
e.enableKeyboard && (T = (o) => {

@@ -282,3 +289,3 @@ o.key === "Escape" && (o.preventDefault(), n()), o.key === "ArrowLeft" && (o.preventDefault(), r()), o.key === "ArrowRight" && (o.preventDefault(), i());

}
function ve() {
function pe() {
T !== null && document.removeEventListener("keyup", T);

@@ -292,3 +299,3 @@ }

t.style.transition = `background-color ${i.toString()}ms ease`;
const s = () => {
const l = () => {
const f = n();

@@ -300,18 +307,12 @@ if (t.classList.contains("ilb-navigation-active") || f === null || t.parentNode === null)

t
), m = u < f ? y.Left : y.Right;
), m = u < f ? E.Left : E.Right;
r(u, m);
};
t.addEventListener("click", s), t.addEventListener("touchend", s), w.appendChild(t);
t.addEventListener("click", l), t.addEventListener("touchend", l), w.appendChild(t);
}
}
function X(e) {
var n, r;
for (let i = 0; i < w.children.length; i++)
(n = w.children.item(i)) == null || n.classList.remove("ilb-navigation-active");
(r = w.children.item(e)) == null || r.classList.add("ilb-navigation-active");
}
function ge(e, n, r, i) {
w.textContent = "", W(e, n, r, i);
const o = n();
o !== null && X(o), E().appendChild(w), w.addEventListener("click", (t) => {
o !== null && X(o), h().appendChild(w), w.addEventListener("click", (t) => {
t.stopPropagation();

@@ -322,3 +323,9 @@ }), w.addEventListener("touchend", (t) => {

}
function pe(e, n) {
function X(e) {
var n, r;
for (let i = 0; i < w.children.length; i++)
(n = w.children.item(i)) == null || n.classList.remove("ilb-navigation-active");
(r = w.children.item(e)) == null || r.classList.add("ilb-navigation-active");
}
function be(e, n) {
let r = e.dataset.ilb2Id;

@@ -328,7 +335,7 @@ r === void 0 && (r = `a${((1 + Math.random()) * 65536 | 0).toString(16)}`), e.dataset.ilb2VideoId = r;

o.setAttribute("id", "ilb-image"), o.preload = "metadata", o.dataset.ilb2VideoId = i;
let t = !1, s = !1;
for (const [h, x] of Object.entries(n))
switch (h) {
let t = !1, l = !1;
for (const [y, x] of Object.entries(n))
switch (y) {
case "autoplay":
s = !0;
l = !0;
break;

@@ -341,10 +348,10 @@ case "controls":

case "src":
o.setAttribute(h, x.toString());
o.setAttribute(y, x.toString());
break;
}
if (n.sources)
for (const h of n.sources) {
for (const y of n.sources) {
const x = document.createElement("source");
for (const [A, p] of Object.entries(h))
x.setAttribute(A, p);
for (const [A, g] of Object.entries(y))
x.setAttribute(A, g);
o.appendChild(x);

@@ -362,3 +369,3 @@ }

function m() {
return s;
return l;
}

@@ -371,3 +378,3 @@ return {

}
function be() {
function he() {
const e = [];

@@ -378,3 +385,3 @@ function n(i) {

t !== void 0 && e.push(
pe(o, JSON.parse(t))
be(o, JSON.parse(t))
);

@@ -391,5 +398,5 @@ }

}
function he(e, n, r) {
const i = [], o = be();
let t = null, s = null;
function ye(e, n, r) {
const i = [], o = he();
let t = null, l = null;
function f() {

@@ -401,43 +408,48 @@ return n;

}
function m(a, l) {
if (s === null)
function m(a, s) {
if (l === null)
return;
const d = s;
d.transitionOut(a, () => {
d.removeFromDOM(), l == null || l();
const c = l;
c.transitionOut(a, () => {
c.removeFromDOM(), s == null || s();
});
}
function h() {
s == null || s.transitionIn(
function y() {
l == null || l.transitionIn(
j,
/* eslint-disable @typescript-eslint/no-use-before-define -- Cyclical dependencies */
$,
c,
p
d,
g
);
}
function x(a) {
s == null || s.addToDOM(a, () => {
var d;
l == null || l.addToDOM(a, () => {
var c;
if (t === null)
return;
const l = i[t];
if (e.caption && ne(
l.dataset.ilb2Caption ?? ((d = l.getElementsByTagName("img").item(0)) == null ? void 0 : d.alt) ?? "",
const s = i[t];
if (e.caption && ie(
s.dataset.ilb2Caption ?? ((c = s.getElementsByTagName("img").item(0)) == null ? void 0 : c.alt) ?? "",
e.animationSpeed
), h(), e.preloadNext && t + 1 < i.length) {
const P = i[t + 1];
document.createElement("img").setAttribute(
), y(), e.preloadNext && t + 1 < i.length) {
const N = i[t + 1], V = document.createElement("img");
V.setAttribute(
"src",
P.getAttribute("href") ?? ""
N.getAttribute("href") ?? ""
), V.setAttribute(
"srcset",
N.dataset.ilb2Srcset ?? ""
), V.setAttribute(
"sizes",
N.dataset.ilb2Sizes ?? ""
);
}
E().dispatchEvent(new Event("ilb:loaded", { bubbles: !0 }));
h().dispatchEvent(new Event("ilb:loaded", { bubbles: !0 }));
});
}
function A(a, l) {
const d = fe(i[a], e, o);
t = a, s = d, d.startLoading(
function A(a, s) {
const c = me(i[a], e, o);
t = a, l = c, c.startLoading(
() => {
x(l);
x(s);
},

@@ -449,9 +461,9 @@ () => {

}
function p(a = !1) {
t !== null && (e.activity && V(), ve(), e.history && !a && z(), E().dispatchEvent(new Event("ilb:quit", { bubbles: !0 })), Z(), m(y.None, () => {
t = null, s = null, te(), oe(), ue(), _();
function g(a = !1) {
t !== null && (e.activity && q(), pe(), e.history && !a && G(), h().dispatchEvent(new Event("ilb:quit", { bubbles: !0 })), ee(), m(E.None, () => {
t = null, l = null, ne(), ae(), fe(), _();
}));
}
function S(a, l, d = !1) {
t !== null && (e.history && !d && K(a, f(), u()), e.activity && V(), X(a), m(l), A(a, l));
function S(a, s, c = !1) {
t !== null && (e.history && !c && K(a, f(), u()), e.activity && q(), X(a), m(s), A(a, s));
}

@@ -464,3 +476,3 @@ function $() {

if (e.quitOnEnd) {
p();
g();
return;

@@ -472,5 +484,5 @@ }

new Event("ilb:previous", { bubbles: !0 })
), S(a, y.Left);
), S(a, E.Left);
}
function c() {
function d() {
if (t === null)

@@ -481,3 +493,3 @@ return;

if (e.quitOnEnd) {
p();
g();
return;

@@ -489,8 +501,8 @@ }

new Event("ilb:next", { bubbles: !0 })
), S(a, y.Right);
), S(a, E.Right);
}
function v(a, l = !1) {
t === null && (G(e.animationSpeed, e.quitOnDocClick, p), e.activity && V(), me(e, p, $, c), e.arrows && ee($, c), e.button && ie(p), e.fullscreen && ae && ce(), e.overlay && Y(), e.history && !l && K(a, f(), u()), i[a].dispatchEvent(
function v(a, s = !1) {
t === null && (Y(e.animationSpeed, e.quitOnDocClick, g), e.activity && q(), ve(e, g, $, d), e.arrows && te($, d), e.button && oe(g), e.fullscreen && re && ue(), e.overlay && Z(), e.history && !s && K(a, f(), u()), i[a].dispatchEvent(
new Event("ilb:start", { bubbles: !0 })
), A(a, y.None), e.navigation && ge(
), A(a, E.None), e.navigation && ge(
u(),

@@ -503,16 +515,16 @@ () => t,

function b(a) {
const l = i.indexOf(a);
l < 0 || v(l);
const s = i.indexOf(a);
s < 0 || v(s);
}
function F(a) {
const l = a.filter((d) => !i.includes(d)).filter(
(d) => d.tagName.toLowerCase() === "a" && (new RegExp(`.(${e.allowedTypes})$`, "i").test(d.href) || d.dataset.ilb2Video !== void 0)
const s = a.filter((c) => !i.includes(c)).filter(
(c) => c.tagName.toLowerCase() === "a" && (new RegExp(`.(${e.allowedTypes})$`, "i").test(c.href) || c.dataset.ilb2Srcset !== void 0 || c.dataset.ilb2Video !== void 0)
);
o.add(l), i.push(...l);
for (const d of l)
d.addEventListener("click", (P) => {
P.preventDefault(), P.stopPropagation(), b(d);
o.add(s), i.push(...s);
for (const c of s)
c.addEventListener("click", (N) => {
N.preventDefault(), N.stopPropagation(), b(c);
});
W(
l,
s,
() => t,

@@ -524,8 +536,8 @@ S,

return F(r), e.history && window.addEventListener("popstate", (a) => {
U(a, f(), u(), t, v, p, S);
U(a, f(), u(), t, v, g, S);
}), {
addImages: F,
close: p,
close: g,
images: u,
next: c,
next: d,
open: v,

@@ -558,3 +570,3 @@ openWithImage: b,

};
this.s = he(
this.s = ye(
i,

@@ -561,0 +573,0 @@ n.length > 0 ? n[0].dataset.imagelightbox ?? "" : "",

{
"name": "imagelightbox",
"version": "3.0.0",
"version": "3.1.0",
"description": "Image Lightbox, Responsive and Touch‑friendly",

@@ -46,4 +46,4 @@ "homepage": "https://marekdedic.github.io/imagelightbox",

"eslint-plugin-compat": "^6.0.0",
"eslint-plugin-perfectionist": "^3.2.0",
"eslint-plugin-playwright": "^1.3.1",
"eslint-plugin-perfectionist": "^4.0.3",
"eslint-plugin-playwright": "^2.0.0",
"eslint-plugin-prefer-arrow-functions": "^3.4.0",

@@ -67,3 +67,3 @@ "eslint-plugin-prettier": "^5.2.1",

"typescript-eslint": "^8.3.0",
"vite": "^5.1.4",
"vite": "^6.0.2",
"vite-plugin-istanbul": "^6.0.0"

@@ -70,0 +70,0 @@ },

@@ -151,2 +151,6 @@ # imagelightbox

});
document.addEventListener("ilb:error", (e) => {
console.log("Error loading image");
console.log(e.detail.target);
});
```

@@ -153,0 +157,0 @@

@@ -0,1 +1,13 @@

declare global {
interface Document {
addEventListener(
type: "ilb:error",
listener: (
this: Document,
ev: CustomEvent<{ target: HTMLImageElement }>,
) => void,
): void;
}
}
interface ILBOptions {

@@ -2,0 +14,0 @@ activity: boolean;

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

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc