accessify-widget 0.3.10 → 0.3.11

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-DxYL6cyB.js";
1
+ import { d, i } from "./index-CK-JGSFG.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-DFuKOs8i.js"),
6436
+ "keyboard-nav": () => import("./keyboard-nav-BK_UYLtc.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-2bsTmvsF.js"),
6443
+ "page-structure": () => import("./page-structure-C7f5kvRE.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)
@@ -8164,10 +8164,25 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8164
8164
  }
8165
8165
  const BADGE_ATTR = "data-accessify-badge";
8166
8166
  function addInfoBadge(target, altText2) {
8167
- target.tagName === "IMG";
8168
- const rect = target.getBoundingClientRect();
8169
- if (rect.width < 40 || rect.height < 40) return;
8170
8167
  if (target.getAttribute(BADGE_ATTR)) return;
8168
+ const rect = target.getBoundingClientRect();
8169
+ if (rect.width < 40 || rect.height < 40) {
8170
+ if (target.tagName === "IMG") {
8171
+ const obs = new IntersectionObserver((entries) => {
8172
+ for (const entry of entries) {
8173
+ if (entry.isIntersecting && entry.boundingClientRect.width >= 40) {
8174
+ obs.disconnect();
8175
+ if (enabled && !target.getAttribute(BADGE_ATTR)) {
8176
+ addInfoBadge(target, altText2);
8177
+ }
8178
+ }
8179
+ }
8180
+ });
8181
+ obs.observe(target);
8182
+ setTimeout(() => obs.disconnect(), 3e4);
8183
+ }
8184
+ return;
8185
+ }
8171
8186
  target.setAttribute(BADGE_ATTR, "1");
8172
8187
  const container = document.createElement("div");
8173
8188
  Object.assign(container.style, {
@@ -8418,9 +8433,12 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8418
8433
  generateSingle(img);
8419
8434
  } else {
8420
8435
  const alt = img.getAttribute("alt");
8421
- if (alt && alt.trim() && !img.getAttribute("title")) {
8422
- img.setAttribute("title", alt);
8423
- img.setAttribute("data-accessify-title", "auto");
8436
+ if (alt && alt.trim()) {
8437
+ if (!img.getAttribute("title")) {
8438
+ img.setAttribute("title", alt);
8439
+ img.setAttribute("data-accessify-title", "auto");
8440
+ }
8441
+ addInfoBadge(img, alt.trim());
8424
8442
  }
8425
8443
  }
8426
8444
  }
@@ -8450,13 +8468,15 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
8450
8468
  document.querySelectorAll("img").forEach((img) => {
8451
8469
  if (!img.complete) tryRegisterImage(img);
8452
8470
  });
8453
- setTimeout(() => {
8454
- if (enabled) {
8455
- document.querySelectorAll("img").forEach(tryRegisterImage);
8456
- applyTitlesToAllImages();
8457
- addBadgesToAllImages();
8458
- }
8459
- }, 2e3);
8471
+ for (const delay of [2e3, 5e3, 1e4]) {
8472
+ setTimeout(() => {
8473
+ if (enabled) {
8474
+ document.querySelectorAll("img").forEach(tryRegisterImage);
8475
+ applyTitlesToAllImages();
8476
+ addBadgesToAllImages();
8477
+ }
8478
+ }, delay);
8479
+ }
8460
8480
  domObserver = new MutationObserver((mutations) => {
8461
8481
  for (const m of mutations) {
8462
8482
  for (const node of m.addedNodes) {
@@ -8688,4 +8708,4 @@ export {
8688
8708
  init as i,
8689
8709
  t
8690
8710
  };
8691
- //# sourceMappingURL=index-DxYL6cyB.js.map
8711
+ //# sourceMappingURL=index-CK-JGSFG.js.map