adecksibility-widget 2.5.5 → 2.5.8
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.
- package/README.md +1 -1
- package/dist/adecksibility-widget-pro.umd.js +290 -183
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ Premium standalone accessibility widget bundle for WordPress and non-WordPress s
|
|
|
11
11
|
platform: "standalone"
|
|
12
12
|
};
|
|
13
13
|
</script>
|
|
14
|
-
<script src="https://cdn.jsdelivr.net/npm/adecksibility-widget@2.5.
|
|
14
|
+
<script src="https://cdn.jsdelivr.net/npm/adecksibility-widget@2.5.8/dist/adecksibility-widget-pro.umd.js" defer></script>
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
## Notes
|
|
@@ -883,8 +883,19 @@ var DEFAULT_STORAGE_KEYS = {
|
|
|
883
883
|
hiddenSession: 'adeck_hidden_session'
|
|
884
884
|
};
|
|
885
885
|
|
|
886
|
-
function buildStorageKeys(storageKeys) {
|
|
887
|
-
|
|
886
|
+
function buildStorageKeys(storageKeys, storageNamespace) {
|
|
887
|
+
var resolvedKeys = Object.assign({}, DEFAULT_STORAGE_KEYS, storageKeys || {});
|
|
888
|
+
var namespace = typeof storageNamespace === 'string' ? storageNamespace.trim() : '';
|
|
889
|
+
|
|
890
|
+
if (!namespace) {
|
|
891
|
+
return resolvedKeys;
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
Object.keys(resolvedKeys).forEach(function (key) {
|
|
895
|
+
resolvedKeys[key] = namespace + ':' + resolvedKeys[key];
|
|
896
|
+
});
|
|
897
|
+
|
|
898
|
+
return resolvedKeys;
|
|
888
899
|
}
|
|
889
900
|
|
|
890
901
|
function createStorageAdapter(storageArea) {
|
|
@@ -978,6 +989,11 @@ var ALLOWED_FEATURE_CLASSES;
|
|
|
978
989
|
var activeFeatures;
|
|
979
990
|
var editionMeta;
|
|
980
991
|
var featureFlags;
|
|
992
|
+
var darkModeEnhancementObserver;
|
|
993
|
+
var mediaObserver;
|
|
994
|
+
var hideImagesObserver;
|
|
995
|
+
var typographyObserver;
|
|
996
|
+
var typographyObserverTimeout;
|
|
981
997
|
|
|
982
998
|
function isFeatureEnabled(featureName) {
|
|
983
999
|
return !featureFlags || featureFlags[featureName] !== false;
|
|
@@ -986,7 +1002,7 @@ function isFeatureEnabled(featureName) {
|
|
|
986
1002
|
function init(options) {
|
|
987
1003
|
options = options || {};
|
|
988
1004
|
|
|
989
|
-
storageKeys = buildStorageKeys(options.storageKeys);
|
|
1005
|
+
storageKeys = buildStorageKeys(options.storageKeys, options.storageNamespace);
|
|
990
1006
|
storage = createStorageAdapter(options.storage || global.localStorage);
|
|
991
1007
|
sessionStore = createStorageAdapter(options.sessionStorage || global.sessionStorage);
|
|
992
1008
|
i18n = options.i18n || getDefaultMessages();
|
|
@@ -1056,7 +1072,48 @@ function init(options) {
|
|
|
1056
1072
|
DARK_MODE_HOVER_BG_IMAGE_ATTR = 'data-adeck-dark-hover-bg-image';
|
|
1057
1073
|
DARK_MODE_HOVER_BG_IMAGE_PRIORITY_ATTR = 'data-adeck-dark-hover-bg-image-priority';
|
|
1058
1074
|
HIDE_IMG_BG_CLASS = 'adeck-hide-bg-image';
|
|
1059
|
-
ALLOWED_FEATURE_CLASSES = Object.keys(classMap).map(function(key) { return classMap[key]; });
|
|
1075
|
+
ALLOWED_FEATURE_CLASSES = Object.keys(classMap).map(function(key) { return classMap[key]; });
|
|
1076
|
+
|
|
1077
|
+
function isDarkModeActive() {
|
|
1078
|
+
return document.documentElement.classList.contains(DARK_MODE_CLASS);
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
function ensureDarkModeEnhancementObserver() {
|
|
1082
|
+
if (darkModeEnhancementObserver || typeof MutationObserver === 'undefined' || !document.body) return;
|
|
1083
|
+
|
|
1084
|
+
darkModeEnhancementObserver = new MutationObserver(function(mutations) {
|
|
1085
|
+
if (!isDarkModeActive()) return;
|
|
1086
|
+
|
|
1087
|
+
for (var index = 0; index < mutations.length; index++) {
|
|
1088
|
+
var mutation = mutations[index];
|
|
1089
|
+
|
|
1090
|
+
if (mutation.type === 'childList') {
|
|
1091
|
+
mutation.addedNodes.forEach(function(node) {
|
|
1092
|
+
if (node.nodeType === 1) refreshDarkModeEnhancements(node);
|
|
1093
|
+
});
|
|
1094
|
+
continue;
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
if (mutation.target && mutation.target.nodeType === 1) {
|
|
1098
|
+
if (mutation.target.hasAttribute(DARK_MODE_AUTO_SURFACE_ATTR) || mutation.target.hasAttribute(DARK_MODE_AUTO_TEXT_ATTR)) continue;
|
|
1099
|
+
refreshDarkModeEnhancements(mutation.target);
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
});
|
|
1103
|
+
|
|
1104
|
+
darkModeEnhancementObserver.observe(document.body, {
|
|
1105
|
+
childList: true,
|
|
1106
|
+
subtree: true,
|
|
1107
|
+
attributes: true,
|
|
1108
|
+
attributeFilter: ['class', 'style']
|
|
1109
|
+
});
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
function disconnectDarkModeEnhancementObserver() {
|
|
1113
|
+
if (!darkModeEnhancementObserver) return;
|
|
1114
|
+
darkModeEnhancementObserver.disconnect();
|
|
1115
|
+
darkModeEnhancementObserver = null;
|
|
1116
|
+
}
|
|
1060
1117
|
/* ============================================================
|
|
1061
1118
|
Visual Filter Overlay
|
|
1062
1119
|
============================================================ */
|
|
@@ -1069,42 +1126,16 @@ function init(options) {
|
|
|
1069
1126
|
var wrapperEl = document.querySelector('.adeck-wrapper');
|
|
1070
1127
|
document.body.insertBefore(overlay, wrapperEl || null);
|
|
1071
1128
|
}
|
|
1072
|
-
injectFilterOverlay();
|
|
1073
|
-
registerVisualFilterTargets();
|
|
1074
|
-
window.addEventListener('load', registerVisualFilterTargets);
|
|
1075
|
-
window.addEventListener('load', function() {
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
if (!document.documentElement.classList.contains(DARK_MODE_CLASS)) return;
|
|
1083
|
-
|
|
1084
|
-
for (var index = 0; index < mutations.length; index++) {
|
|
1085
|
-
var mutation = mutations[index];
|
|
1086
|
-
|
|
1087
|
-
if (mutation.type === 'childList') {
|
|
1088
|
-
mutation.addedNodes.forEach(function(node) {
|
|
1089
|
-
if (node.nodeType === 1) refreshDarkModeEnhancements(node);
|
|
1090
|
-
});
|
|
1091
|
-
continue;
|
|
1092
|
-
}
|
|
1093
|
-
|
|
1094
|
-
if (mutation.target && mutation.target.nodeType === 1) {
|
|
1095
|
-
if (mutation.target.hasAttribute(DARK_MODE_AUTO_SURFACE_ATTR) || mutation.target.hasAttribute(DARK_MODE_AUTO_TEXT_ATTR)) continue;
|
|
1096
|
-
refreshDarkModeEnhancements(mutation.target);
|
|
1097
|
-
}
|
|
1098
|
-
}
|
|
1099
|
-
});
|
|
1100
|
-
|
|
1101
|
-
darkModeEnhancementObserver.observe(document.body, {
|
|
1102
|
-
childList: true,
|
|
1103
|
-
subtree: true,
|
|
1104
|
-
attributes: true,
|
|
1105
|
-
attributeFilter: ['class', 'style']
|
|
1106
|
-
});
|
|
1107
|
-
}
|
|
1129
|
+
injectFilterOverlay();
|
|
1130
|
+
registerVisualFilterTargets();
|
|
1131
|
+
window.addEventListener('load', registerVisualFilterTargets);
|
|
1132
|
+
window.addEventListener('load', function() {
|
|
1133
|
+
if (!isDarkModeActive()) return;
|
|
1134
|
+
rebuildDarkModeEnhancements();
|
|
1135
|
+
window.setTimeout(function() {
|
|
1136
|
+
if (isDarkModeActive()) rebuildDarkModeEnhancements();
|
|
1137
|
+
}, 250);
|
|
1138
|
+
});
|
|
1108
1139
|
|
|
1109
1140
|
activeFeatures = [];
|
|
1110
1141
|
try { activeFeatures = JSON.parse(storage.getItem(storageKeys.features)) || []; }
|
|
@@ -1230,55 +1261,79 @@ function init(options) {
|
|
|
1230
1261
|
if (d) d.textContent = fontScale + '%';
|
|
1231
1262
|
document.querySelectorAll(FONT_SELECTOR).forEach(function(el){ snapshotEl(el); scaleEl(el); });
|
|
1232
1263
|
}
|
|
1233
|
-
function resetFontScale() {
|
|
1234
|
-
fontScale = 100;
|
|
1235
|
-
var d = document.getElementById('adeck-font-val');
|
|
1236
|
-
if (d) d.textContent = '100%';
|
|
1237
|
-
document.querySelectorAll('[' + ORIG_ATTR + ']').forEach(function(el){
|
|
1238
|
-
el.style.removeProperty('font-size'); el.removeAttribute(ORIG_ATTR);
|
|
1239
|
-
});
|
|
1240
|
-
document.body.style.removeProperty('font-size');
|
|
1241
|
-
storage.removeItem(storageKeys.fontScale);
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
if (fontScale
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1264
|
+
function resetFontScale() {
|
|
1265
|
+
fontScale = 100;
|
|
1266
|
+
var d = document.getElementById('adeck-font-val');
|
|
1267
|
+
if (d) d.textContent = '100%';
|
|
1268
|
+
document.querySelectorAll('[' + ORIG_ATTR + ']').forEach(function(el){
|
|
1269
|
+
el.style.removeProperty('font-size'); el.removeAttribute(ORIG_ATTR);
|
|
1270
|
+
});
|
|
1271
|
+
document.body.style.removeProperty('font-size');
|
|
1272
|
+
storage.removeItem(storageKeys.fontScale);
|
|
1273
|
+
syncRuntimeObservers();
|
|
1274
|
+
}
|
|
1275
|
+
function saveAndApplyFont() {
|
|
1276
|
+
if (fontScale < 70) fontScale = 70;
|
|
1277
|
+
if (fontScale > 200) fontScale = 200;
|
|
1278
|
+
storage.setItem(storageKeys.fontScale, fontScale);
|
|
1279
|
+
applyFontScale();
|
|
1280
|
+
syncRuntimeObservers();
|
|
1281
|
+
announce(fontScale + '%');
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
function ensureMediaObserver() {
|
|
1285
|
+
if (mediaObserver || typeof MutationObserver === 'undefined' || !document.body) return;
|
|
1286
|
+
|
|
1287
|
+
mediaObserver = new MutationObserver(function(mutations) {
|
|
1288
|
+
if (!document.documentElement.classList.contains('adeck-mute-media')) return;
|
|
1289
|
+
mutations.forEach(function(m) {
|
|
1290
|
+
m.addedNodes.forEach(function(node) {
|
|
1291
|
+
if (node.nodeType !== 1 || (node.closest && node.closest('.adeck-wrapper'))) return;
|
|
1292
|
+
if (node.matches && node.matches('audio, video')) setMediaMutedState(node, true);
|
|
1293
|
+
if (node.querySelectorAll) {
|
|
1294
|
+
node.querySelectorAll('audio, video').forEach(function(mediaEl) {
|
|
1295
|
+
setMediaMutedState(mediaEl, true);
|
|
1296
|
+
});
|
|
1297
|
+
}
|
|
1298
|
+
});
|
|
1299
|
+
});
|
|
1300
|
+
});
|
|
1301
|
+
|
|
1302
|
+
mediaObserver.observe(document.body, { childList: true, subtree: true });
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
function disconnectMediaObserver() {
|
|
1306
|
+
if (!mediaObserver) return;
|
|
1307
|
+
mediaObserver.disconnect();
|
|
1308
|
+
mediaObserver = null;
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
function ensureHideImagesObserver() {
|
|
1312
|
+
if (hideImagesObserver || typeof MutationObserver === 'undefined' || !document.body) return;
|
|
1313
|
+
|
|
1314
|
+
hideImagesObserver = new MutationObserver(function(mutations) {
|
|
1315
|
+
if (!document.documentElement.classList.contains('adeck-hide-images')) return;
|
|
1316
|
+
mutations.forEach(function(m) {
|
|
1317
|
+
m.addedNodes.forEach(function(node) {
|
|
1318
|
+
if (node.nodeType !== 1 || (node.closest && node.closest('.adeck-wrapper'))) return;
|
|
1319
|
+
if (shouldTrackBackgroundImage(node)) node.classList.add(HIDE_IMG_BG_CLASS);
|
|
1320
|
+
if (node.querySelectorAll) {
|
|
1321
|
+
node.querySelectorAll('*').forEach(function(el) {
|
|
1322
|
+
if (shouldTrackBackgroundImage(el)) el.classList.add(HIDE_IMG_BG_CLASS);
|
|
1323
|
+
});
|
|
1324
|
+
}
|
|
1325
|
+
});
|
|
1326
|
+
});
|
|
1327
|
+
});
|
|
1328
|
+
|
|
1329
|
+
hideImagesObserver.observe(document.body, { childList: true, subtree: true });
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
function disconnectHideImagesObserver() {
|
|
1333
|
+
if (!hideImagesObserver) return;
|
|
1334
|
+
hideImagesObserver.disconnect();
|
|
1335
|
+
hideImagesObserver = null;
|
|
1336
|
+
}
|
|
1282
1337
|
|
|
1283
1338
|
/* ============================================================
|
|
1284
1339
|
LINE HEIGHT & TEXT SPACING SLIDER
|
|
@@ -1306,15 +1361,16 @@ function init(options) {
|
|
|
1306
1361
|
if (d) d.textContent = lhScale + '%';
|
|
1307
1362
|
document.querySelectorAll(LH_SELECTOR).forEach(function(el){ snapshotLhEl(el); scaleLhEl(el); });
|
|
1308
1363
|
}
|
|
1309
|
-
function resetLineHeight() {
|
|
1310
|
-
lhScale = 100;
|
|
1311
|
-
var d = document.getElementById('adeck-lh-val');
|
|
1312
|
-
if (d) d.textContent = '100%';
|
|
1313
|
-
document.querySelectorAll('[' + LH_ORIG_ATTR + ']').forEach(function(el){
|
|
1314
|
-
el.style.removeProperty('line-height'); el.removeAttribute(LH_ORIG_ATTR);
|
|
1315
|
-
});
|
|
1316
|
-
storage.removeItem(storageKeys.lineHeight);
|
|
1317
|
-
|
|
1364
|
+
function resetLineHeight() {
|
|
1365
|
+
lhScale = 100;
|
|
1366
|
+
var d = document.getElementById('adeck-lh-val');
|
|
1367
|
+
if (d) d.textContent = '100%';
|
|
1368
|
+
document.querySelectorAll('[' + LH_ORIG_ATTR + ']').forEach(function(el){
|
|
1369
|
+
el.style.removeProperty('line-height'); el.removeAttribute(LH_ORIG_ATTR);
|
|
1370
|
+
});
|
|
1371
|
+
storage.removeItem(storageKeys.lineHeight);
|
|
1372
|
+
syncRuntimeObservers();
|
|
1373
|
+
}
|
|
1318
1374
|
|
|
1319
1375
|
var TS_LS_ATTR = 'data-adeck-orig-ls', TS_WS_ATTR = 'data-adeck-orig-ws';
|
|
1320
1376
|
var TS_STEP = 10, TS_MIN = 100, TS_MAX = 200;
|
|
@@ -1344,23 +1400,24 @@ function init(options) {
|
|
|
1344
1400
|
if (d) d.textContent = tsScale + '%';
|
|
1345
1401
|
document.querySelectorAll(TS_SELECTOR).forEach(function(el){ snapshotTsEl(el); scaleTsEl(el); });
|
|
1346
1402
|
}
|
|
1347
|
-
function resetTextSpacing() {
|
|
1348
|
-
tsScale = 100;
|
|
1349
|
-
var d = document.getElementById('adeck-ts-val');
|
|
1350
|
-
if (d) d.textContent = '100%';
|
|
1351
|
-
document.querySelectorAll('[' + TS_LS_ATTR + ']').forEach(function(el){
|
|
1352
|
-
el.style.removeProperty('letter-spacing'); el.style.removeProperty('word-spacing');
|
|
1353
|
-
el.removeAttribute(TS_LS_ATTR); el.removeAttribute(TS_WS_ATTR);
|
|
1354
|
-
});
|
|
1355
|
-
storage.removeItem(storageKeys.textSpacing);
|
|
1356
|
-
|
|
1403
|
+
function resetTextSpacing() {
|
|
1404
|
+
tsScale = 100;
|
|
1405
|
+
var d = document.getElementById('adeck-ts-val');
|
|
1406
|
+
if (d) d.textContent = '100%';
|
|
1407
|
+
document.querySelectorAll('[' + TS_LS_ATTR + ']').forEach(function(el){
|
|
1408
|
+
el.style.removeProperty('letter-spacing'); el.style.removeProperty('word-spacing');
|
|
1409
|
+
el.removeAttribute(TS_LS_ATTR); el.removeAttribute(TS_WS_ATTR);
|
|
1410
|
+
});
|
|
1411
|
+
storage.removeItem(storageKeys.textSpacing);
|
|
1412
|
+
syncRuntimeObservers();
|
|
1413
|
+
}
|
|
1357
1414
|
|
|
1358
1415
|
function hasActiveTypographyAdjustments() {
|
|
1359
1416
|
return fontScale !== 100 || lhScale !== 100 || tsScale !== 100;
|
|
1360
1417
|
}
|
|
1361
1418
|
|
|
1362
|
-
function applyTypographyToSubtree(root) {
|
|
1363
|
-
if (!root || root.nodeType !== 1 || (root.closest && root.closest('.adeck-wrapper'))) return;
|
|
1419
|
+
function applyTypographyToSubtree(root) {
|
|
1420
|
+
if (!root || root.nodeType !== 1 || (root.closest && root.closest('.adeck-wrapper'))) return;
|
|
1364
1421
|
|
|
1365
1422
|
if (fontScale !== 100) {
|
|
1366
1423
|
if (root.matches && root.matches(FONT_SELECTOR)) { snapshotEl(root); scaleEl(root); }
|
|
@@ -1372,26 +1429,51 @@ function init(options) {
|
|
|
1372
1429
|
if (root.querySelectorAll) root.querySelectorAll(LH_SELECTOR).forEach(function(el){ snapshotLhEl(el); scaleLhEl(el); });
|
|
1373
1430
|
}
|
|
1374
1431
|
|
|
1375
|
-
if (tsScale !== 100) {
|
|
1376
|
-
if (root.matches && root.matches(TS_SELECTOR)) { snapshotTsEl(root); scaleTsEl(root); }
|
|
1377
|
-
if (root.querySelectorAll) root.querySelectorAll(TS_SELECTOR).forEach(function(el){ snapshotTsEl(el); scaleTsEl(el); });
|
|
1378
|
-
}
|
|
1379
|
-
}
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1432
|
+
if (tsScale !== 100) {
|
|
1433
|
+
if (root.matches && root.matches(TS_SELECTOR)) { snapshotTsEl(root); scaleTsEl(root); }
|
|
1434
|
+
if (root.querySelectorAll) root.querySelectorAll(TS_SELECTOR).forEach(function(el){ snapshotTsEl(el); scaleTsEl(el); });
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
function ensureTypographyObserver() {
|
|
1439
|
+
if (typographyObserver || typeof MutationObserver === 'undefined' || !document.body) return;
|
|
1440
|
+
|
|
1441
|
+
typographyObserver = new MutationObserver(function(mutations) {
|
|
1442
|
+
if (!hasActiveTypographyAdjustments()) return;
|
|
1443
|
+
clearTimeout(typographyObserverTimeout);
|
|
1444
|
+
typographyObserverTimeout = setTimeout(function() {
|
|
1445
|
+
mutations.forEach(function(m) {
|
|
1446
|
+
m.addedNodes.forEach(function(node) {
|
|
1447
|
+
applyTypographyToSubtree(node);
|
|
1448
|
+
});
|
|
1449
|
+
});
|
|
1450
|
+
}, 250);
|
|
1451
|
+
});
|
|
1452
|
+
|
|
1453
|
+
typographyObserver.observe(document.body, { childList: true, subtree: true });
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
function disconnectTypographyObserver() {
|
|
1457
|
+
if (!typographyObserver) return;
|
|
1458
|
+
typographyObserver.disconnect();
|
|
1459
|
+
typographyObserver = null;
|
|
1460
|
+
clearTimeout(typographyObserverTimeout);
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1463
|
+
function syncRuntimeObservers() {
|
|
1464
|
+
if (isDarkModeActive()) ensureDarkModeEnhancementObserver();
|
|
1465
|
+
else disconnectDarkModeEnhancementObserver();
|
|
1466
|
+
|
|
1467
|
+
if (document.documentElement.classList.contains('adeck-mute-media')) ensureMediaObserver();
|
|
1468
|
+
else disconnectMediaObserver();
|
|
1469
|
+
|
|
1470
|
+
if (document.documentElement.classList.contains('adeck-hide-images')) ensureHideImagesObserver();
|
|
1471
|
+
else disconnectHideImagesObserver();
|
|
1472
|
+
|
|
1473
|
+
if (hasActiveTypographyAdjustments()) ensureTypographyObserver();
|
|
1474
|
+
else disconnectTypographyObserver();
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1395
1477
|
/* ============================================================
|
|
1396
1478
|
Utilities and Reset State
|
|
1397
1479
|
============================================================ */
|
|
@@ -1504,13 +1586,14 @@ function init(options) {
|
|
|
1504
1586
|
});
|
|
1505
1587
|
}
|
|
1506
1588
|
|
|
1507
|
-
function clearPersistedFeatureState() {
|
|
1508
|
-
activeFeatures.forEach(function(cls){ document.documentElement.classList.remove(cls); });
|
|
1509
|
-
activeFeatures = [];
|
|
1510
|
-
storage.removeItem(storageKeys.features);
|
|
1511
|
-
setDarkModeState(false, { clearTheme: true, skipTransition: true });
|
|
1512
|
-
clearActiveFeatureButtons();
|
|
1513
|
-
|
|
1589
|
+
function clearPersistedFeatureState() {
|
|
1590
|
+
activeFeatures.forEach(function(cls){ document.documentElement.classList.remove(cls); });
|
|
1591
|
+
activeFeatures = [];
|
|
1592
|
+
storage.removeItem(storageKeys.features);
|
|
1593
|
+
setDarkModeState(false, { clearTheme: true, skipTransition: true });
|
|
1594
|
+
clearActiveFeatureButtons();
|
|
1595
|
+
syncRuntimeObservers();
|
|
1596
|
+
}
|
|
1514
1597
|
|
|
1515
1598
|
function resetFeatureAdjustments() {
|
|
1516
1599
|
resetFontScale();
|
|
@@ -1592,11 +1675,12 @@ function init(options) {
|
|
|
1592
1675
|
if (preset.fontScale !== null) { fontScale = preset.fontScale; storage.setItem(storageKeys.fontScale, fontScale); applyFontScale(); }
|
|
1593
1676
|
if (isFeatureEnabled('lineHeight') && preset.lhScale !== null) { lhScale = preset.lhScale; storage.setItem(storageKeys.lineHeight, lhScale); applyLineHeight(); }
|
|
1594
1677
|
if (isFeatureEnabled('textSpacing') && preset.tsScale !== null) { tsScale = preset.tsScale; storage.setItem(storageKeys.textSpacing, tsScale); applyTextSpacing(); }
|
|
1595
|
-
|
|
1596
|
-
saveActiveFeatures();
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1678
|
+
|
|
1679
|
+
saveActiveFeatures();
|
|
1680
|
+
syncRuntimeObservers();
|
|
1681
|
+
syncHideImagesState();
|
|
1682
|
+
updateDynamicLabels();
|
|
1683
|
+
}
|
|
1600
1684
|
|
|
1601
1685
|
function setActiveProfile(profileKey) {
|
|
1602
1686
|
activeProfile = profileKey;
|
|
@@ -1719,30 +1803,34 @@ function init(options) {
|
|
|
1719
1803
|
if (!isTicking) { window.requestAnimationFrame(function(){ updateGuide(e.touches[0].clientY); isTicking=false; }); isTicking=true; }
|
|
1720
1804
|
}, {passive:true});
|
|
1721
1805
|
|
|
1722
|
-
document.addEventListener('mouseover', function(e) {
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
if (!
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1806
|
+
document.addEventListener('mouseover', function(e) {
|
|
1807
|
+
if (!isDarkModeActive()) return;
|
|
1808
|
+
var candidate = getDarkHoverSurfaceCandidate(e.target);
|
|
1809
|
+
if (!candidate) return;
|
|
1810
|
+
syncDarkHoverSurface(candidate);
|
|
1811
|
+
}, true);
|
|
1812
|
+
|
|
1813
|
+
document.addEventListener('mouseout', function(e) {
|
|
1814
|
+
if (!isDarkModeActive()) return;
|
|
1815
|
+
var candidate = getDarkHoverSurfaceCandidate(e.target);
|
|
1816
|
+
if (!candidate) return;
|
|
1817
|
+
if (e.relatedTarget && candidate.contains(e.relatedTarget)) return;
|
|
1818
|
+
unlockDarkHoverSurface(candidate);
|
|
1819
|
+
}, true);
|
|
1820
|
+
|
|
1821
|
+
document.addEventListener('focusin', function(e) {
|
|
1822
|
+
if (!isDarkModeActive()) return;
|
|
1823
|
+
var candidate = getDarkHoverSurfaceCandidate(e.target);
|
|
1824
|
+
if (!candidate) return;
|
|
1825
|
+
syncDarkHoverSurface(candidate);
|
|
1826
|
+
});
|
|
1827
|
+
|
|
1828
|
+
document.addEventListener('focusout', function(e) {
|
|
1829
|
+
if (!isDarkModeActive()) return;
|
|
1830
|
+
var candidate = getDarkHoverSurfaceCandidate(e.target);
|
|
1831
|
+
if (!candidate) return;
|
|
1832
|
+
if (e.relatedTarget && candidate.contains(e.relatedTarget)) return;
|
|
1833
|
+
unlockDarkHoverSurface(candidate);
|
|
1746
1834
|
});
|
|
1747
1835
|
|
|
1748
1836
|
/* ============================================================
|
|
@@ -1947,10 +2035,12 @@ function init(options) {
|
|
|
1947
2035
|
/* ============================================================
|
|
1948
2036
|
Restore Saved State
|
|
1949
2037
|
============================================================ */
|
|
1950
|
-
activeFeatures.forEach(function(cls){ setFeatureVisualState(cls, true); });
|
|
1951
|
-
setDarkModeState(getStoredTheme() === 'dark', { skipTransition: true });
|
|
1952
|
-
|
|
1953
|
-
applyLanguage(currentLang); updateDynamicLabels();
|
|
2038
|
+
activeFeatures.forEach(function(cls){ setFeatureVisualState(cls, true); });
|
|
2039
|
+
setDarkModeState(getStoredTheme() === 'dark', { skipTransition: true });
|
|
2040
|
+
syncRuntimeObservers();
|
|
2041
|
+
applyLanguage(currentLang); updateDynamicLabels(); checkHideStatus();
|
|
2042
|
+
if (document.documentElement.classList.contains('adeck-hide-images')) syncHideImagesState();
|
|
2043
|
+
if (document.documentElement.classList.contains('adeck-mute-media')) toggleMuteMedia();
|
|
1954
2044
|
|
|
1955
2045
|
if (fontScale !== 100) applyFontScale(); else { var df2 = document.getElementById('adeck-font-val'); if (df2) df2.textContent = '100%'; }
|
|
1956
2046
|
if (lhScale !== 100) applyLineHeight(); else { var dl2 = document.getElementById('adeck-lh-val'); if (dl2) dl2.textContent = '100%'; }
|
|
@@ -2047,13 +2137,14 @@ function init(options) {
|
|
|
2047
2137
|
setFeatureVisualState(cls, isNow);
|
|
2048
2138
|
}
|
|
2049
2139
|
|
|
2050
|
-
if (!isNow && cls === 'adeck-read-aloud') {
|
|
2051
|
-
window.speechSynthesis.cancel();
|
|
2052
|
-
cleanHighlights();
|
|
2053
|
-
}
|
|
2054
|
-
|
|
2055
|
-
saveActiveFeatures();
|
|
2056
|
-
|
|
2140
|
+
if (!isNow && cls === 'adeck-read-aloud') {
|
|
2141
|
+
window.speechSynthesis.cancel();
|
|
2142
|
+
cleanHighlights();
|
|
2143
|
+
}
|
|
2144
|
+
|
|
2145
|
+
saveActiveFeatures();
|
|
2146
|
+
syncRuntimeObservers();
|
|
2147
|
+
updateDynamicLabels();
|
|
2057
2148
|
|
|
2058
2149
|
var fname = (i18n[currentLang] && i18n[currentLang][labelKeys[btn.id]]) || btn.id;
|
|
2059
2150
|
var statusText = (isNow ? (i18n[currentLang]['status_enable'] || 'Enabled') : (i18n[currentLang]['status_disable'] || 'Disabled')) + ': ' + fname;
|
|
@@ -2119,10 +2210,10 @@ function init(options) {
|
|
|
2119
2210
|
|
|
2120
2211
|
if (e.target.closest('#adeck-font-plus')) { fontScale += 10; saveAndApplyFont(); return; }
|
|
2121
2212
|
if (e.target.closest('#adeck-font-min')) { fontScale -= 10; saveAndApplyFont(); return; }
|
|
2122
|
-
if (isFeatureEnabled('lineHeight') && e.target.closest('#adeck-lh-plus')) { lhScale = Math.min(LH_MAX, lhScale + LH_STEP); storage.setItem(storageKeys.lineHeight, lhScale); applyLineHeight(); announce(lhScale+'%'); return; }
|
|
2123
|
-
if (isFeatureEnabled('lineHeight') && e.target.closest('#adeck-lh-min')) { lhScale = Math.max(LH_MIN, lhScale - LH_STEP); if (lhScale === LH_MIN) resetLineHeight(); else { storage.setItem(storageKeys.lineHeight, lhScale); applyLineHeight(); announce(lhScale+'%'); } return; }
|
|
2124
|
-
if (isFeatureEnabled('textSpacing') && e.target.closest('#adeck-ts-plus')) { tsScale = Math.min(TS_MAX, tsScale + TS_STEP); storage.setItem(storageKeys.textSpacing, tsScale); applyTextSpacing(); announce(tsScale+'%'); return; }
|
|
2125
|
-
if (isFeatureEnabled('textSpacing') && e.target.closest('#adeck-ts-min')) { tsScale = Math.max(TS_MIN, tsScale - TS_STEP); if (tsScale === TS_MIN) resetTextSpacing(); else { storage.setItem(storageKeys.textSpacing, tsScale); applyTextSpacing(); announce(tsScale+'%'); } return; }
|
|
2213
|
+
if (isFeatureEnabled('lineHeight') && e.target.closest('#adeck-lh-plus')) { lhScale = Math.min(LH_MAX, lhScale + LH_STEP); storage.setItem(storageKeys.lineHeight, lhScale); applyLineHeight(); syncRuntimeObservers(); announce(lhScale+'%'); return; }
|
|
2214
|
+
if (isFeatureEnabled('lineHeight') && e.target.closest('#adeck-lh-min')) { lhScale = Math.max(LH_MIN, lhScale - LH_STEP); if (lhScale === LH_MIN) resetLineHeight(); else { storage.setItem(storageKeys.lineHeight, lhScale); applyLineHeight(); syncRuntimeObservers(); announce(lhScale+'%'); } return; }
|
|
2215
|
+
if (isFeatureEnabled('textSpacing') && e.target.closest('#adeck-ts-plus')) { tsScale = Math.min(TS_MAX, tsScale + TS_STEP); storage.setItem(storageKeys.textSpacing, tsScale); applyTextSpacing(); syncRuntimeObservers(); announce(tsScale+'%'); return; }
|
|
2216
|
+
if (isFeatureEnabled('textSpacing') && e.target.closest('#adeck-ts-min')) { tsScale = Math.max(TS_MIN, tsScale - TS_STEP); if (tsScale === TS_MIN) resetTextSpacing(); else { storage.setItem(storageKeys.textSpacing, tsScale); applyTextSpacing(); syncRuntimeObservers(); announce(tsScale+'%'); } return; }
|
|
2126
2217
|
if (e.target.closest('#adeck-reset-typography')) { resetTypographyControls(); return; }
|
|
2127
2218
|
|
|
2128
2219
|
if (e.target.closest('#btn-reset')) { handleResetButton(); return; }
|
|
@@ -2537,7 +2628,21 @@ global.ADecksibility.initWhenReady = initWhenReady;
|
|
|
2537
2628
|
}
|
|
2538
2629
|
|
|
2539
2630
|
if (!merged.storageNamespace || merged.storageNamespace === DEFAULT_CONFIG.storageNamespace) {
|
|
2540
|
-
|
|
2631
|
+
var namespaceSeed = '';
|
|
2632
|
+
|
|
2633
|
+
if (typeof merged.host === 'string' && merged.host && merged.host !== 'standalone' && merged.host !== 'generic') {
|
|
2634
|
+
namespaceSeed = merged.host;
|
|
2635
|
+
} else if (merged.tenant && typeof merged.tenant.slug === 'string' && merged.tenant.slug && merged.tenant.slug !== 'default') {
|
|
2636
|
+
namespaceSeed = merged.tenant.slug;
|
|
2637
|
+
} else if (merged.tenant && typeof merged.tenant.id === 'string' && merged.tenant.id && merged.tenant.id !== 'default') {
|
|
2638
|
+
namespaceSeed = merged.tenant.id;
|
|
2639
|
+
} else if (global.location && global.location.host) {
|
|
2640
|
+
namespaceSeed = global.location.host;
|
|
2641
|
+
} else {
|
|
2642
|
+
namespaceSeed = 'default';
|
|
2643
|
+
}
|
|
2644
|
+
|
|
2645
|
+
merged.storageNamespace = 'adecksibility:' + String(namespaceSeed).toLowerCase();
|
|
2541
2646
|
}
|
|
2542
2647
|
|
|
2543
2648
|
if (typeof merged.statementHtml === 'string' && merged.statementHtml.trim()) {
|
|
@@ -2662,9 +2767,11 @@ global.ADecksibility.initWhenReady = initWhenReady;
|
|
|
2662
2767
|
|
|
2663
2768
|
function ensureDarkModeBootstrap(config) {
|
|
2664
2769
|
var themeStorageKey = ((config.storageKeys || {}).theme) || 'adeck_theme';
|
|
2770
|
+
var storageNamespace = (config && typeof config.storageNamespace === 'string') ? config.storageNamespace.trim() : '';
|
|
2771
|
+
var resolvedThemeStorageKey = storageNamespace ? (storageNamespace + ':' + themeStorageKey) : themeStorageKey;
|
|
2665
2772
|
var script = document.getElementById('adeck-dark-mode-bootstrap');
|
|
2666
2773
|
var contents = "(function(){try{var storedTheme=window.localStorage.getItem(" +
|
|
2667
|
-
JSON.stringify(
|
|
2774
|
+
JSON.stringify(resolvedThemeStorageKey) +
|
|
2668
2775
|
");if(storedTheme==='dark'){document.documentElement.setAttribute('data-adeck-theme','dark');document.documentElement.classList.add('adeck-dark-mode','adeck-dark-mode-preload');}}catch(error){}}());";
|
|
2669
2776
|
|
|
2670
2777
|
if (!script) {
|
package/package.json
CHANGED