accessify-widget 0.3.9 → 0.3.10

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-DabFemHm.js";
1
+ import { d, i } from "./index-DxYL6cyB.js";
2
2
  export {
3
3
  d as destroy,
4
4
  i as init
@@ -6433,14 +6433,14 @@ function FeatureGrid($$anchor, $$props) {
6433
6433
  const FEATURE_LOADERS = {
6434
6434
  contrast: () => import("./contrast-CqsICAkU.js"),
6435
6435
  "text-size": () => import("./text-size-C6OFhCGi.js"),
6436
- "keyboard-nav": () => import("./keyboard-nav-BAnuU08t.js"),
6436
+ "keyboard-nav": () => import("./keyboard-nav-DFuKOs8i.js"),
6437
6437
  "link-highlight": () => import("./link-highlight-DBGm067Y.js"),
6438
6438
  "reading-guide": () => import("./reading-guide-VT8NciIL.js"),
6439
6439
  "reading-mask": () => import("./reading-mask-BABChuCz.js"),
6440
6440
  "animation-stop": () => import("./animation-stop-C0MwseK0.js"),
6441
6441
  "hide-images": () => import("./hide-images-B_LeCBcd.js"),
6442
6442
  "big-cursor": () => import("./big-cursor-B2UKu9dQ.js"),
6443
- "page-structure": () => import("./page-structure-DjY63saM.js"),
6443
+ "page-structure": () => import("./page-structure-2bsTmvsF.js"),
6444
6444
  tts: () => import("./tts-CjszLRnb.js"),
6445
6445
  "text-simplify": () => import("./text-simplify-Cvhpio7g.js"),
6446
6446
  "alt-text": () => Promise.resolve().then(() => altText)
@@ -8162,82 +8162,95 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8162
8162
  }
8163
8163
  });
8164
8164
  }
8165
- const INFO_BADGE_CLASS = "accessify-alt-badge";
8166
- const INFO_TOOLTIP_CLASS = "accessify-alt-tooltip";
8167
- let styleEl = null;
8168
- function injectBadgeStyles() {
8169
- if (styleEl) return;
8170
- styleEl = document.createElement("style");
8171
- styleEl.textContent = `
8172
- .${INFO_BADGE_CLASS} {
8173
- position: absolute;
8174
- top: 6px;
8175
- left: 6px;
8176
- width: 22px;
8177
- height: 22px;
8178
- border-radius: 50%;
8179
- background: rgba(0,0,0,0.55);
8180
- color: #fff;
8181
- font: bold 13px/22px sans-serif;
8182
- text-align: center;
8183
- cursor: default;
8184
- z-index: 10;
8185
- pointer-events: auto;
8186
- transition: background 0.15s;
8187
- box-shadow: 0 1px 3px rgba(0,0,0,0.3);
8188
- }
8189
- .${INFO_BADGE_CLASS}:hover {
8190
- background: rgba(0,0,0,0.8);
8191
- }
8192
- .${INFO_TOOLTIP_CLASS} {
8193
- display: none;
8194
- position: absolute;
8195
- top: 32px;
8196
- left: 0;
8197
- min-width: 180px;
8198
- max-width: 300px;
8199
- padding: 8px 10px;
8200
- background: rgba(0,0,0,0.85);
8201
- color: #fff;
8202
- font: normal 12px/1.4 sans-serif;
8203
- border-radius: 6px;
8204
- z-index: 11;
8205
- pointer-events: none;
8206
- word-wrap: break-word;
8207
- box-shadow: 0 2px 8px rgba(0,0,0,0.3);
8208
- }
8209
- .${INFO_BADGE_CLASS}:hover + .${INFO_TOOLTIP_CLASS},
8210
- .${INFO_BADGE_CLASS}:focus + .${INFO_TOOLTIP_CLASS} {
8211
- display: block;
8212
- }
8213
- `;
8214
- document.head.appendChild(styleEl);
8215
- }
8165
+ const BADGE_ATTR = "data-accessify-badge";
8216
8166
  function addInfoBadge(target, altText2) {
8217
- const parent = target.tagName === "IMG" ? target.parentElement : target;
8218
- if (!parent) return;
8219
- if (parent.querySelector(`.${INFO_BADGE_CLASS}`)) return;
8220
- const pos = getComputedStyle(parent).position;
8221
- if (pos === "static") parent.style.position = "relative";
8222
- const badge = document.createElement("span");
8223
- badge.className = INFO_BADGE_CLASS;
8167
+ target.tagName === "IMG";
8168
+ const rect = target.getBoundingClientRect();
8169
+ if (rect.width < 40 || rect.height < 40) return;
8170
+ if (target.getAttribute(BADGE_ATTR)) return;
8171
+ target.setAttribute(BADGE_ATTR, "1");
8172
+ const container = document.createElement("div");
8173
+ Object.assign(container.style, {
8174
+ position: "fixed",
8175
+ top: `${rect.top + 6}px`,
8176
+ left: `${rect.left + 6}px`,
8177
+ zIndex: "99999",
8178
+ pointerEvents: "auto"
8179
+ });
8180
+ container.setAttribute("data-accessify-badge-container", "1");
8181
+ const badge = document.createElement("div");
8182
+ Object.assign(badge.style, {
8183
+ width: "24px",
8184
+ height: "24px",
8185
+ borderRadius: "50%",
8186
+ background: "rgba(0,0,0,0.6)",
8187
+ color: "#fff",
8188
+ fontFamily: "sans-serif",
8189
+ fontWeight: "bold",
8190
+ fontSize: "14px",
8191
+ lineHeight: "24px",
8192
+ textAlign: "center",
8193
+ cursor: "default",
8194
+ boxShadow: "0 1px 4px rgba(0,0,0,0.4)",
8195
+ transition: "background 0.15s"
8196
+ });
8224
8197
  badge.textContent = "i";
8225
8198
  badge.setAttribute("aria-hidden", "true");
8226
- const tooltip = document.createElement("span");
8227
- tooltip.className = INFO_TOOLTIP_CLASS;
8199
+ const tooltip = document.createElement("div");
8200
+ Object.assign(tooltip.style, {
8201
+ display: "none",
8202
+ position: "absolute",
8203
+ top: "28px",
8204
+ left: "0",
8205
+ minWidth: "160px",
8206
+ maxWidth: "300px",
8207
+ padding: "8px 10px",
8208
+ background: "rgba(0,0,0,0.88)",
8209
+ color: "#fff",
8210
+ fontFamily: "sans-serif",
8211
+ fontSize: "12px",
8212
+ lineHeight: "1.4",
8213
+ borderRadius: "6px",
8214
+ pointerEvents: "none",
8215
+ wordWrap: "break-word",
8216
+ boxShadow: "0 2px 8px rgba(0,0,0,0.3)"
8217
+ });
8228
8218
  tooltip.textContent = altText2;
8229
- parent.appendChild(badge);
8230
- parent.appendChild(tooltip);
8219
+ badge.addEventListener("mouseenter", () => {
8220
+ badge.style.background = "rgba(0,0,0,0.85)";
8221
+ tooltip.style.display = "block";
8222
+ });
8223
+ badge.addEventListener("mouseleave", () => {
8224
+ badge.style.background = "rgba(0,0,0,0.6)";
8225
+ tooltip.style.display = "none";
8226
+ });
8227
+ container.appendChild(badge);
8228
+ container.appendChild(tooltip);
8229
+ document.body.appendChild(container);
8230
+ const updatePos = () => {
8231
+ const r = target.getBoundingClientRect();
8232
+ container.style.top = `${r.top + 6}px`;
8233
+ container.style.left = `${r.left + 6}px`;
8234
+ container.style.display = r.bottom < 0 || r.top > window.innerHeight ? "none" : "";
8235
+ };
8236
+ const scrollHandler = () => requestAnimationFrame(updatePos);
8237
+ window.addEventListener("scroll", scrollHandler, { passive: true });
8238
+ window.addEventListener("resize", scrollHandler, { passive: true });
8239
+ container._cleanup = () => {
8240
+ window.removeEventListener("scroll", scrollHandler);
8241
+ window.removeEventListener("resize", scrollHandler);
8242
+ };
8231
8243
  }
8232
8244
  function removeAllBadges() {
8233
- document.querySelectorAll(`.${INFO_BADGE_CLASS}, .${INFO_TOOLTIP_CLASS}`).forEach((el) => el.remove());
8234
- if (styleEl) {
8235
- styleEl.remove();
8236
- styleEl = null;
8237
- }
8245
+ document.querySelectorAll("[data-accessify-badge-container]").forEach((el) => {
8246
+ el._cleanup?.();
8247
+ el.remove();
8248
+ });
8249
+ document.querySelectorAll(`[${BADGE_ATTR}]`).forEach((el) => {
8250
+ el.removeAttribute(BADGE_ATTR);
8251
+ });
8238
8252
  }
8239
8253
  function addBadgesToAllImages() {
8240
- injectBadgeStyles();
8241
8254
  document.querySelectorAll("img").forEach((img) => {
8242
8255
  if (!isValidImage(img)) return;
8243
8256
  const alt = img.getAttribute("alt") || img.getAttribute("title");
@@ -8675,4 +8688,4 @@ export {
8675
8688
  init as i,
8676
8689
  t
8677
8690
  };
8678
- //# sourceMappingURL=index-DabFemHm.js.map
8691
+ //# sourceMappingURL=index-DxYL6cyB.js.map