{"version":3,"file":"ariaenhance.min.js","sources":["https:\/\/moodle.sonsbeekmedia.nl\/caie_39\/mod\/teachingtools\/amd\/src\/ariaenhance.js"],"sourcesContent":["\/\/ This file is part of Moodle - http:\/\/moodle.org\/\n\/\/\n\/\/ Moodle is free software: you can redistribute it and\/or modify\n\/\/ it under the terms of the GNU General Public License as published by\n\/\/ the Free Software Foundation, either version 3 of the License, or\n\/\/ (at your option) any later version.\n\/\/\n\/\/ Moodle is distributed in the hope that it will be useful,\n\/\/ but WITHOUT ANY WARRANTY; without even the implied warranty of\n\/\/ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\/\/ GNU General Public License for more details.\n\/\/\n\/\/ You should have received a copy of the GNU General Public License\n\/\/ along with Moodle. If not, see .\n\n\/**\n * TODO describe module ariaenhance\n *\n * @module mod_teachingtools\/ariaenhance\n * @copyright 2024 Bas Brands \n * @license http:\/\/www.gnu.org\/copyleft\/gpl.html GNU GPL v3 or later\n *\/\n\n\/**\n * Updates an ARIA live region\n * @param {String} text The text to update the live region with\n *\/\nimport Notification from 'core\/notification';\nimport {get_string as getString} from 'core\/str';\n\nlet ariaLive = null;\n\n\/**\n * Text to announce for screen readers\n * @param {HTMLElement} rootElement The root element to add the ARIA live region to\n * @param {String} text The text to update the live region with\n * @param {String} wrapper text string\n * @param {String} plugin The name of the plugin\n *\/\nconst updateAriaLive = async(rootElement, text, wrapper = null, plugin = null) => {\n if (!ariaLive) {\n ariaLive = createAriaLive();\n rootElement.appendChild(ariaLive);\n }\n if (wrapper && plugin) {\n text = await getString(wrapper, plugin, text);\n }\n ariaLive.textContent = text;\n};\n\n\/**\n * Creates an ARIA live region for announcing dynamic updates to screen readers.\n * @return {HTMLElement} The ARIA live region element\n *\/\nconst createAriaLive = () => {\n const ariaLive = document.createElement('div');\n ariaLive.setAttribute('aria-live', 'assertive');\n ariaLive.setAttribute('aria-atomic', 'true');\n ariaLive.setAttribute('aria-relevant', 'additions');\n ariaLive.classList.add('sr-only');\n return ariaLive;\n};\n\n\/**\n * Add a tab listener to the root element, if the user is navigating using the tab key\n * add the tab class to the drawzone element in the root element\n * @param {HTMLElement} rootElement The root element to add the tab listener to\n * @param {String} drawZoneRegion The region name of the drawzone element\n *\/\nconst addTabListener = (rootElement, drawZoneRegion = 'draw-zone') => {\n const drawZone = rootElement.querySelector(`[data-region=\"${drawZoneRegion}\"]`);\n if (!drawZone) {\n Notification.exception('ariaenhance', 'No draw zone element found');\n return;\n }\n rootElement.addEventListener('keydown', (e) => {\n if (e.key === 'Tab') {\n drawZone.classList.add('tab');\n }\n });\n rootElement.addEventListener('mousedown', () => {\n drawZone.classList.remove('tab');\n });\n};\n\n\nexport default {\n updateAriaLive: updateAriaLive,\n addTabListener: addTabListener\n};"],"names":["ariaLive","createAriaLive","document","createElement","setAttribute","classList","add","updateAriaLive","async","rootElement","text","wrapper","plugin","appendChild","textContent","addTabListener","drawZoneRegion","drawZone","querySelector","addEventListener","e","key","remove","exception"],"mappings":";;;;;;;6JA8BIA,SAAW,WAwBTC,eAAiB,WACbD,SAAWE,SAASC,cAAc,cACxCH,SAASI,aAAa,YAAa,aACnCJ,SAASI,aAAa,cAAe,QACrCJ,SAASI,aAAa,gBAAiB,aACvCJ,SAASK,UAAUC,IAAI,WAChBN,uBA0BI,CACXO,eAhDmBC,eAAMC,YAAaC,UAAMC,+DAAU,KAAMC,8DAAS,KAChEZ,WACDA,SAAWC,iBACXQ,YAAYI,YAAYb,WAExBW,SAAWC,SACXF,WAAa,mBAAUC,QAASC,OAAQF,OAE5CV,SAASc,YAAcJ,MAyCvBK,eAnBmB,SAACN,iBAAaO,sEAAiB,kBAC5CC,SAAWR,YAAYS,sCAA+BF,sBACvDC,UAILR,YAAYU,iBAAiB,WAAYC,IACvB,QAAVA,EAAEC,KACFJ,SAASZ,UAAUC,IAAI,UAG\/BG,YAAYU,iBAAiB,aAAa,KACtCF,SAASZ,UAAUiB,OAAO,iCATbC,UAAU,cAAe"}