accessify-widget 0.3.8 → 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-C3jQHPAw.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-CzeLetKR.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-DFT1USJ1.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)
@@ -8149,6 +8149,7 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8149
8149
  img.setAttribute("alt", altText2);
8150
8150
  img.setAttribute("title", altText2);
8151
8151
  processedImages.set(img, { generatedAlt: altText2 });
8152
+ if (enabled) addInfoBadge(img, altText2);
8152
8153
  }
8153
8154
  function applyTitlesToAllImages() {
8154
8155
  document.querySelectorAll("img").forEach((img) => {
@@ -8161,6 +8162,109 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8161
8162
  }
8162
8163
  });
8163
8164
  }
8165
+ const BADGE_ATTR = "data-accessify-badge";
8166
+ function addInfoBadge(target, altText2) {
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
+ });
8197
+ badge.textContent = "i";
8198
+ badge.setAttribute("aria-hidden", "true");
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
+ });
8218
+ tooltip.textContent = altText2;
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
+ };
8243
+ }
8244
+ function removeAllBadges() {
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
+ });
8252
+ }
8253
+ function addBadgesToAllImages() {
8254
+ document.querySelectorAll("img").forEach((img) => {
8255
+ if (!isValidImage(img)) return;
8256
+ const alt = img.getAttribute("alt") || img.getAttribute("title");
8257
+ if (alt && alt.trim()) {
8258
+ addInfoBadge(img, alt.trim());
8259
+ }
8260
+ });
8261
+ document.querySelectorAll("[data-accessify-bg-alt]").forEach((el) => {
8262
+ const alt = el.getAttribute("aria-label");
8263
+ if (alt && alt.trim()) {
8264
+ addInfoBadge(el, alt.trim());
8265
+ }
8266
+ });
8267
+ }
8164
8268
  function removeTitles() {
8165
8269
  document.querySelectorAll('img[data-accessify-title="auto"]').forEach((img) => {
8166
8270
  img.removeAttribute("title");
@@ -8172,6 +8276,7 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8172
8276
  el.removeAttribute("title");
8173
8277
  el.removeAttribute("data-accessify-bg-alt");
8174
8278
  });
8279
+ removeAllBadges();
8175
8280
  }
8176
8281
  function scanForBackgroundImages() {
8177
8282
  const found = [];
@@ -8201,6 +8306,7 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8201
8306
  el.setAttribute("aria-label", altText2);
8202
8307
  el.setAttribute("title", altText2);
8203
8308
  el.setAttribute("data-accessify-bg-alt", "auto");
8309
+ if (enabled) addInfoBadge(el, altText2);
8204
8310
  }
8205
8311
  async function generateBgAlts() {
8206
8312
  if (!aiService || !enabled) return;
@@ -8340,6 +8446,7 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8340
8446
  generateAll();
8341
8447
  generateBgAlts();
8342
8448
  applyTitlesToAllImages();
8449
+ addBadgesToAllImages();
8343
8450
  document.querySelectorAll("img").forEach((img) => {
8344
8451
  if (!img.complete) tryRegisterImage(img);
8345
8452
  });
@@ -8347,6 +8454,7 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8347
8454
  if (enabled) {
8348
8455
  document.querySelectorAll("img").forEach(tryRegisterImage);
8349
8456
  applyTitlesToAllImages();
8457
+ addBadgesToAllImages();
8350
8458
  }
8351
8459
  }, 2e3);
8352
8460
  domObserver = new MutationObserver((mutations) => {
@@ -8580,4 +8688,4 @@ export {
8580
8688
  init as i,
8581
8689
  t
8582
8690
  };
8583
- //# sourceMappingURL=index-C3jQHPAw.js.map
8691
+ //# sourceMappingURL=index-DxYL6cyB.js.map