maidr 2.29.1 → 2.30.1
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/maidr.js +65 -20
- package/dist/maidr.min.js +1 -1
- package/dist/maidr_style.css +1 -1
- package/dist/maidr_style.min.css +1 -1
- package/package.json +1 -1
package/dist/maidr.js
CHANGED
|
@@ -928,7 +928,7 @@ class Menu {
|
|
|
928
928
|
|
|
929
929
|
// initial html for the menu
|
|
930
930
|
menuHtml = `
|
|
931
|
-
<div id="menu" class="modal hidden" role="dialog" tabindex="-1">
|
|
931
|
+
<div id="menu" class="maidr-modal hidden" role="dialog" tabindex="-1">
|
|
932
932
|
<div class="modal-dialog" role="document" tabindex="0">
|
|
933
933
|
<div class="modal-content">
|
|
934
934
|
<div class="modal-header">
|
|
@@ -1686,6 +1686,7 @@ class Menu {
|
|
|
1686
1686
|
UpdateHtml() {
|
|
1687
1687
|
// set aria attributes
|
|
1688
1688
|
constants.infoDiv.setAttribute('aria-live', constants.ariaMode);
|
|
1689
|
+
|
|
1689
1690
|
document
|
|
1690
1691
|
.getElementById(constants.announcement_container_id)
|
|
1691
1692
|
.setAttribute('aria-live', constants.ariaMode);
|
|
@@ -1846,7 +1847,7 @@ class ChatLLM {
|
|
|
1846
1847
|
*/
|
|
1847
1848
|
CreateComponent() {
|
|
1848
1849
|
let html = `
|
|
1849
|
-
<div id="chatLLM" class="modal hidden" role="dialog" tabindex="-1">
|
|
1850
|
+
<div id="chatLLM" class="maidr-modal hidden" role="dialog" tabindex="-1">
|
|
1850
1851
|
<div class="modal-dialog" role="document" tabindex="0">
|
|
1851
1852
|
<div class="modal-content">
|
|
1852
1853
|
<div class="modal-header">
|
|
@@ -2985,7 +2986,7 @@ class Description {
|
|
|
2985
2986
|
CreateComponent() {
|
|
2986
2987
|
// modal containing description summary stuff
|
|
2987
2988
|
let html = `
|
|
2988
|
-
<div id="description" class="modal hidden" role="dialog" tabindex="-1">
|
|
2989
|
+
<div id="description" class="maidr-modal hidden" role="dialog" tabindex="-1">
|
|
2989
2990
|
<div class="modal-dialog" role="document" tabindex="0">
|
|
2990
2991
|
<div class="modal-content">
|
|
2991
2992
|
<div class="modal-header">
|
|
@@ -12145,7 +12146,7 @@ class Goto {
|
|
|
12145
12146
|
|
|
12146
12147
|
// events and init functions
|
|
12147
12148
|
// we do some setup, but most of the work is done when user focuses on an element matching an id from maidr user data
|
|
12148
|
-
|
|
12149
|
+
function init(id) {
|
|
12149
12150
|
// we wrap in DOMContentLoaded to make sure everything has loaded before we run anything
|
|
12150
12151
|
|
|
12151
12152
|
// create global vars
|
|
@@ -12164,30 +12165,67 @@ document.addEventListener('DOMContentLoaded', function (e) {
|
|
|
12164
12165
|
maidrObjects = maidrObjects.concat(window.maidr);
|
|
12165
12166
|
}
|
|
12166
12167
|
}
|
|
12167
|
-
|
|
12168
|
-
|
|
12169
|
-
|
|
12170
|
-
|
|
12171
|
-
|
|
12172
|
-
|
|
12168
|
+
if (id !== undefined) {
|
|
12169
|
+
constants.main_container_id = constants.main_container_id + '-' + id;
|
|
12170
|
+
constants.chart_container_id = constants.chart_container_id + '-' + id;
|
|
12171
|
+
constants.braille_container_id = constants.braille_container_id + '-' + id;
|
|
12172
|
+
constants.braille_input_id = constants.braille_input_id + '-' + id;
|
|
12173
|
+
constants.info_id = constants.info_id + '-' + id;
|
|
12174
|
+
constants.announcement_container_id =
|
|
12175
|
+
constants.announcement_container_id + '-' + id;
|
|
12176
|
+
constants.review_id_container = constants.review_id_container + '-' + id;
|
|
12177
|
+
constants.review_id = constants.review_id + '-' + id;
|
|
12178
|
+
constants.end_chime_id = constants.end_chime_id + '-' + id;
|
|
12179
|
+
|
|
12180
|
+
const elementWithId = document.getElementById(id);
|
|
12181
|
+
if (elementWithId) {
|
|
12182
|
+
let maidrData;
|
|
12183
|
+
try {
|
|
12184
|
+
maidrData = JSON.parse(elementWithId.getAttribute('maidr-data'));
|
|
12185
|
+
} catch (e) {
|
|
12186
|
+
console.error('Failed to parse maidr attribute:', e);
|
|
12187
|
+
return;
|
|
12188
|
+
}
|
|
12173
12189
|
// If id is not provided in the JSON, use the element's id
|
|
12174
12190
|
if (!maidrData.id) {
|
|
12175
|
-
if (
|
|
12176
|
-
maidrData.id =
|
|
12191
|
+
if (elementWithId.id) {
|
|
12192
|
+
maidrData.id = elementWithId.id;
|
|
12177
12193
|
} else {
|
|
12178
12194
|
// Generate a random id if none exists
|
|
12179
|
-
|
|
12180
|
-
maidrData.id =
|
|
12195
|
+
elementWithId.id = 'maidr-' + Math.random().toString(36).substr(2, 9);
|
|
12196
|
+
maidrData.id = elementWithId.id;
|
|
12181
12197
|
}
|
|
12182
12198
|
}
|
|
12183
12199
|
// Check if this id already exists in maidrObjects to avoid duplicates
|
|
12184
12200
|
if (!maidrObjects.some((obj) => obj.id === maidrData.id)) {
|
|
12185
12201
|
maidrObjects.push(maidrData);
|
|
12186
12202
|
}
|
|
12187
|
-
} catch (e) {
|
|
12188
|
-
console.error('Failed to parse maidr attribute:', e);
|
|
12189
12203
|
}
|
|
12190
|
-
}
|
|
12204
|
+
} else {
|
|
12205
|
+
// Then look for elements with maidr attribute
|
|
12206
|
+
const elementsWithMaidrAttr = document.querySelectorAll('[maidr-data]');
|
|
12207
|
+
elementsWithMaidrAttr.forEach((element) => {
|
|
12208
|
+
try {
|
|
12209
|
+
const maidrData = JSON.parse(element.getAttribute('maidr-data'));
|
|
12210
|
+
// If id is not provided in the JSON, use the element's id
|
|
12211
|
+
if (!maidrData.id) {
|
|
12212
|
+
if (element.id) {
|
|
12213
|
+
maidrData.id = element.id;
|
|
12214
|
+
} else {
|
|
12215
|
+
// Generate a random id if none exists
|
|
12216
|
+
element.id = 'maidr-' + Math.random().toString(36).substr(2, 9);
|
|
12217
|
+
maidrData.id = element.id;
|
|
12218
|
+
}
|
|
12219
|
+
}
|
|
12220
|
+
// Check if this id already exists in maidrObjects to avoid duplicates
|
|
12221
|
+
if (!maidrObjects.some((obj) => obj.id === maidrData.id)) {
|
|
12222
|
+
maidrObjects.push(maidrData);
|
|
12223
|
+
}
|
|
12224
|
+
} catch (e) {
|
|
12225
|
+
console.error('Failed to parse maidr attribute:', e);
|
|
12226
|
+
}
|
|
12227
|
+
});
|
|
12228
|
+
}
|
|
12191
12229
|
|
|
12192
12230
|
// set focus events for all maidr ids
|
|
12193
12231
|
DestroyMaidr(); // just in case
|
|
@@ -12208,10 +12246,15 @@ document.addEventListener('DOMContentLoaded', function (e) {
|
|
|
12208
12246
|
// blur done elsewhere
|
|
12209
12247
|
}
|
|
12210
12248
|
}
|
|
12211
|
-
|
|
12212
12249
|
// init components like alt text on just the first chart
|
|
12213
12250
|
CreateChartComponents(firstMaidr, true);
|
|
12214
|
-
}
|
|
12251
|
+
}
|
|
12252
|
+
window.init = init;
|
|
12253
|
+
if (document.readyState === 'loading') {
|
|
12254
|
+
document.addEventListener('DOMContentLoaded', function (e) {
|
|
12255
|
+
init();
|
|
12256
|
+
});
|
|
12257
|
+
}
|
|
12215
12258
|
|
|
12216
12259
|
/**
|
|
12217
12260
|
* Initializes the Maidr app for a given chart, taken from the matching ID of the focused chart
|
|
@@ -12580,7 +12623,9 @@ function CreateChartComponents(thisMaidr, chartOnly = false) {
|
|
|
12580
12623
|
.getElementById(constants.info_id)
|
|
12581
12624
|
.insertAdjacentHTML(
|
|
12582
12625
|
'afterend',
|
|
12583
|
-
'<div id="
|
|
12626
|
+
'<div id="' +
|
|
12627
|
+
constants.announcement_container_id +
|
|
12628
|
+
'" aria-live="assertive" aria-atomic="true" class="mb-3"></div>\n'
|
|
12584
12629
|
);
|
|
12585
12630
|
|
|
12586
12631
|
// review mode form field
|