accessify-widget 0.3.33 → 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-BEHW9bFe.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-CInuB3YJ.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-BjLqiNKh.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,32 +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
- const parentPos = getComputedStyle(parent).position;
8407
- if (parentPos === "static") parent.style.position = "relative";
8408
- anchor = parent;
8409
- const imgEl = target;
8410
- badgeTop = `${imgEl.offsetTop + 6}px`;
8411
- badgeLeft = `${imgEl.offsetLeft + 6}px`;
8412
- } else {
8413
- const pos = getComputedStyle(target).position;
8414
- if (pos === "static") target.style.position = "relative";
8415
- anchor = target;
8416
- }
8458
+ const overlay = getOrCreateOverlay();
8417
8459
  const badge = document.createElement("span");
8418
8460
  Object.assign(badge.style, {
8419
8461
  position: "absolute",
8420
- top: badgeTop,
8421
- left: badgeLeft,
8422
8462
  width: "22px",
8423
8463
  height: "22px",
8424
8464
  borderRadius: "50%",
@@ -8430,7 +8470,6 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8430
8470
  lineHeight: "22px",
8431
8471
  textAlign: "center",
8432
8472
  cursor: "default",
8433
- zIndex: "10000",
8434
8473
  pointerEvents: "auto",
8435
8474
  boxShadow: "0 1px 4px rgba(0,0,0,0.4)",
8436
8475
  transition: "background 0.15s"
@@ -8444,8 +8483,6 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8444
8483
  Object.assign(tooltip.style, {
8445
8484
  display: "none",
8446
8485
  position: "absolute",
8447
- top: `calc(${badgeTop} + 26px)`,
8448
- left: badgeLeft,
8449
8486
  minWidth: "150px",
8450
8487
  maxWidth: "280px",
8451
8488
  padding: "6px 10px",
@@ -8455,10 +8492,10 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8455
8492
  fontSize: "12px",
8456
8493
  lineHeight: "1.4",
8457
8494
  borderRadius: "6px",
8458
- zIndex: "10001",
8459
8495
  pointerEvents: "none",
8460
8496
  wordWrap: "break-word",
8461
- boxShadow: "0 2px 8px rgba(0,0,0,0.3)"
8497
+ boxShadow: "0 2px 8px rgba(0,0,0,0.3)",
8498
+ zIndex: "1"
8462
8499
  });
8463
8500
  tooltip.textContent = altText2;
8464
8501
  tooltip.setAttribute("translate", "no");
@@ -8472,11 +8509,15 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8472
8509
  badge.style.background = "rgba(0,0,0,0.6)";
8473
8510
  tooltip.style.display = "none";
8474
8511
  });
8475
- anchor.appendChild(badge);
8476
- anchor.appendChild(tooltip);
8512
+ overlay.appendChild(badge);
8513
+ overlay.appendChild(tooltip);
8514
+ positionBadge(target, badge, tooltip);
8515
+ trackedBadges.push({ target, badge, tooltip });
8477
8516
  }
8478
8517
  function removeAllBadges() {
8479
- document.querySelectorAll(`[${BADGE_ATTR}="badge"], [${BADGE_ATTR}="tooltip"]`).forEach((el) => el.remove());
8518
+ stopBadgeTracking();
8519
+ trackedBadges = [];
8520
+ document.getElementById(OVERLAY_ID)?.remove();
8480
8521
  document.querySelectorAll(`[${BADGE_ATTR}]`).forEach((el) => el.removeAttribute(BADGE_ATTR));
8481
8522
  document.querySelectorAll(`[${WRAPPER_ATTR}]`).forEach((wrapper) => {
8482
8523
  const img = wrapper.querySelector("img");
@@ -8500,6 +8541,7 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8500
8541
  addInfoBadge(el, alt.trim());
8501
8542
  }
8502
8543
  });
8544
+ if (trackedBadges.length > 0) startBadgeTracking();
8503
8545
  }
8504
8546
  function removeTitles() {
8505
8547
  document.querySelectorAll('img[data-accessify-title="auto"]').forEach((img) => {
@@ -8929,4 +8971,4 @@ export {
8929
8971
  init as i,
8930
8972
  t
8931
8973
  };
8932
- //# sourceMappingURL=index-BEHW9bFe.js.map
8974
+ //# sourceMappingURL=index-BG6LNf5h.js.map