accessify-widget 0.3.32 → 0.3.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { d, i } from "./index-hf7U_NmB.js";
1
+ import { d, i } from "./index-BG6LNf5h.js";
2
2
  export {
3
3
  d as destroy,
4
4
  i as init
@@ -6641,14 +6641,14 @@ function FeatureGrid($$anchor, $$props) {
6641
6641
  const FEATURE_LOADERS = {
6642
6642
  contrast: () => import("./contrast-CqsICAkU.js"),
6643
6643
  "text-size": () => import("./text-size-m_mHNPWo.js"),
6644
- "keyboard-nav": () => import("./keyboard-nav-B6r-k8He.js"),
6644
+ "keyboard-nav": () => import("./keyboard-nav-BjMDStEd.js"),
6645
6645
  "link-highlight": () => import("./link-highlight-DBGm067Y.js"),
6646
6646
  "reading-guide": () => import("./reading-guide-VT8NciIL.js"),
6647
6647
  "reading-mask": () => import("./reading-mask-BABChuCz.js"),
6648
6648
  "animation-stop": () => import("./animation-stop-_chC8bg1.js"),
6649
6649
  "hide-images": () => import("./hide-images-B_LeCBcd.js"),
6650
6650
  "big-cursor": () => import("./big-cursor-B2UKu9dQ.js"),
6651
- "page-structure": () => import("./page-structure-B7Easdyx.js"),
6651
+ "page-structure": () => import("./page-structure-BfDi-GEx.js"),
6652
6652
  tts: () => import("./tts-CjszLRnb.js"),
6653
6653
  "text-simplify": () => import("./text-simplify-Cfykj7Ak.js"),
6654
6654
  "alt-text": () => Promise.resolve().then(() => altText)
@@ -8393,52 +8393,72 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8393
8393
  }
8394
8394
  const BADGE_ATTR = "data-accessify-badge";
8395
8395
  const WRAPPER_ATTR = "data-accessify-badge-wrap";
8396
+ const OVERLAY_ID = "accessify-badge-overlay";
8397
+ let badgePositionRAF = null;
8398
+ let trackedBadges = [];
8399
+ function getOrCreateOverlay() {
8400
+ let overlay = document.getElementById(OVERLAY_ID);
8401
+ if (!overlay) {
8402
+ overlay = document.createElement("div");
8403
+ overlay.id = OVERLAY_ID;
8404
+ Object.assign(overlay.style, {
8405
+ position: "absolute",
8406
+ top: "0",
8407
+ left: "0",
8408
+ width: "0",
8409
+ height: "0",
8410
+ overflow: "visible",
8411
+ pointerEvents: "none",
8412
+ zIndex: "10000"
8413
+ });
8414
+ document.body.appendChild(overlay);
8415
+ }
8416
+ return overlay;
8417
+ }
8418
+ function positionBadge(target, badge, tooltip) {
8419
+ const rect = target.getBoundingClientRect();
8420
+ if (rect.width < 10 || rect.height < 10) {
8421
+ badge.style.display = "none";
8422
+ tooltip.style.display = "none";
8423
+ return;
8424
+ }
8425
+ const scrollX = window.scrollX;
8426
+ const scrollY = window.scrollY;
8427
+ const top = rect.top + scrollY + 6;
8428
+ const left = rect.left + scrollX + 6;
8429
+ badge.style.display = "";
8430
+ badge.style.top = `${top}px`;
8431
+ badge.style.left = `${left}px`;
8432
+ tooltip.style.top = `${top + 26}px`;
8433
+ tooltip.style.left = `${left}px`;
8434
+ }
8435
+ function updateAllBadgePositions() {
8436
+ for (const { target, badge, tooltip } of trackedBadges) {
8437
+ if (!document.body.contains(target)) continue;
8438
+ positionBadge(target, badge, tooltip);
8439
+ }
8440
+ }
8441
+ function startBadgeTracking() {
8442
+ if (badgePositionRAF !== null) return;
8443
+ const tick = () => {
8444
+ updateAllBadgePositions();
8445
+ badgePositionRAF = requestAnimationFrame(tick);
8446
+ };
8447
+ badgePositionRAF = requestAnimationFrame(tick);
8448
+ }
8449
+ function stopBadgeTracking() {
8450
+ if (badgePositionRAF !== null) {
8451
+ cancelAnimationFrame(badgePositionRAF);
8452
+ badgePositionRAF = null;
8453
+ }
8454
+ }
8396
8455
  function addInfoBadge(target, altText2) {
8397
8456
  if (target.getAttribute(BADGE_ATTR)) return;
8398
8457
  target.setAttribute(BADGE_ATTR, "1");
8399
- const isImg = target.tagName === "IMG";
8400
- let anchor;
8401
- let badgeTop = "6px";
8402
- let badgeLeft = "6px";
8403
- if (isImg) {
8404
- const parent = target.parentElement;
8405
- if (!parent) return;
8406
- let overflowAncestor = null;
8407
- let el = parent;
8408
- const MAX_LEVELS = 2;
8409
- for (let i = 0; i < MAX_LEVELS && el && el !== document.body; i++) {
8410
- const cs = getComputedStyle(el);
8411
- if (cs.overflow === "hidden" && cs.position !== "static") {
8412
- overflowAncestor = el;
8413
- break;
8414
- }
8415
- el = el.parentElement;
8416
- }
8417
- if (overflowAncestor) {
8418
- anchor = overflowAncestor;
8419
- const imgEl = target;
8420
- const containerRect = overflowAncestor.getBoundingClientRect();
8421
- const imgRect = imgEl.getBoundingClientRect();
8422
- badgeTop = `${Math.max(6, imgRect.top - containerRect.top + 6)}px`;
8423
- badgeLeft = `${Math.max(6, imgRect.left - containerRect.left + 6)}px`;
8424
- } else {
8425
- const parentPos = getComputedStyle(parent).position;
8426
- if (parentPos === "static") parent.style.position = "relative";
8427
- anchor = parent;
8428
- const imgEl = target;
8429
- badgeTop = `${imgEl.offsetTop + 6}px`;
8430
- badgeLeft = `${imgEl.offsetLeft + 6}px`;
8431
- }
8432
- } else {
8433
- const pos = getComputedStyle(target).position;
8434
- if (pos === "static") target.style.position = "relative";
8435
- anchor = target;
8436
- }
8458
+ const overlay = getOrCreateOverlay();
8437
8459
  const badge = document.createElement("span");
8438
8460
  Object.assign(badge.style, {
8439
8461
  position: "absolute",
8440
- top: badgeTop,
8441
- left: badgeLeft,
8442
8462
  width: "22px",
8443
8463
  height: "22px",
8444
8464
  borderRadius: "50%",
@@ -8450,7 +8470,6 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8450
8470
  lineHeight: "22px",
8451
8471
  textAlign: "center",
8452
8472
  cursor: "default",
8453
- zIndex: "10000",
8454
8473
  pointerEvents: "auto",
8455
8474
  boxShadow: "0 1px 4px rgba(0,0,0,0.4)",
8456
8475
  transition: "background 0.15s"
@@ -8464,8 +8483,6 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8464
8483
  Object.assign(tooltip.style, {
8465
8484
  display: "none",
8466
8485
  position: "absolute",
8467
- top: `calc(${badgeTop} + 26px)`,
8468
- left: badgeLeft,
8469
8486
  minWidth: "150px",
8470
8487
  maxWidth: "280px",
8471
8488
  padding: "6px 10px",
@@ -8475,10 +8492,10 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8475
8492
  fontSize: "12px",
8476
8493
  lineHeight: "1.4",
8477
8494
  borderRadius: "6px",
8478
- zIndex: "10001",
8479
8495
  pointerEvents: "none",
8480
8496
  wordWrap: "break-word",
8481
- boxShadow: "0 2px 8px rgba(0,0,0,0.3)"
8497
+ boxShadow: "0 2px 8px rgba(0,0,0,0.3)",
8498
+ zIndex: "1"
8482
8499
  });
8483
8500
  tooltip.textContent = altText2;
8484
8501
  tooltip.setAttribute("translate", "no");
@@ -8492,11 +8509,15 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8492
8509
  badge.style.background = "rgba(0,0,0,0.6)";
8493
8510
  tooltip.style.display = "none";
8494
8511
  });
8495
- anchor.appendChild(badge);
8496
- anchor.appendChild(tooltip);
8512
+ overlay.appendChild(badge);
8513
+ overlay.appendChild(tooltip);
8514
+ positionBadge(target, badge, tooltip);
8515
+ trackedBadges.push({ target, badge, tooltip });
8497
8516
  }
8498
8517
  function removeAllBadges() {
8499
- document.querySelectorAll(`[${BADGE_ATTR}="badge"], [${BADGE_ATTR}="tooltip"]`).forEach((el) => el.remove());
8518
+ stopBadgeTracking();
8519
+ trackedBadges = [];
8520
+ document.getElementById(OVERLAY_ID)?.remove();
8500
8521
  document.querySelectorAll(`[${BADGE_ATTR}]`).forEach((el) => el.removeAttribute(BADGE_ATTR));
8501
8522
  document.querySelectorAll(`[${WRAPPER_ATTR}]`).forEach((wrapper) => {
8502
8523
  const img = wrapper.querySelector("img");
@@ -8520,6 +8541,7 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8520
8541
  addInfoBadge(el, alt.trim());
8521
8542
  }
8522
8543
  });
8544
+ if (trackedBadges.length > 0) startBadgeTracking();
8523
8545
  }
8524
8546
  function removeTitles() {
8525
8547
  document.querySelectorAll('img[data-accessify-title="auto"]').forEach((img) => {
@@ -8949,4 +8971,4 @@ export {
8949
8971
  init as i,
8950
8972
  t
8951
8973
  };
8952
- //# sourceMappingURL=index-hf7U_NmB.js.map
8974
+ //# sourceMappingURL=index-BG6LNf5h.js.map