first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
define("core/local/aria/aria-hidden",["exports","core/normalise","./selectors"],(function(_exports,_normalise,_selectors){var obj;
/**
* ARIA helpers related to the aria-hidden attribute.
*
* @module core/local/aria/aria-hidden.
* @copyright 2020 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.unhideSiblings=_exports.unhide=_exports.hideSiblings=_exports.hide=void 0,_selectors=(obj=_selectors)&&obj.__esModule?obj:{default:obj};const childObserverMap=new Map,siblingObserverMap=new Map,supportsMutationObservers=()=>MutationObserver&&"function"==typeof MutationObserver,disableElementFocusability=target=>{target instanceof HTMLElement&&(target.matches(_selectors.default.elements.focusable)&&disableAndStoreTabIndex(target),target.querySelectorAll(_selectors.default.elements.focusable).forEach(disableAndStoreTabIndex))},disableAndStoreTabIndex=element=>{void 0===element.dataset.ariaHiddenTabIndex&&(element.getAttribute("tabindex")?element.dataset.ariaHiddenTabIndex=element.getAttribute("tabindex"):element.dataset.ariaHiddenTabIndex="",element.setAttribute("tabindex",-1))},restoreTabIndex=element=>{if(element.closest(_selectors.default.aria.hidden))return;const oldTabIndex=element.dataset.ariaHiddenTabIndex;""===oldTabIndex?element.removeAttribute("tabindex"):element.setAttribute("tabindex",oldTabIndex),delete element.dataset.ariaHiddenTabIndex},hide=target=>(0,_normalise.getList)(target).forEach(_hide);_exports.hide=hide;const _hide=target=>{if(target instanceof HTMLElement&&!target.closest(_selectors.default.aria.hidden)&&(target.setAttribute("aria-hidden",!0),disableElementFocusability(target),supportsMutationObservers())){const mutationObserver=new MutationObserver((mutationList=>{mutationList.forEach((mutation=>{if("childList"===mutation.type)mutation.addedNodes.forEach(disableElementFocusability);else if("attributes"===mutation.type){const element=mutation.target,proposedTabIndex=element.getAttribute("tabindex");"-1"!==proposedTabIndex&&(element.dataset.ariaHiddenTabIndex=proposedTabIndex,element.setAttribute("tabindex",-1))}}))}));mutationObserver.observe(target,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["tabindex"]}),childObserverMap.set(target,mutationObserver)}},unhide=target=>(0,_normalise.getList)(target).forEach(_unhide);_exports.unhide=unhide;const _unhide=target=>{target instanceof HTMLElement&&(target.removeAttribute("aria-hidden"),(target=>{target instanceof HTMLElement&&(target.matches(_selectors.default.elements.focusableToUnhide)&&restoreTabIndex(target),target.querySelectorAll(_selectors.default.elements.focusableToUnhide).forEach(restoreTabIndex))})(target),childObserverMap.has(target)&&(childObserverMap.get(target).disconnect(),childObserverMap.delete(target)))};_exports.hideSiblings=target=>(0,_normalise.getList)(target).forEach(_hideSiblings);const _hideSiblings=target=>{if(target instanceof HTMLElement&&target.parentElement&&(target.parentElement.childNodes.forEach((node=>{node!==target&&hide(node)})),supportsMutationObservers())){const newNodeObserver=new MutationObserver((mutationList=>{mutationList.forEach((mutation=>{mutation.addedNodes.forEach((node=>{target.contains(node)||hide(node)}))}))}));newNodeObserver.observe(target.parentElement,{childList:!0,subtree:!0}),siblingObserverMap.set(target.parentElement,newNodeObserver)}};_exports.unhideSiblings=target=>(0,_normalise.getList)(target).forEach(_unhideSiblings);const _unhideSiblings=target=>{target instanceof HTMLElement&&target.parentElement&&(target.parentElement.childNodes.forEach((node=>{node!==target&&unhide(node)})),siblingObserverMap.has(target.parentElement)&&(siblingObserverMap.get(target.parentElement).disconnect(),siblingObserverMap.delete(target.parentElement)))}}));
//# sourceMappingURL=aria-hidden.min.js.map
File diff suppressed because one or more lines are too long
+13
View File
@@ -0,0 +1,13 @@
define("core/local/aria/focuslock",["exports","./selectors"],(function(_exports,_selectors){var obj;
/**
* Tab locking system.
*
* This is based on code and examples provided in the ARIA specification.
* https://www.w3.org/TR/wai-aria-practices/examples/dialog-modal/dialog.html
*
* @module core/local/aria/focuslock
* @copyright 2019 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.untrapFocus=_exports.trapFocus=void 0,_selectors=(obj=_selectors)&&obj.__esModule?obj:{default:obj};const lockRegionStack=[],initialFocusElementStack=[],finalFocusElementStack=[];let lastFocus=null,ignoreFocusChanges=!1,isLocked=!1;const lockHandler=event=>{if(ignoreFocusChanges)return;let lockRegion=getCurrentLockRegion();for(;lockRegion&&!document.contains(lockRegion);)untrapFocus(),lockRegion=getCurrentLockRegion();lockRegion&&(lockRegion.contains(event.target)?lastFocus=event.target:(focusFirstDescendant(),lastFocus==document.activeElement&&focusLastDescendant(),lastFocus=document.activeElement))},focusFirstDescendant=()=>{const lockRegion=getCurrentLockRegion(),focusableElements=Array.from(lockRegion.querySelectorAll(_selectors.default.elements.focusable));return focusableElements.unshift(lockRegion),focusableElements.some((focusableElement=>attemptFocus(focusableElement)))},focusLastDescendant=()=>{const lockRegion=getCurrentLockRegion(),focusableElements=Array.from(lockRegion.querySelectorAll(_selectors.default.elements.focusable)).reverse();return focusableElements.push(lockRegion),focusableElements.some((focusableElement=>attemptFocus(focusableElement)))},attemptFocus=focusTarget=>{if(!(focusTarget=>{if(focusTarget.tabIndex>0||0===focusTarget.tabIndex&&null!==focusTarget.getAttribute("tabIndex"))return!0;if(focusTarget.disabled)return!1;switch(focusTarget.nodeName){case"A":return!!focusTarget.href&&"ignore"!=focusTarget.rel;case"INPUT":return"hidden"!=focusTarget.type&&"file"!=focusTarget.type;case"BUTTON":case"SELECT":case"TEXTAREA":return!0;default:return!1}})(focusTarget))return!1;ignoreFocusChanges=!0;try{focusTarget.focus()}catch(e){}return ignoreFocusChanges=!1,document.activeElement===focusTarget},getCurrentLockRegion=()=>lockRegionStack[lockRegionStack.length-1];_exports.trapFocus=newLockRegion=>{if((newLockRegion=>{if(newLockRegion===getCurrentLockRegion())return;lockRegionStack.push(newLockRegion);const currentLockRegion=getCurrentLockRegion(),element=document.createElement("div");element.tabIndex=0,element.style.position="fixed",element.style.top=0,element.style.left=0;const initialNode=element.cloneNode();currentLockRegion.parentNode.insertBefore(initialNode,currentLockRegion),initialFocusElementStack.push(initialNode);const finalNode=element.cloneNode();currentLockRegion.parentNode.insertBefore(finalNode,currentLockRegion.nextSibling),finalFocusElementStack.push(finalNode)})(newLockRegion),isLocked||document.addEventListener("focus",lockHandler,!0),!focusFirstDescendant()){const currentLockRegion=getCurrentLockRegion(),originalRegionTabIndex=currentLockRegion.tabIndex;currentLockRegion.tabIndex=0,attemptFocus(currentLockRegion),currentLockRegion.tabIndex=originalRegionTabIndex}lastFocus=document.activeElement,isLocked=!0};const untrapFocus=()=>{(()=>{lockRegionStack.pop();const finalNode=finalFocusElementStack.pop();finalNode&&finalNode.remove();const initialNode=initialFocusElementStack.pop();initialNode&&initialNode.remove()})(),lockRegionStack.length||(document.removeEventListener("focus",lockHandler,!0),lastFocus=null,ignoreFocusChanges=!1,isLocked=!1)};_exports.untrapFocus=untrapFocus}));
//# sourceMappingURL=focuslock.min.js.map
File diff suppressed because one or more lines are too long
+3
View File
@@ -0,0 +1,3 @@
define("core/local/aria/selectors",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0;return _exports.default={aria:{hidden:"[aria-hidden]"},elements:{focusable:'input:not([type="hidden"]):not([disabled]):not([tabindex^="-"]),a[href]:not([disabled]):not([tabindex^="-"]),button:not([disabled]):not([tabindex^="-"]),textarea:not([disabled]):not([tabindex^="-"]),select:not([disabled]):not([tabindex^="-"]),[tabindex]:not([disabled]):not([tabindex^="-"])',focusableToUnhide:"[data-aria-hidden-tab-index]"}},_exports.default}));
//# sourceMappingURL=selectors.min.js.map
@@ -0,0 +1 @@
{"version":3,"file":"selectors.min.js","sources":["../../../src/local/aria/selectors.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 <http://www.gnu.org/licenses/>.\n\n/**\n * Selectors used for ARIA.\n *\n * @module core/local/aria/selectors\n * @copyright 2020 Andrew Nicols <andrew@nicols.co.uk>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nexport default {\n aria: {\n hidden: '[aria-hidden]',\n },\n elements: {\n focusable: 'input:not([type=\"hidden\"]):not([disabled]):not([tabindex^=\"-\"]),' +\n 'a[href]:not([disabled]):not([tabindex^=\"-\"]),' +\n 'button:not([disabled]):not([tabindex^=\"-\"]),' +\n 'textarea:not([disabled]):not([tabindex^=\"-\"]),' +\n 'select:not([disabled]):not([tabindex^=\"-\"]),' +\n '[tabindex]:not([disabled]):not([tabindex^=\"-\"])',\n focusableToUnhide: '[data-aria-hidden-tab-index]',\n },\n};\n"],"names":["aria","hidden","elements","focusable","focusableToUnhide"],"mappings":"2KAsBe,CACXA,KAAM,CACFC,OAAQ,iBAEZC,SAAU,CACNC,UAAW,qSAMXC,kBAAmB"}