diff --git a/lib/amd/build/aria.min.js b/lib/amd/build/aria.min.js
new file mode 100644
index 00000000000..f07ac09626f
--- /dev/null
+++ b/lib/amd/build/aria.min.js
@@ -0,0 +1,2 @@
+define ("core/aria",["exports","./local/aria/aria-hidden"],function(a,b){"use strict";Object.defineProperty(a,"__esModule",{value:!0});Object.defineProperty(a,"hide",{enumerable:!0,get:function get(){return b.hide}});Object.defineProperty(a,"unhide",{enumerable:!0,get:function get(){return b.unhide}});Object.defineProperty(a,"hideSiblings",{enumerable:!0,get:function get(){return b.hideSiblings}});Object.defineProperty(a,"unhideSiblings",{enumerable:!0,get:function get(){return b.unhideSiblings}})});
+//# sourceMappingURL=aria.min.js.map
diff --git a/lib/amd/build/aria.min.js.map b/lib/amd/build/aria.min.js.map
new file mode 100644
index 00000000000..c6a555db86c
--- /dev/null
+++ b/lib/amd/build/aria.min.js.map
@@ -0,0 +1 @@
+{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"aria.min.js"}
\ No newline at end of file
diff --git a/lib/amd/build/local/aria/aria-hidden.min.js b/lib/amd/build/local/aria/aria-hidden.min.js
new file mode 100644
index 00000000000..f5493607069
--- /dev/null
+++ b/lib/amd/build/local/aria/aria-hidden.min.js
@@ -0,0 +1,2 @@
+define ("core/local/aria/aria-hidden",["exports","core/normalise","./selectors"],function(a,b,c){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.unhideSiblings=a.hideSiblings=a.unhide=a.hide=void 0;c=function(a){return a&&a.__esModule?a:{default:a}}(c);var d=new Map,e=new Map,f=function(){return MutationObserver&&"function"==typeof MutationObserver},g=function(a){if(!(a instanceof HTMLElement)){return}if(a.matches(c.default.elements.focusable)){h(a)}a.querySelectorAll(c.default.elements.focusable).forEach(h)},h=function(a){if("undefined"!=typeof a.dataset.ariaHiddenTabIndex){return}if(a.getAttribute("tabindex")){a.dataset.ariaHiddenTabIndex=a.getAttribute("tabindex")}else{a.dataset.ariaHiddenTabIndex=""}a.setAttribute("tabindex",-1)},i=function(a){if(!(a instanceof HTMLElement)){return}if(a.matches(c.default.elements.focusableToUnhide)){j(a)}a.querySelectorAll(c.default.elements.focusableToUnhide).forEach(j)},j=function(a){if(a.closest(c.default.aria.hidden)){return}var b=a.dataset.ariaHiddenTabIndex;if(""===b){a.removeAttribute("tabindex")}else{a.setAttribute("tabindex",b)}delete a.dataset.ariaHiddenTabIndex},k=function(a){return(0,b.getList)(a).forEach(l)};a.hide=k;var l=function(a){if(!(a instanceof HTMLElement)){return}if(a.closest(c.default.aria.hidden)){return}a.setAttribute("aria-hidden",!0);g(a);if(f()){var b=new MutationObserver(function(a){a.forEach(function(a){a.addedNodes.forEach(g)})});b.observe(a,{childList:!0,subtree:!0});d.set(a,b)}},m=function(a){return(0,b.getList)(a).forEach(n)};a.unhide=m;var n=function(a){if(!(a instanceof HTMLElement)){return}a.removeAttribute("aria-hidden");i(a);if(d.has(a)){d.get(a).disconnect();d.delete(a)}};a.hideSiblings=function hideSiblings(a){return(0,b.getList)(a).forEach(o)};var o=function(a){if(!(a instanceof HTMLElement)){return}if(!a.parentElement){return}a.parentElement.childNodes.forEach(function(b){if(b===a){return}k(b)});if(f()){var b=new MutationObserver(function(b){b.forEach(function(b){b.addedNodes.forEach(function(b){if(a.contains(b)){return}k(b)})})});b.observe(a.parentElement,{childList:!0,subtree:!0});e.set(a.parentElement,b)}};a.unhideSiblings=function unhideSiblings(a){return(0,b.getList)(a).forEach(p)};var p=function(a){if(!(a instanceof HTMLElement)){return}if(!a.parentElement){return}a.parentElement.childNodes.forEach(function(b){if(b===a){return}m(b)});if(e.has(a.parentElement)){e.get(a.parentElement).disconnect();e.delete(a.parentElement)}}});
+//# sourceMappingURL=aria-hidden.min.js.map
diff --git a/lib/amd/build/local/aria/aria-hidden.min.js.map b/lib/amd/build/local/aria/aria-hidden.min.js.map
new file mode 100644
index 00000000000..38aa7e26d74
--- /dev/null
+++ b/lib/amd/build/local/aria/aria-hidden.min.js.map
@@ -0,0 +1 @@
+{"version":3,"sources":["../../../src/local/aria/aria-hidden.js"],"names":["childObserverMap","Map","siblingObserverMap","supportsMutationObservers","MutationObserver","disableElementFocusability","target","HTMLElement","matches","Selectors","elements","focusable","disableAndStoreTabIndex","querySelectorAll","forEach","element","dataset","ariaHiddenTabIndex","getAttribute","setAttribute","enableElementFocusability","focusableToUnhide","restoreTabIndex","closest","aria","hidden","oldTabIndex","removeAttribute","hide","_hide","newNodeObserver","mutationList","mutation","addedNodes","observe","childList","subtree","set","unhide","_unhide","has","get","disconnect","delete","hideSiblings","_hideSiblings","parentElement","childNodes","node","contains","unhideSiblings","_unhideSiblings"],"mappings":"sNAyBA,uD,GAGMA,CAAAA,CAAgB,CAAG,GAAIC,CAAAA,G,CACvBC,CAAkB,CAAG,GAAID,CAAAA,G,CAOzBE,CAAyB,CAAG,iBAAOC,CAAAA,gBAAgB,EAAgC,UAA5B,QAAOA,CAAAA,gBAAlC,C,CAO5BC,CAA0B,CAAG,SAAAC,CAAM,CAAI,CACzC,GAAI,EAAEA,CAAM,WAAYC,CAAAA,WAApB,CAAJ,CAAsC,CAGlC,MACH,CAED,GAAID,CAAM,CAACE,OAAP,CAAeC,UAAUC,QAAV,CAAmBC,SAAlC,CAAJ,CAAkD,CAC9CC,CAAuB,CAACN,CAAD,CAC1B,CAEDA,CAAM,CAACO,gBAAP,CAAwBJ,UAAUC,QAAV,CAAmBC,SAA3C,EAAsDG,OAAtD,CAA8DF,CAA9D,CACH,C,CAOKA,CAAuB,CAAG,SAAAG,CAAO,CAAI,CACvC,GAAkD,WAA9C,QAAOA,CAAAA,CAAO,CAACC,OAAR,CAAgBC,kBAA3B,CAA+D,CAG3D,MACH,CAGD,GAAIF,CAAO,CAACG,YAAR,CAAqB,UAArB,CAAJ,CAAsC,CAClCH,CAAO,CAACC,OAAR,CAAgBC,kBAAhB,CAAqCF,CAAO,CAACG,YAAR,CAAqB,UAArB,CACxC,CAFD,IAEO,CACHH,CAAO,CAACC,OAAR,CAAgBC,kBAAhB,CAAq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CAACwC,aAA9B,CAAJ,CAAkD,CAC9C5C,CAAkB,CAACuC,GAAnB,CAAuBnC,CAAM,CAACwC,aAA9B,EAA6CJ,UAA7C,GACAxC,CAAkB,CAACyC,MAAnB,CAA0BrC,CAAM,CAACwC,aAAjC,CACH,CACJ,C","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 * ARIA helpers related to the aria-hidden attribute.\n *\n * @module core/local/aria/aria-hidden.\n * @class aria\n * @package core\n * @copyright 2020 Andrew Nicols \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nimport {getList} from 'core/normalise';\nimport Selectors from './selectors';\n\n// The map of MutationObserver objects for an object.\nconst childObserverMap = new Map();\nconst siblingObserverMap = new Map();\n\n/**\n * Determine whether the browser supports the MutationObserver system.\n *\n * @returns {Bool}\n */\nconst supportsMutationObservers = () => (MutationObserver && typeof MutationObserver === 'function');\n\n/**\n * Disable element focusability, disabling the tabindex for child elements which are normally focusable.\n *\n * @param {HTMLElement} target\n */\nconst disableElementFocusability = target => {\n if (!(target instanceof HTMLElement)) {\n // This element is not an HTMLElement.\n // This can happen for Text Nodes.\n return;\n }\n\n if (target.matches(Selectors.elements.focusable)) {\n disableAndStoreTabIndex(target);\n }\n\n target.querySelectorAll(Selectors.elements.focusable).forEach(disableAndStoreTabIndex);\n};\n\n/**\n * Remove the current tab-index and store it for later restoration.\n *\n * @param {HTMLElement} element\n */\nconst disableAndStoreTabIndex = element => {\n if (typeof element.dataset.ariaHiddenTabIndex !== 'undefined') {\n // This child already has a hidden attribute.\n // Do not modify it as the original value will be lost.\n return;\n }\n\n // Store the old tabindex in a data attribute.\n if (element.getAttribute('tabindex')) {\n element.dataset.ariaHiddenTabIndex = element.getAttribute('tabindex');\n } else {\n element.dataset.ariaHiddenTabIndex = '';\n }\n element.setAttribute('tabindex', -1);\n};\n\n/**\n * Re-enable element focusability, restoring any tabindex.\n *\n * @param {HTMLElement} target\n */\nconst enableElementFocusability = target => {\n if (!(target instanceof HTMLElement)) {\n // This element is not an HTMLElement.\n // This can happen for Text Nodes.\n return;\n }\n\n if (target.matches(Selectors.elements.focusableToUnhide)) {\n restoreTabIndex(target);\n }\n\n target.querySelectorAll(Selectors.elements.focusableToUnhide).forEach(restoreTabIndex);\n};\n\n/**\n * Restore the tab-index of the supplied element.\n *\n * When disabling focusability the current tab-index is stored in the ariaHiddenTabIndex data attribute.\n * This is used to restore the tab-index, but only whilst the parent nodes remain unhidden.\n *\n * @param {HTMLElement} element\n */\nconst restoreTabIndex = element => {\n if (element.closest(Selectors.aria.hidden)) {\n // This item still has a hidden parent, or is hidden itself. Do not unhide it.\n return;\n }\n\n const oldTabIndex = element.dataset.ariaHiddenTabIndex;\n if (oldTabIndex === '') {\n element.removeAttribute('tabindex');\n } else {\n element.setAttribute('tabindex', oldTabIndex);\n }\n\n delete element.dataset.ariaHiddenTabIndex;\n};\n\n/**\n * Update the supplied DOM Module to be hidden.\n *\n * @param {HTMLElement} target\n * @returns {Array}\n */\nexport const hide = target => getList(target).forEach(_hide);\n\nconst _hide = target => {\n if (!(target instanceof HTMLElement)) {\n // This element is not an HTMLElement.\n // This can happen for Text Nodes.\n return;\n }\n\n if (target.closest(Selectors.aria.hidden)) {\n // This Element, or a parent Element, is already hidden.\n // Stop processing.\n return;\n }\n\n // Set the aria-hidden attribute to true.\n target.setAttribute('aria-hidden', true);\n\n // Based on advice from https://dequeuniversity.com/rules/axe/3.3/aria-hidden-focus, upon setting the aria-hidden\n // attribute, all focusable elements underneath that element should be modified such that they are not focusable.\n disableElementFocusability(target);\n\n if (supportsMutationObservers()) {\n // Add a MutationObserver to check for new children to the tree.\n const newNodeObserver = new MutationObserver(mutationList => {\n mutationList.forEach(mutation => {\n mutation.addedNodes.forEach(disableElementFocusability);\n });\n });\n\n newNodeObserver.observe(target, {childList: true, subtree: true});\n childObserverMap.set(target, newNodeObserver);\n }\n};\n\n/**\n * Reverse the effect of the hide action.\n *\n * @param {HTMLElement} target\n * @returns {Array}\n */\nexport const unhide = target => getList(target).forEach(_unhide);\n\nconst _unhide = target => {\n if (!(target instanceof HTMLElement)) {\n return;\n }\n\n // Note: The aria-hidden attribute should be removed, and not set to false.\n // The presence of the attribute is sufficient for some browsers to treat it as being true, regardless of its value.\n target.removeAttribute('aria-hidden');\n\n // Restore the tabindex across all child nodes of the target.\n enableElementFocusability(target);\n\n // Remove the focusability MutationObserver watching this tree.\n if (childObserverMap.has(target)) {\n childObserverMap.get(target).disconnect();\n childObserverMap.delete(target);\n }\n};\n\n/**\n * Correctly mark all siblings of the supplied target Element as hidden.\n *\n * @param {HTMLElement} target\n * @returns {Array}\n */\nexport const hideSiblings = target => getList(target).forEach(_hideSiblings);\n\nconst _hideSiblings = target => {\n if (!(target instanceof HTMLElement)) {\n return;\n }\n\n if (!target.parentElement) {\n return;\n }\n\n target.parentElement.childNodes.forEach(node => {\n if (node === target) {\n // Skip self;\n return;\n }\n\n hide(node);\n });\n\n if (supportsMutationObservers()) {\n // Add a MutationObserver to check for new children to the tree.\n const newNodeObserver = new MutationObserver(mutationList => {\n mutationList.forEach(mutation => {\n mutation.addedNodes.forEach(node => {\n if (target.contains(node)) {\n // Skip self, and children of self.\n return;\n }\n\n hide(node);\n });\n });\n });\n\n newNodeObserver.observe(target.parentElement, {childList: true, subtree: true});\n siblingObserverMap.set(target.parentElement, newNodeObserver);\n }\n};\n\n/**\n * Correctly reverse the hide action of all children of the supplied target Element.\n *\n * @param {HTMLElement} target\n * @returns {Array}\n */\nexport const unhideSiblings = target => getList(target).forEach(_unhideSiblings);\n\nconst _unhideSiblings = target => {\n if (!(target instanceof HTMLElement)) {\n return;\n }\n\n if (!target.parentElement) {\n return;\n }\n\n target.parentElement.childNodes.forEach(node => {\n if (node === target) {\n // Skip self;\n return;\n }\n\n unhide(node);\n });\n\n // Remove the sibling MutationObserver watching this tree.\n if (siblingObserverMap.has(target.parentElement)) {\n siblingObserverMap.get(target.parentElement).disconnect();\n siblingObserverMap.delete(target.parentElement);\n }\n};\n"],"file":"aria-hidden.min.js"}
\ No newline at end of file
diff --git a/lib/amd/build/local/aria/selectors.min.js b/lib/amd/build/local/aria/selectors.min.js
new file mode 100644
index 00000000000..2d113d7e045
--- /dev/null
+++ b/lib/amd/build/local/aria/selectors.min.js
@@ -0,0 +1,2 @@
+define ("core/local/aria/selectors",["exports"],function(a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.default=void 0;a.default={aria:{hidden:"[aria-hidden]"},elements:{focusable:"input:not([type=\"hidden\"]), a[href], button, textarea, select, [tabindex]",focusableToUnhide:"[data-aria-hidden-tab-index]"}};return a.default});
+//# sourceMappingURL=selectors.min.js.map
diff --git a/lib/amd/build/local/aria/selectors.min.js.map b/lib/amd/build/local/aria/selectors.min.js.map
new file mode 100644
index 00000000000..92e687259e7
--- /dev/null
+++ b/lib/amd/build/local/aria/selectors.min.js.map
@@ -0,0 +1 @@
+{"version":3,"sources":["../../../src/local/aria/selectors.js"],"names":["aria","hidden","elements","focusable","focusableToUnhide"],"mappings":"qJAwBe,CACXA,IAAI,CAAE,CACFC,MAAM,CAAE,eADN,CADK,CAIXC,QAAQ,CAAE,CACNC,SAAS,CAAE,6EADL,CAENC,iBAAiB,CAAE,8BAFb,CAJC,C","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 * Selectors used for ARIA.\n *\n * @module core/local/aria/selectors\n * @class selectors\n * @package core\n * @copyright 2020 Andrew Nicols \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\"]), a[href], button, textarea, select, [tabindex]',\n focusableToUnhide: '[data-aria-hidden-tab-index]',\n },\n};\n"],"file":"selectors.min.js"}
\ No newline at end of file
diff --git a/lib/amd/build/modal.min.js b/lib/amd/build/modal.min.js
index 69414dc845e..f1816d776e9 100644
--- a/lib/amd/build/modal.min.js
+++ b/lib/amd/build/modal.min.js
@@ -1,2 +1,2 @@
-function _typeof(a){"@babel/helpers - typeof";if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){_typeof=function(a){return typeof a}}else{_typeof=function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a}}return _typeof(a)}define ("core/modal",["jquery","core/templates","core/notification","core/key_codes","core/custom_interaction_events","core/modal_backdrop","core/event","core/modal_events","core/local/aria/focuslock","core/pending"],function(a,b,c,d,e,f,g,h,i,j){var k={CONTAINER:"[data-region=\"modal-container\"]",MODAL:"[data-region=\"modal\"]",HEADER:"[data-region=\"header\"]",TITLE:"[data-region=\"title\"]",BODY:"[data-region=\"body\"]",FOOTER:"[data-region=\"footer\"]",HIDE:"[data-action=\"hide\"]",DIALOG:"[role=dialog]",FORM:"form",MENU_BAR:"[role=menubar]",HAS_Z_INDEX:".moodle-has-zindex",CAN_RECEIVE_FOCUS:"input:not([type=\"hidden\"]), a[href], button, textarea, select, [tabindex]"},l={LOADING:"core/loading",BACKDROP:"core/modal_backdrop"},m,n=0,o=function(b){this.root=a(b);this.modal=this.root.find(k.MODAL);this.header=this.modal.find(k.HEADER);this.headerPromise=a.Deferred();this.title=this.header.find(k.TITLE);this.titlePromise=a.Deferred();this.body=this.modal.find(k.BODY);this.bodyPromise=a.Deferred();this.footer=this.modal.find(k.FOOTER);this.footerPromise=a.Deferred();this.hiddenSiblings=[];this.isAttached=!1;this.bodyJS=null;this.footerJS=null;this.modalCount=n++;if(!this.root.is(k.CONTAINER)){c.exception({message:"Element is not a modal container"})}if(!this.modal.length){c.exception({message:"Container does not contain a modal"})}if(!this.header.length){c.exception({message:"Modal is missing a header region"})}if(!this.title.length){c.exception({message:"Modal header is missing a title region"})}if(!this.body.length){c.exception({message:"Modal is missing a body region"})}if(!this.footer.length){c.exception({message:"Modal is missing a footer region"})}this.registerEventListeners()};o.prototype.attachToDOM=function(){if(this.isAttached){return}a("body").append(this.root);i.trapFocus(this.root[0]);if(this.bodyJS){b.runTemplateJS(this.bodyJS);this.bodyJS=null}if(this.footerJS){b.runTemplateJS(this.footerJS);this.footerJS=null}this.isAttached=!0};o.prototype.countOtherVisibleModals=function(){var b=0;a("body").find(k.CONTAINER).each(function(c,d){d=a(d);if(!this.root.is(d)&&d.hasClass("show")){b++}}.bind(this));return b};o.prototype.getBackdrop=function(){if(!m){m=b.render(l.BACKDROP,{}).then(function(b){var c=a(b);return new f(c)}).fail(c.exception)}return m};o.prototype.getRoot=function(){return this.root};o.prototype.getModal=function(){return this.modal};o.prototype.getTitle=function(){return this.title};o.prototype.getBody=function(){return this.body};o.prototype.getFooter=function(){return this.footer};o.prototype.getTitlePromise=function(){return this.titlePromise};o.prototype.getBodyPromise=function(){return this.bodyPromise};o.prototype.getFooterPromise=function(){return this.footerPromise};o.prototype.getModalCount=function(){return this.modalCount};o.prototype.setTitle=function(b){var d=this.getTitle();this.titlePromise=a.Deferred();this.asyncSet(b,d.html.bind(d)).then(function(){this.titlePromise.resolve(d)}.bind(this)).catch(c.exception)};o.prototype.setBody=function(d){this.bodyPromise=a.Deferred();var e=this.getBody();if("string"==typeof d){e.html(d);g.notifyFilterContentUpdated(e);this.getRoot().trigger(h.bodyRendered,this);this.bodyPromise.resolve(e)}else{var f="amd-modal-js-pending-id-"+this.getModalCount();M.util.js_pending(f);var i=null;e.css("overflow","hidden");d=a.when(d);if("pending"==d.state()){var j=e.innerHeight();if(100>j){j=100}e.animate({height:j+"px"},150);e.html("");i=b.render(l.LOADING,{}).then(function(b){var c=a(b).hide();e.html(c);c.fadeIn(150);return a.when(c.promise(),d)}).then(function(a){return a.fadeOut(100).promise()}).then(function(){return d})}else{i=d}i.then(function(a,c){var d=null;if(this.isVisible()){e.css("opacity",0);var f=e.innerHeight();e.html(a);e.css("height","");var g=e.innerHeight();e.css("height",f+"px");d=e.animate({height:g+"px",opacity:1},{duration:150,queue:!1}).promise()}else{e.html(a)}if(c){if(this.isAttached){b.runTemplateJS(c)}else{this.bodyJS=c}}return d}.bind(this)).then(function(a){g.notifyFilterContentUpdated(e);this.getRoot().trigger(h.bodyRendered,this);return a}.bind(this)).then(function(){this.bodyPromise.resolve(e)}.bind(this)).fail(c.exception).always(function(){e.css("height","");e.css("overflow","");e.css("opacity","");M.util.js_complete(f)}).fail(c.exception)}};o.prototype.setFooter=function(d){this.showFooter();this.footerPromise=a.Deferred();var e=this.getFooter();if("string"==typeof d){e.html(d);this.footerPromise.resolve(e)}else{b.render(l.LOADING,{}).then(function(a){e.html(a);return d}).then(function(a,c){e.html(a);if(c){if(this.isAttached){b.runTemplateJS(c)}else{this.footerJS=c}}return e}.bind(this)).then(function(a){this.footerPromise.resolve(a)}.bind(this)).catch(c.exception)}};o.prototype.hasFooterContent=function(){return this.getFooter().children().length?!0:!1};o.prototype.hideFooter=function(){this.getFooter().addClass("hidden")};o.prototype.showFooter=function(){this.getFooter().removeClass("hidden")};o.prototype.setLarge=function(){if(this.isLarge()){return}this.getModal().addClass("modal-lg")};o.prototype.isLarge=function(){return this.getModal().hasClass("modal-lg")};o.prototype.setSmall=function(){if(this.isSmall()){return}this.getModal().removeClass("modal-lg")};o.prototype.isSmall=function(){return!this.getModal().hasClass("modal-lg")};o.prototype.setScrollable=function(a){if(!a){this.getModal()[0].classList.remove("modal-dialog-scrollable");return}this.getModal()[0].classList.add("modal-dialog-scrollable")};o.prototype.calculateZIndex=function(){var b=a(k.DIALOG+", "+k.MENU_BAR+", "+k.HAS_Z_INDEX),c=parseInt(this.root.css("z-index"));b.each(function(b,d){d=a(d);var e=d.css("z-index")?parseInt(d.css("z-index")):0;if(e>c){c=e}});return c};o.prototype.isVisible=function(){return this.root.hasClass("show")};o.prototype.hasFocus=function(){var b=a(document.activeElement);return this.root.is(b)||this.root.has(b).length};o.prototype.hasTransitions=function(){return this.getRoot().hasClass("fade")};o.prototype.show=function(){if(this.isVisible()){return a.Deferred().resolve()}var b=new j("core/modal:show");if(this.hasFooterContent()){this.showFooter()}else{this.hideFooter()}if(!this.isAttached){this.attachToDOM()}return this.getBackdrop().then(function(b){var c=this.calculateZIndex(),d=c+2;this.root.css("z-index",d);b.setZIndex(d-1);b.show();this.root.removeClass("hide").addClass("show");this.accessibilityShow();this.getModal().focus();a("body").addClass("modal-open");this.root.trigger(h.shown,this)}.bind(this)).then(b.resolve)};o.prototype.hideIfNotForm=function(){var a=this.modal.find(k.FORM);if(0==a.length){this.hide()}};o.prototype.hide=function(){this.getBackdrop().done(function(b){i.untrapFocus();if(!this.countOtherVisibleModals()){b.hide();a("body").removeClass("modal-open")}var c=parseInt(this.root.css("z-index"));this.root.css("z-index","");b.setZIndex(c-3);this.accessibilityHide();if(this.hasTransitions()){this.getRoot().one("transitionend webkitTransitionEnd oTransitionEnd",function(){this.getRoot().removeClass("show").addClass("hide")}.bind(this))}else{this.getRoot().removeClass("show").addClass("hide")}this.root.trigger(h.hidden,this)}.bind(this))};o.prototype.destroy=function(){this.hide();this.root.remove();this.root.trigger(h.destroyed,this)};o.prototype.accessibilityShow=function(){a("body").children().each(function(b,c){if(!this.root.is(c)){c=a(c);var d=c.attr("aria-hidden");if("true"!==d){c.data("previous-aria-hidden",d);this.hiddenSiblings.push(c);c.attr("aria-hidden","true")}}}.bind(this));this.root.attr("aria-hidden","false")};o.prototype.accessibilityHide=function(){this.root.attr("aria-hidden","true");a.each(this.hiddenSiblings,function(b,c){c=a(c);var d=c.data("previous-aria-hidden");if("undefined"==typeof d){c.removeAttr("aria-hidden")}else{c.attr("aria-hidden",d)}});this.hiddenSiblings=[]};o.prototype.registerEventListeners=function(){this.getRoot().on("keydown",function(a){if(!this.isVisible()){return}if(a.keyCode==d.escape){this.hide()}}.bind(this));this.getRoot().click(function(b){if(!a(b.target).closest(k.MODAL).length){if(a(b.target).closest(k.CONTAINER).length){this.hideIfNotForm()}}}.bind(this));e.define(this.getModal(),[e.events.activate]);this.getModal().on(e.events.activate,k.HIDE,function(a,b){this.hide();b.originalEvent.preventDefault()}.bind(this))};o.prototype.registerCloseOnCancel=function(){this.getModal().on(e.events.activate,this.getActionSelector("cancel"),function(b,c){var d=a.Event(h.cancel);this.getRoot().trigger(d,this);if(!d.isDefaultPrevented()){c.originalEvent.preventDefault();if(this.removeOnClose){this.destroy()}else{this.hide()}}}.bind(this))};o.prototype.registerCloseOnSave=function(){this.getModal().on(e.events.activate,this.getActionSelector("save"),function(b,c){var d=a.Event(h.save);this.getRoot().trigger(d,this);if(!d.isDefaultPrevented()){c.originalEvent.preventDefault();if(this.removeOnClose){this.destroy()}else{this.hide()}}}.bind(this))};o.prototype.asyncSet=function(b,d){var e=b;if("object"!==_typeof(b)||!b.hasOwnProperty("then")){e=a.Deferred();e.resolve(b)}e.then(function(a){d(a)}).fail(c.exception);return e};o.prototype.setButtonText=function(a,b){var c=this.getFooter().find(this.getActionSelector(a));if(!c){throw new Error("Unable to find the '"+a+"' button")}return this.asyncSet(b,c.text.bind(c))};o.prototype.getActionSelector=function(a){return"[data-action='"+a+"']"};o.prototype.setRemoveOnClose=function(a){this.removeOnClose=a};return o});
+function _typeof(a){"@babel/helpers - typeof";if("function"==typeof Symbol&&"symbol"==typeof Symbol.iterator){_typeof=function(a){return typeof a}}else{_typeof=function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a}}return _typeof(a)}define ("core/modal",["jquery","core/templates","core/notification","core/key_codes","core/custom_interaction_events","core/modal_backdrop","core/event","core/modal_events","core/local/aria/focuslock","core/pending","core/aria"],function(a,b,c,d,e,f,g,h,i,j,k){var l={CONTAINER:"[data-region=\"modal-container\"]",MODAL:"[data-region=\"modal\"]",HEADER:"[data-region=\"header\"]",TITLE:"[data-region=\"title\"]",BODY:"[data-region=\"body\"]",FOOTER:"[data-region=\"footer\"]",HIDE:"[data-action=\"hide\"]",DIALOG:"[role=dialog]",FORM:"form",MENU_BAR:"[role=menubar]",HAS_Z_INDEX:".moodle-has-zindex",CAN_RECEIVE_FOCUS:"input:not([type=\"hidden\"]), a[href], button, textarea, select, [tabindex]"},m={LOADING:"core/loading",BACKDROP:"core/modal_backdrop"},n,o=0,p=function(b){this.root=a(b);this.modal=this.root.find(l.MODAL);this.header=this.modal.find(l.HEADER);this.headerPromise=a.Deferred();this.title=this.header.find(l.TITLE);this.titlePromise=a.Deferred();this.body=this.modal.find(l.BODY);this.bodyPromise=a.Deferred();this.footer=this.modal.find(l.FOOTER);this.footerPromise=a.Deferred();this.hiddenSiblings=[];this.isAttached=!1;this.bodyJS=null;this.footerJS=null;this.modalCount=o++;if(!this.root.is(l.CONTAINER)){c.exception({message:"Element is not a modal container"})}if(!this.modal.length){c.exception({message:"Container does not contain a modal"})}if(!this.header.length){c.exception({message:"Modal is missing a header region"})}if(!this.title.length){c.exception({message:"Modal header is missing a title region"})}if(!this.body.length){c.exception({message:"Modal is missing a body region"})}if(!this.footer.length){c.exception({message:"Modal is missing a footer region"})}this.registerEventListeners()};p.prototype.attachToDOM=function(){if(this.isAttached){return}a("body").append(this.root);i.trapFocus(this.root[0]);if(this.bodyJS){b.runTemplateJS(this.bodyJS);this.bodyJS=null}if(this.footerJS){b.runTemplateJS(this.footerJS);this.footerJS=null}this.isAttached=!0};p.prototype.countOtherVisibleModals=function(){var b=0;a("body").find(l.CONTAINER).each(function(c,d){d=a(d);if(!this.root.is(d)&&d.hasClass("show")){b++}}.bind(this));return b};p.prototype.getBackdrop=function(){if(!n){n=b.render(m.BACKDROP,{}).then(function(b){var c=a(b);return new f(c)}).fail(c.exception)}return n};p.prototype.getRoot=function(){return this.root};p.prototype.getModal=function(){return this.modal};p.prototype.getTitle=function(){return this.title};p.prototype.getBody=function(){return this.body};p.prototype.getFooter=function(){return this.footer};p.prototype.getTitlePromise=function(){return this.titlePromise};p.prototype.getBodyPromise=function(){return this.bodyPromise};p.prototype.getFooterPromise=function(){return this.footerPromise};p.prototype.getModalCount=function(){return this.modalCount};p.prototype.setTitle=function(b){var d=this.getTitle();this.titlePromise=a.Deferred();this.asyncSet(b,d.html.bind(d)).then(function(){this.titlePromise.resolve(d)}.bind(this)).catch(c.exception)};p.prototype.setBody=function(d){this.bodyPromise=a.Deferred();var e=this.getBody();if("string"==typeof d){e.html(d);g.notifyFilterContentUpdated(e);this.getRoot().trigger(h.bodyRendered,this);this.bodyPromise.resolve(e)}else{var f="amd-modal-js-pending-id-"+this.getModalCount();M.util.js_pending(f);var i=null;e.css("overflow","hidden");d=a.when(d);if("pending"==d.state()){var j=e.innerHeight();if(100>j){j=100}e.animate({height:j+"px"},150);e.html("");i=b.render(m.LOADING,{}).then(function(b){var c=a(b).hide();e.html(c);c.fadeIn(150);return a.when(c.promise(),d)}).then(function(a){return a.fadeOut(100).promise()}).then(function(){return d})}else{i=d}i.then(function(a,c){var d=null;if(this.isVisible()){e.css("opacity",0);var f=e.innerHeight();e.html(a);e.css("height","");var g=e.innerHeight();e.css("height",f+"px");d=e.animate({height:g+"px",opacity:1},{duration:150,queue:!1}).promise()}else{e.html(a)}if(c){if(this.isAttached){b.runTemplateJS(c)}else{this.bodyJS=c}}return d}.bind(this)).then(function(a){g.notifyFilterContentUpdated(e);this.getRoot().trigger(h.bodyRendered,this);return a}.bind(this)).then(function(){this.bodyPromise.resolve(e)}.bind(this)).fail(c.exception).always(function(){e.css("height","");e.css("overflow","");e.css("opacity","");M.util.js_complete(f)}).fail(c.exception)}};p.prototype.setFooter=function(d){this.showFooter();this.footerPromise=a.Deferred();var e=this.getFooter();if("string"==typeof d){e.html(d);this.footerPromise.resolve(e)}else{b.render(m.LOADING,{}).then(function(a){e.html(a);return d}).then(function(a,c){e.html(a);if(c){if(this.isAttached){b.runTemplateJS(c)}else{this.footerJS=c}}return e}.bind(this)).then(function(a){this.footerPromise.resolve(a)}.bind(this)).catch(c.exception)}};p.prototype.hasFooterContent=function(){return this.getFooter().children().length?!0:!1};p.prototype.hideFooter=function(){this.getFooter().addClass("hidden")};p.prototype.showFooter=function(){this.getFooter().removeClass("hidden")};p.prototype.setLarge=function(){if(this.isLarge()){return}this.getModal().addClass("modal-lg")};p.prototype.isLarge=function(){return this.getModal().hasClass("modal-lg")};p.prototype.setSmall=function(){if(this.isSmall()){return}this.getModal().removeClass("modal-lg")};p.prototype.isSmall=function(){return!this.getModal().hasClass("modal-lg")};p.prototype.setScrollable=function(a){if(!a){this.getModal()[0].classList.remove("modal-dialog-scrollable");return}this.getModal()[0].classList.add("modal-dialog-scrollable")};p.prototype.calculateZIndex=function(){var b=a(l.DIALOG+", "+l.MENU_BAR+", "+l.HAS_Z_INDEX),c=parseInt(this.root.css("z-index"));b.each(function(b,d){d=a(d);var e=d.css("z-index")?parseInt(d.css("z-index")):0;if(e>c){c=e}});return c};p.prototype.isVisible=function(){return this.root.hasClass("show")};p.prototype.hasFocus=function(){var b=a(document.activeElement);return this.root.is(b)||this.root.has(b).length};p.prototype.hasTransitions=function(){return this.getRoot().hasClass("fade")};p.prototype.show=function(){if(this.isVisible()){return a.Deferred().resolve()}var b=new j("core/modal:show");if(this.hasFooterContent()){this.showFooter()}else{this.hideFooter()}if(!this.isAttached){this.attachToDOM()}return this.getBackdrop().then(function(b){var c=this.calculateZIndex(),d=c+2;this.root.css("z-index",d);b.setZIndex(d-1);b.show();this.root.removeClass("hide").addClass("show");this.accessibilityShow();this.getModal().focus();a("body").addClass("modal-open");this.root.trigger(h.shown,this)}.bind(this)).then(b.resolve)};p.prototype.hideIfNotForm=function(){var a=this.modal.find(l.FORM);if(0==a.length){this.hide()}};p.prototype.hide=function(){this.getBackdrop().done(function(b){i.untrapFocus();if(!this.countOtherVisibleModals()){b.hide();a("body").removeClass("modal-open")}var c=parseInt(this.root.css("z-index"));this.root.css("z-index","");b.setZIndex(c-3);this.accessibilityHide();if(this.hasTransitions()){this.getRoot().one("transitionend webkitTransitionEnd oTransitionEnd",function(){this.getRoot().removeClass("show").addClass("hide")}.bind(this))}else{this.getRoot().removeClass("show").addClass("hide")}this.root.trigger(h.hidden,this)}.bind(this))};p.prototype.destroy=function(){this.hide();this.root.remove();this.root.trigger(h.destroyed,this)};p.prototype.accessibilityShow=function(){k.hideSiblings(this.root.get()[0]);this.root.removeAttr("aria-hidden")};p.prototype.accessibilityHide=function(){this.root.attr("aria-hidden","true");k.unhideSiblings(this.root.get()[0])};p.prototype.registerEventListeners=function(){this.getRoot().on("keydown",function(a){if(!this.isVisible()){return}if(a.keyCode==d.escape){this.hide()}}.bind(this));this.getRoot().click(function(b){if(!a(b.target).closest(l.MODAL).length){if(a(b.target).closest(l.CONTAINER).length){this.hideIfNotForm()}}}.bind(this));e.define(this.getModal(),[e.events.activate]);this.getModal().on(e.events.activate,l.HIDE,function(a,b){this.hide();b.originalEvent.preventDefault()}.bind(this))};p.prototype.registerCloseOnCancel=function(){this.getModal().on(e.events.activate,this.getActionSelector("cancel"),function(b,c){var d=a.Event(h.cancel);this.getRoot().trigger(d,this);if(!d.isDefaultPrevented()){c.originalEvent.preventDefault();if(this.removeOnClose){this.destroy()}else{this.hide()}}}.bind(this))};p.prototype.registerCloseOnSave=function(){this.getModal().on(e.events.activate,this.getActionSelector("save"),function(b,c){var d=a.Event(h.save);this.getRoot().trigger(d,this);if(!d.isDefaultPrevented()){c.originalEvent.preventDefault();if(this.removeOnClose){this.destroy()}else{this.hide()}}}.bind(this))};p.prototype.asyncSet=function(b,d){var e=b;if("object"!==_typeof(b)||!b.hasOwnProperty("then")){e=a.Deferred();e.resolve(b)}e.then(function(a){d(a)}).fail(c.exception);return e};p.prototype.setButtonText=function(a,b){var c=this.getFooter().find(this.getActionSelector(a));if(!c){throw new Error("Unable to find the '"+a+"' button")}return this.asyncSet(b,c.text.bind(c))};p.prototype.getActionSelector=function(a){return"[data-action='"+a+"']"};p.prototype.setRemoveOnClose=function(a){this.removeOnClose=a};return p});
//# sourceMappingURL=modal.min.js.map
diff --git a/lib/amd/build/modal.min.js.map b/lib/amd/build/modal.min.js.map
index 19c89db0477..297ee6cf62b 100644
--- a/lib/amd/build/modal.min.js.map
+++ b/lib/amd/build/modal.min.js.map
@@ -1 +1 @@
-{"version":3,"sources":["../src/modal.js"],"names":["define","$","Templates","Notification","KeyCodes","CustomEvents","ModalBackdrop","Event","ModalEvents","FocusLock","Pending","SELECTORS","CONTAINER","MODAL","HEADER","TITLE","BODY","FOOTER","HIDE","DIALOG","FORM","MENU_BAR","HAS_Z_INDEX","CAN_RECEIVE_FOCUS","TEMPLATES","LOADING","BACKDROP","backdropPromise","modalCounter","Modal","root","modal","find","header","headerPromise","Deferred","title","titlePromise","body","bodyPromise","footer","footerPromise","hiddenSiblings","isAttached","bodyJS","footerJS","modalCount","is","exception","message","length","registerEventListeners","prototype","attachToDOM","append","trapFocus","runTemplateJS","countOtherVisibleModals","count","each","index","element","hasClass","bind","getBackdrop","render","then","html","fail","getRoot","getModal","getTitle","getBody","getFooter","getTitlePromise","getBodyPromise","getFooterPromise","getModalCount","setTitle","value","asyncSet","resolve","catch","setBody","notifyFilterContentUpdated","trigger","bodyRendered","jsPendingId","M","util","js_pending","contentPromise","css","when","state","height","innerHeight","animate","loadingIcon","hide","fadeIn","promise","fadeOut","js","result","isVisible","currentHeight","newHeight","opacity","duration","queue","always","js_complete","setFooter","showFooter","hasFooterContent","children","hideFooter","addClass","removeClass","setLarge","isLarge","setSmall","isSmall","setScrollable","classList","remove","add","calculateZIndex","items","zIndex","parseInt","item","itemZIndex","hasFocus","target","document","activeElement","has","hasTransitions","show","pendingPromise","backdrop","currentIndex","newIndex","setZIndex","accessibilityShow","focus","shown","hideIfNotForm","formElement","done","untrapFocus","accessibilityHide","one","hidden","destroy","destroyed","child","attr","data","push","sibling","previousValue","removeAttr","on","e","keyCode","escape","click","closest","events","activate","originalEvent","preventDefault","registerCloseOnCancel","getActionSelector","cancelEvent","cancel","isDefaultPrevented","removeOnClose","registerCloseOnSave","saveEvent","save","setFunction","p","hasOwnProperty","content","setButtonText","action","button","Error","text","setRemoveOnClose"],"mappings":"mSAwBAA,OAAM,cAAC,CACH,QADG,CAEH,gBAFG,CAGH,mBAHG,CAIH,gBAJG,CAKH,gCALG,CAMH,qBANG,CAOH,YAPG,CAQH,mBARG,CASH,2BATG,CAUH,cAVG,CAAD,CAWH,SAASC,CAAT,CAAYC,CAAZ,CAAuBC,CAAvB,CAAqCC,CAArC,CAA+CC,CAA/C,CAA6DC,CAA7D,CAA4EC,CAA5E,CAAmFC,CAAnF,CAAgGC,CAAhG,CAA2GC,CAA3G,CAAoH,IAE/GC,CAAAA,CAAS,CAAG,CACZC,SAAS,CAAE,mCADC,CAEZC,KAAK,CAAE,yBAFK,CAGZC,MAAM,CAAE,0BAHI,CAIZC,KAAK,CAAE,yBAJK,CAKZC,IAAI,CAAE,wBALM,CAMZC,MAAM,CAAE,0BANI,CAOZC,IAAI,CAAE,wBAPM,CAQZC,MAAM,CAAE,eARI,CASZC,IAAI,CAAE,MATM,CAUZC,QAAQ,CAAE,gBAVE,CAWZC,WAAW,CAAE,oBAXD,CAYZC,iBAAiB,CAAE,6EAZP,CAFmG,CAiB/GC,CAAS,CAAG,CACZC,OAAO,CAAE,cADG,CAEZC,QAAQ,CAAE,qBAFE,CAjBmG,CAyB/GC,CAzB+G,CA+B/GC,CAAY,CAAG,CA/BgG,CAsC/GC,CAAK,CAAG,SAASC,CAAT,CAA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AAqBtD,CACxB,CAFD,CAIA,MAAOjG,CAAAA,CACV,CAh5BK,CAAN","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 * Contain the logic for modals.\n *\n * @module core/modal\n * @class modal\n * @package core\n * @copyright 2016 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/templates',\n 'core/notification',\n 'core/key_codes',\n 'core/custom_interaction_events',\n 'core/modal_backdrop',\n 'core/event',\n 'core/modal_events',\n 'core/local/aria/focuslock',\n 'core/pending',\n], function($, Templates, Notification, KeyCodes, CustomEvents, ModalBackdrop, Event, ModalEvents, FocusLock, Pending) {\n\n var SELECTORS = {\n CONTAINER: '[data-region=\"modal-container\"]',\n MODAL: '[data-region=\"modal\"]',\n HEADER: '[data-region=\"header\"]',\n TITLE: '[data-region=\"title\"]',\n BODY: '[data-region=\"body\"]',\n FOOTER: '[data-region=\"footer\"]',\n HIDE: '[data-action=\"hide\"]',\n DIALOG: '[role=dialog]',\n FORM: 'form',\n MENU_BAR: '[role=menubar]',\n HAS_Z_INDEX: '.moodle-has-zindex',\n CAN_RECEIVE_FOCUS: 'input:not([type=\"hidden\"]), a[href], button, textarea, select, [tabindex]',\n };\n\n var TEMPLATES = {\n LOADING: 'core/loading',\n BACKDROP: 'core/modal_backdrop',\n };\n\n /**\n * Module singleton for the backdrop to be reused by all Modal instances.\n */\n var backdropPromise;\n\n /**\n * A counter that gets incremented for each modal created. This can be\n * used to generate unique values for the modals.\n */\n var modalCounter = 0;\n\n /**\n * Constructor for the Modal.\n *\n * @param {object} root The root jQuery element for the modal\n */\n var Modal = function(root) {\n this.root = $(root);\n this.modal = this.root.find(SELECTORS.MODAL);\n this.header = this.modal.find(SELECTORS.HEADER);\n this.headerPromise = $.Deferred();\n this.title = this.header.find(SELECTORS.TITLE);\n this.titlePromise = $.Deferred();\n this.body = this.modal.find(SELECTORS.BODY);\n this.bodyPromise = $.Deferred();\n this.footer = this.modal.find(SELECTORS.FOOTER);\n this.footerPromise = $.Deferred();\n this.hiddenSiblings = [];\n this.isAttached = false;\n this.bodyJS = null;\n this.footerJS = null;\n this.modalCount = modalCounter++;\n\n if (!this.root.is(SELECTORS.CONTAINER)) {\n Notification.exception({message: 'Element is not a modal container'});\n }\n\n if (!this.modal.length) {\n Notification.exception({message: 'Container does not contain a modal'});\n }\n\n if (!this.header.length) {\n Notification.exception({message: 'Modal is missing a header region'});\n }\n\n if (!this.title.length) {\n Notification.exception({message: 'Modal header is missing a title region'});\n }\n\n if (!this.body.length) {\n Notification.exception({message: 'Modal is missing a body region'});\n }\n\n if (!this.footer.length) {\n Notification.exception({message: 'Modal is missing a footer region'});\n }\n\n this.registerEventListeners();\n };\n\n /**\n * Add the modal to the page, if it hasn't already been added. This includes running any\n * javascript that has been cached until now.\n *\n * @method attachToDOM\n */\n Modal.prototype.attachToDOM = function() {\n if (this.isAttached) {\n return;\n }\n\n $('body').append(this.root);\n FocusLock.trapFocus(this.root[0]);\n\n // If we'd cached any JS then we can run it how that the modal is\n // attached to the DOM.\n if (this.bodyJS) {\n Templates.runTemplateJS(this.bodyJS);\n this.bodyJS = null;\n }\n\n if (this.footerJS) {\n Templates.runTemplateJS(this.footerJS);\n this.footerJS = null;\n }\n\n this.isAttached = true;\n };\n\n /**\n * Count the number of other visible modals (not including this one).\n *\n * @method countOtherVisibleModals\n * @return {int}\n */\n Modal.prototype.countOtherVisibleModals = function() {\n var count = 0;\n $('body').find(SELECTORS.CONTAINER).each(function(index, element) {\n element = $(element);\n\n // If we haven't found ourself and the element is visible.\n if (!this.root.is(element) && element.hasClass('show')) {\n count++;\n }\n }.bind(this));\n\n return count;\n };\n\n /**\n * Get the modal backdrop.\n *\n * @method getBackdrop\n * @return {object} jQuery promise\n */\n Modal.prototype.getBackdrop = function() {\n if (!backdropPromise) {\n backdropPromise = Templates.render(TEMPLATES.BACKDROP, {})\n .then(function(html) {\n var element = $(html);\n\n return new ModalBackdrop(element);\n })\n .fail(Notification.exception);\n }\n\n return backdropPromise;\n };\n\n /**\n * Get the root element of this modal.\n *\n * @method getRoot\n * @return {object} jQuery object\n */\n Modal.prototype.getRoot = function() {\n return this.root;\n };\n\n /**\n * Get the modal element of this modal.\n *\n * @method getModal\n * @return {object} jQuery object\n */\n Modal.prototype.getModal = function() {\n return this.modal;\n };\n\n /**\n * Get the modal title element.\n *\n * @method getTitle\n * @return {object} jQuery object\n */\n Modal.prototype.getTitle = function() {\n return this.title;\n };\n\n /**\n * Get the modal body element.\n *\n * @method getBody\n * @return {object} jQuery object\n */\n Modal.prototype.getBody = function() {\n return this.body;\n };\n\n /**\n * Get the modal footer element.\n *\n * @method getFooter\n * @return {object} jQuery object\n */\n Modal.prototype.getFooter = function() {\n return this.footer;\n };\n\n /**\n * Get a promise resolving to the title region.\n *\n * @method getTitlePromise\n * @return {Promise}\n */\n Modal.prototype.getTitlePromise = function() {\n return this.titlePromise;\n };\n\n /**\n * Get a promise resolving to the body region.\n *\n * @method getBodyPromise\n * @return {object} jQuery object\n */\n Modal.prototype.getBodyPromise = function() {\n return this.bodyPromise;\n };\n\n /**\n * Get a promise resolving to the footer region.\n *\n * @method getFooterPromise\n * @return {object} jQuery object\n */\n Modal.prototype.getFooterPromise = function() {\n return this.footerPromise;\n };\n\n /**\n * Get the unique modal count.\n *\n * @method getModalCount\n * @return {int}\n */\n Modal.prototype.getModalCount = function() {\n return this.modalCount;\n };\n\n /**\n * Set the modal title element.\n *\n * This method is overloaded to take either a string value for the title or a jQuery promise that is resolved with\n * HTML most commonly from a Str.get_string call.\n *\n * @method setTitle\n * @param {(string|object)} value The title string or jQuery promise which resolves to the title.\n */\n Modal.prototype.setTitle = function(value) {\n var title = this.getTitle();\n this.titlePromise = $.Deferred();\n\n this.asyncSet(value, title.html.bind(title))\n .then(function() {\n this.titlePromise.resolve(title);\n }.bind(this))\n .catch(Notification.exception);\n };\n\n /**\n * Set the modal body element.\n *\n * This method is overloaded to take either a string value for the body or a jQuery promise that is resolved with\n * HTML and Javascript most commonly from a Templates.render call.\n *\n * @method setBody\n * @param {(string|object)} value The body string or jQuery promise which resolves to the body.\n */\n Modal.prototype.setBody = function(value) {\n this.bodyPromise = $.Deferred();\n\n var body = this.getBody();\n\n if (typeof value === 'string') {\n // Just set the value if it's a string.\n body.html(value);\n Event.notifyFilterContentUpdated(body);\n this.getRoot().trigger(ModalEvents.bodyRendered, this);\n this.bodyPromise.resolve(body);\n } else {\n var jsPendingId = 'amd-modal-js-pending-id-' + this.getModalCount();\n M.util.js_pending(jsPendingId);\n // Otherwise we assume it's a promise to be resolved with\n // html and javascript.\n var contentPromise = null;\n body.css('overflow', 'hidden');\n\n // Ensure that the `value` is a jQuery Promise.\n value = $.when(value);\n\n if (value.state() == 'pending') {\n // We're still waiting for the body promise to resolve so\n // let's show a loading icon.\n var height = body.innerHeight();\n if (height < 100) {\n height = 100;\n }\n\n body.animate({height: height + 'px'}, 150);\n\n body.html('');\n contentPromise = Templates.render(TEMPLATES.LOADING, {})\n .then(function(html) {\n var loadingIcon = $(html).hide();\n body.html(loadingIcon);\n loadingIcon.fadeIn(150);\n\n // We only want the loading icon to fade out\n // when the content for the body has finished\n // loading.\n return $.when(loadingIcon.promise(), value);\n })\n .then(function(loadingIcon) {\n // Once the content has finished loading and\n // the loading icon has been shown then we can\n // fade the icon away to reveal the content.\n return loadingIcon.fadeOut(100).promise();\n })\n .then(function() {\n return value;\n });\n } else {\n // The content is already loaded so let's just display\n // it to the user. No need for a loading icon.\n contentPromise = value;\n }\n\n // Now we can actually display the content.\n contentPromise.then(function(html, js) {\n var result = null;\n\n if (this.isVisible()) {\n // If the modal is visible then we should display\n // the content gracefully for the user.\n body.css('opacity', 0);\n var currentHeight = body.innerHeight();\n body.html(html);\n // We need to clear any height values we've set here\n // in order to measure the height of the content being\n // added. This then allows us to animate the height\n // transition.\n body.css('height', '');\n var newHeight = body.innerHeight();\n body.css('height', currentHeight + 'px');\n result = body.animate(\n {height: newHeight + 'px', opacity: 1},\n {duration: 150, queue: false}\n ).promise();\n } else {\n // Since the modal isn't visible we can just immediately\n // set the content. No need to animate it.\n body.html(html);\n }\n\n if (js) {\n if (this.isAttached) {\n // If we're in the DOM then run the JS immediately.\n Templates.runTemplateJS(js);\n } else {\n // Otherwise cache it to be run when we're attached.\n this.bodyJS = js;\n }\n }\n\n return result;\n }.bind(this))\n .then(function(result) {\n Event.notifyFilterContentUpdated(body);\n this.getRoot().trigger(ModalEvents.bodyRendered, this);\n return result;\n }.bind(this))\n .then(function() {\n this.bodyPromise.resolve(body);\n return;\n }.bind(this))\n .fail(Notification.exception)\n .always(function() {\n // When we're done displaying all of the content we need\n // to clear the custom values we've set here.\n body.css('height', '');\n body.css('overflow', '');\n body.css('opacity', '');\n M.util.js_complete(jsPendingId);\n\n return;\n })\n .fail(Notification.exception);\n }\n };\n\n /**\n * Set the modal footer element. The footer element is made visible, if it\n * isn't already.\n *\n * This method is overloaded to take either a string\n * value for the body or a jQuery promise that is resolved with HTML and Javascript\n * most commonly from a Templates.render call.\n *\n * @method setFooter\n * @param {(string|object)} value The footer string or jQuery promise\n */\n Modal.prototype.setFooter = function(value) {\n // Make sure the footer is visible.\n this.showFooter();\n this.footerPromise = $.Deferred();\n\n var footer = this.getFooter();\n\n if (typeof value === 'string') {\n // Just set the value if it's a string.\n footer.html(value);\n this.footerPromise.resolve(footer);\n } else {\n // Otherwise we assume it's a promise to be resolved with\n // html and javascript.\n Templates.render(TEMPLATES.LOADING, {})\n .then(function(html) {\n footer.html(html);\n\n return value;\n })\n .then(function(html, js) {\n footer.html(html);\n\n if (js) {\n if (this.isAttached) {\n // If we're in the DOM then run the JS immediately.\n Templates.runTemplateJS(js);\n } else {\n // Otherwise cache it to be run when we're attached.\n this.footerJS = js;\n }\n }\n\n return footer;\n }.bind(this))\n .then(function(footer) {\n this.footerPromise.resolve(footer);\n return;\n }.bind(this))\n .catch(Notification.exception);\n }\n };\n\n /**\n * Check if the footer has any content in it.\n *\n * @method hasFooterContent\n * @return {bool}\n */\n Modal.prototype.hasFooterContent = function() {\n return this.getFooter().children().length ? true : false;\n };\n\n /**\n * Hide the footer element.\n *\n * @method hideFooter\n */\n Modal.prototype.hideFooter = function() {\n this.getFooter().addClass('hidden');\n };\n\n /**\n * Show the footer element.\n *\n * @method showFooter\n */\n Modal.prototype.showFooter = function() {\n this.getFooter().removeClass('hidden');\n };\n\n /**\n * Mark the modal as a large modal.\n *\n * @method setLarge\n */\n Modal.prototype.setLarge = function() {\n if (this.isLarge()) {\n return;\n }\n\n this.getModal().addClass('modal-lg');\n };\n\n /**\n * Check if the modal is a large modal.\n *\n * @method isLarge\n * @return {bool}\n */\n Modal.prototype.isLarge = function() {\n return this.getModal().hasClass('modal-lg');\n };\n\n /**\n * Mark the modal as a small modal.\n *\n * @method setSmall\n */\n Modal.prototype.setSmall = function() {\n if (this.isSmall()) {\n return;\n }\n\n this.getModal().removeClass('modal-lg');\n };\n\n /**\n * Check if the modal is a small modal.\n *\n * @method isSmall\n * @return {bool}\n */\n Modal.prototype.isSmall = function() {\n return !this.getModal().hasClass('modal-lg');\n };\n\n /**\n * Set this modal to be scrollable or not.\n *\n * @method setScrollable\n * @param {bool} value Whether the modal is scrollable or not\n */\n Modal.prototype.setScrollable = function(value) {\n if (!value) {\n this.getModal()[0].classList.remove('modal-dialog-scrollable');\n return;\n }\n\n this.getModal()[0].classList.add('modal-dialog-scrollable');\n };\n\n\n /**\n * Determine the highest z-index value currently on the page.\n *\n * @method calculateZIndex\n * @return {int}\n */\n Modal.prototype.calculateZIndex = function() {\n var items = $(SELECTORS.DIALOG + ', ' + SELECTORS.MENU_BAR + ', ' + SELECTORS.HAS_Z_INDEX);\n var zIndex = parseInt(this.root.css('z-index'));\n\n items.each(function(index, item) {\n item = $(item);\n // Note that webkit browsers won't return the z-index value from the CSS stylesheet\n // if the element doesn't have a position specified. Instead it'll return \"auto\".\n var itemZIndex = item.css('z-index') ? parseInt(item.css('z-index')) : 0;\n\n if (itemZIndex > zIndex) {\n zIndex = itemZIndex;\n }\n });\n\n return zIndex;\n };\n\n /**\n * Check if this modal is visible.\n *\n * @method isVisible\n * @return {bool}\n */\n Modal.prototype.isVisible = function() {\n return this.root.hasClass('show');\n };\n\n /**\n * Check if this modal has focus.\n *\n * @method hasFocus\n * @return {bool}\n */\n Modal.prototype.hasFocus = function() {\n var target = $(document.activeElement);\n return this.root.is(target) || this.root.has(target).length;\n };\n\n /**\n * Check if this modal has CSS transitions applied.\n *\n * @method hasTransitions\n * @return {bool}\n */\n Modal.prototype.hasTransitions = function() {\n return this.getRoot().hasClass('fade');\n };\n\n /**\n * Display this modal. The modal will be attached to the DOM if it hasn't\n * already been.\n *\n * @method show\n * @returns {Promise}\n */\n Modal.prototype.show = function() {\n if (this.isVisible()) {\n return $.Deferred().resolve();\n }\n\n var pendingPromise = new Pending('core/modal:show');\n\n if (this.hasFooterContent()) {\n this.showFooter();\n } else {\n this.hideFooter();\n }\n\n if (!this.isAttached) {\n this.attachToDOM();\n }\n\n return this.getBackdrop()\n .then(function(backdrop) {\n var currentIndex = this.calculateZIndex();\n var newIndex = currentIndex + 2;\n var newBackdropIndex = newIndex - 1;\n this.root.css('z-index', newIndex);\n backdrop.setZIndex(newBackdropIndex);\n backdrop.show();\n\n this.root.removeClass('hide').addClass('show');\n this.accessibilityShow();\n this.getModal().focus();\n $('body').addClass('modal-open');\n this.root.trigger(ModalEvents.shown, this);\n\n return;\n }.bind(this))\n .then(pendingPromise.resolve);\n };\n\n /**\n * Hide this modal if it does not contain a form.\n *\n * @method hideIfNotForm\n */\n Modal.prototype.hideIfNotForm = function() {\n var formElement = this.modal.find(SELECTORS.FORM);\n if (formElement.length == 0) {\n this.hide();\n }\n };\n\n /**\n * Hide this modal.\n *\n * @method hide\n */\n Modal.prototype.hide = function() {\n this.getBackdrop().done(function(backdrop) {\n FocusLock.untrapFocus();\n if (!this.countOtherVisibleModals()) {\n // Hide the backdrop if we're the last open modal.\n backdrop.hide();\n $('body').removeClass('modal-open');\n }\n\n var currentIndex = parseInt(this.root.css('z-index'));\n this.root.css('z-index', '');\n backdrop.setZIndex(currentIndex - 3);\n\n this.accessibilityHide();\n\n if (this.hasTransitions()) {\n // Wait for CSS transitions to complete before hiding the element.\n this.getRoot().one('transitionend webkitTransitionEnd oTransitionEnd', function() {\n this.getRoot().removeClass('show').addClass('hide');\n }.bind(this));\n } else {\n this.getRoot().removeClass('show').addClass('hide');\n }\n\n this.root.trigger(ModalEvents.hidden, this);\n }.bind(this));\n };\n\n /**\n * Remove this modal from the DOM.\n *\n * @method destroy\n */\n Modal.prototype.destroy = function() {\n this.hide();\n this.root.remove();\n this.root.trigger(ModalEvents.destroyed, this);\n };\n\n /**\n * Sets the appropriate aria attributes on this dialogue and the other\n * elements in the DOM to ensure that screen readers are able to navigate\n * the dialogue popup correctly.\n *\n * @method accessibilityShow\n */\n Modal.prototype.accessibilityShow = function() {\n // We need to get a list containing each sibling element and the shallowest\n // non-ancestral nodes in the DOM. We can shortcut this a little by leveraging\n // the fact that this dialogue is always appended to the document body therefore\n // it's siblings are the shallowest non-ancestral nodes. If that changes then\n // this code should also be updated.\n $('body').children().each(function(index, child) {\n // Skip the current modal.\n if (!this.root.is(child)) {\n child = $(child);\n var hidden = child.attr('aria-hidden');\n // If they are already hidden we can ignore them.\n if (hidden !== 'true') {\n // Save their current state.\n child.data('previous-aria-hidden', hidden);\n this.hiddenSiblings.push(child);\n\n // Hide this node from screen readers.\n child.attr('aria-hidden', 'true');\n }\n }\n }.bind(this));\n\n // Make us visible to screen readers.\n this.root.attr('aria-hidden', 'false');\n };\n\n /**\n * Restores the aria visibility on the DOM elements changed when displaying\n * the dialogue popup and makes the dialogue aria hidden to allow screen\n * readers to navigate the main page correctly when the dialogue is closed.\n *\n * @method accessibilityHide\n */\n Modal.prototype.accessibilityHide = function() {\n this.root.attr('aria-hidden', 'true');\n\n // Restore the sibling nodes back to their original values.\n $.each(this.hiddenSiblings, function(index, sibling) {\n sibling = $(sibling);\n var previousValue = sibling.data('previous-aria-hidden');\n // If the element didn't previously have an aria-hidden attribute\n // then we can just remove the one we set.\n if (typeof previousValue == 'undefined') {\n sibling.removeAttr('aria-hidden');\n } else {\n // Otherwise set it back to the old value (which will be false).\n sibling.attr('aria-hidden', previousValue);\n }\n });\n\n // Clear the cache. No longer need to store these.\n this.hiddenSiblings = [];\n };\n\n /**\n * Set up all of the event handling for the modal.\n *\n * @method registerEventListeners\n */\n Modal.prototype.registerEventListeners = function() {\n this.getRoot().on('keydown', function(e) {\n if (!this.isVisible()) {\n return;\n }\n\n if (e.keyCode == KeyCodes.escape) {\n this.hide();\n }\n }.bind(this));\n\n // Listen for clicks on the modal container.\n this.getRoot().click(function(e) {\n // If the click wasn't inside the modal element then we should\n // hide the modal.\n if (!$(e.target).closest(SELECTORS.MODAL).length) {\n // The check above fails to detect the click was inside the modal when the DOM tree is already changed.\n // So, we check if we can still find the container element or not. If not, then the DOM tree is changed.\n // It's best not to hide the modal in that case.\n if ($(e.target).closest(SELECTORS.CONTAINER).length) {\n this.hideIfNotForm();\n }\n }\n }.bind(this));\n\n CustomEvents.define(this.getModal(), [CustomEvents.events.activate]);\n this.getModal().on(CustomEvents.events.activate, SELECTORS.HIDE, function(e, data) {\n this.hide();\n data.originalEvent.preventDefault();\n }.bind(this));\n };\n\n /**\n * Register a listener to close the dialogue when the cancel button is pressed.\n *\n * @method registerCloseOnCancel\n */\n Modal.prototype.registerCloseOnCancel = function() {\n // Handle the clicking of the Cancel button.\n this.getModal().on(CustomEvents.events.activate, this.getActionSelector('cancel'), function(e, data) {\n var cancelEvent = $.Event(ModalEvents.cancel);\n this.getRoot().trigger(cancelEvent, this);\n\n if (!cancelEvent.isDefaultPrevented()) {\n data.originalEvent.preventDefault();\n\n if (this.removeOnClose) {\n this.destroy();\n } else {\n this.hide();\n }\n }\n }.bind(this));\n };\n\n /**\n * Register a listener to close the dialogue when the save button is pressed.\n *\n * @method registerCloseOnSave\n */\n Modal.prototype.registerCloseOnSave = function() {\n // Handle the clicking of the Cancel button.\n this.getModal().on(CustomEvents.events.activate, this.getActionSelector('save'), function(e, data) {\n var saveEvent = $.Event(ModalEvents.save);\n this.getRoot().trigger(saveEvent, this);\n\n if (!saveEvent.isDefaultPrevented()) {\n data.originalEvent.preventDefault();\n\n if (this.removeOnClose) {\n this.destroy();\n } else {\n this.hide();\n }\n }\n }.bind(this));\n };\n\n /**\n * Set or resolve and set the value using the function.\n *\n * @method asyncSet\n * @param {(string|object)} value The string or jQuery promise.\n * @param {function} setFunction The setter\n * @return {Promise}\n */\n Modal.prototype.asyncSet = function(value, setFunction) {\n var p = value;\n if (typeof value !== 'object' || !value.hasOwnProperty('then')) {\n p = $.Deferred();\n p.resolve(value);\n }\n\n p.then(function(content) {\n setFunction(content);\n\n return;\n })\n .fail(Notification.exception);\n\n return p;\n };\n\n /**\n * Set the title text of a button.\n *\n * This method is overloaded to take either a string value for the button title or a jQuery promise that is resolved with\n * text most commonly from a Str.get_string call.\n *\n * @param {DOMString} action The action of the button\n * @param {(String|object)} value The button text, or a promise which will resolve to it\n * @returns {Promise}\n */\n Modal.prototype.setButtonText = function(action, value) {\n const button = this.getFooter().find(this.getActionSelector(action));\n\n if (!button) {\n throw new Error(\"Unable to find the '\" + action + \"' button\");\n }\n\n return this.asyncSet(value, button.text.bind(button));\n };\n\n /**\n * Get the Selector for an action.\n *\n * @param {String} action\n * @returns {DOMString}\n */\n Modal.prototype.getActionSelector = function(action) {\n return \"[data-action='\" + action + \"']\";\n };\n\n /**\n * Set the flag to remove the modal from the DOM on close.\n *\n * @param {Boolean} remove\n */\n Modal.prototype.setRemoveOnClose = function(remove) {\n this.removeOnClose = remove;\n };\n\n return Modal;\n});\n"],"file":"modal.min.js"}
\ No newline at end of file
+{"version":3,"sources":["../src/modal.js"],"names":["define","$","Templates","Notification","KeyCodes","CustomEvents","ModalBackdrop","Event","ModalEvents","FocusLock","Pending","Aria","SELECTORS","CONTAINER","MODAL","HEADER","TITLE","BODY","FOOTER","HIDE","DIALOG","FORM","MENU_BAR","HAS_Z_INDEX","CAN_RECEIVE_FOCUS","TEMPLATES","LOADING","BACKDROP","backdropPromise","modalCounter","Modal","root","modal","find","header","headerPromise","Deferred","title","titlePromise","body","bodyPromise","footer","footerPromise","hiddenSiblings","isAttached","bodyJS","footerJS","modalCount","is","exception","message","length","registerEventListeners","prototype","attachToDOM","append","trapFocus","runTemplateJS","countOtherVisibleModals","count","each","index","element","hasClass","bind","getBackdrop","render","then","html","fail","getRoot","getModal","getTitle","getBody","getFooter","getTitlePromise","getBodyPromise","getFooterPromise","getModalCount","setTitle","value","asyncSet","resolve","catch","setBody","notifyFilterContentUpdated","trigger","bodyRendered","jsPendingId","M","util","js_pending","contentPromise","css","when","state","height","innerHeight","animate","loadingIcon","hide","fadeIn","promise","fadeOut","js","result","isVisible","currentHeight","newHeight","opacity","duration","queue","always","js_complete","setFooter","showFooter","hasFooterContent","children","hideFooter","addClass","removeClass","setLarge","isLarge","setSmall","isSmall","setScrollable","classList","remove","add","calculateZIndex","items","zIndex","parseInt","item","itemZIndex","hasFocus","target","document","activeElement","has","hasTransitions","show","pendingPromise","backdrop","currentIndex","newIndex","setZIndex","accessibilityShow","focus","shown","hideIfNotForm","formElement","done","untrapFocus","accessibilityHide","one","hidden","destroy","destroyed","hideSiblings","get","removeAttr","attr","unhideSiblings","on","e","keyCode","escape","click","closest","events","activate","data","originalEvent","preventDefault","registerCloseOnCancel","getActionSelector","cancelEvent","cancel","isDefaultPrevented","removeOnClose","registerCloseOnSave","saveEvent","save","setFunction","p","hasOwnProperty","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gB4I,gBAAhB,CAAmC,SAASlE,CAAT,CAAiB,CAChD,KAAKqD,aAAL,CAAqBrD,CACxB,CAFD,CAIA,MAAOjG,CAAAA,CACV,CA92BK,CAAN","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 * Contain the logic for modals.\n *\n * @module core/modal\n * @class modal\n * @package core\n * @copyright 2016 Ryan Wyllie \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/templates',\n 'core/notification',\n 'core/key_codes',\n 'core/custom_interaction_events',\n 'core/modal_backdrop',\n 'core/event',\n 'core/modal_events',\n 'core/local/aria/focuslock',\n 'core/pending',\n 'core/aria',\n], function($, Templates, Notification, KeyCodes, CustomEvents, ModalBackdrop, Event, ModalEvents, FocusLock, Pending, Aria) {\n\n var SELECTORS = {\n CONTAINER: '[data-region=\"modal-container\"]',\n MODAL: '[data-region=\"modal\"]',\n HEADER: '[data-region=\"header\"]',\n TITLE: '[data-region=\"title\"]',\n BODY: '[data-region=\"body\"]',\n FOOTER: '[data-region=\"footer\"]',\n HIDE: '[data-action=\"hide\"]',\n DIALOG: '[role=dialog]',\n FORM: 'form',\n MENU_BAR: '[role=menubar]',\n HAS_Z_INDEX: '.moodle-has-zindex',\n CAN_RECEIVE_FOCUS: 'input:not([type=\"hidden\"]), a[href], button, textarea, select, [tabindex]',\n };\n\n var TEMPLATES = {\n LOADING: 'core/loading',\n BACKDROP: 'core/modal_backdrop',\n };\n\n /**\n * Module singleton for the backdrop to be reused by all Modal instances.\n */\n var backdropPromise;\n\n /**\n * A counter that gets incremented for each modal created. This can be\n * used to generate unique values for the modals.\n */\n var modalCounter = 0;\n\n /**\n * Constructor for the Modal.\n *\n * @param {object} root The root jQuery element for the modal\n */\n var Modal = function(root) {\n this.root = $(root);\n this.modal = this.root.find(SELECTORS.MODAL);\n this.header = this.modal.find(SELECTORS.HEADER);\n this.headerPromise = $.Deferred();\n this.title = this.header.find(SELECTORS.TITLE);\n this.titlePromise = $.Deferred();\n this.body = this.modal.find(SELECTORS.BODY);\n this.bodyPromise = $.Deferred();\n this.footer = this.modal.find(SELECTORS.FOOTER);\n this.footerPromise = $.Deferred();\n this.hiddenSiblings = [];\n this.isAttached = false;\n this.bodyJS = null;\n this.footerJS = null;\n this.modalCount = modalCounter++;\n\n if (!this.root.is(SELECTORS.CONTAINER)) {\n Notification.exception({message: 'Element is not a modal container'});\n }\n\n if (!this.modal.length) {\n Notification.exception({message: 'Container does not contain a modal'});\n }\n\n if (!this.header.length) {\n Notification.exception({message: 'Modal is missing a header region'});\n }\n\n if (!this.title.length) {\n Notification.exception({message: 'Modal header is missing a title region'});\n }\n\n if (!this.body.length) {\n Notification.exception({message: 'Modal is missing a body region'});\n }\n\n if (!this.footer.length) {\n Notification.exception({message: 'Modal is missing a footer region'});\n }\n\n this.registerEventListeners();\n };\n\n /**\n * Add the modal to the page, if it hasn't already been added. This includes running any\n * javascript that has been cached until now.\n *\n * @method attachToDOM\n */\n Modal.prototype.attachToDOM = function() {\n if (this.isAttached) {\n return;\n }\n\n $('body').append(this.root);\n FocusLock.trapFocus(this.root[0]);\n\n // If we'd cached any JS then we can run it how that the modal is\n // attached to the DOM.\n if (this.bodyJS) {\n Templates.runTemplateJS(this.bodyJS);\n this.bodyJS = null;\n }\n\n if (this.footerJS) {\n Templates.runTemplateJS(this.footerJS);\n this.footerJS = null;\n }\n\n this.isAttached = true;\n };\n\n /**\n * Count the number of other visible modals (not including this one).\n *\n * @method countOtherVisibleModals\n * @return {int}\n */\n Modal.prototype.countOtherVisibleModals = function() {\n var count = 0;\n $('body').find(SELECTORS.CONTAINER).each(function(index, element) {\n element = $(element);\n\n // If we haven't found ourself and the element is visible.\n if (!this.root.is(element) && element.hasClass('show')) {\n count++;\n }\n }.bind(this));\n\n return count;\n };\n\n /**\n * Get the modal backdrop.\n *\n * @method getBackdrop\n * @return {object} jQuery promise\n */\n Modal.prototype.getBackdrop = function() {\n if (!backdropPromise) {\n backdropPromise = Templates.render(TEMPLATES.BACKDROP, {})\n .then(function(html) {\n var element = $(html);\n\n return new ModalBackdrop(element);\n })\n .fail(Notification.exception);\n }\n\n return backdropPromise;\n };\n\n /**\n * Get the root element of this modal.\n *\n * @method getRoot\n * @return {object} jQuery object\n */\n Modal.prototype.getRoot = function() {\n return this.root;\n };\n\n /**\n * Get the modal element of this modal.\n *\n * @method getModal\n * @return {object} jQuery object\n */\n Modal.prototype.getModal = function() {\n return this.modal;\n };\n\n /**\n * Get the modal title element.\n *\n * @method getTitle\n * @return {object} jQuery object\n */\n Modal.prototype.getTitle = function() {\n return this.title;\n };\n\n /**\n * Get the modal body element.\n *\n * @method getBody\n * @return {object} jQuery object\n */\n Modal.prototype.getBody = function() {\n return this.body;\n };\n\n /**\n * Get the modal footer element.\n *\n * @method getFooter\n * @return {object} jQuery object\n */\n Modal.prototype.getFooter = function() {\n return this.footer;\n };\n\n /**\n * Get a promise resolving to the title region.\n *\n * @method getTitlePromise\n * @return {Promise}\n */\n Modal.prototype.getTitlePromise = function() {\n return this.titlePromise;\n };\n\n /**\n * Get a promise resolving to the body region.\n *\n * @method getBodyPromise\n * @return {object} jQuery object\n */\n Modal.prototype.getBodyPromise = function() {\n return this.bodyPromise;\n };\n\n /**\n * Get a promise resolving to the footer region.\n *\n * @method getFooterPromise\n * @return {object} jQuery object\n */\n Modal.prototype.getFooterPromise = function() {\n return this.footerPromise;\n };\n\n /**\n * Get the unique modal count.\n *\n * @method getModalCount\n * @return {int}\n */\n Modal.prototype.getModalCount = function() {\n return this.modalCount;\n };\n\n /**\n * Set the modal title element.\n *\n * This method is overloaded to take either a string value for the title or a jQuery promise that is resolved with\n * HTML most commonly from a Str.get_string call.\n *\n * @method setTitle\n * @param {(string|object)} value The title string or jQuery promise which resolves to the title.\n */\n Modal.prototype.setTitle = function(value) {\n var title = this.getTitle();\n this.titlePromise = $.Deferred();\n\n this.asyncSet(value, title.html.bind(title))\n .then(function() {\n this.titlePromise.resolve(title);\n }.bind(this))\n .catch(Notification.exception);\n };\n\n /**\n * Set the modal body element.\n *\n * This method is overloaded to take either a string value for the body or a jQuery promise that is resolved with\n * HTML and Javascript most commonly from a Templates.render call.\n *\n * @method setBody\n * @param {(string|object)} value The body string or jQuery promise which resolves to the body.\n */\n Modal.prototype.setBody = function(value) {\n this.bodyPromise = $.Deferred();\n\n var body = this.getBody();\n\n if (typeof value === 'string') {\n // Just set the value if it's a string.\n body.html(value);\n Event.notifyFilterContentUpdated(body);\n this.getRoot().trigger(ModalEvents.bodyRendered, this);\n this.bodyPromise.resolve(body);\n } else {\n var jsPendingId = 'amd-modal-js-pending-id-' + this.getModalCount();\n M.util.js_pending(jsPendingId);\n // Otherwise we assume it's a promise to be resolved with\n // html and javascript.\n var contentPromise = null;\n body.css('overflow', 'hidden');\n\n // Ensure that the `value` is a jQuery Promise.\n value = $.when(value);\n\n if (value.state() == 'pending') {\n // We're still waiting for the body promise to resolve so\n // let's show a loading icon.\n var height = body.innerHeight();\n if (height < 100) {\n height = 100;\n }\n\n body.animate({height: height + 'px'}, 150);\n\n body.html('');\n contentPromise = Templates.render(TEMPLATES.LOADING, {})\n .then(function(html) {\n var loadingIcon = $(html).hide();\n body.html(loadingIcon);\n loadingIcon.fadeIn(150);\n\n // We only want the loading icon to fade out\n // when the content for the body has finished\n // loading.\n return $.when(loadingIcon.promise(), value);\n })\n .then(function(loadingIcon) {\n // Once the content has finished loading and\n // the loading icon has been shown then we can\n // fade the icon away to reveal the content.\n return loadingIcon.fadeOut(100).promise();\n })\n .then(function() {\n return value;\n });\n } else {\n // The content is already loaded so let's just display\n // it to the user. No need for a loading icon.\n contentPromise = value;\n }\n\n // Now we can actually display the content.\n contentPromise.then(function(html, js) {\n var result = null;\n\n if (this.isVisible()) {\n // If the modal is visible then we should display\n // the content gracefully for the user.\n body.css('opacity', 0);\n var currentHeight = body.innerHeight();\n body.html(html);\n // We need to clear any height values we've set here\n // in order to measure the height of the content being\n // added. This then allows us to animate the height\n // transition.\n body.css('height', '');\n var newHeight = body.innerHeight();\n body.css('height', currentHeight + 'px');\n result = body.animate(\n {height: newHeight + 'px', opacity: 1},\n {duration: 150, queue: false}\n ).promise();\n } else {\n // Since the modal isn't visible we can just immediately\n // set the content. No need to animate it.\n body.html(html);\n }\n\n if (js) {\n if (this.isAttached) {\n // If we're in the DOM then run the JS immediately.\n Templates.runTemplateJS(js);\n } else {\n // Otherwise cache it to be run when we're attached.\n this.bodyJS = js;\n }\n }\n\n return result;\n }.bind(this))\n .then(function(result) {\n Event.notifyFilterContentUpdated(body);\n this.getRoot().trigger(ModalEvents.bodyRendered, this);\n return result;\n }.bind(this))\n .then(function() {\n this.bodyPromise.resolve(body);\n return;\n }.bind(this))\n .fail(Notification.exception)\n .always(function() {\n // When we're done displaying all of the content we need\n // to clear the custom values we've set here.\n body.css('height', '');\n body.css('overflow', '');\n body.css('opacity', '');\n M.util.js_complete(jsPendingId);\n\n return;\n })\n .fail(Notification.exception);\n }\n };\n\n /**\n * Set the modal footer element. The footer element is made visible, if it\n * isn't already.\n *\n * This method is overloaded to take either a string\n * value for the body or a jQuery promise that is resolved with HTML and Javascript\n * most commonly from a Templates.render call.\n *\n * @method setFooter\n * @param {(string|object)} value The footer string or jQuery promise\n */\n Modal.prototype.setFooter = function(value) {\n // Make sure the footer is visible.\n this.showFooter();\n this.footerPromise = $.Deferred();\n\n var footer = this.getFooter();\n\n if (typeof value === 'string') {\n // Just set the value if it's a string.\n footer.html(value);\n this.footerPromise.resolve(footer);\n } else {\n // Otherwise we assume it's a promise to be resolved with\n // html and javascript.\n Templates.render(TEMPLATES.LOADING, {})\n .then(function(html) {\n footer.html(html);\n\n return value;\n })\n .then(function(html, js) {\n footer.html(html);\n\n if (js) {\n if (this.isAttached) {\n // If we're in the DOM then run the JS immediately.\n Templates.runTemplateJS(js);\n } else {\n // Otherwise cache it to be run when we're attached.\n this.footerJS = js;\n }\n }\n\n return footer;\n }.bind(this))\n .then(function(footer) {\n this.footerPromise.resolve(footer);\n return;\n }.bind(this))\n .catch(Notification.exception);\n }\n };\n\n /**\n * Check if the footer has any content in it.\n *\n * @method hasFooterContent\n * @return {bool}\n */\n Modal.prototype.hasFooterContent = function() {\n return this.getFooter().children().length ? true : false;\n };\n\n /**\n * Hide the footer element.\n *\n * @method hideFooter\n */\n Modal.prototype.hideFooter = function() {\n this.getFooter().addClass('hidden');\n };\n\n /**\n * Show the footer element.\n *\n * @method showFooter\n */\n Modal.prototype.showFooter = function() {\n this.getFooter().removeClass('hidden');\n };\n\n /**\n * Mark the modal as a large modal.\n *\n * @method setLarge\n */\n Modal.prototype.setLarge = function() {\n if (this.isLarge()) {\n return;\n }\n\n this.getModal().addClass('modal-lg');\n };\n\n /**\n * Check if the modal is a large modal.\n *\n * @method isLarge\n * @return {bool}\n */\n Modal.prototype.isLarge = function() {\n return this.getModal().hasClass('modal-lg');\n };\n\n /**\n * Mark the modal as a small modal.\n *\n * @method setSmall\n */\n Modal.prototype.setSmall = function() {\n if (this.isSmall()) {\n return;\n }\n\n this.getModal().removeClass('modal-lg');\n };\n\n /**\n * Check if the modal is a small modal.\n *\n * @method isSmall\n * @return {bool}\n */\n Modal.prototype.isSmall = function() {\n return !this.getModal().hasClass('modal-lg');\n };\n\n /**\n * Set this modal to be scrollable or not.\n *\n * @method setScrollable\n * @param {bool} value Whether the modal is scrollable or not\n */\n Modal.prototype.setScrollable = function(value) {\n if (!value) {\n this.getModal()[0].classList.remove('modal-dialog-scrollable');\n return;\n }\n\n this.getModal()[0].classList.add('modal-dialog-scrollable');\n };\n\n\n /**\n * Determine the highest z-index value currently on the page.\n *\n * @method calculateZIndex\n * @return {int}\n */\n Modal.prototype.calculateZIndex = function() {\n var items = $(SELECTORS.DIALOG + ', ' + SELECTORS.MENU_BAR + ', ' + SELECTORS.HAS_Z_INDEX);\n var zIndex = parseInt(this.root.css('z-index'));\n\n items.each(function(index, item) {\n item = $(item);\n // Note that webkit browsers won't return the z-index value from the CSS stylesheet\n // if the element doesn't have a position specified. Instead it'll return \"auto\".\n var itemZIndex = item.css('z-index') ? parseInt(item.css('z-index')) : 0;\n\n if (itemZIndex > zIndex) {\n zIndex = itemZIndex;\n }\n });\n\n return zIndex;\n };\n\n /**\n * Check if this modal is visible.\n *\n * @method isVisible\n * @return {bool}\n */\n Modal.prototype.isVisible = function() {\n return this.root.hasClass('show');\n };\n\n /**\n * Check if this modal has focus.\n *\n * @method hasFocus\n * @return {bool}\n */\n Modal.prototype.hasFocus = function() {\n var target = $(document.activeElement);\n return this.root.is(target) || this.root.has(target).length;\n };\n\n /**\n * Check if this modal has CSS transitions applied.\n *\n * @method hasTransitions\n * @return {bool}\n */\n Modal.prototype.hasTransitions = function() {\n return this.getRoot().hasClass('fade');\n };\n\n /**\n * Display this modal. The modal will be attached to the DOM if it hasn't\n * already been.\n *\n * @method show\n * @returns {Promise}\n */\n Modal.prototype.show = function() {\n if (this.isVisible()) {\n return $.Deferred().resolve();\n }\n\n var pendingPromise = new Pending('core/modal:show');\n\n if (this.hasFooterContent()) {\n this.showFooter();\n } else {\n this.hideFooter();\n }\n\n if (!this.isAttached) {\n this.attachToDOM();\n }\n\n return this.getBackdrop()\n .then(function(backdrop) {\n var currentIndex = this.calculateZIndex();\n var newIndex = currentIndex + 2;\n var newBackdropIndex = newIndex - 1;\n this.root.css('z-index', newIndex);\n backdrop.setZIndex(newBackdropIndex);\n backdrop.show();\n\n this.root.removeClass('hide').addClass('show');\n this.accessibilityShow();\n this.getModal().focus();\n $('body').addClass('modal-open');\n this.root.trigger(ModalEvents.shown, this);\n\n return;\n }.bind(this))\n .then(pendingPromise.resolve);\n };\n\n /**\n * Hide this modal if it does not contain a form.\n *\n * @method hideIfNotForm\n */\n Modal.prototype.hideIfNotForm = function() {\n var formElement = this.modal.find(SELECTORS.FORM);\n if (formElement.length == 0) {\n this.hide();\n }\n };\n\n /**\n * Hide this modal.\n *\n * @method hide\n */\n Modal.prototype.hide = function() {\n this.getBackdrop().done(function(backdrop) {\n FocusLock.untrapFocus();\n if (!this.countOtherVisibleModals()) {\n // Hide the backdrop if we're the last open modal.\n backdrop.hide();\n $('body').removeClass('modal-open');\n }\n\n var currentIndex = parseInt(this.root.css('z-index'));\n this.root.css('z-index', '');\n backdrop.setZIndex(currentIndex - 3);\n\n this.accessibilityHide();\n\n if (this.hasTransitions()) {\n // Wait for CSS transitions to complete before hiding the element.\n this.getRoot().one('transitionend webkitTransitionEnd oTransitionEnd', function() {\n this.getRoot().removeClass('show').addClass('hide');\n }.bind(this));\n } else {\n this.getRoot().removeClass('show').addClass('hide');\n }\n\n this.root.trigger(ModalEvents.hidden, this);\n }.bind(this));\n };\n\n /**\n * Remove this modal from the DOM.\n *\n * @method destroy\n */\n Modal.prototype.destroy = function() {\n this.hide();\n this.root.remove();\n this.root.trigger(ModalEvents.destroyed, this);\n };\n\n /**\n * Sets the appropriate aria attributes on this dialogue and the other\n * elements in the DOM to ensure that screen readers are able to navigate\n * the dialogue popup correctly.\n *\n * @method accessibilityShow\n */\n Modal.prototype.accessibilityShow = function() {\n Aria.hideSiblings(this.root.get()[0]);\n\n // Make us visible to screen readers.\n this.root.removeAttr('aria-hidden');\n };\n\n /**\n * Restores the aria visibility on the DOM elements changed when displaying\n * the dialogue popup and makes the dialogue aria hidden to allow screen\n * readers to navigate the main page correctly when the dialogue is closed.\n *\n * @method accessibilityHide\n */\n Modal.prototype.accessibilityHide = function() {\n this.root.attr('aria-hidden', 'true');\n\n Aria.unhideSiblings(this.root.get()[0]);\n };\n\n /**\n * Set up all of the event handling for the modal.\n *\n * @method registerEventListeners\n */\n Modal.prototype.registerEventListeners = function() {\n this.getRoot().on('keydown', function(e) {\n if (!this.isVisible()) {\n return;\n }\n\n if (e.keyCode == KeyCodes.escape) {\n this.hide();\n }\n }.bind(this));\n\n // Listen for clicks on the modal container.\n this.getRoot().click(function(e) {\n // If the click wasn't inside the modal element then we should\n // hide the modal.\n if (!$(e.target).closest(SELECTORS.MODAL).length) {\n // The check above fails to detect the click was inside the modal when the DOM tree is already changed.\n // So, we check if we can still find the container element or not. If not, then the DOM tree is changed.\n // It's best not to hide the modal in that case.\n if ($(e.target).closest(SELECTORS.CONTAINER).length) {\n this.hideIfNotForm();\n }\n }\n }.bind(this));\n\n CustomEvents.define(this.getModal(), [CustomEvents.events.activate]);\n this.getModal().on(CustomEvents.events.activate, SELECTORS.HIDE, function(e, data) {\n this.hide();\n data.originalEvent.preventDefault();\n }.bind(this));\n };\n\n /**\n * Register a listener to close the dialogue when the cancel button is pressed.\n *\n * @method registerCloseOnCancel\n */\n Modal.prototype.registerCloseOnCancel = function() {\n // Handle the clicking of the Cancel button.\n this.getModal().on(CustomEvents.events.activate, this.getActionSelector('cancel'), function(e, data) {\n var cancelEvent = $.Event(ModalEvents.cancel);\n this.getRoot().trigger(cancelEvent, this);\n\n if (!cancelEvent.isDefaultPrevented()) {\n data.originalEvent.preventDefault();\n\n if (this.removeOnClose) {\n this.destroy();\n } else {\n this.hide();\n }\n }\n }.bind(this));\n };\n\n /**\n * Register a listener to close the dialogue when the save button is pressed.\n *\n * @method registerCloseOnSave\n */\n Modal.prototype.registerCloseOnSave = function() {\n // Handle the clicking of the Cancel button.\n this.getModal().on(CustomEvents.events.activate, this.getActionSelector('save'), function(e, data) {\n var saveEvent = $.Event(ModalEvents.save);\n this.getRoot().trigger(saveEvent, this);\n\n if (!saveEvent.isDefaultPrevented()) {\n data.originalEvent.preventDefault();\n\n if (this.removeOnClose) {\n this.destroy();\n } else {\n this.hide();\n }\n }\n }.bind(this));\n };\n\n /**\n * Set or resolve and set the value using the function.\n *\n * @method asyncSet\n * @param {(string|object)} value The string or jQuery promise.\n * @param {function} setFunction The setter\n * @return {Promise}\n */\n Modal.prototype.asyncSet = function(value, setFunction) {\n var p = value;\n if (typeof value !== 'object' || !value.hasOwnProperty('then')) {\n p = $.Deferred();\n p.resolve(value);\n }\n\n p.then(function(content) {\n setFunction(content);\n\n return;\n })\n .fail(Notification.exception);\n\n return p;\n };\n\n /**\n * Set the title text of a button.\n *\n * This method is overloaded to take either a string value for the button title or a jQuery promise that is resolved with\n * text most commonly from a Str.get_string call.\n *\n * @param {DOMString} action The action of the button\n * @param {(String|object)} value The button text, or a promise which will resolve to it\n * @returns {Promise}\n */\n Modal.prototype.setButtonText = function(action, value) {\n const button = this.getFooter().find(this.getActionSelector(action));\n\n if (!button) {\n throw new Error(\"Unable to find the '\" + action + \"' button\");\n }\n\n return this.asyncSet(value, button.text.bind(button));\n };\n\n /**\n * Get the Selector for an action.\n *\n * @param {String} action\n * @returns {DOMString}\n */\n Modal.prototype.getActionSelector = function(action) {\n return \"[data-action='\" + action + \"']\";\n };\n\n /**\n * Set the flag to remove the modal from the DOM on close.\n *\n * @param {Boolean} remove\n */\n Modal.prototype.setRemoveOnClose = function(remove) {\n this.removeOnClose = remove;\n };\n\n return Modal;\n});\n"],"file":"modal.min.js"}
\ No newline at end of file
diff --git a/lib/amd/build/normalise.min.js b/lib/amd/build/normalise.min.js
new file mode 100644
index 00000000000..b31b2d0a77f
--- /dev/null
+++ b/lib/amd/build/normalise.min.js
@@ -0,0 +1,2 @@
+define ("core/normalise",["exports","jquery"],function(a,b){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.getList=void 0;b=function(a){return a&&a.__esModule?a:{default:a}}(b);var c=function(a){if(a instanceof HTMLElement){return[a]}if(a instanceof Array){return a}if(a instanceof NodeList){return Array.from(a)}if(a instanceof b.default){return a.get()}return Array.from(a)};a.getList=c});
+//# sourceMappingURL=normalise.min.js.map
diff --git a/lib/amd/build/normalise.min.js.map b/lib/amd/build/normalise.min.js.map
new file mode 100644
index 00000000000..c9598b2d1aa
--- /dev/null
+++ b/lib/amd/build/normalise.min.js.map
@@ -0,0 +1 @@
+{"version":3,"sources":["../src/normalise.js"],"names":["getList","nodes","HTMLElement","Array","NodeList","from","jQuery","get"],"mappings":"2IAyBA,uDAEO,GAAMA,CAAAA,CAAO,CAAG,SAAAC,CAAK,CAAI,CAC5B,GAAIA,CAAK,WAAYC,CAAAA,WAArB,CAAkC,CAE9B,MAAO,CAACD,CAAD,CACV,CAED,GAAIA,CAAK,WAAYE,CAAAA,KAArB,CAA4B,CAExB,MAAOF,CAAAA,CACV,CAED,GAAIA,CAAK,WAAYG,CAAAA,QAArB,CAA+B,CAE3B,MAAOD,CAAAA,KAAK,CAACE,IAAN,CAAWJ,CAAX,CACV,CAED,GAAIA,CAAK,WAAYK,UAArB,CAA6B,CAEzB,MAAOL,CAAAA,CAAK,CAACM,GAAN,EACV,CAGD,MAAOJ,CAAAA,KAAK,CAACE,IAAN,CAAWJ,CAAX,CACV,CAvBM,C","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 * Normalisation helpers.\n *\n * @module core/normalise\n * @class normalise\n * @package core\n * @copyright 2020 Andrew Nicols \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport jQuery from 'jquery';\n\nexport const getList = nodes => {\n if (nodes instanceof HTMLElement) {\n // A single record to conver to a NodeList.\n return [nodes];\n }\n\n if (nodes instanceof Array) {\n // A single record to conver to a NodeList.\n return nodes;\n }\n\n if (nodes instanceof NodeList) {\n // Already a NodeList.\n return Array.from(nodes);\n }\n\n if (nodes instanceof jQuery) {\n // A jQuery object to a NodeList.\n return nodes.get();\n }\n\n // Fallback to just having a go.\n return Array.from(nodes);\n};\n"],"file":"normalise.min.js"}
\ No newline at end of file
diff --git a/lib/amd/src/aria.js b/lib/amd/src/aria.js
new file mode 100644
index 00000000000..394effea47b
--- /dev/null
+++ b/lib/amd/src/aria.js
@@ -0,0 +1,31 @@
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see .
+
+/**
+ * Helpers to perform ARIA compliance changes to the DOM.
+ *
+ * @module core/aria
+ * @class aria
+ * @package core
+ * @copyright 2020 Andrew Nicols
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+export {
+ hide,
+ unhide,
+ hideSiblings,
+ unhideSiblings,
+} from './local/aria/aria-hidden';
diff --git a/lib/amd/src/local/aria/aria-hidden.js b/lib/amd/src/local/aria/aria-hidden.js
new file mode 100644
index 00000000000..a5989a02a80
--- /dev/null
+++ b/lib/amd/src/local/aria/aria-hidden.js
@@ -0,0 +1,267 @@
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see .
+
+/**
+ * ARIA helpers related to the aria-hidden attribute.
+ *
+ * @module core/local/aria/aria-hidden.
+ * @class aria
+ * @package core
+ * @copyright 2020 Andrew Nicols
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+import {getList} from 'core/normalise';
+import Selectors from './selectors';
+
+// The map of MutationObserver objects for an object.
+const childObserverMap = new Map();
+const siblingObserverMap = new Map();
+
+/**
+ * Determine whether the browser supports the MutationObserver system.
+ *
+ * @returns {Bool}
+ */
+const supportsMutationObservers = () => (MutationObserver && typeof MutationObserver === 'function');
+
+/**
+ * Disable element focusability, disabling the tabindex for child elements which are normally focusable.
+ *
+ * @param {HTMLElement} target
+ */
+const disableElementFocusability = target => {
+ if (!(target instanceof HTMLElement)) {
+ // This element is not an HTMLElement.
+ // This can happen for Text Nodes.
+ return;
+ }
+
+ if (target.matches(Selectors.elements.focusable)) {
+ disableAndStoreTabIndex(target);
+ }
+
+ target.querySelectorAll(Selectors.elements.focusable).forEach(disableAndStoreTabIndex);
+};
+
+/**
+ * Remove the current tab-index and store it for later restoration.
+ *
+ * @param {HTMLElement} element
+ */
+const disableAndStoreTabIndex = element => {
+ if (typeof element.dataset.ariaHiddenTabIndex !== 'undefined') {
+ // This child already has a hidden attribute.
+ // Do not modify it as the original value will be lost.
+ return;
+ }
+
+ // Store the old tabindex in a data attribute.
+ if (element.getAttribute('tabindex')) {
+ element.dataset.ariaHiddenTabIndex = element.getAttribute('tabindex');
+ } else {
+ element.dataset.ariaHiddenTabIndex = '';
+ }
+ element.setAttribute('tabindex', -1);
+};
+
+/**
+ * Re-enable element focusability, restoring any tabindex.
+ *
+ * @param {HTMLElement} target
+ */
+const enableElementFocusability = target => {
+ if (!(target instanceof HTMLElement)) {
+ // This element is not an HTMLElement.
+ // This can happen for Text Nodes.
+ return;
+ }
+
+ if (target.matches(Selectors.elements.focusableToUnhide)) {
+ restoreTabIndex(target);
+ }
+
+ target.querySelectorAll(Selectors.elements.focusableToUnhide).forEach(restoreTabIndex);
+};
+
+/**
+ * Restore the tab-index of the supplied element.
+ *
+ * When disabling focusability the current tab-index is stored in the ariaHiddenTabIndex data attribute.
+ * This is used to restore the tab-index, but only whilst the parent nodes remain unhidden.
+ *
+ * @param {HTMLElement} element
+ */
+const restoreTabIndex = element => {
+ if (element.closest(Selectors.aria.hidden)) {
+ // This item still has a hidden parent, or is hidden itself. Do not unhide it.
+ return;
+ }
+
+ const oldTabIndex = element.dataset.ariaHiddenTabIndex;
+ if (oldTabIndex === '') {
+ element.removeAttribute('tabindex');
+ } else {
+ element.setAttribute('tabindex', oldTabIndex);
+ }
+
+ delete element.dataset.ariaHiddenTabIndex;
+};
+
+/**
+ * Update the supplied DOM Module to be hidden.
+ *
+ * @param {HTMLElement} target
+ * @returns {Array}
+ */
+export const hide = target => getList(target).forEach(_hide);
+
+const _hide = target => {
+ if (!(target instanceof HTMLElement)) {
+ // This element is not an HTMLElement.
+ // This can happen for Text Nodes.
+ return;
+ }
+
+ if (target.closest(Selectors.aria.hidden)) {
+ // This Element, or a parent Element, is already hidden.
+ // Stop processing.
+ return;
+ }
+
+ // Set the aria-hidden attribute to true.
+ target.setAttribute('aria-hidden', true);
+
+ // Based on advice from https://dequeuniversity.com/rules/axe/3.3/aria-hidden-focus, upon setting the aria-hidden
+ // attribute, all focusable elements underneath that element should be modified such that they are not focusable.
+ disableElementFocusability(target);
+
+ if (supportsMutationObservers()) {
+ // Add a MutationObserver to check for new children to the tree.
+ const newNodeObserver = new MutationObserver(mutationList => {
+ mutationList.forEach(mutation => {
+ mutation.addedNodes.forEach(disableElementFocusability);
+ });
+ });
+
+ newNodeObserver.observe(target, {childList: true, subtree: true});
+ childObserverMap.set(target, newNodeObserver);
+ }
+};
+
+/**
+ * Reverse the effect of the hide action.
+ *
+ * @param {HTMLElement} target
+ * @returns {Array}
+ */
+export const unhide = target => getList(target).forEach(_unhide);
+
+const _unhide = target => {
+ if (!(target instanceof HTMLElement)) {
+ return;
+ }
+
+ // Note: The aria-hidden attribute should be removed, and not set to false.
+ // The presence of the attribute is sufficient for some browsers to treat it as being true, regardless of its value.
+ target.removeAttribute('aria-hidden');
+
+ // Restore the tabindex across all child nodes of the target.
+ enableElementFocusability(target);
+
+ // Remove the focusability MutationObserver watching this tree.
+ if (childObserverMap.has(target)) {
+ childObserverMap.get(target).disconnect();
+ childObserverMap.delete(target);
+ }
+};
+
+/**
+ * Correctly mark all siblings of the supplied target Element as hidden.
+ *
+ * @param {HTMLElement} target
+ * @returns {Array}
+ */
+export const hideSiblings = target => getList(target).forEach(_hideSiblings);
+
+const _hideSiblings = target => {
+ if (!(target instanceof HTMLElement)) {
+ return;
+ }
+
+ if (!target.parentElement) {
+ return;
+ }
+
+ target.parentElement.childNodes.forEach(node => {
+ if (node === target) {
+ // Skip self;
+ return;
+ }
+
+ hide(node);
+ });
+
+ if (supportsMutationObservers()) {
+ // Add a MutationObserver to check for new children to the tree.
+ const newNodeObserver = new MutationObserver(mutationList => {
+ mutationList.forEach(mutation => {
+ mutation.addedNodes.forEach(node => {
+ if (target.contains(node)) {
+ // Skip self, and children of self.
+ return;
+ }
+
+ hide(node);
+ });
+ });
+ });
+
+ newNodeObserver.observe(target.parentElement, {childList: true, subtree: true});
+ siblingObserverMap.set(target.parentElement, newNodeObserver);
+ }
+};
+
+/**
+ * Correctly reverse the hide action of all children of the supplied target Element.
+ *
+ * @param {HTMLElement} target
+ * @returns {Array}
+ */
+export const unhideSiblings = target => getList(target).forEach(_unhideSiblings);
+
+const _unhideSiblings = target => {
+ if (!(target instanceof HTMLElement)) {
+ return;
+ }
+
+ if (!target.parentElement) {
+ return;
+ }
+
+ target.parentElement.childNodes.forEach(node => {
+ if (node === target) {
+ // Skip self;
+ return;
+ }
+
+ unhide(node);
+ });
+
+ // Remove the sibling MutationObserver watching this tree.
+ if (siblingObserverMap.has(target.parentElement)) {
+ siblingObserverMap.get(target.parentElement).disconnect();
+ siblingObserverMap.delete(target.parentElement);
+ }
+};
diff --git a/lib/amd/src/local/aria/selectors.js b/lib/amd/src/local/aria/selectors.js
new file mode 100644
index 00000000000..c7a45efdcf2
--- /dev/null
+++ b/lib/amd/src/local/aria/selectors.js
@@ -0,0 +1,33 @@
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see .
+
+/**
+ * Selectors used for ARIA.
+ *
+ * @module core/local/aria/selectors
+ * @class selectors
+ * @package core
+ * @copyright 2020 Andrew Nicols
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+export default {
+ aria: {
+ hidden: '[aria-hidden]',
+ },
+ elements: {
+ focusable: 'input:not([type="hidden"]), a[href], button, textarea, select, [tabindex]',
+ focusableToUnhide: '[data-aria-hidden-tab-index]',
+ },
+};
diff --git a/lib/amd/src/modal.js b/lib/amd/src/modal.js
index 442c5b0f052..184c8d6e5de 100644
--- a/lib/amd/src/modal.js
+++ b/lib/amd/src/modal.js
@@ -33,7 +33,8 @@ define([
'core/modal_events',
'core/local/aria/focuslock',
'core/pending',
-], function($, Templates, Notification, KeyCodes, CustomEvents, ModalBackdrop, Event, ModalEvents, FocusLock, Pending) {
+ 'core/aria',
+], function($, Templates, Notification, KeyCodes, CustomEvents, ModalBackdrop, Event, ModalEvents, FocusLock, Pending, Aria) {
var SELECTORS = {
CONTAINER: '[data-region="modal-container"]',
@@ -732,30 +733,10 @@ define([
* @method accessibilityShow
*/
Modal.prototype.accessibilityShow = function() {
- // We need to get a list containing each sibling element and the shallowest
- // non-ancestral nodes in the DOM. We can shortcut this a little by leveraging
- // the fact that this dialogue is always appended to the document body therefore
- // it's siblings are the shallowest non-ancestral nodes. If that changes then
- // this code should also be updated.
- $('body').children().each(function(index, child) {
- // Skip the current modal.
- if (!this.root.is(child)) {
- child = $(child);
- var hidden = child.attr('aria-hidden');
- // If they are already hidden we can ignore them.
- if (hidden !== 'true') {
- // Save their current state.
- child.data('previous-aria-hidden', hidden);
- this.hiddenSiblings.push(child);
-
- // Hide this node from screen readers.
- child.attr('aria-hidden', 'true');
- }
- }
- }.bind(this));
+ Aria.hideSiblings(this.root.get()[0]);
// Make us visible to screen readers.
- this.root.attr('aria-hidden', 'false');
+ this.root.removeAttr('aria-hidden');
};
/**
@@ -768,22 +749,7 @@ define([
Modal.prototype.accessibilityHide = function() {
this.root.attr('aria-hidden', 'true');
- // Restore the sibling nodes back to their original values.
- $.each(this.hiddenSiblings, function(index, sibling) {
- sibling = $(sibling);
- var previousValue = sibling.data('previous-aria-hidden');
- // If the element didn't previously have an aria-hidden attribute
- // then we can just remove the one we set.
- if (typeof previousValue == 'undefined') {
- sibling.removeAttr('aria-hidden');
- } else {
- // Otherwise set it back to the old value (which will be false).
- sibling.attr('aria-hidden', previousValue);
- }
- });
-
- // Clear the cache. No longer need to store these.
- this.hiddenSiblings = [];
+ Aria.unhideSiblings(this.root.get()[0]);
};
/**
diff --git a/lib/amd/src/normalise.js b/lib/amd/src/normalise.js
new file mode 100644
index 00000000000..e5afcafb190
--- /dev/null
+++ b/lib/amd/src/normalise.js
@@ -0,0 +1,51 @@
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see .
+
+/**
+ * Normalisation helpers.
+ *
+ * @module core/normalise
+ * @class normalise
+ * @package core
+ * @copyright 2020 Andrew Nicols
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+import jQuery from 'jquery';
+
+export const getList = nodes => {
+ if (nodes instanceof HTMLElement) {
+ // A single record to conver to a NodeList.
+ return [nodes];
+ }
+
+ if (nodes instanceof Array) {
+ // A single record to conver to a NodeList.
+ return nodes;
+ }
+
+ if (nodes instanceof NodeList) {
+ // Already a NodeList.
+ return Array.from(nodes);
+ }
+
+ if (nodes instanceof jQuery) {
+ // A jQuery object to a NodeList.
+ return nodes.get();
+ }
+
+ // Fallback to just having a go.
+ return Array.from(nodes);
+};