ufc-itapaje-accessibility 1.0.0
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/dist/index.d.mts +442 -0
- package/dist/index.d.ts +442 -0
- package/dist/index.global.js +2472 -0
- package/dist/index.global.js.map +1 -0
- package/dist/index.js +1939 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1916 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +40 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,1916 @@
|
|
|
1
|
+
// src/main.ts
|
|
2
|
+
import "regenerator-runtime/runtime.js";
|
|
3
|
+
|
|
4
|
+
// src/common.ts
|
|
5
|
+
var _Common = class _Common {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.body = document.body || document.querySelector("body");
|
|
8
|
+
this.deployedMap = /* @__PURE__ */ new Map();
|
|
9
|
+
}
|
|
10
|
+
isIOS() {
|
|
11
|
+
if (typeof this._isIOS === "boolean") return this._isIOS;
|
|
12
|
+
const devices = ["iPad Simulator", "iPhone Simulator", "iPod Simulator", "iPad", "iPhone", "iPod"];
|
|
13
|
+
this._isIOS = !!navigator.platform && devices.some((d) => navigator.platform === d);
|
|
14
|
+
return this._isIOS;
|
|
15
|
+
}
|
|
16
|
+
jsonToHtml(obj) {
|
|
17
|
+
var _a, _b, _c;
|
|
18
|
+
let elm = document.createElement(obj.type);
|
|
19
|
+
for (let i in obj.attrs) {
|
|
20
|
+
elm.setAttribute(i, obj.attrs[i]);
|
|
21
|
+
}
|
|
22
|
+
for (const child of (_a = obj.children) != null ? _a : []) {
|
|
23
|
+
let newElem = null;
|
|
24
|
+
if (child.type === "#text") {
|
|
25
|
+
newElem = document.createTextNode((_b = child.text) != null ? _b : "");
|
|
26
|
+
} else {
|
|
27
|
+
newElem = this.jsonToHtml(child);
|
|
28
|
+
}
|
|
29
|
+
if (((_c = newElem == null ? void 0 : newElem.tagName) == null ? void 0 : _c.toLowerCase()) !== "undefined" || newElem.nodeType === 3)
|
|
30
|
+
elm.appendChild(newElem);
|
|
31
|
+
}
|
|
32
|
+
return elm;
|
|
33
|
+
}
|
|
34
|
+
injectStyle(css, innerOptions = {}) {
|
|
35
|
+
let sheet = document.createElement("style");
|
|
36
|
+
sheet.appendChild(document.createTextNode(css));
|
|
37
|
+
if (innerOptions.className) sheet.classList.add(innerOptions.className);
|
|
38
|
+
this.body.appendChild(sheet);
|
|
39
|
+
return sheet;
|
|
40
|
+
}
|
|
41
|
+
getFormattedDim(value) {
|
|
42
|
+
if (!value) return null;
|
|
43
|
+
value = String(value);
|
|
44
|
+
const by = (val, suffix) => ({
|
|
45
|
+
size: val.substring(0, val.indexOf(suffix)),
|
|
46
|
+
suffix
|
|
47
|
+
});
|
|
48
|
+
if (value.includes("%")) return by(value, "%");
|
|
49
|
+
if (value.includes("rem")) return by(value, "rem");
|
|
50
|
+
if (value.includes("px")) return by(value, "px");
|
|
51
|
+
if (value.includes("em")) return by(value, "em");
|
|
52
|
+
if (value.includes("pt")) return by(value, "pt");
|
|
53
|
+
if (value === "auto") return by(value, "");
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
extend(src, dest) {
|
|
57
|
+
for (let i in src) {
|
|
58
|
+
if (typeof src[i] === "object") {
|
|
59
|
+
if (dest && dest[i]) {
|
|
60
|
+
if (dest[i] instanceof Array) src[i] = dest[i];
|
|
61
|
+
else src[i] = this.extend(src[i], dest[i]);
|
|
62
|
+
}
|
|
63
|
+
} else if (typeof dest === "object" && typeof dest[i] !== "undefined") {
|
|
64
|
+
src[i] = dest[i];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return src;
|
|
68
|
+
}
|
|
69
|
+
injectIconsFont(urls, callback) {
|
|
70
|
+
if (!(urls == null ? void 0 : urls.length)) return;
|
|
71
|
+
let head = document.getElementsByTagName("head")[0];
|
|
72
|
+
let counter = 0;
|
|
73
|
+
let hasErrors = false;
|
|
74
|
+
let onload = (e) => {
|
|
75
|
+
if (typeof e === "string" || e.type === "error") hasErrors = true;
|
|
76
|
+
if (!--counter) callback(hasErrors);
|
|
77
|
+
};
|
|
78
|
+
urls.forEach((url) => {
|
|
79
|
+
let link = document.createElement("link");
|
|
80
|
+
link.type = "text/css";
|
|
81
|
+
link.rel = "stylesheet";
|
|
82
|
+
link.href = url;
|
|
83
|
+
link.className = `_access-font-icon-${counter++}`;
|
|
84
|
+
link.onload = onload;
|
|
85
|
+
link.onerror = onload;
|
|
86
|
+
this.deployedObjects.set("." + link.className, true);
|
|
87
|
+
head.appendChild(link);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
getFixedFont(name) {
|
|
91
|
+
if (this.isIOS()) return name.replaceAll(" ", "+");
|
|
92
|
+
return name;
|
|
93
|
+
}
|
|
94
|
+
getFixedPseudoFont(name) {
|
|
95
|
+
if (this.isIOS()) return name.replaceAll("+", " ");
|
|
96
|
+
return name;
|
|
97
|
+
}
|
|
98
|
+
isFontLoaded(fontFamily, callback) {
|
|
99
|
+
try {
|
|
100
|
+
const onReady = () => callback(document.fonts.check(`1em ${fontFamily.replaceAll("+", " ")}`));
|
|
101
|
+
document.fonts.ready.then(onReady, onReady);
|
|
102
|
+
} catch (e) {
|
|
103
|
+
callback(true);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
warn(msg) {
|
|
107
|
+
const prefix = "AccessibilityWidget: ";
|
|
108
|
+
(console.warn || console.log)(prefix + msg);
|
|
109
|
+
}
|
|
110
|
+
get deployedObjects() {
|
|
111
|
+
return {
|
|
112
|
+
get: (key) => this.deployedMap.get(key),
|
|
113
|
+
contains: (key) => this.deployedMap.has(key),
|
|
114
|
+
set: (key, val) => {
|
|
115
|
+
this.deployedMap.set(key, val);
|
|
116
|
+
},
|
|
117
|
+
remove: (key) => {
|
|
118
|
+
this.deployedMap.delete(key);
|
|
119
|
+
},
|
|
120
|
+
getAll: () => this.deployedMap
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
createScreenshot(url) {
|
|
124
|
+
return new Promise((resolve) => {
|
|
125
|
+
if (!this._canvas) this._canvas = document.createElement("canvas");
|
|
126
|
+
const img = new Image();
|
|
127
|
+
this._canvas.style.cssText = "position:fixed;top:0;left:0;opacity:0.05;transform:scale(0.05)";
|
|
128
|
+
img.crossOrigin = "anonymous";
|
|
129
|
+
img.onload = () => {
|
|
130
|
+
document.body.appendChild(this._canvas);
|
|
131
|
+
const ctx = this._canvas.getContext("2d");
|
|
132
|
+
this._canvas.width = img.naturalWidth;
|
|
133
|
+
this._canvas.height = img.naturalHeight;
|
|
134
|
+
ctx.clearRect(0, 0, this._canvas.width, this._canvas.height);
|
|
135
|
+
ctx.drawImage(img, 0, 0);
|
|
136
|
+
let res = _Common.DEFAULT_PIXEL;
|
|
137
|
+
try {
|
|
138
|
+
res = this._canvas.toDataURL("image/png");
|
|
139
|
+
} catch (e) {
|
|
140
|
+
}
|
|
141
|
+
resolve(res);
|
|
142
|
+
this._canvas.remove();
|
|
143
|
+
};
|
|
144
|
+
img.onerror = () => resolve(_Common.DEFAULT_PIXEL);
|
|
145
|
+
img.src = url;
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
getFileExtension(filename) {
|
|
149
|
+
return filename.substring(filename.lastIndexOf(".") + 1) || filename;
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
_Common.DEFAULT_PIXEL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAA1JREFUGFdj+P///38ACfsD/QVDRcoAAAAASUVORK5CYII=";
|
|
153
|
+
var Common = _Common;
|
|
154
|
+
|
|
155
|
+
// src/interfaces/accessibility.interface.ts
|
|
156
|
+
var AccessibilityModulesType = /* @__PURE__ */ ((AccessibilityModulesType2) => {
|
|
157
|
+
AccessibilityModulesType2[AccessibilityModulesType2["increaseText"] = 1] = "increaseText";
|
|
158
|
+
AccessibilityModulesType2[AccessibilityModulesType2["decreaseText"] = 2] = "decreaseText";
|
|
159
|
+
AccessibilityModulesType2[AccessibilityModulesType2["increaseTextSpacing"] = 3] = "increaseTextSpacing";
|
|
160
|
+
AccessibilityModulesType2[AccessibilityModulesType2["decreaseTextSpacing"] = 4] = "decreaseTextSpacing";
|
|
161
|
+
AccessibilityModulesType2[AccessibilityModulesType2["increaseLineHeight"] = 5] = "increaseLineHeight";
|
|
162
|
+
AccessibilityModulesType2[AccessibilityModulesType2["decreaseLineHeight"] = 6] = "decreaseLineHeight";
|
|
163
|
+
AccessibilityModulesType2[AccessibilityModulesType2["invertColors"] = 7] = "invertColors";
|
|
164
|
+
AccessibilityModulesType2[AccessibilityModulesType2["grayHues"] = 8] = "grayHues";
|
|
165
|
+
AccessibilityModulesType2[AccessibilityModulesType2["bigCursor"] = 9] = "bigCursor";
|
|
166
|
+
AccessibilityModulesType2[AccessibilityModulesType2["readingGuide"] = 10] = "readingGuide";
|
|
167
|
+
AccessibilityModulesType2[AccessibilityModulesType2["underlineLinks"] = 11] = "underlineLinks";
|
|
168
|
+
AccessibilityModulesType2[AccessibilityModulesType2["textToSpeech"] = 12] = "textToSpeech";
|
|
169
|
+
AccessibilityModulesType2[AccessibilityModulesType2["speechToText"] = 13] = "speechToText";
|
|
170
|
+
AccessibilityModulesType2[AccessibilityModulesType2["disableAnimations"] = 14] = "disableAnimations";
|
|
171
|
+
AccessibilityModulesType2[AccessibilityModulesType2["iframeModals"] = 15] = "iframeModals";
|
|
172
|
+
AccessibilityModulesType2[AccessibilityModulesType2["customFunctions"] = 16] = "customFunctions";
|
|
173
|
+
AccessibilityModulesType2[AccessibilityModulesType2["dyslexicFont"] = 17] = "dyslexicFont";
|
|
174
|
+
AccessibilityModulesType2[AccessibilityModulesType2["hideImages"] = 18] = "hideImages";
|
|
175
|
+
return AccessibilityModulesType2;
|
|
176
|
+
})(AccessibilityModulesType || {});
|
|
177
|
+
|
|
178
|
+
// src/menu-interface.ts
|
|
179
|
+
var MenuInterface = class {
|
|
180
|
+
constructor(accessibility) {
|
|
181
|
+
this._acc = accessibility;
|
|
182
|
+
this.readBind = this._acc.read.bind(this._acc);
|
|
183
|
+
}
|
|
184
|
+
updateCycleButton(btn, level, max) {
|
|
185
|
+
if (level > 0) btn.classList.add("active");
|
|
186
|
+
else btn.classList.remove("active");
|
|
187
|
+
let indicator = btn.querySelector("._access-cycle-indicator");
|
|
188
|
+
if (!indicator) {
|
|
189
|
+
indicator = document.createElement("div");
|
|
190
|
+
indicator.className = "_access-cycle-indicator";
|
|
191
|
+
for (let i = 0; i < max; i++) indicator.appendChild(document.createElement("span"));
|
|
192
|
+
btn.appendChild(indicator);
|
|
193
|
+
}
|
|
194
|
+
indicator.querySelectorAll("span").forEach((span, i) => span.classList.toggle("filled", i < level));
|
|
195
|
+
}
|
|
196
|
+
refreshCycleButtons() {
|
|
197
|
+
const find = (action) => {
|
|
198
|
+
var _a;
|
|
199
|
+
return (_a = this._acc.menu) == null ? void 0 : _a.querySelector(`[data-access-action="${action}"]`);
|
|
200
|
+
};
|
|
201
|
+
const t = find("increaseText");
|
|
202
|
+
if (t) this.updateCycleButton(t, this._acc.sessionState.textSize, 3);
|
|
203
|
+
const s = find("increaseTextSpacing");
|
|
204
|
+
if (s) this.updateCycleButton(s, this._acc.sessionState.textSpace, 3);
|
|
205
|
+
const l = find("increaseLineHeight");
|
|
206
|
+
if (l) this.updateCycleButton(l, this._acc.sessionState.lineHeight, 3);
|
|
207
|
+
}
|
|
208
|
+
increaseText(_destroy, btn) {
|
|
209
|
+
if (this._acc.sessionState.textSize >= 3) {
|
|
210
|
+
this._acc.resetTextSize();
|
|
211
|
+
} else {
|
|
212
|
+
this._acc.alterTextSize(true);
|
|
213
|
+
}
|
|
214
|
+
if (btn) this.updateCycleButton(btn, this._acc.sessionState.textSize, 3);
|
|
215
|
+
}
|
|
216
|
+
decreaseText() {
|
|
217
|
+
this._acc.alterTextSize(false);
|
|
218
|
+
}
|
|
219
|
+
increaseTextSpacing(_destroy, btn) {
|
|
220
|
+
if (this._acc.sessionState.textSpace >= 3) {
|
|
221
|
+
this._acc.resetTextSpace();
|
|
222
|
+
} else {
|
|
223
|
+
this._acc.alterTextSpace(true);
|
|
224
|
+
}
|
|
225
|
+
if (btn) this.updateCycleButton(btn, this._acc.sessionState.textSpace, 3);
|
|
226
|
+
}
|
|
227
|
+
decreaseTextSpacing() {
|
|
228
|
+
this._acc.alterTextSpace(false);
|
|
229
|
+
}
|
|
230
|
+
increaseLineHeight(_destroy, btn) {
|
|
231
|
+
if (this._acc.sessionState.lineHeight >= 3) {
|
|
232
|
+
this._acc.resetLineHeight();
|
|
233
|
+
} else {
|
|
234
|
+
this._acc.alterLineHeight(true);
|
|
235
|
+
}
|
|
236
|
+
if (btn) this.updateCycleButton(btn, this._acc.sessionState.lineHeight, 3);
|
|
237
|
+
}
|
|
238
|
+
decreaseLineHeight() {
|
|
239
|
+
this._acc.alterLineHeight(false);
|
|
240
|
+
}
|
|
241
|
+
invertColors(destroy) {
|
|
242
|
+
var _a, _b;
|
|
243
|
+
const counterClass = "_access-invert-counter";
|
|
244
|
+
const removeCounter = () => {
|
|
245
|
+
var _a2;
|
|
246
|
+
return (_a2 = document.querySelector("." + counterClass)) == null ? void 0 : _a2.remove();
|
|
247
|
+
};
|
|
248
|
+
if (typeof this._acc.stateValues.html.backgroundColor === "undefined")
|
|
249
|
+
this._acc.stateValues.html.backgroundColor = getComputedStyle(this._acc.html).backgroundColor;
|
|
250
|
+
if (typeof this._acc.stateValues.html.color === "undefined")
|
|
251
|
+
this._acc.stateValues.html.color = getComputedStyle(this._acc.html).color;
|
|
252
|
+
if (destroy) {
|
|
253
|
+
this._acc.resetIfDefined(this._acc.stateValues.html.backgroundColor, this._acc.html.style, "backgroundColor");
|
|
254
|
+
this._acc.resetIfDefined(this._acc.stateValues.html.color, this._acc.html.style, "color");
|
|
255
|
+
if (!this._acc.options.suppressDomInjection)
|
|
256
|
+
(_a = this._acc.menu.querySelector('[data-access-action="invertColors"]')) == null ? void 0 : _a.classList.remove("active");
|
|
257
|
+
this._acc.stateValues.invertColors = false;
|
|
258
|
+
this._acc.sessionState.invertColors = false;
|
|
259
|
+
this._acc.onChange(true);
|
|
260
|
+
this._acc.html.style.filter = "";
|
|
261
|
+
removeCounter();
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
if (!this._acc.options.suppressDomInjection)
|
|
265
|
+
(_b = this._acc.menu.querySelector('[data-access-action="invertColors"]')) == null ? void 0 : _b.classList.toggle("active");
|
|
266
|
+
this._acc.stateValues.invertColors = !this._acc.stateValues.invertColors;
|
|
267
|
+
this._acc.sessionState.invertColors = this._acc.stateValues.invertColors;
|
|
268
|
+
this._acc.onChange(true);
|
|
269
|
+
if (this._acc.stateValues.invertColors) {
|
|
270
|
+
if (this._acc.stateValues.grayHues) this._acc.menuInterface.grayHues(true);
|
|
271
|
+
this._acc.html.style.filter = "invert(1)";
|
|
272
|
+
this._acc.common.injectStyle("._access { filter: invert(1) !important; }", { className: counterClass });
|
|
273
|
+
this._acc.common.deployedObjects.set("." + counterClass, false);
|
|
274
|
+
if (this._acc.stateValues.textToSpeech) this._acc.textToSpeech("Colors Inverted");
|
|
275
|
+
} else {
|
|
276
|
+
this._acc.html.style.filter = "";
|
|
277
|
+
removeCounter();
|
|
278
|
+
if (this._acc.stateValues.textToSpeech) this._acc.textToSpeech("Colors Set To Normal");
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
grayHues(destroy) {
|
|
282
|
+
var _a, _b;
|
|
283
|
+
const overlayClass = "_access-gray-overlay";
|
|
284
|
+
const removeOverlay = () => {
|
|
285
|
+
var _a2;
|
|
286
|
+
(_a2 = document.querySelector("." + overlayClass)) == null ? void 0 : _a2.remove();
|
|
287
|
+
};
|
|
288
|
+
if (destroy) {
|
|
289
|
+
if (!this._acc.options.suppressDomInjection)
|
|
290
|
+
(_a = this._acc.menu.querySelector('[data-access-action="grayHues"]')) == null ? void 0 : _a.classList.remove("active");
|
|
291
|
+
this._acc.stateValues.grayHues = false;
|
|
292
|
+
this._acc.sessionState.grayHues = false;
|
|
293
|
+
this._acc.onChange(true);
|
|
294
|
+
removeOverlay();
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
if (!this._acc.options.suppressDomInjection)
|
|
298
|
+
(_b = this._acc.menu.querySelector('[data-access-action="grayHues"]')) == null ? void 0 : _b.classList.toggle("active");
|
|
299
|
+
this._acc.stateValues.grayHues = !this._acc.stateValues.grayHues;
|
|
300
|
+
this._acc.sessionState.grayHues = this._acc.stateValues.grayHues;
|
|
301
|
+
this._acc.onChange(true);
|
|
302
|
+
if (this._acc.stateValues.grayHues) {
|
|
303
|
+
if (this._acc.stateValues.invertColors) this.invertColors(true);
|
|
304
|
+
const overlay = document.createElement("div");
|
|
305
|
+
overlay.className = overlayClass;
|
|
306
|
+
overlay.style.cssText = "position:fixed;inset:0;z-index:9998;backdrop-filter:grayscale(1);-webkit-backdrop-filter:grayscale(1);pointer-events:none;";
|
|
307
|
+
document.body.appendChild(overlay);
|
|
308
|
+
this._acc.common.deployedObjects.set("." + overlayClass, false);
|
|
309
|
+
if (this._acc.stateValues.textToSpeech) this._acc.textToSpeech("Gray Hues Enabled.");
|
|
310
|
+
} else {
|
|
311
|
+
removeOverlay();
|
|
312
|
+
if (this._acc.stateValues.textToSpeech) this._acc.textToSpeech("Gray Hues Disabled.");
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
underlineLinks(destroy) {
|
|
316
|
+
var _a, _b, _c;
|
|
317
|
+
const className = "_access-underline";
|
|
318
|
+
const remove = () => {
|
|
319
|
+
const style = document.querySelector("." + className);
|
|
320
|
+
if (style) {
|
|
321
|
+
style.parentElement.removeChild(style);
|
|
322
|
+
this._acc.common.deployedObjects.remove("." + className);
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
if (destroy) {
|
|
326
|
+
this._acc.stateValues.underlineLinks = false;
|
|
327
|
+
this._acc.sessionState.underlineLinks = false;
|
|
328
|
+
this._acc.onChange(true);
|
|
329
|
+
if (!this._acc.options.suppressDomInjection)
|
|
330
|
+
(_a = this._acc.menu.querySelector('[data-access-action="underlineLinks"]')) == null ? void 0 : _a.classList.remove("active");
|
|
331
|
+
return remove();
|
|
332
|
+
}
|
|
333
|
+
if (!this._acc.options.suppressDomInjection)
|
|
334
|
+
(_b = this._acc.menu.querySelector('[data-access-action="underlineLinks"]')) == null ? void 0 : _b.classList.toggle("active");
|
|
335
|
+
this._acc.stateValues.underlineLinks = !this._acc.stateValues.underlineLinks;
|
|
336
|
+
this._acc.sessionState.underlineLinks = this._acc.stateValues.underlineLinks;
|
|
337
|
+
this._acc.onChange(true);
|
|
338
|
+
if (this._acc.stateValues.underlineLinks) {
|
|
339
|
+
const parts = ((_c = this._acc.options.linkSelector) != null ? _c : "a").split(",").map((s) => s.trim());
|
|
340
|
+
const rules = parts.flatMap((s) => [`body ${s}`, `body ${s} *`]).join(", ");
|
|
341
|
+
this._acc.common.injectStyle(`${rules} { text-decoration: underline !important; }`, { className });
|
|
342
|
+
this._acc.common.deployedObjects.set("." + className, true);
|
|
343
|
+
if (this._acc.stateValues.textToSpeech) this._acc.textToSpeech("Links UnderLined");
|
|
344
|
+
} else {
|
|
345
|
+
if (this._acc.stateValues.textToSpeech) this._acc.textToSpeech("Links UnderLine Removed");
|
|
346
|
+
remove();
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
bigCursor(destroy) {
|
|
350
|
+
var _a, _b;
|
|
351
|
+
if (destroy) {
|
|
352
|
+
this._acc.html.classList.remove("_access_cursor");
|
|
353
|
+
if (!this._acc.options.suppressDomInjection)
|
|
354
|
+
(_a = this._acc.menu.querySelector('[data-access-action="bigCursor"]')) == null ? void 0 : _a.classList.remove("active");
|
|
355
|
+
this._acc.stateValues.bigCursor = false;
|
|
356
|
+
this._acc.sessionState.bigCursor = false;
|
|
357
|
+
this._acc.onChange(true);
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
if (!this._acc.options.suppressDomInjection)
|
|
361
|
+
(_b = this._acc.menu.querySelector('[data-access-action="bigCursor"]')) == null ? void 0 : _b.classList.toggle("active");
|
|
362
|
+
this._acc.stateValues.bigCursor = !this._acc.stateValues.bigCursor;
|
|
363
|
+
this._acc.sessionState.bigCursor = this._acc.stateValues.bigCursor;
|
|
364
|
+
this._acc.onChange(true);
|
|
365
|
+
this._acc.html.classList.toggle("_access_cursor");
|
|
366
|
+
if (this._acc.stateValues.textToSpeech)
|
|
367
|
+
this._acc.textToSpeech(this._acc.stateValues.bigCursor ? "Big Cursor Enabled" : "Big Cursor Disabled");
|
|
368
|
+
}
|
|
369
|
+
readingGuide(destroy) {
|
|
370
|
+
var _a, _b, _c, _d;
|
|
371
|
+
if (destroy) {
|
|
372
|
+
(_a = document.getElementById("access_read_guide_bar")) == null ? void 0 : _a.remove();
|
|
373
|
+
if (!this._acc.options.suppressDomInjection)
|
|
374
|
+
(_b = this._acc.menu.querySelector('[data-access-action="readingGuide"]')) == null ? void 0 : _b.classList.remove("active");
|
|
375
|
+
this._acc.stateValues.readingGuide = false;
|
|
376
|
+
this._acc.sessionState.readingGuide = false;
|
|
377
|
+
this._acc.onChange(true);
|
|
378
|
+
document.body.removeEventListener("touchmove", this._acc.updateReadGuide, false);
|
|
379
|
+
document.body.removeEventListener("mousemove", this._acc.updateReadGuide, false);
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
if (!this._acc.options.suppressDomInjection)
|
|
383
|
+
(_c = this._acc.menu.querySelector('[data-access-action="readingGuide"]')) == null ? void 0 : _c.classList.toggle("active");
|
|
384
|
+
this._acc.stateValues.readingGuide = !this._acc.stateValues.readingGuide;
|
|
385
|
+
this._acc.sessionState.readingGuide = this._acc.stateValues.readingGuide;
|
|
386
|
+
this._acc.onChange(true);
|
|
387
|
+
if (this._acc.stateValues.readingGuide) {
|
|
388
|
+
const read = document.createElement("div");
|
|
389
|
+
read.id = "access_read_guide_bar";
|
|
390
|
+
read.classList.add("access_read_guide_bar");
|
|
391
|
+
document.body.append(read);
|
|
392
|
+
document.body.addEventListener("touchmove", this._acc.updateReadGuide, false);
|
|
393
|
+
document.body.addEventListener("mousemove", this._acc.updateReadGuide, false);
|
|
394
|
+
} else {
|
|
395
|
+
(_d = document.getElementById("access_read_guide_bar")) == null ? void 0 : _d.remove();
|
|
396
|
+
document.body.removeEventListener("touchmove", this._acc.updateReadGuide, false);
|
|
397
|
+
document.body.removeEventListener("mousemove", this._acc.updateReadGuide, false);
|
|
398
|
+
if (this._acc.stateValues.textToSpeech) this._acc.textToSpeech("Reading Guide Disabled");
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
textToSpeech(destroy) {
|
|
402
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
403
|
+
const tSpeechList = this._acc.menu.querySelector('[data-access-action="textToSpeech"]');
|
|
404
|
+
if (!tSpeechList) return;
|
|
405
|
+
const step1 = document.getElementsByClassName("screen-reader-wrapper-step-1");
|
|
406
|
+
const step2 = document.getElementsByClassName("screen-reader-wrapper-step-2");
|
|
407
|
+
const step3 = document.getElementsByClassName("screen-reader-wrapper-step-3");
|
|
408
|
+
this._acc.onChange(false);
|
|
409
|
+
const className = "_access-text-to-speech";
|
|
410
|
+
const remove = () => {
|
|
411
|
+
var _a2;
|
|
412
|
+
const style = document.querySelector("." + className);
|
|
413
|
+
if (style) {
|
|
414
|
+
style.parentElement.removeChild(style);
|
|
415
|
+
document.removeEventListener("click", this.readBind, false);
|
|
416
|
+
document.removeEventListener("keyup", this.readBind, false);
|
|
417
|
+
this._acc.common.deployedObjects.remove("." + className);
|
|
418
|
+
}
|
|
419
|
+
(_a2 = window.speechSynthesis) == null ? void 0 : _a2.cancel();
|
|
420
|
+
this._acc.isReading = false;
|
|
421
|
+
};
|
|
422
|
+
if (destroy) {
|
|
423
|
+
tSpeechList.classList.remove("active");
|
|
424
|
+
(_a = step1[0]) == null ? void 0 : _a.classList.remove("active");
|
|
425
|
+
(_b = step2[0]) == null ? void 0 : _b.classList.remove("active");
|
|
426
|
+
(_c = step3[0]) == null ? void 0 : _c.classList.remove("active");
|
|
427
|
+
this._acc.stateValues.textToSpeech = false;
|
|
428
|
+
(_d = window.speechSynthesis) == null ? void 0 : _d.cancel();
|
|
429
|
+
return remove();
|
|
430
|
+
}
|
|
431
|
+
if (this._acc.stateValues.speechRate === 1 && !tSpeechList.classList.contains("active")) {
|
|
432
|
+
this._acc.stateValues.textToSpeech = true;
|
|
433
|
+
this._acc.textToSpeech("Screen Reader enabled. Reading Pace - Normal");
|
|
434
|
+
tSpeechList.classList.add("active");
|
|
435
|
+
(_e = step1[0]) == null ? void 0 : _e.classList.add("active");
|
|
436
|
+
(_f = step2[0]) == null ? void 0 : _f.classList.add("active");
|
|
437
|
+
(_g = step3[0]) == null ? void 0 : _g.classList.add("active");
|
|
438
|
+
} else if (this._acc.stateValues.speechRate === 1 && tSpeechList.classList.contains("active")) {
|
|
439
|
+
this._acc.stateValues.speechRate = 1.5;
|
|
440
|
+
this._acc.textToSpeech("Reading Pace - Fast");
|
|
441
|
+
(_h = step1[0]) == null ? void 0 : _h.classList.remove("active");
|
|
442
|
+
} else if (this._acc.stateValues.speechRate === 1.5 && tSpeechList.classList.contains("active")) {
|
|
443
|
+
this._acc.stateValues.speechRate = 0.7;
|
|
444
|
+
this._acc.textToSpeech("Reading Pace - Slow");
|
|
445
|
+
(_i = step2[0]) == null ? void 0 : _i.classList.remove("active");
|
|
446
|
+
} else {
|
|
447
|
+
this._acc.stateValues.speechRate = 1;
|
|
448
|
+
this._acc.textToSpeech("Screen Reader - Disabled");
|
|
449
|
+
tSpeechList.classList.remove("active");
|
|
450
|
+
(_j = step3[0]) == null ? void 0 : _j.classList.remove("active");
|
|
451
|
+
const timeout = setInterval(() => {
|
|
452
|
+
if (this._acc.isReading) return;
|
|
453
|
+
this._acc.stateValues.textToSpeech = false;
|
|
454
|
+
remove();
|
|
455
|
+
clearTimeout(timeout);
|
|
456
|
+
}, 500);
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
if (tSpeechList.classList.contains("active") && this._acc.stateValues.speechRate === 1) {
|
|
460
|
+
this._acc.common.injectStyle("*:hover { box-shadow: 2px 2px 2px rgba(180,180,180,0.7); }", { className });
|
|
461
|
+
this._acc.common.deployedObjects.set("." + className, true);
|
|
462
|
+
document.addEventListener("click", this.readBind, false);
|
|
463
|
+
document.addEventListener("keyup", this.readBind, false);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
speechToText(destroy) {
|
|
467
|
+
var _a, _b;
|
|
468
|
+
const sTextList = this._acc.menu.querySelector('[data-access-action="speechToText"]');
|
|
469
|
+
if (!sTextList) return;
|
|
470
|
+
this._acc.onChange(false);
|
|
471
|
+
const className = "_access-speech-to-text";
|
|
472
|
+
const remove = () => {
|
|
473
|
+
var _a2, _b2, _c, _d;
|
|
474
|
+
(_b2 = (_a2 = this._acc.recognition) == null ? void 0 : _a2.stop) == null ? void 0 : _b2.call(_a2);
|
|
475
|
+
this._acc.body.classList.remove("_access-listening");
|
|
476
|
+
(_d = (_c = document.querySelector("." + className)) == null ? void 0 : _c.parentElement) == null ? void 0 : _d.removeChild(document.querySelector("." + className));
|
|
477
|
+
this._acc.common.deployedObjects.remove("." + className);
|
|
478
|
+
document.querySelectorAll("._access-mic").forEach((input) => {
|
|
479
|
+
input.removeEventListener("focus", this._acc.listen.bind(this._acc), false);
|
|
480
|
+
input.classList.remove("_access-mic");
|
|
481
|
+
});
|
|
482
|
+
sTextList.classList.remove("active");
|
|
483
|
+
};
|
|
484
|
+
if (destroy) {
|
|
485
|
+
this._acc.stateValues.speechToText = false;
|
|
486
|
+
return remove();
|
|
487
|
+
}
|
|
488
|
+
this._acc.stateValues.speechToText = !this._acc.stateValues.speechToText;
|
|
489
|
+
if (this._acc.stateValues.speechToText) {
|
|
490
|
+
const iconContent = !((_a = this._acc.options.icon) == null ? void 0 : _a.useEmojis) ? '"mic"' : 'var(--_access-menu-item-icon-mic,"\u{1F3A4}")';
|
|
491
|
+
const fontFamily = !((_b = this._acc.options.icon) == null ? void 0 : _b.useEmojis) ? `font-family: var(--_access-menu-item-icon-font-family-after, ${this._acc.fixedDefaultFont});` : "";
|
|
492
|
+
const css = `
|
|
493
|
+
body:after {
|
|
494
|
+
content: ${iconContent};
|
|
495
|
+
${fontFamily}
|
|
496
|
+
position: fixed; z-index: 1100; top: 1vw; right: 1vw;
|
|
497
|
+
width: 36px; height: 36px; font-size: 30px; line-height: 36px;
|
|
498
|
+
border-radius: 50%; background: rgba(255,255,255,0.7);
|
|
499
|
+
display: flex; justify-content: center; align-items: center;
|
|
500
|
+
}
|
|
501
|
+
body._access-listening:after { animation: _access-listening-animation 2s infinite ease; }
|
|
502
|
+
@keyframes _access-listening-animation {
|
|
503
|
+
0% { background-color: transparent; }
|
|
504
|
+
50% { background-color: #EF9A9A; }
|
|
505
|
+
}
|
|
506
|
+
`;
|
|
507
|
+
this._acc.common.injectStyle(css, { className });
|
|
508
|
+
this._acc.common.deployedObjects.set("." + className, true);
|
|
509
|
+
document.querySelectorAll('input[type="text"], input[type="email"], input[type="tel"], input[type="search"], textarea, [contenteditable]').forEach((input) => {
|
|
510
|
+
input.addEventListener("blur", () => {
|
|
511
|
+
var _a2, _b2;
|
|
512
|
+
return (_b2 = (_a2 = this._acc.recognition) == null ? void 0 : _a2.stop) == null ? void 0 : _b2.call(_a2);
|
|
513
|
+
}, false);
|
|
514
|
+
input.addEventListener("focus", this._acc.listen.bind(this._acc), false);
|
|
515
|
+
input.parentElement.classList.add("_access-mic");
|
|
516
|
+
});
|
|
517
|
+
sTextList.classList.add("active");
|
|
518
|
+
} else {
|
|
519
|
+
remove();
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
disableAnimations(destroy) {
|
|
523
|
+
var _a;
|
|
524
|
+
const className = "_access-disable-animations";
|
|
525
|
+
const autoplayStopped = "data-autoplay-stopped";
|
|
526
|
+
const remove = () => {
|
|
527
|
+
var _a2, _b, _c;
|
|
528
|
+
if (!this._acc.options.suppressDomInjection)
|
|
529
|
+
(_a2 = this._acc.menu.querySelector('[data-access-action="disableAnimations"]')) == null ? void 0 : _a2.classList.remove("active");
|
|
530
|
+
this._acc.stateValues.disableAnimations = false;
|
|
531
|
+
(_c = (_b = document.querySelector("." + className)) == null ? void 0 : _b.parentElement) == null ? void 0 : _c.removeChild(document.querySelector("." + className));
|
|
532
|
+
this._acc.common.deployedObjects.remove("." + className);
|
|
533
|
+
document.querySelectorAll("[data-org-src]").forEach((img) => {
|
|
534
|
+
const screenshot = img.src;
|
|
535
|
+
img.setAttribute("src", img.getAttribute("data-org-src"));
|
|
536
|
+
img.setAttribute("data-org-src", screenshot);
|
|
537
|
+
});
|
|
538
|
+
document.querySelectorAll(`video[${autoplayStopped}]`).forEach((v) => {
|
|
539
|
+
v.setAttribute("autoplay", "");
|
|
540
|
+
v.removeAttribute(autoplayStopped);
|
|
541
|
+
v.play();
|
|
542
|
+
});
|
|
543
|
+
};
|
|
544
|
+
if (destroy) {
|
|
545
|
+
remove();
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
this._acc.stateValues.disableAnimations = !this._acc.stateValues.disableAnimations;
|
|
549
|
+
if (!this._acc.stateValues.disableAnimations) {
|
|
550
|
+
remove();
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
if (!this._acc.options.suppressDomInjection)
|
|
554
|
+
(_a = this._acc.menu.querySelector('[data-access-action="disableAnimations"]')) == null ? void 0 : _a.classList.add("active");
|
|
555
|
+
this._acc.common.injectStyle(
|
|
556
|
+
"body * { animation-duration: 0.0ms !important; transition-duration: 0.0ms !important; }",
|
|
557
|
+
{ className }
|
|
558
|
+
);
|
|
559
|
+
this._acc.common.deployedObjects.set("." + className, true);
|
|
560
|
+
document.querySelectorAll("img").forEach(async (img) => {
|
|
561
|
+
const ext = this._acc.common.getFileExtension(img.src);
|
|
562
|
+
if ((ext == null ? void 0 : ext.toLowerCase()) === "gif") {
|
|
563
|
+
let screenshot = img.getAttribute("data-org-src");
|
|
564
|
+
if (!screenshot) screenshot = await this._acc.common.createScreenshot(img.src);
|
|
565
|
+
img.setAttribute("data-org-src", img.src);
|
|
566
|
+
img.src = screenshot;
|
|
567
|
+
}
|
|
568
|
+
});
|
|
569
|
+
document.querySelectorAll("video[autoplay]").forEach((v) => {
|
|
570
|
+
v.setAttribute(autoplayStopped, "");
|
|
571
|
+
v.removeAttribute("autoplay");
|
|
572
|
+
v.pause();
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
iframeModals(destroy, button) {
|
|
576
|
+
var _a, _b, _c, _d;
|
|
577
|
+
if (!button) destroy = true;
|
|
578
|
+
const close = () => {
|
|
579
|
+
if (this._dialog) {
|
|
580
|
+
this._dialog.classList.add("closing");
|
|
581
|
+
setTimeout(() => {
|
|
582
|
+
this._dialog.classList.remove("closing");
|
|
583
|
+
this._dialog.close();
|
|
584
|
+
this._dialog.remove();
|
|
585
|
+
detach();
|
|
586
|
+
}, 350);
|
|
587
|
+
}
|
|
588
|
+
button == null ? void 0 : button.classList.remove("active");
|
|
589
|
+
};
|
|
590
|
+
const onClose = () => close();
|
|
591
|
+
const detach = () => {
|
|
592
|
+
var _a2, _b2, _c2;
|
|
593
|
+
(_b2 = (_a2 = this._dialog) == null ? void 0 : _a2.querySelector("button")) == null ? void 0 : _b2.removeEventListener("click", onClose, false);
|
|
594
|
+
(_c2 = this._dialog) == null ? void 0 : _c2.removeEventListener("close", onClose);
|
|
595
|
+
};
|
|
596
|
+
if (destroy) {
|
|
597
|
+
close();
|
|
598
|
+
return;
|
|
599
|
+
}
|
|
600
|
+
button.classList.add("active");
|
|
601
|
+
if (!this._dialog) this._dialog = document.createElement("dialog");
|
|
602
|
+
this._dialog.classList.add("_access");
|
|
603
|
+
this._dialog.innerHTML = "";
|
|
604
|
+
this._dialog.appendChild(this._acc.common.jsonToHtml({
|
|
605
|
+
type: "div",
|
|
606
|
+
children: [
|
|
607
|
+
{
|
|
608
|
+
type: "div",
|
|
609
|
+
children: [{
|
|
610
|
+
type: "button",
|
|
611
|
+
attrs: {
|
|
612
|
+
role: "button",
|
|
613
|
+
class: ((_a = this._acc.options.icon) == null ? void 0 : _a.useEmojis) ? "" : (_c = (_b = this._acc.options.icon) == null ? void 0 : _b.fontClass) != null ? _c : "",
|
|
614
|
+
style: "position:absolute;top:5px;cursor:pointer;font-size:24px!important;font-weight:bold;background:transparent;border:none;left:5px;color:#d63c3c;padding:0;"
|
|
615
|
+
},
|
|
616
|
+
children: [{ type: "#text", text: ((_d = this._acc.options.icon) == null ? void 0 : _d.useEmojis) ? "X" : "close" }]
|
|
617
|
+
}]
|
|
618
|
+
},
|
|
619
|
+
{
|
|
620
|
+
type: "div",
|
|
621
|
+
children: [{
|
|
622
|
+
type: "iframe",
|
|
623
|
+
attrs: { src: button.getAttribute("data-access-url"), style: "width:50vw;height:50vh;padding:30px;" }
|
|
624
|
+
}]
|
|
625
|
+
}
|
|
626
|
+
]
|
|
627
|
+
}));
|
|
628
|
+
document.body.appendChild(this._dialog);
|
|
629
|
+
this._dialog.querySelector("button").addEventListener("click", onClose, false);
|
|
630
|
+
this._dialog.addEventListener("close", onClose);
|
|
631
|
+
this._dialog.showModal();
|
|
632
|
+
}
|
|
633
|
+
customFunctions(destroy, button) {
|
|
634
|
+
if (!button) return;
|
|
635
|
+
const cf = this._acc.options.customFunctions[parseInt(button.getAttribute("data-access-custom-index"))];
|
|
636
|
+
if (cf.toggle && button.classList.contains("active")) destroy = true;
|
|
637
|
+
if (destroy) {
|
|
638
|
+
if (cf.toggle) button.classList.remove("active");
|
|
639
|
+
cf.method(cf, false);
|
|
640
|
+
} else {
|
|
641
|
+
if (cf.toggle) button.classList.add("active");
|
|
642
|
+
cf.method(cf, true);
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
dyslexicFont(destroy) {
|
|
646
|
+
var _a, _b;
|
|
647
|
+
const className = "_access-dyslexic-font";
|
|
648
|
+
const btn = this._acc.menu.querySelector('[data-access-action="dyslexicFont"]');
|
|
649
|
+
if (destroy) {
|
|
650
|
+
this._acc.stateValues.dyslexicFont = false;
|
|
651
|
+
btn == null ? void 0 : btn.classList.remove("active");
|
|
652
|
+
(_a = document.querySelector("." + className)) == null ? void 0 : _a.remove();
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
this._acc.stateValues.dyslexicFont = !this._acc.stateValues.dyslexicFont;
|
|
656
|
+
btn == null ? void 0 : btn.classList.toggle("active");
|
|
657
|
+
if (this._acc.stateValues.dyslexicFont) {
|
|
658
|
+
this._acc.common.injectStyle(`
|
|
659
|
+
@font-face {
|
|
660
|
+
font-family: 'OpenDyslexic';
|
|
661
|
+
src: url('https://cdn.jsdelivr.net/npm/open-dyslexic@1.0.3/open-dyslexic-regular.woff2') format('woff2');
|
|
662
|
+
font-weight: normal; font-style: normal;
|
|
663
|
+
}
|
|
664
|
+
body *:not(._access):not(._access *) { font-family: OpenDyslexic, Arial, sans-serif !important; }
|
|
665
|
+
`, { className });
|
|
666
|
+
this._acc.common.deployedObjects.set("." + className, false);
|
|
667
|
+
} else {
|
|
668
|
+
(_b = document.querySelector("." + className)) == null ? void 0 : _b.remove();
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
hideImages(destroy) {
|
|
672
|
+
var _a, _b;
|
|
673
|
+
const className = "_access-hide-images";
|
|
674
|
+
const btn = this._acc.menu.querySelector('[data-access-action="hideImages"]');
|
|
675
|
+
if (destroy) {
|
|
676
|
+
this._acc.stateValues.hideImages = false;
|
|
677
|
+
btn == null ? void 0 : btn.classList.remove("active");
|
|
678
|
+
(_a = document.querySelector("." + className)) == null ? void 0 : _a.remove();
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
681
|
+
this._acc.stateValues.hideImages = !this._acc.stateValues.hideImages;
|
|
682
|
+
btn == null ? void 0 : btn.classList.toggle("active");
|
|
683
|
+
if (this._acc.stateValues.hideImages) {
|
|
684
|
+
this._acc.common.injectStyle(
|
|
685
|
+
"img, picture, svg:not(._access svg) { visibility: hidden !important; } *:not(._access):not(._access *) { background-image: none !important; }",
|
|
686
|
+
{ className }
|
|
687
|
+
);
|
|
688
|
+
this._acc.common.deployedObjects.set("." + className, false);
|
|
689
|
+
} else {
|
|
690
|
+
(_b = document.querySelector("." + className)) == null ? void 0 : _b.remove();
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
};
|
|
694
|
+
|
|
695
|
+
// src/storage.ts
|
|
696
|
+
var Storage = class {
|
|
697
|
+
has(key) {
|
|
698
|
+
return Object.prototype.hasOwnProperty.call(window.localStorage, key);
|
|
699
|
+
}
|
|
700
|
+
set(key, value) {
|
|
701
|
+
window.localStorage.setItem(key, JSON.stringify(value));
|
|
702
|
+
}
|
|
703
|
+
get(key) {
|
|
704
|
+
const item = window.localStorage.getItem(key);
|
|
705
|
+
try {
|
|
706
|
+
return JSON.parse(item);
|
|
707
|
+
} catch (e) {
|
|
708
|
+
return item;
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
clear() {
|
|
712
|
+
window.localStorage.clear();
|
|
713
|
+
}
|
|
714
|
+
remove(key) {
|
|
715
|
+
window.localStorage.removeItem(key);
|
|
716
|
+
}
|
|
717
|
+
isSupported() {
|
|
718
|
+
const test = "_test";
|
|
719
|
+
try {
|
|
720
|
+
localStorage.setItem(test, test);
|
|
721
|
+
localStorage.removeItem(test);
|
|
722
|
+
return true;
|
|
723
|
+
} catch (e) {
|
|
724
|
+
return false;
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
};
|
|
728
|
+
|
|
729
|
+
// src/main.ts
|
|
730
|
+
var _Accessibility = class _Accessibility {
|
|
731
|
+
constructor(options = {}) {
|
|
732
|
+
this._isReading = false;
|
|
733
|
+
var _a, _b, _c, _d;
|
|
734
|
+
this._common = new Common();
|
|
735
|
+
this._storage = new Storage();
|
|
736
|
+
this._fixedDefaultFont = this._common.getFixedFont("Material Icons");
|
|
737
|
+
this._options = this.defaultOptions;
|
|
738
|
+
this.options = this._common.extend(this._options, options);
|
|
739
|
+
this.addModuleOrderIfNotDefined();
|
|
740
|
+
this.addDefaultOptions(options);
|
|
741
|
+
this.disabledUnsupportedFeatures();
|
|
742
|
+
this._onKeyDownBind = this.onKeyDown.bind(this);
|
|
743
|
+
this._sessionState = {
|
|
744
|
+
textSize: 0,
|
|
745
|
+
textSpace: 0,
|
|
746
|
+
lineHeight: 0,
|
|
747
|
+
invertColors: false,
|
|
748
|
+
grayHues: false,
|
|
749
|
+
underlineLinks: false,
|
|
750
|
+
bigCursor: false,
|
|
751
|
+
readingGuide: false
|
|
752
|
+
};
|
|
753
|
+
if ((_a = this.options.icon) == null ? void 0 : _a.useEmojis) {
|
|
754
|
+
this.fontFallback();
|
|
755
|
+
this.build();
|
|
756
|
+
} else {
|
|
757
|
+
this._common.injectIconsFont((_c = (_b = this.options.icon) == null ? void 0 : _b.fontFaceSrc) != null ? _c : [], (hasError) => {
|
|
758
|
+
var _a2;
|
|
759
|
+
this.build();
|
|
760
|
+
if ((_a2 = this.options.icon) == null ? void 0 : _a2.fontFamilyValidation) {
|
|
761
|
+
setTimeout(() => {
|
|
762
|
+
this._common.isFontLoaded(this.options.icon.fontFamilyValidation, (isLoaded) => {
|
|
763
|
+
if (!isLoaded || hasError) {
|
|
764
|
+
this._common.warn(`${this.options.icon.fontFamilyValidation} font not loaded, using emojis`);
|
|
765
|
+
this.fontFallback();
|
|
766
|
+
this.destroy();
|
|
767
|
+
this.build();
|
|
768
|
+
}
|
|
769
|
+
});
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
if ((_d = this.options.modules) == null ? void 0 : _d.speechToText) {
|
|
775
|
+
window.addEventListener("beforeunload", () => {
|
|
776
|
+
if (this._isReading) {
|
|
777
|
+
window.speechSynthesis.cancel();
|
|
778
|
+
this._isReading = false;
|
|
779
|
+
}
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
get stateValues() {
|
|
784
|
+
return this._stateValues;
|
|
785
|
+
}
|
|
786
|
+
set stateValues(value) {
|
|
787
|
+
this._stateValues = value;
|
|
788
|
+
}
|
|
789
|
+
get html() {
|
|
790
|
+
return this._html;
|
|
791
|
+
}
|
|
792
|
+
get body() {
|
|
793
|
+
return this._body;
|
|
794
|
+
}
|
|
795
|
+
get menu() {
|
|
796
|
+
return this._menu;
|
|
797
|
+
}
|
|
798
|
+
get sessionState() {
|
|
799
|
+
return this._sessionState;
|
|
800
|
+
}
|
|
801
|
+
set sessionState(value) {
|
|
802
|
+
this._sessionState = value;
|
|
803
|
+
}
|
|
804
|
+
get common() {
|
|
805
|
+
return this._common;
|
|
806
|
+
}
|
|
807
|
+
get recognition() {
|
|
808
|
+
return this._recognition;
|
|
809
|
+
}
|
|
810
|
+
get isReading() {
|
|
811
|
+
return this._isReading;
|
|
812
|
+
}
|
|
813
|
+
set isReading(value) {
|
|
814
|
+
this._isReading = value;
|
|
815
|
+
}
|
|
816
|
+
get fixedDefaultFont() {
|
|
817
|
+
return this._fixedDefaultFont;
|
|
818
|
+
}
|
|
819
|
+
get defaultOptions() {
|
|
820
|
+
const res = {
|
|
821
|
+
icon: {
|
|
822
|
+
img: "accessibility",
|
|
823
|
+
fontFaceSrc: ["https://fonts.googleapis.com/icon?family=Material+Icons"],
|
|
824
|
+
fontClass: "material-icons",
|
|
825
|
+
useEmojis: false,
|
|
826
|
+
closeIcon: "close",
|
|
827
|
+
resetIcon: "refresh"
|
|
828
|
+
},
|
|
829
|
+
hotkeys: {
|
|
830
|
+
enabled: false,
|
|
831
|
+
helpTitles: true,
|
|
832
|
+
keys: {
|
|
833
|
+
toggleMenu: ["ctrlKey", "altKey", 65],
|
|
834
|
+
invertColors: ["ctrlKey", "altKey", 73],
|
|
835
|
+
grayHues: ["ctrlKey", "altKey", 71],
|
|
836
|
+
underlineLinks: ["ctrlKey", "altKey", 85],
|
|
837
|
+
bigCursor: ["ctrlKey", "altKey", 67],
|
|
838
|
+
readingGuide: ["ctrlKey", "altKey", 82],
|
|
839
|
+
textToSpeech: ["ctrlKey", "altKey", 84],
|
|
840
|
+
speechToText: ["ctrlKey", "altKey", 83],
|
|
841
|
+
disableAnimations: ["ctrlKey", "altKey", 81]
|
|
842
|
+
}
|
|
843
|
+
},
|
|
844
|
+
guide: { cBorder: "#20ff69", cBackground: "#000000", height: "12px" },
|
|
845
|
+
suppressCssInjection: false,
|
|
846
|
+
suppressDomInjection: false,
|
|
847
|
+
labels: {
|
|
848
|
+
resetTitle: "Reset",
|
|
849
|
+
closeTitle: "Close",
|
|
850
|
+
menuTitle: "Accessibility Options",
|
|
851
|
+
increaseText: "increase text size",
|
|
852
|
+
decreaseText: "decrease text size",
|
|
853
|
+
increaseTextSpacing: "increase text spacing",
|
|
854
|
+
decreaseTextSpacing: "decrease text spacing",
|
|
855
|
+
invertColors: "invert colors",
|
|
856
|
+
grayHues: "gray hues",
|
|
857
|
+
bigCursor: "big cursor",
|
|
858
|
+
readingGuide: "reading guide",
|
|
859
|
+
underlineLinks: "underline links",
|
|
860
|
+
textToSpeech: "text to speech",
|
|
861
|
+
speechToText: "speech to text",
|
|
862
|
+
disableAnimations: "disable animations",
|
|
863
|
+
increaseLineHeight: "increase line height",
|
|
864
|
+
decreaseLineHeight: "decrease line height",
|
|
865
|
+
hotkeyPrefix: "Hotkey: ",
|
|
866
|
+
dyslexicFont: "Dyslexic font",
|
|
867
|
+
hideImages: "Hide images"
|
|
868
|
+
},
|
|
869
|
+
textPixelMode: false,
|
|
870
|
+
textEmlMode: true,
|
|
871
|
+
textSizeFactor: 12.5,
|
|
872
|
+
animations: { buttons: true },
|
|
873
|
+
modules: {
|
|
874
|
+
increaseText: true,
|
|
875
|
+
decreaseText: true,
|
|
876
|
+
increaseTextSpacing: true,
|
|
877
|
+
decreaseTextSpacing: true,
|
|
878
|
+
increaseLineHeight: true,
|
|
879
|
+
decreaseLineHeight: true,
|
|
880
|
+
invertColors: true,
|
|
881
|
+
grayHues: true,
|
|
882
|
+
bigCursor: true,
|
|
883
|
+
readingGuide: true,
|
|
884
|
+
underlineLinks: true,
|
|
885
|
+
textToSpeech: true,
|
|
886
|
+
speechToText: true,
|
|
887
|
+
disableAnimations: true,
|
|
888
|
+
dyslexicFont: true,
|
|
889
|
+
hideImages: true
|
|
890
|
+
},
|
|
891
|
+
modulesOrder: [],
|
|
892
|
+
session: { persistent: true },
|
|
893
|
+
iframeModals: [],
|
|
894
|
+
customFunctions: [],
|
|
895
|
+
statement: { url: "" },
|
|
896
|
+
feedback: { url: "" },
|
|
897
|
+
linkSelector: "a",
|
|
898
|
+
logoImage: "",
|
|
899
|
+
language: { textToSpeechLang: "", speechToTextLang: "" }
|
|
900
|
+
};
|
|
901
|
+
Object.keys(AccessibilityModulesType).filter((k) => !isNaN(parseInt(k))).forEach((k) => {
|
|
902
|
+
const n = parseInt(k);
|
|
903
|
+
res.modulesOrder.push({ type: n, order: n });
|
|
904
|
+
});
|
|
905
|
+
return res;
|
|
906
|
+
}
|
|
907
|
+
initFontSize() {
|
|
908
|
+
if (!this._htmlInitFS) {
|
|
909
|
+
const htmlInitFS = this._common.getFormattedDim(getComputedStyle(this._html).fontSize);
|
|
910
|
+
const bodyInitFS = this._common.getFormattedDim(getComputedStyle(this._body).fontSize);
|
|
911
|
+
this._html.style.fontSize = htmlInitFS.size / 16 * 100 + "%";
|
|
912
|
+
this._htmlOrgFontSize = this._html.style.fontSize;
|
|
913
|
+
this._body.style.fontSize = bodyInitFS.size / htmlInitFS.size + "em";
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
fontFallback() {
|
|
917
|
+
this.options.icon.useEmojis = true;
|
|
918
|
+
this.options.icon.img = "\u267F";
|
|
919
|
+
this.options.icon.fontClass = "";
|
|
920
|
+
}
|
|
921
|
+
addDefaultOptions(options) {
|
|
922
|
+
var _a, _b, _c, _d, _e;
|
|
923
|
+
if ((_a = options.icon) == null ? void 0 : _a.closeIconElem) this.options.icon.closeIconElem = options.icon.closeIconElem;
|
|
924
|
+
if ((_b = options.icon) == null ? void 0 : _b.resetIconElem) this.options.icon.resetIconElem = options.icon.resetIconElem;
|
|
925
|
+
if ((_c = options.icon) == null ? void 0 : _c.imgElem) this.options.icon.imgElem = options.icon.imgElem;
|
|
926
|
+
if (!this.options.icon.closeIconElem)
|
|
927
|
+
this.options.icon.closeIconElem = { type: "#text", text: !this.options.icon.useEmojis ? (_d = this.options.icon.closeIcon) != null ? _d : "close" : "X" };
|
|
928
|
+
if (!this.options.icon.resetIconElem)
|
|
929
|
+
this.options.icon.resetIconElem = { type: "#text", text: !this.options.icon.useEmojis ? (_e = this.options.icon.resetIcon) != null ? _e : "refresh" : "\u2672" };
|
|
930
|
+
if (!this.options.icon.imgElem)
|
|
931
|
+
this.options.icon.imgElem = { type: "#text", text: this.options.icon.img };
|
|
932
|
+
}
|
|
933
|
+
addModuleOrderIfNotDefined() {
|
|
934
|
+
this.defaultOptions.modulesOrder.forEach((mo) => {
|
|
935
|
+
if (!this.options.modulesOrder.find((imo) => imo.type === mo.type))
|
|
936
|
+
this.options.modulesOrder.push(mo);
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
disabledUnsupportedFeatures() {
|
|
940
|
+
if (!("webkitSpeechRecognition" in window) || location.protocol !== "https:") {
|
|
941
|
+
this._common.warn("speech to text requires a browser with webkitSpeechRecognition and https");
|
|
942
|
+
this.options.modules.speechToText = false;
|
|
943
|
+
}
|
|
944
|
+
const w = window;
|
|
945
|
+
if (!w.SpeechSynthesisUtterance || !w.speechSynthesis) {
|
|
946
|
+
this._common.warn("text to speech is not supported in this browser");
|
|
947
|
+
this.options.modules.textToSpeech = false;
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
injectCss(injectFull) {
|
|
951
|
+
var _a;
|
|
952
|
+
const iconTop = "7px", iconLeft = "5px";
|
|
953
|
+
const useEmojis = (_a = this.options.icon) == null ? void 0 : _a.useEmojis;
|
|
954
|
+
const mandatory = `
|
|
955
|
+
html._access_cursor * {
|
|
956
|
+
cursor: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iTGF5ZXJfMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSIyOS4xODhweCIgaGVpZ2h0PSI0My42MjVweCIgdmlld0JveD0iMCAwIDI5LjE4OCA0My42MjUiIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDI5LjE4OCA0My42MjUiIHhtbDpzcGFjZT0icHJlc2VydmUiPjxnPjxwb2x5Z29uIGZpbGw9IiNGRkZGRkYiIHN0cm9rZT0iI0Q5REFEOSIgc3Ryb2tlLXdpZHRoPSIxLjE0MDYiIHN0cm9rZS1taXRlcmxpbWl0PSIxMCIgcG9pbnRzPSIyLjgsNC41NDkgMjYuODQ3LDE5LjkwMiAxNi45NjQsMjIuNzAxIDI0LjIzOSwzNy43NDkgMTguMjc4LDQyLjAxNyA5Ljc0MSwzMC43MjQgMS4xMzgsMzUuODA5ICIvPjxnPjxnPjxnPjxwYXRoIGZpbGw9IiMyMTI2MjciIGQ9Ik0yOS4xNzUsMjEuMTU1YzAuMDcxLTAuNjEzLTAuMTY1LTEuMjUzLTAuNjM1LTEuNTczTDIuMTY1LDAuMjU4Yy0wLjQyNC0wLjMyLTAuOTg4LTAuMzQ2LTEuNDM1LTAuMDUzQzAuMjgyLDAuNDk3LDAsMS4wMywwLDEuNjE3djM0LjE3MWMwLDAuNjEzLDAuMzA2LDEuMTQ2LDAuNzc2LDEuNDM5YzAuNDcxLDAuMjY3LDEuMDU5LDAuMjEzLDEuNDgyLTAuMTZsNy40ODItNi4zNDRsNi44NDcsMTIuMTU1YzAuMjU5LDAuNDgsMC43MjksMC43NDYsMS4yLDAuNzQ2YzAuMjM1LDAsMC40OTQtMC4wOCwwLjcwNi0wLjIxM2w2Ljk4OC00LjU4NWMwLjMyOS0wLjIxMywwLjU2NS0wLjU4NiwwLjY1OS0xLjAxM2MwLjA5NC0wLjQyNiwwLjAyNC0wLjg4LTAuMTg4LTEuMjI2bC02LjM3Ni0xMS4zODJsOC42MTEtMi43NDVDMjguNzA1LDIyLjI3NCwyOS4xMDUsMjEuNzY4LDI5LjE3NSwyMS4xNTV6IE0xNi45NjQsMjIuNzAxYy0wLjQyNCwwLjEzMy0wLjc3NiwwLjUwNi0wLjk0MSwwLjk2Yy0wLjE2NSwwLjQ4LTAuMTE4LDEuMDEzLDAuMTE4LDEuNDM5bDYuNTg4LDExLjc4MWwtNC41NDEsMi45ODVsLTYuODk0LTEyLjMxNWMtMC4yMTItMC4zNzMtMC41NDEtMC42NC0wLjk0MS0wLjcyYy0wLjA5NC0wLjAyNy0wLjE2NS0wLjAyNy0wLjI1OS0wLjAyN2MtMC4zMDYsMC0wLjU4OCwwLjEwNy0wLjg0NywwLjMyTDIuOCwzMi41OVY0LjU0OWwyMS41OTksMTUuODA2TDE2Ljk2NCwyMi43MDF6Ii8+PC9nPjwvZz48L2c+PC9nPjwvc3ZnPg==),auto!important;
|
|
957
|
+
}
|
|
958
|
+
@keyframes _access-dialog-backdrop {
|
|
959
|
+
0% { background: var(--_access-menu-dialog-backdrop-background-start, rgba(0,0,0,0.1)); }
|
|
960
|
+
100% { background: var(--_access-menu-dialog-backdrop-background-end, rgba(0,0,0,0.5)); }
|
|
961
|
+
}
|
|
962
|
+
dialog._access::backdrop, dialog._access {
|
|
963
|
+
transition-duration: var(--_access-menu-dialog-backdrop-transition-duration, 0.35s);
|
|
964
|
+
transition-timing-function: var(--_access-menu-dialog-backdrop-transition-timing-function, ease-in-out);
|
|
965
|
+
}
|
|
966
|
+
dialog._access:modal { border-color: transparent; border-width: 0; padding: 0; }
|
|
967
|
+
dialog._access[open]::backdrop {
|
|
968
|
+
background: var(--_access-menu-dialog-backdrop-background-end, rgba(0,0,0,0.5));
|
|
969
|
+
animation: _access-dialog-backdrop var(--_access-menu-dialog-backdrop-transition-duration, 0.35s) ease-in-out;
|
|
970
|
+
}
|
|
971
|
+
dialog._access.closing[open]::backdrop { background: var(--_access-menu-dialog-backdrop-background-start, rgba(0,0,0,0.1)); }
|
|
972
|
+
dialog._access.closing[open] { opacity: 0; }
|
|
973
|
+
.screen-reader-wrapper { margin: 0; position: absolute; bottom: -4px; width: calc(100% - 2px); left: 1px; }
|
|
974
|
+
.screen-reader-wrapper-step-1, .screen-reader-wrapper-step-2, .screen-reader-wrapper-step-3 {
|
|
975
|
+
float: left; background: var(--_access-menu-background-color, #fff);
|
|
976
|
+
width: 33.33%; height: 3px; border-radius: 10px;
|
|
977
|
+
}
|
|
978
|
+
.screen-reader-wrapper-step-1.active, .screen-reader-wrapper-step-2.active, .screen-reader-wrapper-step-3.active {
|
|
979
|
+
background: var(--_access-menu-item-button-background, #f9f9f9);
|
|
980
|
+
}
|
|
981
|
+
.access_read_guide_bar {
|
|
982
|
+
box-sizing: border-box;
|
|
983
|
+
background: var(--_access-menu-read-guide-bg, ${this.options.guide.cBackground});
|
|
984
|
+
width: 100%!important; min-width: 100%!important; position: fixed!important;
|
|
985
|
+
height: var(--_access-menu-read-guide-height, ${this.options.guide.height}) !important;
|
|
986
|
+
border: var(--_access-menu-read-guide-border, solid 3px ${this.options.guide.cBorder});
|
|
987
|
+
border-radius: 5px; top: 15px; z-index: 2147483647;
|
|
988
|
+
}`;
|
|
989
|
+
let css = mandatory;
|
|
990
|
+
if (injectFull) {
|
|
991
|
+
css = `
|
|
992
|
+
._access-scrollbar::-webkit-scrollbar-track { -webkit-box-shadow: var(--_access-scrollbar-track-box-shadow, inset 0 0 6px rgba(0,0,0,0.3)); background-color: var(--_access-scrollbar-track-background-color, #F5F5F5); }
|
|
993
|
+
._access-scrollbar::-webkit-scrollbar { width: var(--_access-scrollbar-width, 6px); background-color: var(--_access-scrollbar-background-color, #F5F5F5); }
|
|
994
|
+
._access-scrollbar::-webkit-scrollbar-thumb { background-color: var(--_access-scrollbar-thumb-background-color, #999999); }
|
|
995
|
+
._access-icon {
|
|
996
|
+
position: var(--_access-icon-position, fixed);
|
|
997
|
+
width: var(--_access-icon-width, 50px); height: var(--_access-icon-height, 50px);
|
|
998
|
+
bottom: var(--_access-icon-bottom, 80px); top: var(--_access-icon-top, unset);
|
|
999
|
+
left: var(--_access-icon-left, unset); right: var(--_access-icon-right, 10px);
|
|
1000
|
+
z-index: var(--_access-icon-z-index, 9999);
|
|
1001
|
+
font: var(--_access-icon-font, 40px / 45px "Material Icons");
|
|
1002
|
+
background: var(--_access-icon-bg, #4054b2); color: var(--_access-icon-color, #fff);
|
|
1003
|
+
background-repeat: no-repeat; background-size: contain;
|
|
1004
|
+
cursor: pointer; opacity: 0; transition-duration: .35s;
|
|
1005
|
+
user-select: none;
|
|
1006
|
+
${!useEmojis ? "box-shadow: 1px 1px 5px rgba(0,0,0,.5);" : ""}
|
|
1007
|
+
transform: ${!useEmojis ? "scale(1)" : "skewX(14deg)"};
|
|
1008
|
+
border-radius: 50%;
|
|
1009
|
+
border: 3px solid #FFFFFF;
|
|
1010
|
+
text-align: var(--_access-icon-text-align, center);
|
|
1011
|
+
display: flex; align-items: center; justify-content: center;
|
|
1012
|
+
}
|
|
1013
|
+
.content {
|
|
1014
|
+
display: flex;
|
|
1015
|
+
flex-direction: column;
|
|
1016
|
+
align-items: center;
|
|
1017
|
+
flex: 1;
|
|
1018
|
+
min-height: 0;
|
|
1019
|
+
border-top-left-radius: 20px;
|
|
1020
|
+
border-top-right-radius: 20px;
|
|
1021
|
+
padding: 30px 0px 20px;
|
|
1022
|
+
background: #F3F4F6;
|
|
1023
|
+
overflow-y: auto;
|
|
1024
|
+
}
|
|
1025
|
+
._access-icon:hover { transform: var(--_access-icon-transform-hover, scale(1.1)); }
|
|
1026
|
+
._access-menu {
|
|
1027
|
+
user-select: none; position: fixed;
|
|
1028
|
+
width: var(--_access-menu-width, ${_Accessibility.MENU_WIDTH});
|
|
1029
|
+
height: var(--_access-menu-height, auto);
|
|
1030
|
+
padding: 0px;
|
|
1031
|
+
display: flex;
|
|
1032
|
+
flex-direction: column;
|
|
1033
|
+
align-items: center;
|
|
1034
|
+
transition-duration: var(--_access-menu-transition-duration, .35s);
|
|
1035
|
+
z-index: var(--_access-menu-z-index, 99991); opacity: 1;
|
|
1036
|
+
background-color: var(--_access-menu-background-color, #F3F4F6);
|
|
1037
|
+
color: var(--_access-menu-color, #000);
|
|
1038
|
+
border-radius: var(--_access-menu-border-radius, 3px);
|
|
1039
|
+
font-family: var(--_access-menu-font-family, RobotoDraft, Roboto, sans-serif, Arial);
|
|
1040
|
+
min-width: var(--_access-menu-min-width, 300px);
|
|
1041
|
+
box-shadow: var(--_access-menu-box-shadow, -2px -2px 12px rgba(0, 0, 0, 0.2));
|
|
1042
|
+
height: 100%;
|
|
1043
|
+
${getComputedStyle(this._body).direction === "rtl" ? "text-indent: -5px" : ""}
|
|
1044
|
+
top: var(--_access-menu-top, unset); left: var(--_access-menu-left, unset);
|
|
1045
|
+
bottom: var(--_access-menu-bottom, 0); right: var(--_access-menu-right, 0);
|
|
1046
|
+
padding-bottom: 20px;
|
|
1047
|
+
word-spacing: normal; letter-spacing: normal; line-height: normal;
|
|
1048
|
+
overflow-y: auto;
|
|
1049
|
+
}
|
|
1050
|
+
@media (max-width: 600px) {
|
|
1051
|
+
._access-menu {
|
|
1052
|
+
height: 100vh !important; /* For\xE7a ocupar toda a altura */
|
|
1053
|
+
height: 100dvh !important; /* Corre\xE7\xE3o para navegadores mobile (Safari/Chrome) */
|
|
1054
|
+
max-height: 100dvh !important;
|
|
1055
|
+
overflow-y: auto; /* Permite rolar os bot\xF5es caso sumam da tela */
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
._access-menu.close {
|
|
1059
|
+
z-index: -1; width: 0; opacity: 0; background-color: transparent;
|
|
1060
|
+
right: calc(-1 * var(--_access-menu-width, ${_Accessibility.MENU_WIDTH}));
|
|
1061
|
+
}
|
|
1062
|
+
._access-menu ._text-center {
|
|
1063
|
+
font-size: var(--_access-menu-header-font-size, 22px);
|
|
1064
|
+
font-weight: var(--_access-menu-header-font-weight, bold);
|
|
1065
|
+
margin: var(--_access-menu-header-margin, 0px 0 -15px);
|
|
1066
|
+
padding: 40px 30px;
|
|
1067
|
+
color: var(--_access-menu-header-color, #FFFFFF);
|
|
1068
|
+
text-align: var(--_access-menu-header-text-align, left);
|
|
1069
|
+
background: #0048FF;
|
|
1070
|
+
width: 100%;
|
|
1071
|
+
display: flex;
|
|
1072
|
+
flex-direction: row-reverse;
|
|
1073
|
+
align-items: center;
|
|
1074
|
+
justify-content: space-between;
|
|
1075
|
+
gap: 8px;
|
|
1076
|
+
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
|
|
1080
|
+
._access-menu ._menu-close-btn {
|
|
1081
|
+
|
|
1082
|
+
padding: 10px;
|
|
1083
|
+
color: #FFFFFF;
|
|
1084
|
+
border-radius: 50%;
|
|
1085
|
+
transition: .3s ease;
|
|
1086
|
+
transform: rotate(0deg);
|
|
1087
|
+
-style: normal !important;
|
|
1088
|
+
background: #0d2f8a;
|
|
1089
|
+
blur: 1.2;
|
|
1090
|
+
cursor: pointer;
|
|
1091
|
+
font-size: 24px !important;
|
|
1092
|
+
font-weight: bold;
|
|
1093
|
+
align-self: flex-end;
|
|
1094
|
+
justify-self: flex-end;
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
@media (max-width: 765px) {
|
|
1098
|
+
._access-menu ._text-center {
|
|
1099
|
+
font-size: 18px;
|
|
1100
|
+
padding: 40px 20px;
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
._access-menu ._menu-close-btn {
|
|
1104
|
+
font-size: 18px;
|
|
1105
|
+
padding: 5px;
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
._access-menu ._menu-reset-btn {
|
|
1109
|
+
position: relative;
|
|
1110
|
+
width: 90%;
|
|
1111
|
+
padding: 15px;
|
|
1112
|
+
margin: 10px auto;
|
|
1113
|
+
background: #0048FF;
|
|
1114
|
+
color: #FFFFFF;
|
|
1115
|
+
border-radius: 10px;
|
|
1116
|
+
box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.5);
|
|
1117
|
+
cursor: pointer;
|
|
1118
|
+
font-style: normal !important;
|
|
1119
|
+
display: flex; align-items: center; justify-content: center; gap: 6px;
|
|
1120
|
+
}
|
|
1121
|
+
._access-menu ._menu-close-btn:hover { scale: 1.05; }
|
|
1122
|
+
._access-menu ._menu-reset-btn:hover { scale: 1.03; }
|
|
1123
|
+
|
|
1124
|
+
._access-menu ul {
|
|
1125
|
+
width: 90%;
|
|
1126
|
+
padding: 0 0 5px;
|
|
1127
|
+
position: relative;
|
|
1128
|
+
display: flex;
|
|
1129
|
+
flex-wrap: wrap;
|
|
1130
|
+
gap: 4px;
|
|
1131
|
+
font-size: var(--_access-menu-font-size, 18px);
|
|
1132
|
+
margin: 0;
|
|
1133
|
+
max-height: 100hv;
|
|
1134
|
+
background: #F3F4F6;
|
|
1135
|
+
}
|
|
1136
|
+
${mandatory}
|
|
1137
|
+
._access-menu ul li {
|
|
1138
|
+
width: 45%;
|
|
1139
|
+
min-height: 100px;
|
|
1140
|
+
position: relative;
|
|
1141
|
+
list-style-type: none;
|
|
1142
|
+
user-select: none;
|
|
1143
|
+
margin: 2px auto;
|
|
1144
|
+
font-size: var(--_access-menu-item-font-size, 18px) !important;
|
|
1145
|
+
line-height: var(--_access-menu-item-line-height, 18px) !important;
|
|
1146
|
+
color: var(--_access-menu-item-color, rgba(0,0,0,.8));
|
|
1147
|
+
}
|
|
1148
|
+
._access-menu ul li button {
|
|
1149
|
+
display: inline-flex;
|
|
1150
|
+
flex-direction: column;
|
|
1151
|
+
align-items: center;
|
|
1152
|
+
justify-content: center;
|
|
1153
|
+
background: var(--_access-menu-item-button-background, #FFFFFF);
|
|
1154
|
+
padding: 10px;
|
|
1155
|
+
gap: 8px;
|
|
1156
|
+
width: 100%;
|
|
1157
|
+
height: 100%;
|
|
1158
|
+
text-align: center;
|
|
1159
|
+
position: relative;
|
|
1160
|
+
transition-duration: var(--_access-menu-item-button-transition-duration, .35s);
|
|
1161
|
+
box-shadow: 4px 2px 1px rgba(0, 0, 0, 0.1);
|
|
1162
|
+
border-radius: var(--_access-menu-item-button-border-radius, 8px);
|
|
1163
|
+
cursor: pointer;
|
|
1164
|
+
}
|
|
1165
|
+
._access-menu ul li.position { display: inline-block; width: auto; }
|
|
1166
|
+
._access-menu ul.before-collapse li button { opacity: var(--_access-menu-item-button-before-collapse-opacity, 0.05); }
|
|
1167
|
+
._access-menu ul li button.active, ._access-menu ul li button.active:hover {
|
|
1168
|
+
border: 2px solid var(--_access-menu-item-button-active-border-color, #0048FF) !important;
|
|
1169
|
+
}
|
|
1170
|
+
._access-menu div.active { color: var(--_access-menu-div-active-color, #0048FF); }
|
|
1171
|
+
._access-menu ul li button.active, ._access-menu ul li button.active:hover, ._access-menu ul li button.active:before, ._access-menu ul li button.active:hover:before { color: var(--_access-menu-item-button-active-color, #0048FF); }
|
|
1172
|
+
._access-menu ul li button:hover {
|
|
1173
|
+
color: var(--_access-menu-item-button-hover-color, #003366);
|
|
1174
|
+
background-color: var(--_access-menu-item-button-hover-background-color, #FFFFFF);
|
|
1175
|
+
scale: 1.03;
|
|
1176
|
+
}
|
|
1177
|
+
._access-menu ul li.not-supported { display: none; }
|
|
1178
|
+
._access-menu ul li button:before {
|
|
1179
|
+
content: ' ';
|
|
1180
|
+
font-family: var(--_access-menu-button-font-family-before, ${this._fixedDefaultFont});
|
|
1181
|
+
text-rendering: optimizeLegibility;
|
|
1182
|
+
font-feature-settings: "liga" 1;
|
|
1183
|
+
font-style: normal;
|
|
1184
|
+
text-transform: none;
|
|
1185
|
+
line-height: ${!useEmojis ? "1" : "1.1"};
|
|
1186
|
+
font-size: ${!useEmojis ? "24px" : "20px"} !important;
|
|
1187
|
+
|
|
1188
|
+
/* Alinhamento corrigido */
|
|
1189
|
+
display: flex;
|
|
1190
|
+
align-items: center;
|
|
1191
|
+
justify-content: center;
|
|
1192
|
+
width: 20px;
|
|
1193
|
+
height: 20px;
|
|
1194
|
+
|
|
1195
|
+
-webkit-font-smoothing: antialiased;
|
|
1196
|
+
color: var(--_access-menu-item-icon-color, rgba(0,0,0,.6));
|
|
1197
|
+
direction: ltr;
|
|
1198
|
+
text-indent: 0;
|
|
1199
|
+
transition-duration: .35s;
|
|
1200
|
+
|
|
1201
|
+
}
|
|
1202
|
+
._access-menu ul li button svg path { fill: var(--_access-menu-item-icon-color, rgba(0,0,0,.8)); transition-duration: .35s; }
|
|
1203
|
+
._access-menu ul li button:hover svg path { fill: var(--_access-menu-item-hover-icon-color, #003366); }
|
|
1204
|
+
._access-menu ul li button.active svg path { fill: var(--_access-menu-item-active-icon-color, #0048FF); }
|
|
1205
|
+
._access-menu ul li:hover button:before { color: var(--_access-menu-item-hover-icon-color, #003366); }
|
|
1206
|
+
._access-menu ul li button[data-access-action="increaseText"]:before { content: var(--_access-menu-item-icon-increase-text, ${!useEmojis ? '"zoom_in"' : '"\u{1F53C}"'}); top: var(--_access-menu-item-icon-increase-text-top, ${iconTop}); left: var(--_access-menu-item-icon-increase-text-left, ${iconLeft}); }
|
|
1207
|
+
._access-menu ul li button[data-access-action="decreaseText"]:before { content: var(--_access-menu-item-icon-decrease-text, ${!useEmojis ? '"zoom_out"' : '"\u{1F53D}"'}); top: ${iconTop}; left: ${iconLeft}; }
|
|
1208
|
+
._access-menu ul li button[data-access-action="increaseTextSpacing"]:before { content: var(--_access-menu-item-icon-increase-text-spacing, ${!useEmojis ? '"unfold_more"' : '"\u{1F53C}"'}); transform: var(--_access-menu-item-icon-increase-text-spacing-transform, rotate(90deg) translate(-7px, 2px)); top: 14px; left: 0; }
|
|
1209
|
+
._access-menu ul li button[data-access-action="decreaseTextSpacing"]:before { content: var(--_access-menu-item-icon-decrease-text-spacing, ${!useEmojis ? '"unfold_less"' : '"\u{1F53D}"'}); transform: var(--_access-menu-item-icon-decrease-text-spacing-transform, rotate(90deg) translate(-7px, 2px)); top: 14px; left: 0; }
|
|
1210
|
+
._access-menu ul li button[data-access-action="invertColors"]:before { content: var(--_access-menu-item-icon-invert-colors, ${!useEmojis ? '"invert_colors"' : '"\u{1F386}"'}); top: ${iconTop}; left: ${iconLeft}; }
|
|
1211
|
+
._access-menu ul li button[data-access-action="grayHues"]:before { content: var(--_access-menu-item-icon-gray-hues, ${!useEmojis ? '"format_color_reset"' : '"\u{1F32B}\uFE0F"'}); top: ${iconTop}; left: ${iconLeft}; }
|
|
1212
|
+
._access-menu ul li button[data-access-action="underlineLinks"]:before { content: var(--_access-menu-item-icon-underline-links, ${!useEmojis ? '"format_underlined"' : '"\u{1F517}"'}); top: ${iconTop}; left: ${iconLeft}; }
|
|
1213
|
+
._access-menu ul li button[data-access-action="bigCursor"]:before { content: var(--_access-menu-item-icon-big-cursor, inherit); top: ${iconTop}; left: ${iconLeft}; }
|
|
1214
|
+
._access-menu ul li button[data-access-action="readingGuide"]:before { content: var(--_access-menu-item-icon-reading-guide, ${!useEmojis ? '"border_horizontal"' : '"\u2194\uFE0F"'}); top: ${iconTop}; left: ${iconLeft}; }
|
|
1215
|
+
._access-menu ul li button[data-access-action="textToSpeech"]:before { content: var(--_access-menu-item-icon-text-to-speech, ${!useEmojis ? '"record_voice_over"' : '"\u23FA\uFE0F"'}); top: ${iconTop}; left: ${iconLeft}; }
|
|
1216
|
+
._access-menu ul li button[data-access-action="speechToText"]:before { content: var(--_access-menu-item-icon-speech-to-text, ${!useEmojis ? '"mic"' : '"\u{1F3A4}"'}); top: ${iconTop}; left: ${iconLeft}; }
|
|
1217
|
+
._access-menu ul li button[data-access-action="disableAnimations"]:before { content: var(--_access-menu-item-icon-disable-animations, ${!useEmojis ? '"animation"' : '"\u{1F3C3}\u200D\u2642\uFE0F"'}); top: ${iconTop}; left: ${iconLeft}; }
|
|
1218
|
+
._access-menu ul li button[data-access-action="iframeModals"]:before { content: var(--_access-menu-item-icon-iframe-modals, ${!useEmojis ? '"policy"' : '"\u2696\uFE0F"'}); top: ${iconTop}; left: ${iconLeft}; }
|
|
1219
|
+
._access-menu ul li button[data-access-action="customFunctions"]:before { content: var(--_access-menu-item-icon-custom-functions, ${!useEmojis ? '"psychology_alt"' : '"\u2753"'}); top: ${iconTop}; left: ${iconLeft}; }
|
|
1220
|
+
._access-menu ul li button[data-access-action="increaseLineHeight"]:before { content: var(--_access-menu-item-icon-increase-line-height, ${!useEmojis ? '"unfold_more"' : '"\u{1F53C}"'}); top: ${iconTop}; left: ${iconLeft}; }
|
|
1221
|
+
._access-menu ul li button[data-access-action="decreaseLineHeight"]:before { content: var(--_access-menu-item-icon-decrease-line-height, ${!useEmojis ? '"unfold_less"' : '"\u{1F53D}"'}); top: ${iconTop}; left: ${iconLeft}; }
|
|
1222
|
+
._access-menu ul li button[data-access-action="dyslexicFont"]:before { content: var(--_access-menu-item-icon-dyslexic-font, ${!useEmojis ? '"font_download"' : '"\u{1F524}"'}); top: ${iconTop}; left: ${iconLeft}; }
|
|
1223
|
+
._access-menu ul li button[data-access-action="hideImages"]:before { content: var(--_access-menu-item-icon-hide-images, ${!useEmojis ? '"hide_image"' : '"\u{1F6AB}"'}); top: ${iconTop}; left: ${iconLeft}; }
|
|
1224
|
+
._access-menu-logo {
|
|
1225
|
+
display: block;
|
|
1226
|
+
max-width: 40%;
|
|
1227
|
+
margin: 8px auto 4px;
|
|
1228
|
+
object-fit: contain;
|
|
1229
|
+
}
|
|
1230
|
+
._access-cycle-indicator { position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%); display: flex; gap: 4px; }
|
|
1231
|
+
._access-cycle-indicator span { width: 16px; height: 3px; border-radius: 2px; background: #ccc; transition: background 0.2s; }
|
|
1232
|
+
._access-cycle-indicator span.filled { background: #0048FF; }
|
|
1233
|
+
`;
|
|
1234
|
+
}
|
|
1235
|
+
this._common.injectStyle(css, { className: _Accessibility.CSS_CLASS_NAME });
|
|
1236
|
+
this._common.deployedObjects.set(`.${_Accessibility.CSS_CLASS_NAME}`, false);
|
|
1237
|
+
}
|
|
1238
|
+
removeCSS() {
|
|
1239
|
+
var _a;
|
|
1240
|
+
(_a = document.querySelector(`.${_Accessibility.CSS_CLASS_NAME}`)) == null ? void 0 : _a.remove();
|
|
1241
|
+
}
|
|
1242
|
+
injectIcon() {
|
|
1243
|
+
const className = `_access-icon ${this.options.icon.fontClass} _access`;
|
|
1244
|
+
const iconElem = this._common.jsonToHtml({
|
|
1245
|
+
type: "i",
|
|
1246
|
+
attrs: {
|
|
1247
|
+
class: className,
|
|
1248
|
+
title: this.options.hotkeys.enabled ? this.parseKeys(this.options.hotkeys.keys.toggleMenu) : this.options.labels.menuTitle,
|
|
1249
|
+
tabIndex: "0"
|
|
1250
|
+
},
|
|
1251
|
+
children: [this.options.icon.imgElem]
|
|
1252
|
+
});
|
|
1253
|
+
this._body.appendChild(iconElem);
|
|
1254
|
+
this._common.deployedObjects.set("._access-icon", false);
|
|
1255
|
+
return iconElem;
|
|
1256
|
+
}
|
|
1257
|
+
parseKeys(arr) {
|
|
1258
|
+
if (!this.options.hotkeys.enabled) return "";
|
|
1259
|
+
if (!this.options.hotkeys.helpTitles) return "";
|
|
1260
|
+
return this.options.labels.hotkeyPrefix + arr.map((val) => Number.isInteger(val) ? String.fromCharCode(val).toLowerCase() : val.replace("Key", "")).join("+");
|
|
1261
|
+
}
|
|
1262
|
+
injectMenu() {
|
|
1263
|
+
var _a;
|
|
1264
|
+
const labels = this.options.labels;
|
|
1265
|
+
const hotkeys = this.options.hotkeys;
|
|
1266
|
+
const mods = (_a = this.options.modules) != null ? _a : {};
|
|
1267
|
+
const menuItems = [
|
|
1268
|
+
{ action: "increaseText", label: labels.increaseText },
|
|
1269
|
+
{ action: "decreaseText", label: labels.decreaseText },
|
|
1270
|
+
{ action: "increaseTextSpacing", label: labels.increaseTextSpacing },
|
|
1271
|
+
{ action: "decreaseTextSpacing", label: labels.decreaseTextSpacing },
|
|
1272
|
+
{ action: "increaseLineHeight", label: labels.increaseLineHeight },
|
|
1273
|
+
{ action: "decreaseLineHeight", label: labels.decreaseLineHeight },
|
|
1274
|
+
{ action: "invertColors", label: labels.invertColors, hotkey: hotkeys.keys.invertColors },
|
|
1275
|
+
{ action: "grayHues", label: labels.grayHues, hotkey: hotkeys.keys.grayHues },
|
|
1276
|
+
{ action: "underlineLinks", label: labels.underlineLinks, hotkey: hotkeys.keys.underlineLinks },
|
|
1277
|
+
{ action: "bigCursor", label: labels.bigCursor, hotkey: hotkeys.keys.bigCursor },
|
|
1278
|
+
{ action: "readingGuide", label: labels.readingGuide, hotkey: hotkeys.keys.readingGuide },
|
|
1279
|
+
{ action: "disableAnimations", label: labels.disableAnimations, hotkey: hotkeys.keys.disableAnimations },
|
|
1280
|
+
{ action: "dyslexicFont", label: labels.dyslexicFont },
|
|
1281
|
+
{ action: "hideImages", label: labels.hideImages }
|
|
1282
|
+
].filter(({ action }) => mods[action] !== false).map(({ action, label, hotkey }) => ({
|
|
1283
|
+
type: "li",
|
|
1284
|
+
children: [{
|
|
1285
|
+
type: "button",
|
|
1286
|
+
attrs: { "data-access-action": action, ...hotkey ? { title: this.parseKeys(hotkey) } : {} },
|
|
1287
|
+
children: [
|
|
1288
|
+
...action === "bigCursor" ? [{ type: "div", attrs: { id: "iconBigCursor" } }] : [],
|
|
1289
|
+
{ type: "#text", text: label }
|
|
1290
|
+
]
|
|
1291
|
+
}]
|
|
1292
|
+
}));
|
|
1293
|
+
const json = {
|
|
1294
|
+
type: "div",
|
|
1295
|
+
attrs: { class: "_access-menu close _access" },
|
|
1296
|
+
children: [
|
|
1297
|
+
{
|
|
1298
|
+
type: "div",
|
|
1299
|
+
attrs: { class: "_text-center", role: "presentation" },
|
|
1300
|
+
children: [
|
|
1301
|
+
{
|
|
1302
|
+
type: "button",
|
|
1303
|
+
attrs: { class: `_menu-close-btn _menu-btn ${this.options.icon.fontClass}`, style: `font-family: var(--_access-menu-close-btn-font-family, ${this._fixedDefaultFont})`, title: hotkeys.enabled ? this.parseKeys(hotkeys.keys.toggleMenu) : labels.closeTitle },
|
|
1304
|
+
children: [this.options.icon.closeIconElem]
|
|
1305
|
+
},
|
|
1306
|
+
{ type: "#text", text: labels.menuTitle }
|
|
1307
|
+
]
|
|
1308
|
+
},
|
|
1309
|
+
{
|
|
1310
|
+
type: "div",
|
|
1311
|
+
attrs: { class: "content" },
|
|
1312
|
+
children: [
|
|
1313
|
+
{ type: "ul", attrs: { class: "before-collapse _access-scrollbar" }, children: menuItems },
|
|
1314
|
+
{
|
|
1315
|
+
type: "button",
|
|
1316
|
+
attrs: { class: "_menu-reset-btn", title: labels.resetTitle },
|
|
1317
|
+
children: [
|
|
1318
|
+
{ type: "span", attrs: { class: this.options.icon.fontClass, style: `font-family: var(--_access-menu-reset-btn-font-family, ${this._fixedDefaultFont}); font-size: 18px; line-height: 1;` }, children: [this.options.icon.resetIconElem] },
|
|
1319
|
+
{ type: "span", children: [{ type: "#text", text: labels.resetTitle }] }
|
|
1320
|
+
]
|
|
1321
|
+
}
|
|
1322
|
+
]
|
|
1323
|
+
},
|
|
1324
|
+
...this.options.logoImage ? [{
|
|
1325
|
+
type: "img",
|
|
1326
|
+
attrs: { src: this.options.logoImage, alt: "", class: "_access-menu-logo" }
|
|
1327
|
+
}] : []
|
|
1328
|
+
]
|
|
1329
|
+
};
|
|
1330
|
+
if (this.options.iframeModals) {
|
|
1331
|
+
this.options.iframeModals.forEach((im, i) => {
|
|
1332
|
+
var _a2, _b;
|
|
1333
|
+
const btn = {
|
|
1334
|
+
type: "li",
|
|
1335
|
+
children: [{
|
|
1336
|
+
type: "button",
|
|
1337
|
+
attrs: { "data-access-action": "iframeModals", "data-access-url": im.iframeUrl },
|
|
1338
|
+
children: [{ type: "#text", text: im.buttonText }]
|
|
1339
|
+
}]
|
|
1340
|
+
};
|
|
1341
|
+
const icon = im.icon && !((_a2 = this.options.icon) == null ? void 0 : _a2.useEmojis) ? im.icon : im.emoji && ((_b = this.options.icon) == null ? void 0 : _b.useEmojis) ? im.emoji : null;
|
|
1342
|
+
if (icon) {
|
|
1343
|
+
btn.children[0].attrs["data-access-iframe-index"] = String(i);
|
|
1344
|
+
const className = "_data-access-iframe-index-" + i;
|
|
1345
|
+
this._common.injectStyle(`._access-menu ul li button[data-access-action="iframeModals"][data-access-iframe-index="${i}"]:before { content: "${icon}"; }`, { className });
|
|
1346
|
+
this._common.deployedObjects.set("." + className, false);
|
|
1347
|
+
}
|
|
1348
|
+
const ul = json.children[1].children[0];
|
|
1349
|
+
if (this.options.modules.textToSpeech) ul.children.splice(ul.children.length - 2, 0, btn);
|
|
1350
|
+
else ul.children.push(btn);
|
|
1351
|
+
});
|
|
1352
|
+
}
|
|
1353
|
+
if (this.options.customFunctions) {
|
|
1354
|
+
this.options.customFunctions.forEach((cf, i) => {
|
|
1355
|
+
var _a2, _b;
|
|
1356
|
+
const btn = {
|
|
1357
|
+
type: "li",
|
|
1358
|
+
children: [{
|
|
1359
|
+
type: "button",
|
|
1360
|
+
attrs: { "data-access-action": "customFunctions", "data-access-custom-id": cf.id, "data-access-custom-index": String(i) },
|
|
1361
|
+
children: [{ type: "#text", text: cf.buttonText }]
|
|
1362
|
+
}]
|
|
1363
|
+
};
|
|
1364
|
+
const icon = cf.icon && !((_a2 = this.options.icon) == null ? void 0 : _a2.useEmojis) ? cf.icon : cf.emoji && ((_b = this.options.icon) == null ? void 0 : _b.useEmojis) ? cf.emoji : null;
|
|
1365
|
+
if (icon) {
|
|
1366
|
+
const className = "_data-access-custom-id-" + cf.id;
|
|
1367
|
+
this._common.injectStyle(`._access-menu ul li button[data-access-action="customFunctions"][data-access-custom-id="${cf.id}"]:before { content: "${icon}"; }`, { className });
|
|
1368
|
+
this._common.deployedObjects.set("." + className, false);
|
|
1369
|
+
}
|
|
1370
|
+
const ul = json.children[1].children[0];
|
|
1371
|
+
if (this.options.modules.textToSpeech) ul.children.splice(ul.children.length - 2, 0, btn);
|
|
1372
|
+
else ul.children.push(btn);
|
|
1373
|
+
});
|
|
1374
|
+
}
|
|
1375
|
+
const menuElem = this._common.jsonToHtml(json);
|
|
1376
|
+
this._body.appendChild(menuElem);
|
|
1377
|
+
setTimeout(() => {
|
|
1378
|
+
var _a2;
|
|
1379
|
+
const ic = document.getElementById("iconBigCursor");
|
|
1380
|
+
if (ic) {
|
|
1381
|
+
ic.outerHTML += '<svg version="1.1" id="iconBigCursorSvg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style="position:absolute;width:19px;height:19px;top:9px;left:9px" xml:space="preserve"><path d="M 423.547 323.115 l -320 -320 c -3.051 -3.051 -7.637 -3.947 -11.627 -2.304 s -6.592 5.547 -6.592 9.856 V 480 c 0 4.501 2.837 8.533 7.083 10.048 c 4.224 1.536 8.981 0.192 11.84 -3.285 l 85.205 -104.128 l 56.853 123.179 c 1.792 3.883 5.653 6.187 9.685 6.187 c 1.408 0 2.837 -0.277 4.203 -0.875 l 74.667 -32 c 2.645 -1.131 4.736 -3.285 5.76 -5.973 c 1.024 -2.688 0.939 -5.675 -0.277 -8.299 l -57.024 -123.52 h 132.672 c 4.309 0 8.213 -2.603 9.856 -6.592 C 427.515 330.752 426.598 326.187 423.547 323.115 Z"/></svg>';
|
|
1382
|
+
(_a2 = document.getElementById("iconBigCursor")) == null ? void 0 : _a2.remove();
|
|
1383
|
+
}
|
|
1384
|
+
}, 1);
|
|
1385
|
+
this._common.deployedObjects.set("._access-menu", false);
|
|
1386
|
+
const addToggleListener = (el, handler) => {
|
|
1387
|
+
el == null ? void 0 : el.addEventListener("click", () => handler(), false);
|
|
1388
|
+
el == null ? void 0 : el.addEventListener("keyup", (e) => {
|
|
1389
|
+
if (e.key === "Enter") handler();
|
|
1390
|
+
}, false);
|
|
1391
|
+
};
|
|
1392
|
+
addToggleListener(menuElem.querySelector("._menu-close-btn"), () => this.toggleMenu());
|
|
1393
|
+
addToggleListener(menuElem.querySelector("._menu-reset-btn"), () => this.resetAll());
|
|
1394
|
+
return menuElem;
|
|
1395
|
+
}
|
|
1396
|
+
getVoices() {
|
|
1397
|
+
return new Promise((resolve) => {
|
|
1398
|
+
const synth = window.speechSynthesis;
|
|
1399
|
+
const id = setInterval(() => {
|
|
1400
|
+
if (synth.getVoices().length !== 0) {
|
|
1401
|
+
resolve(synth.getVoices());
|
|
1402
|
+
clearInterval(id);
|
|
1403
|
+
}
|
|
1404
|
+
}, 10);
|
|
1405
|
+
});
|
|
1406
|
+
}
|
|
1407
|
+
async injectTts() {
|
|
1408
|
+
const voices = await this.getVoices();
|
|
1409
|
+
const targetLang = this.options.language.textToSpeechLang.toLowerCase();
|
|
1410
|
+
const isLngSupported = !targetLang || voices.some(
|
|
1411
|
+
(v) => v.lang.toLowerCase() === targetLang || v.lang.toLowerCase().startsWith(targetLang.split("-")[0])
|
|
1412
|
+
);
|
|
1413
|
+
if (!isLngSupported) return;
|
|
1414
|
+
const tts = this.common.jsonToHtml({
|
|
1415
|
+
type: "li",
|
|
1416
|
+
children: [{
|
|
1417
|
+
type: "button",
|
|
1418
|
+
attrs: { "data-access-action": "textToSpeech", title: this.parseKeys(this.options.hotkeys.keys.textToSpeech) },
|
|
1419
|
+
children: [
|
|
1420
|
+
{ type: "#text", text: this.options.labels.textToSpeech },
|
|
1421
|
+
{
|
|
1422
|
+
type: "div",
|
|
1423
|
+
attrs: { class: "screen-reader-wrapper" },
|
|
1424
|
+
children: [
|
|
1425
|
+
{ type: "div", attrs: { class: "screen-reader-wrapper-step-1", tabIndex: "-1" } },
|
|
1426
|
+
{ type: "div", attrs: { class: "screen-reader-wrapper-step-2", tabIndex: "-1" } },
|
|
1427
|
+
{ type: "div", attrs: { class: "screen-reader-wrapper-step-3", tabIndex: "-1" } }
|
|
1428
|
+
]
|
|
1429
|
+
}
|
|
1430
|
+
]
|
|
1431
|
+
}]
|
|
1432
|
+
});
|
|
1433
|
+
const sts = this.common.jsonToHtml({
|
|
1434
|
+
type: "li",
|
|
1435
|
+
children: [{
|
|
1436
|
+
type: "button",
|
|
1437
|
+
attrs: { "data-access-action": "speechToText", title: this.parseKeys(this.options.hotkeys.keys.speechToText) },
|
|
1438
|
+
children: [{ type: "#text", text: this.options.labels.speechToText }]
|
|
1439
|
+
}]
|
|
1440
|
+
});
|
|
1441
|
+
const ul = this._menu.querySelector("ul");
|
|
1442
|
+
ul.appendChild(sts);
|
|
1443
|
+
ul.appendChild(tts);
|
|
1444
|
+
}
|
|
1445
|
+
addListeners() {
|
|
1446
|
+
this._menu.querySelectorAll("ul li").forEach((li) => {
|
|
1447
|
+
["click", "keyup"].forEach(
|
|
1448
|
+
(evt) => li.addEventListener(evt, (e) => {
|
|
1449
|
+
const ev = e || window.event;
|
|
1450
|
+
if (ev.detail === 0 && ev.key !== "Enter") return;
|
|
1451
|
+
const actionEl = ev.target.closest("[data-access-action]");
|
|
1452
|
+
if (!actionEl) return;
|
|
1453
|
+
this.invoke(actionEl.getAttribute("data-access-action"), actionEl);
|
|
1454
|
+
})
|
|
1455
|
+
);
|
|
1456
|
+
});
|
|
1457
|
+
[
|
|
1458
|
+
...Array.from(this._menu.getElementsByClassName("screen-reader-wrapper-step-1")),
|
|
1459
|
+
...Array.from(this._menu.getElementsByClassName("screen-reader-wrapper-step-2")),
|
|
1460
|
+
...Array.from(this._menu.getElementsByClassName("screen-reader-wrapper-step-3"))
|
|
1461
|
+
].forEach(
|
|
1462
|
+
(el) => el.addEventListener("click", (e) => {
|
|
1463
|
+
const action = e.target.parentElement.parentElement.getAttribute("data-access-action");
|
|
1464
|
+
this.invoke(action, e.target);
|
|
1465
|
+
}, false)
|
|
1466
|
+
);
|
|
1467
|
+
}
|
|
1468
|
+
sortModuleTypes() {
|
|
1469
|
+
this.options.modulesOrder.sort((a, b) => a.order - b.order);
|
|
1470
|
+
}
|
|
1471
|
+
disableUnsupportedModulesAndSort() {
|
|
1472
|
+
this.sortModuleTypes();
|
|
1473
|
+
const ul = this._menu.querySelector("ul");
|
|
1474
|
+
this.options.modulesOrder.forEach((item) => {
|
|
1475
|
+
const module = AccessibilityModulesType[item.type];
|
|
1476
|
+
const enabled = this.options.modules[module];
|
|
1477
|
+
const btn = this._menu.querySelector(`button[data-access-action="${module}"]`);
|
|
1478
|
+
if (btn) {
|
|
1479
|
+
btn.parentElement.remove();
|
|
1480
|
+
ul.appendChild(btn.parentElement);
|
|
1481
|
+
if (!enabled) btn.parentElement.classList.add("not-supported");
|
|
1482
|
+
}
|
|
1483
|
+
});
|
|
1484
|
+
}
|
|
1485
|
+
resetAll() {
|
|
1486
|
+
this.menuInterface.textToSpeech(true);
|
|
1487
|
+
this.menuInterface.speechToText(true);
|
|
1488
|
+
this.menuInterface.disableAnimations(true);
|
|
1489
|
+
this.menuInterface.underlineLinks(true);
|
|
1490
|
+
this.menuInterface.grayHues(true);
|
|
1491
|
+
this.menuInterface.invertColors(true);
|
|
1492
|
+
this.menuInterface.bigCursor(true);
|
|
1493
|
+
this.menuInterface.readingGuide(true);
|
|
1494
|
+
this.menuInterface.dyslexicFont(true);
|
|
1495
|
+
this.menuInterface.hideImages(true);
|
|
1496
|
+
this.resetTextSize();
|
|
1497
|
+
this.resetTextSpace();
|
|
1498
|
+
this.resetLineHeight();
|
|
1499
|
+
this.menuInterface.refreshCycleButtons();
|
|
1500
|
+
}
|
|
1501
|
+
resetTextSize() {
|
|
1502
|
+
this.resetIfDefined(this._stateValues.body.fontSize, this._body.style, "fontSize");
|
|
1503
|
+
if (typeof this._htmlOrgFontSize !== "undefined") this._html.style.fontSize = this._htmlOrgFontSize;
|
|
1504
|
+
document.querySelectorAll("[data-init-font-size]").forEach((el) => {
|
|
1505
|
+
el.style.fontSize = el.getAttribute("data-init-font-size");
|
|
1506
|
+
el.removeAttribute("data-init-font-size");
|
|
1507
|
+
});
|
|
1508
|
+
this._sessionState.textSize = 0;
|
|
1509
|
+
this.onChange(true);
|
|
1510
|
+
}
|
|
1511
|
+
resetLineHeight() {
|
|
1512
|
+
this.resetIfDefined(this._stateValues.body.lineHeight, this.body.style, "lineHeight");
|
|
1513
|
+
document.querySelectorAll("[data-init-line-height]").forEach((el) => {
|
|
1514
|
+
el.style.lineHeight = el.getAttribute("data-init-line-height");
|
|
1515
|
+
el.removeAttribute("data-init-line-height");
|
|
1516
|
+
});
|
|
1517
|
+
this.sessionState.lineHeight = 0;
|
|
1518
|
+
this.onChange(true);
|
|
1519
|
+
}
|
|
1520
|
+
resetTextSpace() {
|
|
1521
|
+
this.resetIfDefined(this._stateValues.body.wordSpacing, this._body.style, "wordSpacing");
|
|
1522
|
+
this.resetIfDefined(this._stateValues.body.letterSpacing, this._body.style, "letterSpacing");
|
|
1523
|
+
document.querySelectorAll("[data-init-word-spacing]").forEach((el) => {
|
|
1524
|
+
el.style.wordSpacing = el.getAttribute("data-init-word-spacing");
|
|
1525
|
+
el.removeAttribute("data-init-word-spacing");
|
|
1526
|
+
});
|
|
1527
|
+
document.querySelectorAll("[data-init-letter-spacing]").forEach((el) => {
|
|
1528
|
+
el.style.letterSpacing = el.getAttribute("data-init-letter-spacing");
|
|
1529
|
+
el.removeAttribute("data-init-letter-spacing");
|
|
1530
|
+
});
|
|
1531
|
+
this._sessionState.textSpace = 0;
|
|
1532
|
+
this.onChange(true);
|
|
1533
|
+
}
|
|
1534
|
+
alterTextSize(isIncrease) {
|
|
1535
|
+
this._sessionState.textSize += isIncrease ? 1 : -1;
|
|
1536
|
+
this.onChange(true);
|
|
1537
|
+
let factor = this.options.textSizeFactor * (isIncrease ? 1 : -1);
|
|
1538
|
+
if (this.options.textPixelMode) {
|
|
1539
|
+
const excludeSize = Array.from(document.querySelectorAll("._access *"));
|
|
1540
|
+
document.querySelectorAll("*:not(._access)").forEach((el) => {
|
|
1541
|
+
if (excludeSize.includes(el)) return;
|
|
1542
|
+
const fSize = getComputedStyle(el).fontSize;
|
|
1543
|
+
if (fSize == null ? void 0 : fSize.includes("px")) {
|
|
1544
|
+
if (!el.getAttribute("data-init-font-size")) el.setAttribute("data-init-font-size", fSize);
|
|
1545
|
+
el.style.fontSize = parseInt(fSize) + factor + "px";
|
|
1546
|
+
}
|
|
1547
|
+
});
|
|
1548
|
+
const bodyFs = getComputedStyle(this._body).fontSize;
|
|
1549
|
+
if (bodyFs == null ? void 0 : bodyFs.includes("px")) {
|
|
1550
|
+
if (!this._body.getAttribute("data-init-font-size")) this._body.setAttribute("data-init-font-size", bodyFs);
|
|
1551
|
+
this._body.style.fontSize = parseInt(bodyFs) + factor + "px";
|
|
1552
|
+
}
|
|
1553
|
+
} else if (this.options.textEmlMode) {
|
|
1554
|
+
const fp = this._html.style.fontSize;
|
|
1555
|
+
if (fp.includes("%")) this._html.style.fontSize = parseInt(fp) + factor + "%";
|
|
1556
|
+
else this._common.warn("textEmlMode: html element font-size is not in %.");
|
|
1557
|
+
} else {
|
|
1558
|
+
const fSize = this._common.getFormattedDim(getComputedStyle(this._body).fontSize);
|
|
1559
|
+
if (typeof this._stateValues.body.fontSize === "undefined")
|
|
1560
|
+
this._stateValues.body.fontSize = fSize.size + fSize.suffix;
|
|
1561
|
+
if (fSize == null ? void 0 : fSize.suffix) this._body.style.fontSize = fSize.size + factor + fSize.suffix;
|
|
1562
|
+
}
|
|
1563
|
+
if (this._stateValues.textToSpeech) this.textToSpeech(`Text Size ${isIncrease ? "Increased" : "Decreased"}`);
|
|
1564
|
+
}
|
|
1565
|
+
alterLineHeight(isIncrease) {
|
|
1566
|
+
this.sessionState.lineHeight += isIncrease ? 1 : -1;
|
|
1567
|
+
this.onChange(true);
|
|
1568
|
+
let factor = (isIncrease ? 1 : -1) * (this.options.textEmlMode ? 20 : 2);
|
|
1569
|
+
const exclude = Array.from(document.querySelectorAll("._access *"));
|
|
1570
|
+
document.querySelectorAll("*:not(._access)").forEach((el) => {
|
|
1571
|
+
if (exclude.includes(el)) return;
|
|
1572
|
+
if (this.options.textPixelMode) {
|
|
1573
|
+
const lh = getComputedStyle(el).lineHeight;
|
|
1574
|
+
if (lh == null ? void 0 : lh.includes("px")) {
|
|
1575
|
+
if (!el.getAttribute("data-init-line-height")) el.setAttribute("data-init-line-height", lh);
|
|
1576
|
+
el.style.lineHeight = parseInt(lh) + factor + "px";
|
|
1577
|
+
}
|
|
1578
|
+
} else if (this.options.textEmlMode) {
|
|
1579
|
+
let lh = getComputedStyle(el).lineHeight;
|
|
1580
|
+
const fs = getComputedStyle(el).fontSize;
|
|
1581
|
+
if (lh === "normal") lh = parseInt(fs) * 1.2 + "px";
|
|
1582
|
+
if (lh == null ? void 0 : lh.includes("px")) {
|
|
1583
|
+
const pct = parseInt(lh) * 100 / parseInt(fs);
|
|
1584
|
+
if (!el.getAttribute("data-init-line-height")) el.setAttribute("data-init-line-height", pct + "%");
|
|
1585
|
+
el.style.lineHeight = pct + factor + "%";
|
|
1586
|
+
}
|
|
1587
|
+
if (typeof this._stateValues.body.lineHeight === "undefined") this._stateValues.body.lineHeight = "";
|
|
1588
|
+
}
|
|
1589
|
+
});
|
|
1590
|
+
if (this._stateValues.textToSpeech) this.textToSpeech(`Line Height ${isIncrease ? "Increased" : "Decreased"}`);
|
|
1591
|
+
}
|
|
1592
|
+
alterTextSpace(isIncrease) {
|
|
1593
|
+
this._sessionState.textSpace += isIncrease ? 1 : -1;
|
|
1594
|
+
this.onChange(true);
|
|
1595
|
+
const factor = isIncrease ? 2 : -2;
|
|
1596
|
+
if (this.options.textPixelMode) {
|
|
1597
|
+
const exclude = Array.from(document.querySelectorAll("._access *"));
|
|
1598
|
+
document.querySelectorAll("*:not(._access)").forEach((el) => {
|
|
1599
|
+
if (exclude.includes(el)) return;
|
|
1600
|
+
const ws = el.style.wordSpacing;
|
|
1601
|
+
if (!el.getAttribute("data-init-word-spacing")) el.setAttribute("data-init-word-spacing", ws);
|
|
1602
|
+
el.style.wordSpacing = (ws == null ? void 0 : ws.includes("px")) ? parseInt(ws) + factor + "px" : factor + "px";
|
|
1603
|
+
const ls = el.style.letterSpacing;
|
|
1604
|
+
if (!el.getAttribute("data-init-letter-spacing")) el.setAttribute("data-init-letter-spacing", ls);
|
|
1605
|
+
el.style.letterSpacing = (ls == null ? void 0 : ls.includes("px")) ? parseInt(ls) + factor + "px" : factor + "px";
|
|
1606
|
+
});
|
|
1607
|
+
} else {
|
|
1608
|
+
const ws = this._common.getFormattedDim(getComputedStyle(this._body).wordSpacing);
|
|
1609
|
+
if (typeof this._stateValues.body.wordSpacing === "undefined") this._stateValues.body.wordSpacing = "";
|
|
1610
|
+
if (ws == null ? void 0 : ws.suffix) this._body.style.wordSpacing = ws.size * 1 + factor + ws.suffix;
|
|
1611
|
+
const ls = this._common.getFormattedDim(getComputedStyle(this._body).letterSpacing);
|
|
1612
|
+
if (typeof this._stateValues.body.letterSpacing === "undefined") this._stateValues.body.letterSpacing = "";
|
|
1613
|
+
if (ls == null ? void 0 : ls.suffix) this._body.style.letterSpacing = ls.size * 1 + factor + ls.suffix;
|
|
1614
|
+
}
|
|
1615
|
+
if (this._stateValues.textToSpeech) this.textToSpeech(`Text Spacing ${isIncrease ? "Increased" : "Decreased"}`);
|
|
1616
|
+
}
|
|
1617
|
+
speechToText() {
|
|
1618
|
+
const SR = window.SpeechRecognition || window.webkitSpeechRecognition;
|
|
1619
|
+
if (!SR) return;
|
|
1620
|
+
this._recognition = new SR();
|
|
1621
|
+
this._recognition.continuous = true;
|
|
1622
|
+
this._recognition.interimResults = true;
|
|
1623
|
+
this._recognition.onstart = () => this._body.classList.add("_access-listening");
|
|
1624
|
+
this._recognition.onend = () => this._body.classList.remove("_access-listening");
|
|
1625
|
+
this._recognition.onresult = (event) => {
|
|
1626
|
+
if (typeof event.results === "undefined") return;
|
|
1627
|
+
let final = "";
|
|
1628
|
+
for (let i = event.resultIndex; i < event.results.length; ++i)
|
|
1629
|
+
if (event.results[i].isFinal) final += event.results[i][0].transcript;
|
|
1630
|
+
if (final && this._speechToTextTarget) {
|
|
1631
|
+
this._speechToTextTarget.parentElement.classList.remove("_access-listening");
|
|
1632
|
+
const tag = this._speechToTextTarget.tagName.toLowerCase();
|
|
1633
|
+
if (tag === "input" || tag === "textarea")
|
|
1634
|
+
this._speechToTextTarget.value = final;
|
|
1635
|
+
else if (this._speechToTextTarget.getAttribute("contenteditable") !== null)
|
|
1636
|
+
this._speechToTextTarget.innerText = final;
|
|
1637
|
+
}
|
|
1638
|
+
};
|
|
1639
|
+
this._recognition.lang = this.options.language.speechToTextLang;
|
|
1640
|
+
this._recognition.start();
|
|
1641
|
+
}
|
|
1642
|
+
textToSpeech(text) {
|
|
1643
|
+
const w = window;
|
|
1644
|
+
if (!w.SpeechSynthesisUtterance || !w.speechSynthesis) return;
|
|
1645
|
+
const msg = new w.SpeechSynthesisUtterance(text);
|
|
1646
|
+
msg.lang = this.options.language.textToSpeechLang;
|
|
1647
|
+
msg.rate = this._stateValues.speechRate;
|
|
1648
|
+
msg.onend = () => {
|
|
1649
|
+
this._isReading = false;
|
|
1650
|
+
};
|
|
1651
|
+
const voices = w.speechSynthesis.getVoices();
|
|
1652
|
+
const voice = voices.find((v) => v.lang === msg.lang);
|
|
1653
|
+
if (voice) msg.voice = voice;
|
|
1654
|
+
else this._common.warn("text to speech language not supported!");
|
|
1655
|
+
if (window.speechSynthesis.pending || window.speechSynthesis.speaking) window.speechSynthesis.cancel();
|
|
1656
|
+
window.speechSynthesis.speak(msg);
|
|
1657
|
+
this._isReading = true;
|
|
1658
|
+
}
|
|
1659
|
+
createScreenShot(url) {
|
|
1660
|
+
return this._common.createScreenshot(url);
|
|
1661
|
+
}
|
|
1662
|
+
listen() {
|
|
1663
|
+
var _a, _b, _c;
|
|
1664
|
+
(_b = (_a = this._recognition) == null ? void 0 : _a.stop) == null ? void 0 : _b.call(_a);
|
|
1665
|
+
this._speechToTextTarget = (_c = window.event) == null ? void 0 : _c.target;
|
|
1666
|
+
this.speechToText();
|
|
1667
|
+
}
|
|
1668
|
+
read(e) {
|
|
1669
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1670
|
+
try {
|
|
1671
|
+
e = window.event || e;
|
|
1672
|
+
(_a = e == null ? void 0 : e.preventDefault) == null ? void 0 : _a.call(e);
|
|
1673
|
+
(_b = e == null ? void 0 : e.stopPropagation) == null ? void 0 : _b.call(e);
|
|
1674
|
+
} catch (e2) {
|
|
1675
|
+
}
|
|
1676
|
+
const menuEls = Array.from(document.querySelectorAll("._access-menu *"));
|
|
1677
|
+
if (menuEls.includes((_c = window.event) == null ? void 0 : _c.target) && e instanceof MouseEvent) return;
|
|
1678
|
+
if (e instanceof KeyboardEvent && (e.shiftKey && e.key === "Tab" || e.key === "Tab")) {
|
|
1679
|
+
this.textToSpeech((_e = (_d = window.event) == null ? void 0 : _d.target) == null ? void 0 : _e.innerText);
|
|
1680
|
+
return;
|
|
1681
|
+
}
|
|
1682
|
+
if (this._isReading) {
|
|
1683
|
+
window.speechSynthesis.cancel();
|
|
1684
|
+
this._isReading = false;
|
|
1685
|
+
} else this.textToSpeech((_g = (_f = window.event) == null ? void 0 : _f.target) == null ? void 0 : _g.innerText);
|
|
1686
|
+
}
|
|
1687
|
+
runHotkey(name) {
|
|
1688
|
+
if (name === "toggleMenu") {
|
|
1689
|
+
this.toggleMenu();
|
|
1690
|
+
return;
|
|
1691
|
+
}
|
|
1692
|
+
if (typeof this.menuInterface[name] === "function" && this._options.modules[name])
|
|
1693
|
+
this.menuInterface[name](false);
|
|
1694
|
+
}
|
|
1695
|
+
toggleMenu() {
|
|
1696
|
+
const shouldClose = this._menu.classList.contains("close");
|
|
1697
|
+
setTimeout(() => this._menu.querySelector("ul").classList.toggle("before-collapse"), shouldClose ? 10 : 500);
|
|
1698
|
+
this._menu.classList.toggle("close");
|
|
1699
|
+
this.options.icon.tabIndex = shouldClose ? 0 : -1;
|
|
1700
|
+
this._menu.childNodes.forEach((child) => {
|
|
1701
|
+
if (child.hasChildNodes() && child.nodeType === Node.ELEMENT_NODE && child.tagName === "P")
|
|
1702
|
+
child.tabIndex = -1;
|
|
1703
|
+
});
|
|
1704
|
+
}
|
|
1705
|
+
invoke(action, button) {
|
|
1706
|
+
if (typeof this.menuInterface[action] === "function")
|
|
1707
|
+
this.menuInterface[action](void 0, button);
|
|
1708
|
+
}
|
|
1709
|
+
onKeyDown(e) {
|
|
1710
|
+
const act = Object.entries(this.options.hotkeys.keys).find(
|
|
1711
|
+
([, keys]) => keys.every((k) => Number.isInteger(k) ? e.keyCode === k : e[k] === true)
|
|
1712
|
+
);
|
|
1713
|
+
if (act) this.runHotkey(act[0]);
|
|
1714
|
+
}
|
|
1715
|
+
build() {
|
|
1716
|
+
this._stateValues = { underlineLinks: false, textToSpeech: false, bigCursor: false, readingGuide: false, speechRate: 1, body: {}, html: {} };
|
|
1717
|
+
this._body = document.body;
|
|
1718
|
+
this._html = document.documentElement;
|
|
1719
|
+
if (this.options.textEmlMode) this.initFontSize();
|
|
1720
|
+
this.injectCss(!this.options.suppressCssInjection && !this.options.suppressDomInjection);
|
|
1721
|
+
if (!this.options.suppressDomInjection) {
|
|
1722
|
+
this._icon = this.injectIcon();
|
|
1723
|
+
this._menu = this.injectMenu();
|
|
1724
|
+
this.injectTts();
|
|
1725
|
+
setTimeout(() => {
|
|
1726
|
+
this.addListeners();
|
|
1727
|
+
this.disableUnsupportedModulesAndSort();
|
|
1728
|
+
}, 10);
|
|
1729
|
+
if (this.options.hotkeys.enabled) document.addEventListener("keydown", this._onKeyDownBind, false);
|
|
1730
|
+
this._icon.addEventListener("click", () => this.toggleMenu(), false);
|
|
1731
|
+
this._icon.addEventListener("keyup", (e) => {
|
|
1732
|
+
if (e.key === "Enter") this.toggleMenu();
|
|
1733
|
+
}, false);
|
|
1734
|
+
setTimeout(() => {
|
|
1735
|
+
this._icon.style.opacity = "1";
|
|
1736
|
+
}, 10);
|
|
1737
|
+
document.addEventListener("keydown", (e) => {
|
|
1738
|
+
if (e.key === "Escape" && !this._menu.classList.contains("close")) this.toggleMenu();
|
|
1739
|
+
}, false);
|
|
1740
|
+
document.addEventListener("click", (e) => {
|
|
1741
|
+
if (this._menu.classList.contains("close")) return;
|
|
1742
|
+
if (this._menu.contains(e.target) || this._icon.contains(e.target)) return;
|
|
1743
|
+
this.toggleMenu();
|
|
1744
|
+
}, false);
|
|
1745
|
+
}
|
|
1746
|
+
this.updateReadGuide = (e) => {
|
|
1747
|
+
const newPos = e.type === "touchmove" ? e.changedTouches[0].clientY : e.y;
|
|
1748
|
+
const bar = document.getElementById("access_read_guide_bar");
|
|
1749
|
+
if (bar) bar.style.top = newPos - (parseInt(this.options.guide.height) + 5) + "px";
|
|
1750
|
+
};
|
|
1751
|
+
this.menuInterface = new MenuInterface(this);
|
|
1752
|
+
if (this.options.session.persistent) this.setSessionFromCache();
|
|
1753
|
+
}
|
|
1754
|
+
updateReadGuide(e) {
|
|
1755
|
+
const newPos = e.type === "touchmove" ? e.changedTouches[0].clientY : e.y;
|
|
1756
|
+
const bar = document.getElementById("access_read_guide_bar");
|
|
1757
|
+
if (bar) bar.style.top = newPos - (parseInt(this.options.guide.height) + 5) + "px";
|
|
1758
|
+
}
|
|
1759
|
+
resetIfDefined(src, dest, prop) {
|
|
1760
|
+
if (typeof src !== "undefined") dest[prop] = src;
|
|
1761
|
+
}
|
|
1762
|
+
onChange(updateSession) {
|
|
1763
|
+
if (updateSession && this.options.session.persistent) this.saveSession();
|
|
1764
|
+
}
|
|
1765
|
+
saveSession() {
|
|
1766
|
+
this._storage.set("_accessState", this.sessionState);
|
|
1767
|
+
}
|
|
1768
|
+
setSessionFromCache() {
|
|
1769
|
+
const s = this._storage.get("_accessState");
|
|
1770
|
+
if (!s) return;
|
|
1771
|
+
if (s.textSize) {
|
|
1772
|
+
let n = s.textSize;
|
|
1773
|
+
if (n > 0) while (n--) this.alterTextSize(true);
|
|
1774
|
+
else while (n++) this.alterTextSize(false);
|
|
1775
|
+
}
|
|
1776
|
+
if (s.textSpace) {
|
|
1777
|
+
let n = s.textSpace;
|
|
1778
|
+
if (n > 0) while (n--) this.alterTextSpace(true);
|
|
1779
|
+
else while (n++) this.alterTextSpace(false);
|
|
1780
|
+
}
|
|
1781
|
+
if (s.lineHeight) {
|
|
1782
|
+
let n = s.lineHeight;
|
|
1783
|
+
if (n > 0) while (n--) this.alterLineHeight(true);
|
|
1784
|
+
else while (n++) this.alterLineHeight(false);
|
|
1785
|
+
}
|
|
1786
|
+
if (s.invertColors) this.menuInterface.invertColors();
|
|
1787
|
+
if (s.grayHues) this.menuInterface.grayHues();
|
|
1788
|
+
if (s.underlineLinks) this.menuInterface.underlineLinks();
|
|
1789
|
+
if (s.bigCursor) this.menuInterface.bigCursor();
|
|
1790
|
+
if (s.readingGuide) this.menuInterface.readingGuide();
|
|
1791
|
+
this.sessionState = s;
|
|
1792
|
+
}
|
|
1793
|
+
destroy() {
|
|
1794
|
+
this._common.deployedObjects.getAll().forEach((_, key) => {
|
|
1795
|
+
var _a, _b;
|
|
1796
|
+
(_b = (_a = document.querySelector(key)) == null ? void 0 : _a.parentElement) == null ? void 0 : _b.removeChild(document.querySelector(key));
|
|
1797
|
+
});
|
|
1798
|
+
document.removeEventListener("keydown", this._onKeyDownBind, false);
|
|
1799
|
+
}
|
|
1800
|
+
};
|
|
1801
|
+
_Accessibility.CSS_CLASS_NAME = "_access-main-css";
|
|
1802
|
+
_Accessibility.MENU_WIDTH = "20vw";
|
|
1803
|
+
var Accessibility = _Accessibility;
|
|
1804
|
+
var main_default = Accessibility;
|
|
1805
|
+
|
|
1806
|
+
// src/theme.ts
|
|
1807
|
+
var VAR_MAP = {
|
|
1808
|
+
primaryColor: ["--_access-icon-bg", "--_access-menu-item-button-active-background-color"],
|
|
1809
|
+
menuBackground: "--_access-menu-background-color",
|
|
1810
|
+
menuColor: "--_access-menu-color",
|
|
1811
|
+
iconBackground: "--_access-icon-bg",
|
|
1812
|
+
iconColor: "--_access-icon-color",
|
|
1813
|
+
menuWidth: "--_access-menu-width",
|
|
1814
|
+
borderRadius: ["--_access-menu-border-radius", "--_access-icon-border-radius", "--_access-menu-item-button-border-radius"],
|
|
1815
|
+
fontFamily: "--_access-menu-font-family",
|
|
1816
|
+
itemColor: "--_access-menu-item-color",
|
|
1817
|
+
itemButtonBackground: "--_access-menu-item-button-background",
|
|
1818
|
+
itemButtonHoverBackground: "--_access-menu-item-button-hover-background-color",
|
|
1819
|
+
itemIconColor: "--_access-menu-item-icon-color",
|
|
1820
|
+
iconBoxShadow: "--_access-icon-box-shadow",
|
|
1821
|
+
menuHeight: "--_access-menu-height",
|
|
1822
|
+
menuMaxHeight: "--_access-menu-max-height",
|
|
1823
|
+
menuTop: "--_access-menu-top"
|
|
1824
|
+
};
|
|
1825
|
+
function createThemeCss(theme) {
|
|
1826
|
+
const declarations = [];
|
|
1827
|
+
for (const [key, value] of Object.entries(theme)) {
|
|
1828
|
+
if (!value) continue;
|
|
1829
|
+
const vars = VAR_MAP[key];
|
|
1830
|
+
if (!vars) continue;
|
|
1831
|
+
const varList = Array.isArray(vars) ? vars : [vars];
|
|
1832
|
+
varList.forEach((v) => declarations.push(` ${v}: ${value};`));
|
|
1833
|
+
}
|
|
1834
|
+
return `:root {
|
|
1835
|
+
${declarations.join("\n")}
|
|
1836
|
+
}`;
|
|
1837
|
+
}
|
|
1838
|
+
function applyTheme(theme) {
|
|
1839
|
+
const css = createThemeCss(theme);
|
|
1840
|
+
const id = "accessibility-widget-theme";
|
|
1841
|
+
const existing = document.getElementById(id);
|
|
1842
|
+
if (existing) {
|
|
1843
|
+
existing.textContent = css;
|
|
1844
|
+
return;
|
|
1845
|
+
}
|
|
1846
|
+
const style = document.createElement("style");
|
|
1847
|
+
style.id = id;
|
|
1848
|
+
style.textContent = css;
|
|
1849
|
+
document.head.appendChild(style);
|
|
1850
|
+
}
|
|
1851
|
+
function removeTheme() {
|
|
1852
|
+
var _a;
|
|
1853
|
+
(_a = document.getElementById("accessibility-widget-theme")) == null ? void 0 : _a.remove();
|
|
1854
|
+
}
|
|
1855
|
+
|
|
1856
|
+
// src/presets/pt-br.ts
|
|
1857
|
+
var ptBRLabels = {
|
|
1858
|
+
resetTitle: "Resetar",
|
|
1859
|
+
closeTitle: "Fechar",
|
|
1860
|
+
menuTitle: "Menu de Acessibilidade",
|
|
1861
|
+
increaseText: "Aumentar texto",
|
|
1862
|
+
decreaseText: "Diminuir texto",
|
|
1863
|
+
increaseTextSpacing: "Aumentar espa\xE7amento",
|
|
1864
|
+
decreaseTextSpacing: "Diminuir espa\xE7amento",
|
|
1865
|
+
invertColors: "Inverter cores",
|
|
1866
|
+
grayHues: "Tons de cinza",
|
|
1867
|
+
bigCursor: "Cursor grande",
|
|
1868
|
+
readingGuide: "Guia de leitura",
|
|
1869
|
+
underlineLinks: "Sublinhar links",
|
|
1870
|
+
textToSpeech: "Texto para fala",
|
|
1871
|
+
speechToText: "Fala para texto",
|
|
1872
|
+
disableAnimations: "Desativar anima\xE7\xF5es",
|
|
1873
|
+
increaseLineHeight: "Aumentar altura de linha",
|
|
1874
|
+
decreaseLineHeight: "Diminuir altura de linha",
|
|
1875
|
+
hotkeyPrefix: "Atalho: ",
|
|
1876
|
+
dyslexicFont: "Fonte para dislexia",
|
|
1877
|
+
hideImages: "Ocultar imagens"
|
|
1878
|
+
};
|
|
1879
|
+
|
|
1880
|
+
// src/presets/modules.ts
|
|
1881
|
+
function createModule(config) {
|
|
1882
|
+
var _a;
|
|
1883
|
+
return {
|
|
1884
|
+
id: config.id,
|
|
1885
|
+
buttonText: config.label,
|
|
1886
|
+
icon: config.icon,
|
|
1887
|
+
emoji: config.emoji,
|
|
1888
|
+
toggle: (_a = config.toggle) != null ? _a : true,
|
|
1889
|
+
method: (_cf, active) => {
|
|
1890
|
+
var _a2;
|
|
1891
|
+
if (active) config.onActivate();
|
|
1892
|
+
else (_a2 = config.onDeactivate) == null ? void 0 : _a2.call(config);
|
|
1893
|
+
}
|
|
1894
|
+
};
|
|
1895
|
+
}
|
|
1896
|
+
function createModules(configs) {
|
|
1897
|
+
return configs.map(createModule);
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1900
|
+
// src/accessibility.ts
|
|
1901
|
+
if (typeof window !== "undefined") {
|
|
1902
|
+
window.Accessibility = main_default;
|
|
1903
|
+
}
|
|
1904
|
+
var accessibility_default = main_default;
|
|
1905
|
+
export {
|
|
1906
|
+
main_default as Accessibility,
|
|
1907
|
+
AccessibilityModulesType,
|
|
1908
|
+
applyTheme,
|
|
1909
|
+
createModule,
|
|
1910
|
+
createModules,
|
|
1911
|
+
createThemeCss,
|
|
1912
|
+
accessibility_default as default,
|
|
1913
|
+
ptBRLabels,
|
|
1914
|
+
removeTheme
|
|
1915
|
+
};
|
|
1916
|
+
//# sourceMappingURL=index.mjs.map
|