accessify-widget 0.3.7 → 0.3.9

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-C_cEJXg7.js";
1
+ import { d, i } from "./index-DabFemHm.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-BN8NOhTx.js"),
6436
+ "keyboard-nav": () => import("./keyboard-nav-BAnuU08t.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-CK_agCbv.js"),
6443
+ "page-structure": () => import("./page-structure-DjY63saM.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,96 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8161
8162
  }
8162
8163
  });
8163
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
+ }
8216
+ 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;
8224
+ badge.textContent = "i";
8225
+ badge.setAttribute("aria-hidden", "true");
8226
+ const tooltip = document.createElement("span");
8227
+ tooltip.className = INFO_TOOLTIP_CLASS;
8228
+ tooltip.textContent = altText2;
8229
+ parent.appendChild(badge);
8230
+ parent.appendChild(tooltip);
8231
+ }
8232
+ 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
+ }
8238
+ }
8239
+ function addBadgesToAllImages() {
8240
+ injectBadgeStyles();
8241
+ document.querySelectorAll("img").forEach((img) => {
8242
+ if (!isValidImage(img)) return;
8243
+ const alt = img.getAttribute("alt") || img.getAttribute("title");
8244
+ if (alt && alt.trim()) {
8245
+ addInfoBadge(img, alt.trim());
8246
+ }
8247
+ });
8248
+ document.querySelectorAll("[data-accessify-bg-alt]").forEach((el) => {
8249
+ const alt = el.getAttribute("aria-label");
8250
+ if (alt && alt.trim()) {
8251
+ addInfoBadge(el, alt.trim());
8252
+ }
8253
+ });
8254
+ }
8164
8255
  function removeTitles() {
8165
8256
  document.querySelectorAll('img[data-accessify-title="auto"]').forEach((img) => {
8166
8257
  img.removeAttribute("title");
@@ -8172,22 +8263,21 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8172
8263
  el.removeAttribute("title");
8173
8264
  el.removeAttribute("data-accessify-bg-alt");
8174
8265
  });
8266
+ removeAllBadges();
8175
8267
  }
8176
8268
  function scanForBackgroundImages() {
8177
8269
  const found = [];
8178
- const candidates = document.querySelectorAll(
8179
- 'header, [class*="hero"], [class*="banner"], [class*="header"], [class*="bg-"], [class*="background"], [style*="background"]'
8180
- );
8181
- for (const el of candidates) {
8270
+ const allElements = document.querySelectorAll("*");
8271
+ for (const el of allElements) {
8182
8272
  if (el.closest("#accessify-root") || el.closest("accessify-widget")) continue;
8183
8273
  if (el.getAttribute("data-accessify-bg-alt")) continue;
8274
+ if (el.offsetWidth < 200 || el.offsetHeight < 150) continue;
8184
8275
  const style = getComputedStyle(el);
8185
8276
  const bg = style.backgroundImage;
8186
8277
  if (!bg || bg === "none") continue;
8187
8278
  const urlMatch = bg.match(/url\(["']?([^"')]+)["']?\)/);
8188
8279
  if (!urlMatch) continue;
8189
- const rect = el.getBoundingClientRect();
8190
- if (rect.width < 100 || rect.height < 100) continue;
8280
+ if (urlMatch[1].startsWith("data:image/svg")) continue;
8191
8281
  if (el.getAttribute("role") === "img" && el.getAttribute("aria-label")) continue;
8192
8282
  found.push(el);
8193
8283
  }
@@ -8203,6 +8293,7 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8203
8293
  el.setAttribute("aria-label", altText2);
8204
8294
  el.setAttribute("title", altText2);
8205
8295
  el.setAttribute("data-accessify-bg-alt", "auto");
8296
+ if (enabled) addInfoBadge(el, altText2);
8206
8297
  }
8207
8298
  async function generateBgAlts() {
8208
8299
  if (!aiService || !enabled) return;
@@ -8342,6 +8433,7 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8342
8433
  generateAll();
8343
8434
  generateBgAlts();
8344
8435
  applyTitlesToAllImages();
8436
+ addBadgesToAllImages();
8345
8437
  document.querySelectorAll("img").forEach((img) => {
8346
8438
  if (!img.complete) tryRegisterImage(img);
8347
8439
  });
@@ -8349,6 +8441,7 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8349
8441
  if (enabled) {
8350
8442
  document.querySelectorAll("img").forEach(tryRegisterImage);
8351
8443
  applyTitlesToAllImages();
8444
+ addBadgesToAllImages();
8352
8445
  }
8353
8446
  }, 2e3);
8354
8447
  domObserver = new MutationObserver((mutations) => {
@@ -8582,4 +8675,4 @@ export {
8582
8675
  init as i,
8583
8676
  t
8584
8677
  };
8585
- //# sourceMappingURL=index-C_cEJXg7.js.map
8678
+ //# sourceMappingURL=index-DabFemHm.js.map